From ce490f17ce87b36c1a18d83c1d7fc48300798a75 Mon Sep 17 00:00:00 2001 From: Martin Rojas Miguel Angel Date: Thu, 24 May 2018 10:28:25 +0200 Subject: [PATCH] TSK-483-508 make lookup configurable and refactored environment file --- .../data-sources/customized-fields.json | 56 +++++++++++++++++++ .../data-sources/environment-information.json | 52 +---------------- .../access-items/access-items.component.html | 11 +++- .../access-items/access-items.component.ts | 1 + .../workbasket-information.component.html | 7 ++- .../workbasket-information.component.ts | 1 + .../components/nav-bar/nav-bar.component.html | 2 +- .../custom-fields/custom-fields.service.ts | 4 +- .../startup-service/startup.service.ts | 20 ++++++- web/src/app/services/titles/titles.service.ts | 2 +- .../data-sources/customized-fields.json | 56 +++++++++++++++++++ .../data-sources/environment-information.json | 54 +----------------- web/src/environments/data-sources/titles.json | 28 +++++----- 13 files changed, 168 insertions(+), 126 deletions(-) create mode 100644 rest/taskana-rest-spring-example/src/main/resources/static/environments/data-sources/customized-fields.json create mode 100644 web/src/environments/data-sources/customized-fields.json diff --git a/rest/taskana-rest-spring-example/src/main/resources/static/environments/data-sources/customized-fields.json b/rest/taskana-rest-spring-example/src/main/resources/static/environments/data-sources/customized-fields.json new file mode 100644 index 000000000..82adbf53e --- /dev/null +++ b/rest/taskana-rest-spring-example/src/main/resources/static/environments/data-sources/customized-fields.json @@ -0,0 +1,56 @@ +{ + "EN": { + "workbaskets": { + "information": { + "lookupField": { + "visible": false + }, + "custom1": { + "field": "Customized field 1 title", + "visible": true + }, + "custom3": { + "field": "", + "visible": false + } + }, + "access-items": { + "lookupField": { + "visible": true + }, + "custom3": { + "field": "", + "visible": false + }, + "custom9": { + "field": "Some custom field", + "visible": true + }, + "custom10": { + "field": "", + "visible": false + }, + "custom11": { + "field": "", + "visible": false + }, + "custom12": { + "field": "", + "visible": false + } + } + }, + "classifications": { + "information": { + "custom1": { + "field": "Classification custom 1", + "visible": true + }, + "custom3": { + "field": "", + "visible": false + } + } + } + } +} \ No newline at end of file diff --git a/rest/taskana-rest-spring-example/src/main/resources/static/environments/data-sources/environment-information.json b/rest/taskana-rest-spring-example/src/main/resources/static/environments/data-sources/environment-information.json index 96d257b23..dfb727b53 100644 --- a/rest/taskana-rest-spring-example/src/main/resources/static/environments/data-sources/environment-information.json +++ b/rest/taskana-rest-spring-example/src/main/resources/static/environments/data-sources/environment-information.json @@ -1,53 +1,3 @@ { - "taskanaRestUrl": "https://taskana-rest.mybluemix.net", - "customizedFields": { - "EN": { - "workbaskets": { - "information": { - "custom1": { - "field": "Customized field 1 title", - "visible": true - }, - "custom3": { - "field": "", - "visible": false - } - }, - "access-items": { - "custom3": { - "field": "", - "visible": false - }, - "custom9": { - "field": "Some custom field", - "visible": true - }, - "custom10": { - "field": "", - "visible": false - }, - "custom11": { - "field": "", - "visible": false - }, - "custom12": { - "field": "", - "visible": false - } - } - }, - "classifications": { - "information": { - "custom1": { - "field": "Classification custom 1", - "visible": true - }, - "custom3": { - "field": "", - "visible": false - } - } - } - } - } + "taskanaRestUrl": "https://taskana-rest.mybluemix.net" } diff --git a/web/src/app/administration/workbasket/details/access-items/access-items.component.html b/web/src/app/administration/workbasket/details/access-items/access-items.component.html index 3a4167e78..c89f66b1a 100644 --- a/web/src/app/administration/workbasket/details/access-items/access-items.component.html +++ b/web/src/app/administration/workbasket/details/access-items/access-items.component.html @@ -42,12 +42,21 @@ - + + +
+ +
+ +
diff --git a/web/src/app/administration/workbasket/details/access-items/access-items.component.ts b/web/src/app/administration/workbasket/details/access-items/access-items.component.ts index 86b77f543..3a0548486 100644 --- a/web/src/app/administration/workbasket/details/access-items/access-items.component.ts +++ b/web/src/app/administration/workbasket/details/access-items/access-items.component.ts @@ -34,6 +34,7 @@ export class AccessItemsComponent implements OnChanges, OnDestroy { active: string; badgeMessage = ''; + lookupField = this.customFieldService.getCustomField('Owner', 'workbaskets.access-items.lookupField'); custom1Field = this.customFieldService.getCustomField('Custom 1', 'workbaskets.access-items.custom1'); custom2Field = this.customFieldService.getCustomField('Custom 2', 'workbaskets.access-items.custom2'); custom3Field = this.customFieldService.getCustomField('Custom 3', 'workbaskets.access-items.custom3'); diff --git a/web/src/app/administration/workbasket/details/information/workbasket-information.component.html b/web/src/app/administration/workbasket/details/information/workbasket-information.component.html index b4fea6bfe..156104315 100644 --- a/web/src/app/administration/workbasket/details/information/workbasket-information.component.html +++ b/web/src/app/administration/workbasket/details/information/workbasket-information.component.html @@ -39,7 +39,12 @@
- + + + +
* Owner is required
diff --git a/web/src/app/administration/workbasket/details/information/workbasket-information.component.ts b/web/src/app/administration/workbasket/details/information/workbasket-information.component.ts index 66ec053fb..2d1f63f3b 100644 --- a/web/src/app/administration/workbasket/details/information/workbasket-information.component.ts +++ b/web/src/app/administration/workbasket/details/information/workbasket-information.component.ts @@ -37,6 +37,7 @@ export class WorkbasketInformationComponent implements OnInit, OnChanges, OnDest requestInProgress = false; badgeMessage = ''; + lookupField = this.customFieldsService.getCustomField('Owner', 'workbaskets.information.lookupField'); custom1Field = this.customFieldsService.getCustomField('Custom 1', 'workbaskets.information.custom1'); custom2Field = this.customFieldsService.getCustomField('Custom 2', 'workbaskets.information.custom2'); custom3Field = this.customFieldsService.getCustomField('Custom 3', 'workbaskets.information.custom3'); diff --git a/web/src/app/components/nav-bar/nav-bar.component.html b/web/src/app/components/nav-bar/nav-bar.component.html index dbbf20056..f019af46f 100644 --- a/web/src/app/components/nav-bar/nav-bar.component.html +++ b/web/src/app/components/nav-bar/nav-bar.component.html @@ -23,7 +23,7 @@ diff --git a/web/src/app/services/custom-fields/custom-fields.service.ts b/web/src/app/services/custom-fields/custom-fields.service.ts index 39d558b2b..74daa094d 100644 --- a/web/src/app/services/custom-fields/custom-fields.service.ts +++ b/web/src/app/services/custom-fields/custom-fields.service.ts @@ -7,7 +7,7 @@ export class CustomFieldsService { constructor() { } initCustomFields(language: string = 'EN', jsonFile: any) { - this.customizedFields = jsonFile.customizedFields[language]; + this.customizedFields = jsonFile[language]; } getCustomField(fallbacktext: string, customPath: string = undefined): CustomField { @@ -19,7 +19,7 @@ export class CustomFieldsService { private jsonPath(path: string, fallbacktext: string): CustomField { if (!this.customizedFields) { - return undefined; + return new CustomField(true, fallbacktext); }; const paths = path.split('.'); let value = this.customizedFields; diff --git a/web/src/app/services/startup-service/startup.service.ts b/web/src/app/services/startup-service/startup.service.ts index 7cfa57b18..396f9eaf0 100644 --- a/web/src/app/services/startup-service/startup.service.ts +++ b/web/src/app/services/startup-service/startup.service.ts @@ -18,8 +18,13 @@ export class StartupService { return this.loadEnvironment(); } - private loadEnvironment() { + return this.getEnvironmentFilePromise().then( + () => this.geCustomizedFieldsFilePromise() + ); + } + + getEnvironmentFilePromise() { return this.httpClient.get('environments/data-sources/environment-information.json').map(jsonFile => { if (jsonFile) { environment.taskanaRestUrl = jsonFile.taskanaRestUrl === '' ? @@ -29,6 +34,17 @@ export class StartupService { }).toPromise() .catch(() => { return Observable.of(true) - }) + }); + } + + geCustomizedFieldsFilePromise() { + return this.httpClient.get('environments/data-sources/customized-fields.json').map(jsonFile => { + if (jsonFile) { + this.customFieldsService.initCustomFields('EN', jsonFile); + } + }).toPromise() + .catch(() => { + return Observable.of(true) + }); } } diff --git a/web/src/app/services/titles/titles.service.ts b/web/src/app/services/titles/titles.service.ts index 02a3b4871..cc0ed18d0 100644 --- a/web/src/app/services/titles/titles.service.ts +++ b/web/src/app/services/titles/titles.service.ts @@ -8,7 +8,7 @@ export class TitlesService { constructor() { } initTitles(language: string = 'EN', jsonFile: any) { - this.titles = jsonFile.titles[language]; + this.titles = jsonFile[language]; } getTitle(id: number, fallBacktext: string, customPath: string = undefined) { diff --git a/web/src/environments/data-sources/customized-fields.json b/web/src/environments/data-sources/customized-fields.json new file mode 100644 index 000000000..fb204da48 --- /dev/null +++ b/web/src/environments/data-sources/customized-fields.json @@ -0,0 +1,56 @@ +{ + "EN": { + "workbaskets": { + "information": { + "lookupField": { + "visible": true + }, + "custom1": { + "field": "Customized field 1 title", + "visible": true + }, + "custom3": { + "field": "", + "visible": false + } + }, + "access-items": { + "lookupField": { + "visible": false + }, + "custom3": { + "field": "", + "visible": false + }, + "custom9": { + "field": "Some custom field", + "visible": true + }, + "custom10": { + "field": "", + "visible": false + }, + "custom11": { + "field": "", + "visible": false + }, + "custom12": { + "field": "", + "visible": false + } + } + }, + "classifications": { + "information": { + "custom1": { + "field": "Classification custom 1", + "visible": true + }, + "custom3": { + "field": "", + "visible": false + } + } + } + } +} \ No newline at end of file diff --git a/web/src/environments/data-sources/environment-information.json b/web/src/environments/data-sources/environment-information.json index 5dc152cad..86271efcb 100644 --- a/web/src/environments/data-sources/environment-information.json +++ b/web/src/environments/data-sources/environment-information.json @@ -1,53 +1,3 @@ { - "taskanaRestUrl": "", - "customizedFields": { - "EN": { - "workbaskets": { - "information": { - "custom1": { - "field": "Customized field 1 title", - "visible": true - }, - "custom3": { - "field": "", - "visible": false - } - }, - "access-items": { - "custom3": { - "field": "", - "visible": false - }, - "custom9": { - "field": "Some custom field", - "visible": true - }, - "custom10": { - "field": "", - "visible": false - }, - "custom11": { - "field": "", - "visible": false - }, - "custom12": { - "field": "", - "visible": false - } - } - }, - "classifications": { - "information": { - "custom1": { - "field": "Classification custom 1", - "visible": true - }, - "custom3": { - "field": "", - "visible": false - } - } - } - } - } -} + "taskanaRestUrl": "" +} \ No newline at end of file diff --git a/web/src/environments/data-sources/titles.json b/web/src/environments/data-sources/titles.json index fbb073c3a..2831112ae 100644 --- a/web/src/environments/data-sources/titles.json +++ b/web/src/environments/data-sources/titles.json @@ -1,18 +1,16 @@ { - "titles": { - "EN": { - "0": "Administration", - "1": "Custom 1", - "2": "Custom 2", - "3": "Custom 3", - "4": "Custom 4" - }, - "DE": { - "0": "Verwaltung", - "1": "Gewohnheit 1", - "2": "Gewohnheit 2", - "3": "Gewohnheit 3", - "4": "Gewohnheit 4" - } + "EN": { + "0": "Administration", + "1": "Custom 1", + "2": "Custom 2", + "3": "Custom 3", + "4": "Custom 4" + }, + "DE": { + "0": "Administration", + "1": "Zusatzfeld 1", + "2": "Zusatzfeld 2", + "3": "Zusatzfeld 3", + "4": "Zusatzfeld 4" } } \ No newline at end of file