diff --git a/src/lib/listing/workflow/workflow.component.html b/src/lib/listing/workflow/workflow.component.html index 9475848..b506131 100644 --- a/src/lib/listing/workflow/workflow.component.html +++ b/src/lib/listing/workflow/workflow.component.html @@ -1,11 +1,21 @@ -
+ + +
{ } export interface WorkflowConfig { - key: string; + columnIdentifierFn: (entity: T) => K; itemVersionFn: (entity: T) => string; columns: WorkflowColumn[]; } @@ -39,7 +39,6 @@ export interface WorkflowConfig { changeDetection: ChangeDetectionStrategy.OnPush }) export class WorkflowComponent implements OnInit { - readonly listingModes = ListingModes; @Input() headerTemplate?: TemplateRef; @Input() @Required() itemTemplate!: TemplateRef; @Input() @Required() config!: WorkflowConfig; @@ -47,6 +46,12 @@ export class WorkflowComponent implements @Input() itemClasses?: { [key: string]: (e: T) => boolean }; @Input() addElementIcon?: string; @Input() addElementColumn?: K; + @Input() noDataText?: string; + @Input() noDataIcon?: string; + @Input() noDataButtonIcon?: string; + @Input() noDataButtonLabel?: string; + @Input() showNoDataButton = false; + @Output() readonly noDataAction = new EventEmitter(); @Output() readonly addElement = new EventEmitter(); dragging = false; @@ -145,24 +150,23 @@ export class WorkflowComponent implements this._addEntity(entity); } }); - - // this._computeItemHeight(); } private _addEntity(entity: T): void { - this._existingEntities[entity.id] = entity; - const column = this._getColumnByKey(entity[this.config.key] as K); - if (column) { - if (!column.entities) { - column.entities = []; - } - column.entities.push(entity); + const column = this._getColumnByKey(this.config.columnIdentifierFn(entity)); + if (!column) { + return; } + if (!column.entities) { + column.entities = []; + } + this._existingEntities[entity.id] = entity; + column.entities.push(entity); } private _removeEntity(entity: T): void { const existingEntity = this._existingEntities[entity.id]; - const column = this._getColumnByKey(existingEntity[this.config.key] as K); + const column = this._getColumnByKey(this.config.columnIdentifierFn(existingEntity)); if (column) { const idx = (column.entities as T[]).findIndex(item => item.id === entity.id); column.entities?.splice(idx, 1);