bug/TSK-809: Duplicated http call when selecting a task in workplaces
Fix the problem that the list doesnt show every classification Create a new component (dropdown) Change subscription to promise asyn/away change location getclassification and add a test
This commit is contained in:
parent
f34aeaae77
commit
8d63d775f9
|
|
@ -504,8 +504,7 @@
|
||||||
"ansi-regex": {
|
"ansi-regex": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"aproba": {
|
"aproba": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
|
|
@ -526,14 +525,12 @@
|
||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
|
|
@ -548,20 +545,17 @@
|
||||||
"code-point-at": {
|
"code-point-at": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"console-control-strings": {
|
"console-control-strings": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
|
|
@ -678,8 +672,7 @@
|
||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"ini": {
|
"ini": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
|
|
@ -691,7 +684,6 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"number-is-nan": "^1.0.0"
|
"number-is-nan": "^1.0.0"
|
||||||
}
|
}
|
||||||
|
|
@ -706,7 +698,6 @@
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
|
|
@ -714,14 +705,12 @@
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "2.3.5",
|
"version": "2.3.5",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "^5.1.2",
|
"safe-buffer": "^5.1.2",
|
||||||
"yallist": "^3.0.0"
|
"yallist": "^3.0.0"
|
||||||
|
|
@ -740,7 +729,6 @@
|
||||||
"version": "0.5.1",
|
"version": "0.5.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "0.0.8"
|
"minimist": "0.0.8"
|
||||||
}
|
}
|
||||||
|
|
@ -821,8 +809,7 @@
|
||||||
"number-is-nan": {
|
"number-is-nan": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"object-assign": {
|
"object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
|
|
@ -834,7 +821,6 @@
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
}
|
}
|
||||||
|
|
@ -920,8 +906,7 @@
|
||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
"version": "5.1.2",
|
"version": "5.1.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"safer-buffer": {
|
"safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
|
|
@ -957,7 +942,6 @@
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"code-point-at": "^1.0.0",
|
"code-point-at": "^1.0.0",
|
||||||
"is-fullwidth-code-point": "^1.0.0",
|
"is-fullwidth-code-point": "^1.0.0",
|
||||||
|
|
@ -977,7 +961,6 @@
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-regex": "^2.0.0"
|
"ansi-regex": "^2.0.0"
|
||||||
}
|
}
|
||||||
|
|
@ -1021,14 +1004,12 @@
|
||||||
"wrappy": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -4808,8 +4789,7 @@
|
||||||
"ansi-regex": {
|
"ansi-regex": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"aproba": {
|
"aproba": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
|
|
@ -4830,14 +4810,12 @@
|
||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
|
|
@ -4852,20 +4830,17 @@
|
||||||
"code-point-at": {
|
"code-point-at": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"console-control-strings": {
|
"console-control-strings": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
|
|
@ -4982,8 +4957,7 @@
|
||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"ini": {
|
"ini": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
|
|
@ -4995,7 +4969,6 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"number-is-nan": "^1.0.0"
|
"number-is-nan": "^1.0.0"
|
||||||
}
|
}
|
||||||
|
|
@ -5010,7 +4983,6 @@
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
|
|
@ -5018,14 +4990,12 @@
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "2.2.4",
|
"version": "2.2.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "^5.1.1",
|
"safe-buffer": "^5.1.1",
|
||||||
"yallist": "^3.0.0"
|
"yallist": "^3.0.0"
|
||||||
|
|
@ -5044,7 +5014,6 @@
|
||||||
"version": "0.5.1",
|
"version": "0.5.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "0.0.8"
|
"minimist": "0.0.8"
|
||||||
}
|
}
|
||||||
|
|
@ -5125,8 +5094,7 @@
|
||||||
"number-is-nan": {
|
"number-is-nan": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"object-assign": {
|
"object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
|
|
@ -5138,7 +5106,6 @@
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
}
|
}
|
||||||
|
|
@ -5224,8 +5191,7 @@
|
||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"safer-buffer": {
|
"safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
|
|
@ -5261,7 +5227,6 @@
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"code-point-at": "^1.0.0",
|
"code-point-at": "^1.0.0",
|
||||||
"is-fullwidth-code-point": "^1.0.0",
|
"is-fullwidth-code-point": "^1.0.0",
|
||||||
|
|
@ -5281,7 +5246,6 @@
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-regex": "^2.0.0"
|
"ansi-regex": "^2.0.0"
|
||||||
}
|
}
|
||||||
|
|
@ -5325,14 +5289,12 @@
|
||||||
"wrappy": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { Classification } from './classification';
|
import { Classification } from './classification';
|
||||||
import { Links } from './links';
|
import { Links } from './links';
|
||||||
|
|
||||||
|
|
||||||
export class ClassificationResource {
|
export class ClassificationResource {
|
||||||
constructor(
|
constructor(
|
||||||
public _embedded: {
|
public _embedded: {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
import { Observable, Subject, combineLatest } from 'rxjs';
|
import { combineLatest, Observable, Subject} from 'rxjs';
|
||||||
import { mergeMap, tap } from 'rxjs/operators';
|
import { mergeMap, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { Classification } from 'app/models/classification';
|
import { Classification } from 'app/models/classification';
|
||||||
|
|
@ -20,6 +20,8 @@ export class ClassificationsService {
|
||||||
private url = `${environment.taskanaRestUrl}/v1/classifications/`;
|
private url = `${environment.taskanaRestUrl}/v1/classifications/`;
|
||||||
private classificationSelected = new Subject<ClassificationDefinition>();
|
private classificationSelected = new Subject<ClassificationDefinition>();
|
||||||
private classificationSaved = new Subject<number>();
|
private classificationSaved = new Subject<number>();
|
||||||
|
private classificationResourcePromise: Promise<ClassificationResource>;
|
||||||
|
private lastDomain: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private httpClient: HttpClient,
|
private httpClient: HttpClient,
|
||||||
|
|
@ -39,6 +41,16 @@ export class ClassificationsService {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GET
|
||||||
|
getClassificationsByDomain(domain: string, forceRefresh = false): Promise<ClassificationResource> {
|
||||||
|
if (this.lastDomain !== domain || !this.classificationResourcePromise || forceRefresh) {
|
||||||
|
this.lastDomain = domain;
|
||||||
|
this.classificationResourcePromise = this.httpClient.get<ClassificationResource>(
|
||||||
|
`${this.url}${TaskanaQueryParameters.getQueryParameters(this.classificationParameters(domain))}`).toPromise();
|
||||||
|
}
|
||||||
|
return this.classificationResourcePromise;
|
||||||
|
}
|
||||||
|
|
||||||
// GET
|
// GET
|
||||||
getClassification(id: string): Observable<ClassificationDefinition> {
|
getClassification(id: string): Observable<ClassificationDefinition> {
|
||||||
return this.httpClient.get<ClassificationDefinition>(`${this.url}${id}`)
|
return this.httpClient.get<ClassificationDefinition>(`${this.url}${id}`)
|
||||||
|
|
@ -49,7 +61,6 @@ export class ClassificationsService {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// POST
|
// POST
|
||||||
postClassification(classification: Classification): Observable<Classification> {
|
postClassification(classification: Classification): Observable<Classification> {
|
||||||
return this.httpClient.post<Classification>(`${this.url}`, classification);
|
return this.httpClient.post<Classification>(`${this.url}`, classification);
|
||||||
|
|
@ -72,7 +83,6 @@ export class ClassificationsService {
|
||||||
|
|
||||||
getSelectedClassification(): Observable<ClassificationDefinition> {
|
getSelectedClassification(): Observable<ClassificationDefinition> {
|
||||||
return this.classificationSelected.asObservable();
|
return this.classificationSelected.asObservable();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
triggerClassificationSaved() {
|
triggerClassificationSaved() {
|
||||||
|
|
@ -97,7 +107,7 @@ export class ClassificationsService {
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getClassificationObservable(classificationRef: Observable<any>): Observable<any> {
|
private getClassificationObservable(classificationRef: Observable<any>): Observable<Array<Classification>> {
|
||||||
const classificationTypes = this.classificationCategoriesService.getSelectedClassificationType();
|
const classificationTypes = this.classificationCategoriesService.getSelectedClassificationType();
|
||||||
return combineLatest(
|
return combineLatest(
|
||||||
classificationRef,
|
classificationRef,
|
||||||
|
|
@ -111,7 +121,7 @@ export class ClassificationsService {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildHierarchy(classifications: Array<Classification>, type: string) {
|
private buildHierarchy(classifications: Array<Classification>, type: string): Array<Classification> {
|
||||||
const roots = [];
|
const roots = [];
|
||||||
const children = [];
|
const children = [];
|
||||||
|
|
||||||
|
|
@ -139,4 +149,3 @@ export class ClassificationsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<div class="input-group dropdown" dropdown>
|
||||||
|
<button class="btn btn-default dropdown-toggle" type="button" dropdownToggle
|
||||||
|
data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" name="">
|
||||||
|
{{ itemSelected?.name }}
|
||||||
|
<span class="caret"></span>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu height-and-scroll">
|
||||||
|
<li *ngFor="let item of list" (click)="selectItem(item)">
|
||||||
|
<a>
|
||||||
|
<label>
|
||||||
|
<span class="material-icons md-20 blue ">{{item.key === itemSelected?.key ?
|
||||||
|
'check_box' : 'check_box_outline_blank'}} </span>
|
||||||
|
<span> {{item.name}} </span>
|
||||||
|
</label>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
.height-and-scroll {
|
||||||
|
max-height: 300px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
|
import {DropdownComponent} from './dropdown.component';
|
||||||
|
|
||||||
|
describe('DropdownComponent', () => {
|
||||||
|
let component: DropdownComponent;
|
||||||
|
let fixture: ComponentFixture<DropdownComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [DropdownComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(DropdownComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have values', () => {
|
||||||
|
component.list = new Array<any>('first', 'second');
|
||||||
|
component.itemSelected = 'second';
|
||||||
|
expect(component.list).not.toBeNull();
|
||||||
|
expect(component.list).not.toBeNaN();
|
||||||
|
expect(component.itemSelected).not.toBeNull();
|
||||||
|
expect(component.itemSelected).not.toBeNaN();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have the correct item selected', () => {
|
||||||
|
component.list = new Array<any>('first', 'second');
|
||||||
|
|
||||||
|
component.selectItem('first');
|
||||||
|
expect(component.itemSelected).toBe('first');
|
||||||
|
|
||||||
|
component.selectItem('second');
|
||||||
|
expect(component.itemSelected).toBe('second');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||||
|
import {SortingModel} from '../../models/sorting';
|
||||||
|
import {Classification} from '../../models/classification';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'taskana-dropdown',
|
||||||
|
templateUrl: './dropdown.component.html',
|
||||||
|
styleUrls: ['./dropdown.component.scss']
|
||||||
|
})
|
||||||
|
export class DropdownComponent implements OnInit {
|
||||||
|
|
||||||
|
@Input() itemSelected: any;
|
||||||
|
@Input() list: Array<any>;
|
||||||
|
@Output() performClassification = new EventEmitter<any>();
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
selectItem(item: any) {
|
||||||
|
this.itemSelected = item;
|
||||||
|
this.performClassification.emit(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -26,6 +26,7 @@ import {PaginationComponent} from './pagination/pagination.component';
|
||||||
import {NumberPickerComponent} from './number-picker/number-picker.component';
|
import {NumberPickerComponent} from './number-picker/number-picker.component';
|
||||||
import {ProgressBarComponent} from './progress-bar/progress-bar.component';
|
import {ProgressBarComponent} from './progress-bar/progress-bar.component';
|
||||||
import {DatePickerComponent} from './date-picker/date-picker.component';
|
import {DatePickerComponent} from './date-picker/date-picker.component';
|
||||||
|
import {DropdownComponent} from './dropdown/dropdown.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pipes
|
* Pipes
|
||||||
|
|
@ -82,7 +83,8 @@ const DECLARATIONS = [
|
||||||
PaginationComponent,
|
PaginationComponent,
|
||||||
NumberPickerComponent,
|
NumberPickerComponent,
|
||||||
ProgressBarComponent,
|
ProgressBarComponent,
|
||||||
DatePickerComponent
|
DatePickerComponent,
|
||||||
|
DropdownComponent
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
|
||||||
|
|
@ -57,25 +57,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-xs-6 required">
|
<div class="form-group col-xs-6 required">
|
||||||
<label for="wb-type" class="control-label">Classification</label>
|
<label for="classification" class="control-label">Classification</label>
|
||||||
<div class="input-group" dropdown>
|
<taskana-dropdown [list]="classifications" (performClassification)="changedClassification($event)" [itemSelected]="task?.classificationSummaryResource" id="classification"></taskana-dropdown>
|
||||||
<button class="btn btn-default" type="button" dropdownToggle id="task.classificationSummaryResource"
|
|
||||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" name="">
|
|
||||||
{{task.classificationSummaryResource?.name }}
|
|
||||||
<span class="caret"></span>
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu" *dropdownMenu>
|
|
||||||
<li *ngFor="let classification of classifications" (click)="selectClassification(classification)">
|
|
||||||
<a>
|
|
||||||
<label>
|
|
||||||
<span class="material-icons md-20 blue ">{{classification.name === task.classificationSummaryResource?.name ?
|
|
||||||
'check_box': 'check_box_outline_blank'}} </span>
|
|
||||||
<span> {{classification.name}} </span>
|
|
||||||
</label>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-xs-4">
|
<div class="form-group col-xs-4">
|
||||||
<label for="task-due" class="control-label">Due date</label>
|
<label for="task-due" class="control-label">Due date</label>
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,25 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import { TaskdetailsGeneralFieldsComponent } from './general-fields.component';
|
import {TaskdetailsGeneralFieldsComponent} from './general-fields.component';
|
||||||
import { FormsModule } from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import { ClassificationsService } from 'app/services/classifications/classifications.service';
|
import {HttpClient, HttpClientModule} from '@angular/common/http';
|
||||||
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
import {ClassificationCategoriesService} from 'app/services/classifications/classification-categories.service';
|
||||||
import { ClassificationCategoriesService } from 'app/services/classifications/classification-categories.service';
|
import {CustomFieldsService} from 'app/services/custom-fields/custom-fields.service';
|
||||||
import { CustomFieldsService } from 'app/services/custom-fields/custom-fields.service';
|
import {DomainService} from 'app/services/domain/domain.service';
|
||||||
import { DomainService } from 'app/services/domain/domain.service';
|
import {RouterTestingModule} from '@angular/router/testing';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import {Routes} from '@angular/router';
|
||||||
import { Routes } from '@angular/router';
|
import {Component} from '@angular/core';
|
||||||
import { Component } from '@angular/core';
|
import {RequestInProgressService} from 'app/services/requestInProgress/request-in-progress.service';
|
||||||
import { RequestInProgressService } from 'app/services/requestInProgress/request-in-progress.service';
|
import {SelectedRouteService} from 'app/services/selected-route/selected-route';
|
||||||
import { SelectedRouteService } from 'app/services/selected-route/selected-route';
|
import {ClassificationsService} from '../../../services/classifications/classifications.service';
|
||||||
|
import {configureTests} from '../../../app.test.configuration';
|
||||||
|
import {Classification} from '../../../models/classification';
|
||||||
|
import {Links} from '../../../models/links';
|
||||||
|
import {ClassificationResource} from '../../../models/classification-resource';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-dummy-detail',
|
selector: 'taskana-dummy-detail',
|
||||||
template: 'dummydetail'
|
template: 'dummydetail'
|
||||||
})
|
})
|
||||||
export class DummyDetailComponent {
|
export class DummyDetailComponent {
|
||||||
}
|
}
|
||||||
|
|
@ -24,20 +28,35 @@ export class DummyDetailComponent {
|
||||||
xdescribe('GeneralComponent', () => {
|
xdescribe('GeneralComponent', () => {
|
||||||
let component: TaskdetailsGeneralFieldsComponent;
|
let component: TaskdetailsGeneralFieldsComponent;
|
||||||
let fixture: ComponentFixture<TaskdetailsGeneralFieldsComponent>;
|
let fixture: ComponentFixture<TaskdetailsGeneralFieldsComponent>;
|
||||||
|
let classificationsService;
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '*', component: DummyDetailComponent }
|
{path: '*', component: DummyDetailComponent}
|
||||||
];
|
];
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(done => {
|
||||||
TestBed.configureTestingModule({
|
const configure = (testBed: TestBed) => {
|
||||||
imports: [FormsModule, HttpClientModule, RouterTestingModule.withRoutes(routes)],
|
TestBed.configureTestingModule({
|
||||||
declarations: [TaskdetailsGeneralFieldsComponent, DummyDetailComponent],
|
imports: [FormsModule, HttpClientModule, RouterTestingModule.withRoutes(routes)],
|
||||||
providers: [ClassificationsService, HttpClient, ClassificationCategoriesService, CustomFieldsService,
|
declarations: [TaskdetailsGeneralFieldsComponent, DummyDetailComponent],
|
||||||
DomainService, RequestInProgressService, SelectedRouteService]
|
providers: [HttpClient, ClassificationCategoriesService, CustomFieldsService,
|
||||||
})
|
DomainService, RequestInProgressService, SelectedRouteService, ClassificationsService]
|
||||||
.compileComponents();
|
})
|
||||||
}));
|
};
|
||||||
|
configureTests(configure).then(testBed => {
|
||||||
|
classificationsService = TestBed.get(ClassificationsService);
|
||||||
|
spyOn(classificationsService, 'getClassificationsByDomain').and.returnValue(new ClassificationResource(
|
||||||
|
{
|
||||||
|
'classificationSummaryResourceList': new Array<Classification>(
|
||||||
|
new Classification('id1', '1', 'category', 'type', 'domain_a', 'classification1', 'parentId',
|
||||||
|
1, 'service', new Links({ 'href': 'someurl' })),
|
||||||
|
new Classification('id2', '2', 'category', 'type', 'domain_a', 'classification2', 'parentId2',
|
||||||
|
1, 'service', new Links({ 'href': 'someurl' })))
|
||||||
|
}, new Links({ 'href': 'someurl' })
|
||||||
|
));
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(TaskdetailsGeneralFieldsComponent);
|
fixture = TestBed.createComponent(TaskdetailsGeneralFieldsComponent);
|
||||||
|
|
@ -48,4 +67,10 @@ xdescribe('GeneralComponent', () => {
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call to getClassificationsByDomain', done => {
|
||||||
|
component.ngOnInit();
|
||||||
|
expect(classificationsService.getClassificationsByDomain).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
import { Component, EventEmitter, Input, OnInit, Output, ViewChild, SimpleChanges, OnChanges, HostListener } from '@angular/core';
|
import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild} from '@angular/core';
|
||||||
import { Task } from 'app/workplace/models/task';
|
import {Task} from 'app/workplace/models/task';
|
||||||
import { Classification } from '../../../models/classification';
|
import {Classification} from '../../../models/classification';
|
||||||
import { ClassificationsService } from '../../../services/classifications/classifications.service';
|
import {ClassificationsService} from '../../../services/classifications/classifications.service';
|
||||||
import { CustomFieldsService } from 'app/services/custom-fields/custom-fields.service';
|
import {CustomFieldsService} from 'app/services/custom-fields/custom-fields.service';
|
||||||
import { FormsValidatorService } from 'app/shared/services/forms/forms-validator.service';
|
import {FormsValidatorService} from 'app/shared/services/forms/forms-validator.service';
|
||||||
import { NgForm } from '@angular/forms';
|
import {NgForm} from '@angular/forms';
|
||||||
|
import {DomainService} from '../../../services/domain/domain.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-task-details-general-fields',
|
selector: 'taskana-task-details-general-fields',
|
||||||
|
|
@ -21,8 +22,6 @@ export class TaskdetailsGeneralFieldsComponent implements OnInit, OnChanges {
|
||||||
saveToggleTriggered: boolean;
|
saveToggleTriggered: boolean;
|
||||||
@Output() formValid: EventEmitter<boolean> = new EventEmitter<boolean>();
|
@Output() formValid: EventEmitter<boolean> = new EventEmitter<boolean>();
|
||||||
|
|
||||||
@Output() classificationsReceived: EventEmitter<Classification[]> = new EventEmitter<Classification[]>();
|
|
||||||
|
|
||||||
@ViewChild('TaskForm')
|
@ViewChild('TaskForm')
|
||||||
taskForm: NgForm;
|
taskForm: NgForm;
|
||||||
|
|
||||||
|
|
@ -38,7 +37,12 @@ export class TaskdetailsGeneralFieldsComponent implements OnInit, OnChanges {
|
||||||
constructor(
|
constructor(
|
||||||
private classificationService: ClassificationsService,
|
private classificationService: ClassificationsService,
|
||||||
private customFieldsService: CustomFieldsService,
|
private customFieldsService: CustomFieldsService,
|
||||||
private formsValidatorService: FormsValidatorService) {
|
private formsValidatorService: FormsValidatorService,
|
||||||
|
private domainService: DomainService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getClassificationByDomain();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
|
@ -47,20 +51,10 @@ export class TaskdetailsGeneralFieldsComponent implements OnInit, OnChanges {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.requestInProgress = true;
|
|
||||||
this.classificationService.getClassifications().subscribe(classificationList => {
|
|
||||||
this.requestInProgress = false;
|
|
||||||
this.classifications = classificationList;
|
|
||||||
this.classificationsReceived.emit(this.classifications);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
selectClassification(classification: Classification) {
|
selectClassification(classification: Classification) {
|
||||||
this.task.classificationSummaryResource = classification;
|
this.task.classificationSummaryResource = classification;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
isFieldValid(field: string): boolean {
|
isFieldValid(field: string): boolean {
|
||||||
return this.formsValidatorService.isFieldValid(this.taskForm, field);
|
return this.formsValidatorService.isFieldValid(this.taskForm, field);
|
||||||
}
|
}
|
||||||
|
|
@ -81,4 +75,15 @@ export class TaskdetailsGeneralFieldsComponent implements OnInit, OnChanges {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private changedClassification(itemSelected: any) {
|
||||||
|
this.task.classificationSummaryResource = itemSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getClassificationByDomain() {
|
||||||
|
this.requestInProgress = true;
|
||||||
|
this.classifications = (await this.classificationService.getClassificationsByDomain(this.domainService.getSelectedDomainValue()))
|
||||||
|
._embedded.classificationSummaryResourceList;
|
||||||
|
this.requestInProgress = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,6 @@ export class TaskdetailsComponent implements OnInit, OnDestroy {
|
||||||
this.onSave();
|
this.onSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
openTask() {
|
openTask() {
|
||||||
this.router.navigate([{outlets: {detail: `task/${this.currentId}`}}], {relativeTo: this.route.parent});
|
this.router.navigate([{outlets: {detail: `task/${this.currentId}`}}], {relativeTo: this.route.parent});
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +123,6 @@ export class TaskdetailsComponent implements OnInit, OnDestroy {
|
||||||
this.tabSelected = tab;
|
this.tabSelected = tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
backClicked(): void {
|
backClicked(): void {
|
||||||
this.task = undefined;
|
this.task = undefined;
|
||||||
this.taskService.selectTask(this.task);
|
this.taskService.selectTask(this.task);
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ export class TaskListToolbarComponent implements OnInit {
|
||||||
toolbarState = false;
|
toolbarState = false;
|
||||||
filterType = TaskanaType.TASKS;
|
filterType = TaskanaType.TASKS;
|
||||||
searched = false;
|
searched = false;
|
||||||
searchParam = 'search';
|
|
||||||
|
|
||||||
search = Search;
|
search = Search;
|
||||||
searchSelected: Search = Search.byWorkbasket;
|
searchSelected: Search = Search.byWorkbasket;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
border-bottom-right-radius: 0;
|
border-bottom-right-radius: 0;
|
||||||
border-top-right-radius: 0;
|
border-top-right-radius: 0;
|
||||||
}
|
}
|
||||||
.btn-group ul + .btn, {
|
.btn-group ul + .btn {
|
||||||
margin-left: -1px;
|
margin-left: -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue