Fixed workflow multiplying items

This commit is contained in:
Adina Țeudan 2021-10-14 01:47:47 +03:00
parent f466cf23ea
commit eb1204ad7e

View File

@ -13,7 +13,7 @@ import {
} from '@angular/core';
import { ListingComponent } from '../listing-component.directive';
import { CdkDrag, CdkDragDrop, CdkDropList } from '@angular/cdk/drag-drop';
import { Required } from '../../utils';
import { AutoUnsubscribe, Required } from '../../utils';
import { LoadingService } from '../../loading';
import { IListable } from '../models';
import { EntitiesService, ListingService } from '../services';
@ -39,7 +39,7 @@ export interface WorkflowConfig<T, K> {
styleUrls: ['./workflow.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class WorkflowComponent<T extends IListable, K extends string> implements OnInit {
export class WorkflowComponent<T extends IListable, K extends string> extends AutoUnsubscribe implements OnInit {
@Input() headerTemplate?: TemplateRef<unknown>;
@Input() @Required() itemTemplate!: TemplateRef<T>;
@Input() @Required() config!: WorkflowConfig<T, K>;
@ -66,6 +66,7 @@ export class WorkflowComponent<T extends IListable, K extends string> implements
readonly listingService: ListingService<T>,
readonly entitiesService: EntitiesService<T>,
) {
super();
}
get tableHeaderLabel(): string | undefined {
@ -90,7 +91,8 @@ export class WorkflowComponent<T extends IListable, K extends string> implements
}
ngOnInit(): void {
this.listingService.displayed$.subscribe(entities => this._updateConfigItems(entities));
this.config.columns.forEach(c => (c.entities = []));
this.addSubscription = this.listingService.displayed$.subscribe(entities => this._updateConfigItems(entities));
}
canMoveTo(column: WorkflowColumn<T, K>): (item: CdkDrag<T>) => boolean {