fix dossier's status bar
This commit is contained in:
parent
4d840effd8
commit
7b375e481a
@ -1,4 +1,4 @@
|
||||
<iqser-status-bar [configs]="statusBarConfig"></iqser-status-bar>
|
||||
<iqser-status-bar [configs]="statusConfig"></iqser-status-bar>
|
||||
<div class="action-buttons">
|
||||
<iqser-circle-button
|
||||
(action)="openEditDossierDialog($event, dossier)"
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { DossierWrapper } from '@state/model/dossier.wrapper';
|
||||
import { StatusSorter } from '@utils/sorters/status-sorter';
|
||||
@ -6,7 +6,6 @@ import { AppStateService } from '@state/app-state.service';
|
||||
import { DossiersDialogService } from '../../services/dossiers-dialog.service';
|
||||
import { CircleButtonTypes, StatusBarConfig } from '@iqser/common-ui';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { FileStatusWrapper } from '@models/file/file-status.wrapper';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossier-listing-actions',
|
||||
@ -14,15 +13,13 @@ import { FileStatusWrapper } from '@models/file/file-status.wrapper';
|
||||
styleUrls: ['./dossier-listing-actions.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class DossierListingActionsComponent implements OnInit {
|
||||
export class DossierListingActionsComponent {
|
||||
readonly circleButtonTypes = CircleButtonTypes;
|
||||
readonly currentUser = this._userService.currentUser;
|
||||
|
||||
@Input() dossier: DossierWrapper;
|
||||
@Output() actionPerformed = new EventEmitter<DossierWrapper | undefined>();
|
||||
|
||||
statusBarConfig: readonly StatusBarConfig<string>[];
|
||||
|
||||
constructor(
|
||||
readonly permissionsService: PermissionsService,
|
||||
readonly appStateService: AppStateService,
|
||||
@ -30,26 +27,24 @@ export class DossierListingActionsComponent implements OnInit {
|
||||
private readonly _userService: UserService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.statusBarConfig = this._getStatusConfig(this.dossier.files);
|
||||
}
|
||||
|
||||
openEditDossierDialog($event: MouseEvent, dossierWrapper: DossierWrapper) {
|
||||
openEditDossierDialog($event: MouseEvent, dossierWrapper: DossierWrapper): void {
|
||||
this._dialogService.openDialog('editDossier', $event, {
|
||||
dossierWrapper,
|
||||
afterSave: () => this.actionPerformed.emit()
|
||||
});
|
||||
}
|
||||
|
||||
reanalyseDossier($event: MouseEvent, dossier: DossierWrapper) {
|
||||
reanalyseDossier($event: MouseEvent, dossier: DossierWrapper): void {
|
||||
$event.stopPropagation();
|
||||
this.appStateService.reanalyzeDossier(dossier).then(() => {
|
||||
this.appStateService.loadAllDossiers().then(() => this.actionPerformed.emit());
|
||||
});
|
||||
}
|
||||
|
||||
private _getStatusConfig(files: readonly FileStatusWrapper[]) {
|
||||
const obj = files.reduce((acc, file) => {
|
||||
get statusConfig(): readonly StatusBarConfig<string>[] {
|
||||
if (!this.dossier) return [];
|
||||
|
||||
const obj = this.dossier.files.reduce((acc, file) => {
|
||||
const status = file.status;
|
||||
if (!acc[status]) {
|
||||
acc[status] = 1;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { AfterViewInit, Component, Injector, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { Dossier, DossierTemplateModel } from '@redaction/red-ui-http';
|
||||
import { Dossier } from '@redaction/red-ui-http';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { DoughnutChartConfig } from '@shared/components/simple-doughnut-chart/simple-doughnut-chart.component';
|
||||
@ -45,7 +45,7 @@ export class DossierListingScreenComponent
|
||||
readonly buttonConfigs: readonly ButtonConfig[] = [
|
||||
{
|
||||
label: _('dossier-listing.add-new'),
|
||||
action: () => this.openAddDossierDialog(),
|
||||
action: (): void => this.openAddDossierDialog(),
|
||||
hide: !this.currentUser.isManager,
|
||||
icon: 'red:plus',
|
||||
type: 'primary'
|
||||
@ -74,7 +74,7 @@ export class DossierListingScreenComponent
|
||||
private _lastScrolledIndex: number;
|
||||
|
||||
@ViewChild('needsWorkTemplate', { read: TemplateRef, static: true })
|
||||
private readonly _needsWorkTemplate: TemplateRef<any>;
|
||||
private readonly _needsWorkTemplate: TemplateRef<unknown>;
|
||||
@ViewChild(CdkVirtualScrollViewport)
|
||||
private readonly _scrollViewport: CdkVirtualScrollViewport;
|
||||
|
||||
@ -116,11 +116,11 @@ export class DossierListingScreenComponent
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
ngAfterViewInit(): void {
|
||||
this.addSubscription = this._scrollViewport.scrolledIndexChange.pipe(tap(index => (this._lastScrolledIndex = index))).subscribe();
|
||||
}
|
||||
|
||||
ngOnAttach() {
|
||||
ngOnAttach(): void {
|
||||
this._appStateService.reset();
|
||||
this._loadEntitiesFromState();
|
||||
this.ngOnInit();
|
||||
@ -132,10 +132,6 @@ export class DossierListingScreenComponent
|
||||
this.ngOnDestroy();
|
||||
}
|
||||
|
||||
private _getDossierTemplate(dossierTemplateId: string): DossierTemplateModel {
|
||||
return this._appStateService.getDossierTemplateById(dossierTemplateId);
|
||||
}
|
||||
|
||||
openAddDossierDialog(): void {
|
||||
this._dialogService.openDialog('addDossier', null, null, async addResponse => {
|
||||
await this._router.navigate([`/main/dossiers/${addResponse.dossier.dossierId}`]);
|
||||
@ -148,7 +144,7 @@ export class DossierListingScreenComponent
|
||||
});
|
||||
}
|
||||
|
||||
calculateData() {
|
||||
calculateData(): void {
|
||||
this._computeAllFilters();
|
||||
|
||||
this.dossiersChartData = [
|
||||
@ -171,7 +167,6 @@ export class DossierListingScreenComponent
|
||||
}
|
||||
|
||||
private _loadEntitiesFromState() {
|
||||
console.log(this._appStateService.allDossiers);
|
||||
this.entitiesService.setEntities(this._appStateService.allDossiers);
|
||||
}
|
||||
|
||||
|
||||
@ -20,22 +20,22 @@ import { delay, distinctUntilChanged, map, shareReplay } from 'rxjs/operators';
|
||||
]
|
||||
})
|
||||
export class PopupFilterComponent implements OnInit {
|
||||
@Input() actionsTemplate: TemplateRef<any>;
|
||||
@Input() actionsTemplate: TemplateRef<unknown>;
|
||||
@Input() primaryFiltersSlug: string;
|
||||
@Input() secondaryFiltersSlug: string;
|
||||
|
||||
atLeastOneFilterIsExpandable$?: Observable<boolean>;
|
||||
atLeastOneSecondaryFilterIsExpandable$?: Observable<boolean>;
|
||||
hasActiveFilters$?: Observable<boolean>;
|
||||
expanded = new BehaviorSubject<boolean>(null);
|
||||
expanded$ = this.expanded.asObservable().pipe(delay(200));
|
||||
readonly expanded = new BehaviorSubject<boolean>(null);
|
||||
readonly expanded$ = this.expanded.asObservable().pipe(delay(200));
|
||||
|
||||
primaryFilterGroup$?: Observable<FilterGroup>;
|
||||
secondaryFilterGroup$?: Observable<FilterGroup>;
|
||||
|
||||
constructor(readonly filterService: FilterService) {}
|
||||
|
||||
ngOnInit() {
|
||||
ngOnInit(): void {
|
||||
this.primaryFilterGroup$ = this.filterService.getGroup$(this.primaryFiltersSlug);
|
||||
this.secondaryFilterGroup$ = this.filterService.getGroup$(this.secondaryFiltersSlug);
|
||||
this.hasActiveFilters$ = combineLatest([this.primaryFilterGroup$, this.secondaryFilterGroup$]).pipe(
|
||||
@ -55,7 +55,7 @@ export class PopupFilterComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
filterCheckboxClicked($event: any, nestedFilter: NestedFilter, parent?: NestedFilter) {
|
||||
filterCheckboxClicked($event: MouseEvent, nestedFilter: NestedFilter, parent?: NestedFilter): void {
|
||||
$event.stopPropagation();
|
||||
|
||||
nestedFilter.checked = !nestedFilter.checked;
|
||||
@ -71,22 +71,22 @@ export class PopupFilterComponent implements OnInit {
|
||||
this.filterService.refresh();
|
||||
}
|
||||
|
||||
activatePrimaryFilters() {
|
||||
activatePrimaryFilters(): void {
|
||||
this._setFilters(this.primaryFiltersSlug, true);
|
||||
}
|
||||
|
||||
deactivateFilters() {
|
||||
deactivateFilters(): void {
|
||||
this._setFilters(this.primaryFiltersSlug);
|
||||
this._setFilters(this.secondaryFiltersSlug);
|
||||
if (this.secondaryFiltersSlug) this._setFilters(this.secondaryFiltersSlug);
|
||||
}
|
||||
|
||||
toggleFilterExpanded($event: MouseEvent, nestedFilter: NestedFilter) {
|
||||
toggleFilterExpanded($event: MouseEvent, nestedFilter: NestedFilter): void {
|
||||
$event.stopPropagation();
|
||||
nestedFilter.expanded = !nestedFilter.expanded;
|
||||
this.filterService.refresh();
|
||||
}
|
||||
|
||||
isExpandable(nestedFilter: NestedFilter) {
|
||||
isExpandable(nestedFilter: NestedFilter): boolean {
|
||||
return nestedFilter?.children?.length > 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user