From 7c4138ea62975c2e08f3f5e0b55621dcaf8eeeba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 14 Feb 2017 14:49:48 +0100 Subject: [PATCH] Correct milestone attribute name in cell builder --- .../wp-fast-table/builders/cell-builder.ts | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/frontend/app/components/wp-fast-table/builders/cell-builder.ts b/frontend/app/components/wp-fast-table/builders/cell-builder.ts index ffcbb35808..7a604bad04 100644 --- a/frontend/app/components/wp-fast-table/builders/cell-builder.ts +++ b/frontend/app/components/wp-fast-table/builders/cell-builder.ts @@ -18,12 +18,13 @@ export class CellBuilder { injectorBridge(this); } - public build(workPackage:WorkPackageResource, name:string) { - let fieldSchema = workPackage.schema[name]; + public build(workPackage:WorkPackageResource, attribute:string) { + const name = this.correctDateAttribute(workPackage, attribute); + const fieldSchema = workPackage.schema[name]; - let td = document.createElement('td'); + const td = document.createElement('td'); td.classList.add(tdClassName, name); - let span = document.createElement('span'); + const span = document.createElement('span'); span.classList.add(cellClassName, 'inplace-edit', 'wp-edit-field', name); span.dataset['fieldName'] = name; @@ -36,7 +37,6 @@ export class CellBuilder { } const field = this.wpDisplayField.getField(workPackage, name, fieldSchema) as DisplayField; - let text; if (name === 'id') { @@ -66,6 +66,17 @@ export class CellBuilder { return td; } + + /** + * Milestones should display the 'date' attribute for start and due dates + */ + private correctDateAttribute(workPackage:WorkPackageResource, name:string):string { + if (workPackage.isMilestone && (name === 'dueDate' || name === 'startDate')) { + return 'date'; + } + + return name; + } } CellBuilder.$inject = ['wpDisplayField'];