TSK-439 Add classification types call
This commit is contained in:
parent
e79829c516
commit
80e61cfb8c
|
|
@ -18,6 +18,8 @@ import { TreeNodeModel } from 'app/models/tree-node';
|
||||||
import { ErrorModalService } from 'app/services/errorModal/error-modal.service';
|
import { ErrorModalService } from 'app/services/errorModal/error-modal.service';
|
||||||
import { AlertService } from 'app/services/alert/alert.service';
|
import { AlertService } from 'app/services/alert/alert.service';
|
||||||
import { TreeService } from 'app/services/tree/tree.service';
|
import { TreeService } from 'app/services/tree/tree.service';
|
||||||
|
import { ClassificationTypesService } from 'app/services/classification-types/classification-types.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-dummy-detail',
|
selector: 'taskana-dummy-detail',
|
||||||
|
|
@ -36,7 +38,7 @@ describe('ClassificationDetailsComponent', () => {
|
||||||
const treeNodes: Array<TreeNodeModel> = new Array(new TreeNodeModel());
|
const treeNodes: Array<TreeNodeModel> = new Array(new TreeNodeModel());
|
||||||
const classificationTypes: Array<string> = new Array<string>('type1', 'type2');
|
const classificationTypes: Array<string> = new Array<string>('type1', 'type2');
|
||||||
let classificationsSpy, classificationsTypesSpy;
|
let classificationsSpy, classificationsTypesSpy;
|
||||||
let classificationsService;
|
let classificationsService, classificationTypesService;
|
||||||
let treeService;
|
let treeService;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
|
|
@ -44,7 +46,7 @@ describe('ClassificationDetailsComponent', () => {
|
||||||
imports: [FormsModule, HttpClientModule, RouterTestingModule.withRoutes(routes)],
|
imports: [FormsModule, HttpClientModule, RouterTestingModule.withRoutes(routes)],
|
||||||
declarations: [ClassificationDetailsComponent, SpinnerComponent, DummyDetailComponent],
|
declarations: [ClassificationDetailsComponent, SpinnerComponent, DummyDetailComponent],
|
||||||
providers: [MasterAndDetailService, RequestInProgressService, ClassificationsService, HttpClient, ErrorModalService, AlertService,
|
providers: [MasterAndDetailService, RequestInProgressService, ClassificationsService, HttpClient, ErrorModalService, AlertService,
|
||||||
TreeService]
|
TreeService, ClassificationTypesService]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
@ -53,8 +55,10 @@ describe('ClassificationDetailsComponent', () => {
|
||||||
fixture = TestBed.createComponent(ClassificationDetailsComponent);
|
fixture = TestBed.createComponent(ClassificationDetailsComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
classificationsService = TestBed.get(ClassificationsService);
|
classificationsService = TestBed.get(ClassificationsService);
|
||||||
|
classificationTypesService = TestBed.get(ClassificationTypesService);
|
||||||
classificationsSpy = spyOn(classificationsService, 'getClassifications').and.returnValue(Observable.of(treeNodes));
|
classificationsSpy = spyOn(classificationsService, 'getClassifications').and.returnValue(Observable.of(treeNodes));
|
||||||
classificationsTypesSpy = spyOn(classificationsService, 'getClassificationTypes').and.returnValue(Observable.of(classificationTypes));
|
classificationsTypesSpy = spyOn(classificationTypesService, 'getClassificationTypes')
|
||||||
|
.and.returnValue(Observable.of(classificationTypes));
|
||||||
spyOn(classificationsService, 'deleteClassification').and.returnValue(Observable.of(true));
|
spyOn(classificationsService, 'deleteClassification').and.returnValue(Observable.of(true));
|
||||||
|
|
||||||
treeService = TestBed.get(TreeService);
|
treeService = TestBed.get(TreeService);
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import { ErrorModalService } from 'app/services/errorModal/error-modal.service';
|
||||||
import { RequestInProgressService } from 'app/services/requestInProgress/request-in-progress.service';
|
import { RequestInProgressService } from 'app/services/requestInProgress/request-in-progress.service';
|
||||||
import { AlertService } from 'app/services/alert/alert.service';
|
import { AlertService } from 'app/services/alert/alert.service';
|
||||||
import { TreeService } from 'app/services/tree/tree.service';
|
import { TreeService } from 'app/services/tree/tree.service';
|
||||||
|
import { ClassificationTypesService } from 'app/services/classification-types/classification-types.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-classification-details',
|
selector: 'taskana-classification-details',
|
||||||
|
|
@ -48,12 +49,13 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
||||||
private errorModalService: ErrorModalService,
|
private errorModalService: ErrorModalService,
|
||||||
private requestInProgressService: RequestInProgressService,
|
private requestInProgressService: RequestInProgressService,
|
||||||
private alertService: AlertService,
|
private alertService: AlertService,
|
||||||
private treeService: TreeService) { }
|
private treeService: TreeService,
|
||||||
|
private classificationTypeService: ClassificationTypesService) { }
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.classificationsService.getClassificationTypes().subscribe((classificationTypes: Array<string>) => {
|
this.classificationTypeService.getClassificationTypes().subscribe((classificationTypes: Array<string>) => {
|
||||||
this.classificationTypes = classificationTypes;
|
this.classificationTypes = classificationTypes;
|
||||||
})
|
})
|
||||||
this.classificationSelectedSubscription = this.classificationsService.getSelectedClassification()
|
this.classificationSelectedSubscription = this.classificationsService.getSelectedClassification()
|
||||||
|
|
@ -161,7 +163,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
||||||
private getClassificationInformation(classificationIdSelected: string) {
|
private getClassificationInformation(classificationIdSelected: string) {
|
||||||
if (this.action === ACTION.CREATE) { // CREATE
|
if (this.action === ACTION.CREATE) { // CREATE
|
||||||
this.classification = new ClassificationDefinition();
|
this.classification = new ClassificationDefinition();
|
||||||
this.selectedClassificationSubscription = this.classificationsService.getSelectedClassificationType().subscribe(value => {
|
this.selectedClassificationSubscription = this.classificationTypeService.getSelectedClassificationType().subscribe(value => {
|
||||||
if (this.classification) { this.classification.type = value; }
|
if (this.classification) { this.classification.type = value; }
|
||||||
});
|
});
|
||||||
this.addDateToClassification();
|
this.addDateToClassification();
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import { ClassificationsService } from 'app/services/classifications/classificat
|
||||||
import { ClassificationDefinitionService } from 'app/services/classification-definition/classification-definition.service';
|
import { ClassificationDefinitionService } from 'app/services/classification-definition/classification-definition.service';
|
||||||
import { DomainService } from 'app/services/domains/domain.service';
|
import { DomainService } from 'app/services/domains/domain.service';
|
||||||
import { ErrorModalService } from 'app/services/errorModal/error-modal.service';
|
import { ErrorModalService } from 'app/services/errorModal/error-modal.service';
|
||||||
|
import { ClassificationTypesService } from 'app/services/classification-types/classification-types.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-tree',
|
selector: 'taskana-tree',
|
||||||
|
|
@ -48,7 +49,7 @@ describe('ClassificationListComponent', () => {
|
||||||
const treeNodes: Array<TreeNodeModel> = new Array(new TreeNodeModel());
|
const treeNodes: Array<TreeNodeModel> = new Array(new TreeNodeModel());
|
||||||
const classificationTypes: Array<string> = new Array<string>('type1', 'type2');
|
const classificationTypes: Array<string> = new Array<string>('type1', 'type2');
|
||||||
let classificationsSpy, classificationsTypesSpy;
|
let classificationsSpy, classificationsTypesSpy;
|
||||||
let classificationsService;
|
let classificationsService, classificationTypesService;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
|
@ -57,7 +58,7 @@ describe('ClassificationListComponent', () => {
|
||||||
imports: [HttpClientModule, RouterTestingModule.withRoutes(routes)],
|
imports: [HttpClientModule, RouterTestingModule.withRoutes(routes)],
|
||||||
providers: [
|
providers: [
|
||||||
HttpClient, WorkbasketDefinitionService, AlertService, ClassificationsService, DomainService, ClassificationDefinitionService,
|
HttpClient, WorkbasketDefinitionService, AlertService, ClassificationsService, DomainService, ClassificationDefinitionService,
|
||||||
ErrorModalService
|
ErrorModalService, ClassificationTypesService
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
@ -68,8 +69,10 @@ describe('ClassificationListComponent', () => {
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
|
||||||
classificationsService = TestBed.get(ClassificationsService);
|
classificationsService = TestBed.get(ClassificationsService);
|
||||||
|
classificationTypesService = TestBed.get(ClassificationTypesService);
|
||||||
classificationsSpy = spyOn(classificationsService, 'getClassifications').and.returnValue(Observable.of(treeNodes));
|
classificationsSpy = spyOn(classificationsService, 'getClassifications').and.returnValue(Observable.of(treeNodes));
|
||||||
classificationsTypesSpy = spyOn(classificationsService, 'getClassificationTypes').and.returnValue(Observable.of(classificationTypes));
|
classificationsTypesSpy = spyOn(classificationTypesService, 'getClassificationTypes')
|
||||||
|
.and.returnValue(Observable.of(classificationTypes));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import { Classification } from 'app/models/classification';
|
||||||
import { TreeNodeModel } from 'app/models/tree-node';
|
import { TreeNodeModel } from 'app/models/tree-node';
|
||||||
|
|
||||||
import { ClassificationsService } from 'app/services/classifications/classifications.service';
|
import { ClassificationsService } from 'app/services/classifications/classifications.service';
|
||||||
|
import { ClassificationTypesService } from 'app/services/classification-types/classification-types.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-classification-list',
|
selector: 'taskana-classification-list',
|
||||||
|
|
@ -33,7 +34,8 @@ export class ClassificationListComponent implements OnInit, OnDestroy {
|
||||||
constructor(
|
constructor(
|
||||||
private classificationService: ClassificationsService,
|
private classificationService: ClassificationsService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute) {
|
private route: ActivatedRoute,
|
||||||
|
private classificationTypeService: ClassificationTypesService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
@ -42,7 +44,7 @@ export class ClassificationListComponent implements OnInit, OnDestroy {
|
||||||
.subscribe(value => {
|
.subscribe(value => {
|
||||||
this.performRequest(true);
|
this.performRequest(true);
|
||||||
})
|
})
|
||||||
this.selectedClassificationSubscription = this.classificationService.getSelectedClassificationType().subscribe(value => {
|
this.selectedClassificationSubscription = this.classificationTypeService.getSelectedClassificationType().subscribe(value => {
|
||||||
this.classificationTypeSelected = value;
|
this.classificationTypeSelected = value;
|
||||||
this.performRequest();
|
this.performRequest();
|
||||||
})
|
})
|
||||||
|
|
@ -51,7 +53,7 @@ export class ClassificationListComponent implements OnInit, OnDestroy {
|
||||||
selectClassificationType(classificationTypeSelected: string) {
|
selectClassificationType(classificationTypeSelected: string) {
|
||||||
this.classifications = [];
|
this.classifications = [];
|
||||||
this.requestInProgress = true;
|
this.requestInProgress = true;
|
||||||
this.classificationService.selectClassificationType(classificationTypeSelected);
|
this.classificationTypeService.selectClassificationType(classificationTypeSelected);
|
||||||
this.classificationService.getClassifications(true, classificationTypeSelected)
|
this.classificationService.getClassifications(true, classificationTypeSelected)
|
||||||
.subscribe((classifications: Array<TreeNodeModel>) => {
|
.subscribe((classifications: Array<TreeNodeModel>) => {
|
||||||
this.classifications = classifications;
|
this.classifications = classifications;
|
||||||
|
|
@ -86,7 +88,7 @@ export class ClassificationListComponent implements OnInit, OnDestroy {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
this.classifications = classifications;
|
this.classifications = classifications;
|
||||||
this.classificationTypeServiceSubscription = this.classificationService.getClassificationTypes()
|
this.classificationTypeServiceSubscription = this.classificationTypeService.getClassificationTypes()
|
||||||
.subscribe((classificationsTypes: Array<string>) => {
|
.subscribe((classificationsTypes: Array<string>) => {
|
||||||
this.classificationsTypes = classificationsTypes;
|
this.classificationsTypes = classificationsTypes;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ import { WorkbasketDefinitionService } from './services/workbasket-definition/wo
|
||||||
import { SelectedRouteService } from './services/selected-route/selected-route';
|
import { SelectedRouteService } from './services/selected-route/selected-route';
|
||||||
import { ClassificationsService } from './services/classifications/classifications.service';
|
import { ClassificationsService } from './services/classifications/classifications.service';
|
||||||
import { TreeService } from './services/tree/tree.service';
|
import { TreeService } from './services/tree/tree.service';
|
||||||
|
import { ClassificationTypesService } from './services/classification-types/classification-types.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pipes
|
* Pipes
|
||||||
|
|
@ -131,7 +132,8 @@ const DECLARATIONS = [
|
||||||
OrientationService,
|
OrientationService,
|
||||||
SelectedRouteService,
|
SelectedRouteService,
|
||||||
ClassificationsService,
|
ClassificationsService,
|
||||||
TreeService
|
TreeService,
|
||||||
|
ClassificationTypesService
|
||||||
],
|
],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { TestBed, inject } from '@angular/core/testing';
|
||||||
|
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
|
||||||
|
import { ClassificationTypesService } from './classification-types.service';
|
||||||
|
|
||||||
|
describe('ClassificationTypesService', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [HttpClientModule],
|
||||||
|
providers: [HttpClient, ClassificationTypesService]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', inject([ClassificationTypesService], (service: ClassificationTypesService) => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import { Subject } from 'rxjs/Subject';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ClassificationTypesService {
|
||||||
|
private url = environment.taskanaRestUrl + '/v1/classification-types';
|
||||||
|
httpOptions = {
|
||||||
|
headers: new HttpHeaders({
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': 'Basic VEVBTUxFQURfMTpURUFNTEVBRF8x'
|
||||||
|
})
|
||||||
|
};
|
||||||
|
private classificationTypeSelectedValue = 'TASK';
|
||||||
|
private classificationTypeSelected = new BehaviorSubject<string>(this.classificationTypeSelectedValue);
|
||||||
|
|
||||||
|
constructor(private httpClient: HttpClient) { }
|
||||||
|
|
||||||
|
getClassificationTypes(): Observable<Array<string>> {
|
||||||
|
return this.httpClient.get<Array<string>>(this.url, this.httpOptions);
|
||||||
|
};
|
||||||
|
|
||||||
|
selectClassificationType(id: string) {
|
||||||
|
this.classificationTypeSelectedValue = id;
|
||||||
|
this.classificationTypeSelected.next(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
getSelectedClassificationType(): Observable<string> {
|
||||||
|
return this.classificationTypeSelected.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,15 +1,18 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
import { environment } from '../../../environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { Subject } from 'rxjs/Subject';
|
import { Subject } from 'rxjs/Subject';
|
||||||
|
import 'rxjs/add/observable/forkJoin';
|
||||||
|
import 'rxjs/add/observable/combineLatest';
|
||||||
|
|
||||||
import { Classification } from 'app/models/classification';
|
import { Classification } from 'app/models/classification';
|
||||||
import { TreeNodeModel } from 'app/models/tree-node';
|
import { TreeNodeModel } from 'app/models/tree-node';
|
||||||
import { ClassificationDefinition } from 'app/models/classification-definition';
|
import { ClassificationDefinition } from 'app/models/classification-definition';
|
||||||
|
|
||||||
import { ClassificationResource } from '../../models/classification-resource';
|
import { ClassificationResource } from '../../models/classification-resource';
|
||||||
|
import { ClassificationTypesService } from '../classification-types/classification-types.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ClassificationsService {
|
export class ClassificationsService {
|
||||||
|
|
@ -17,8 +20,6 @@ export class ClassificationsService {
|
||||||
private url = environment.taskanaRestUrl + '/v1/classifications';
|
private url = environment.taskanaRestUrl + '/v1/classifications';
|
||||||
private classificationSelected = new Subject<string>();
|
private classificationSelected = new Subject<string>();
|
||||||
private classificationSaved = new Subject<number>();
|
private classificationSaved = new Subject<number>();
|
||||||
private classificationTypeSelectedValue = 'TASK';
|
|
||||||
private classificationTypeSelected = new BehaviorSubject<string>(this.classificationTypeSelectedValue);
|
|
||||||
|
|
||||||
httpOptions = {
|
httpOptions = {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
|
|
@ -30,29 +31,20 @@ export class ClassificationsService {
|
||||||
private classificationRef: Observable<ClassificationResource>;
|
private classificationRef: Observable<ClassificationResource>;
|
||||||
private classificationTypes: Array<string>;
|
private classificationTypes: Array<string>;
|
||||||
|
|
||||||
constructor(private httpClient: HttpClient) {
|
constructor(private httpClient: HttpClient, private classificationTypeService: ClassificationTypesService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET
|
// GET
|
||||||
getClassifications(forceRequest = false, domain = ''): Observable<Array<TreeNodeModel>> {
|
getClassifications(forceRequest = false, domain = ''): Observable<any> {
|
||||||
|
|
||||||
|
const classificationTypes = this.classificationTypeService.getSelectedClassificationType();
|
||||||
if (!forceRequest && this.classificationRef) {
|
if (!forceRequest && this.classificationRef) {
|
||||||
return this.classificationRef.map((response: ClassificationResource) => {
|
return this.getClassificationObservable(domain, this.classificationRef)
|
||||||
if (!response._embedded) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return this.buildHierarchy(response._embedded.classificationSummaryResourceList, this.classificationTypeSelectedValue, domain);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
this.classificationRef = this.httpClient.get<ClassificationResource>(`${environment.taskanaRestUrl}/v1/classifications`,
|
this.classificationRef = this.httpClient.get<ClassificationResource>(`${environment.taskanaRestUrl}/v1/classifications`,
|
||||||
this.httpOptions);
|
this.httpOptions);
|
||||||
|
return this.getClassificationObservable(domain, this.classificationRef)
|
||||||
|
|
||||||
return this.classificationRef.map((response: ClassificationResource) => {
|
|
||||||
if (!response._embedded) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return this.buildHierarchy(response._embedded.classificationSummaryResourceList, this.classificationTypeSelectedValue, domain);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET
|
// GET
|
||||||
|
|
@ -60,26 +52,11 @@ export class ClassificationsService {
|
||||||
return this.httpClient.get<ClassificationDefinition>(`${environment.taskanaRestUrl}/v1/classifications/${id}`, this.httpOptions)
|
return this.httpClient.get<ClassificationDefinition>(`${environment.taskanaRestUrl}/v1/classifications/${id}`, this.httpOptions)
|
||||||
.do((classification: ClassificationDefinition) => {
|
.do((classification: ClassificationDefinition) => {
|
||||||
if (classification) {
|
if (classification) {
|
||||||
this.selectClassificationType(classification.type);
|
this.classificationTypeService.selectClassificationType(classification.type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getClassificationTypes(): Observable<Array<string>> {
|
|
||||||
const typesSubject = new Subject<Array<string>>();
|
|
||||||
this.classificationRef.subscribe((classifications: ClassificationResource) => {
|
|
||||||
if (!classifications._embedded) {
|
|
||||||
return typesSubject;
|
|
||||||
}
|
|
||||||
const types = new Map<string, string>();
|
|
||||||
classifications._embedded.classificationSummaryResourceList.forEach(element => {
|
|
||||||
types.set(element.type, element.type);
|
|
||||||
});
|
|
||||||
|
|
||||||
typesSubject.next(this.map2Array(types));
|
|
||||||
});
|
|
||||||
return typesSubject.asObservable();
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST
|
// POST
|
||||||
postClassification(classification: Classification): Observable<Classification> {
|
postClassification(classification: Classification): Observable<Classification> {
|
||||||
|
|
@ -114,17 +91,23 @@ export class ClassificationsService {
|
||||||
return this.classificationSaved.asObservable();
|
return this.classificationSaved.asObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
selectClassificationType(id: string) {
|
|
||||||
this.classificationTypeSelectedValue = id;
|
|
||||||
this.classificationTypeSelected.next(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
getSelectedClassificationType(): Observable<string> {
|
|
||||||
return this.classificationTypeSelected.asObservable();
|
|
||||||
}
|
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
|
private getClassificationObservable(domain: string, clasisficationRef: Observable<any>): Observable<any> {
|
||||||
|
const classificationTypes = this.classificationTypeService.getSelectedClassificationType();
|
||||||
|
return Observable.combineLatest(
|
||||||
|
clasisficationRef,
|
||||||
|
classificationTypes
|
||||||
|
|
||||||
|
).map((data: any[]) => {
|
||||||
|
if (!data[0]._embedded) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return this.buildHierarchy(data[0]._embedded.classificationSummaryResourceList, data[1], domain);
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private buildHierarchy(classifications: Array<Classification>, type: string, domain: string) {
|
private buildHierarchy(classifications: Array<Classification>, type: string, domain: string) {
|
||||||
const roots = []
|
const roots = []
|
||||||
const children = new Array<any>();
|
const children = new Array<any>();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue