TSK-440 Fix loading... text when remove the last children of a node
This commit is contained in:
parent
36d66064a7
commit
e79829c516
|
@ -8,14 +8,16 @@ import { Observable } from 'rxjs/Observable';
|
||||||
|
|
||||||
import { ClassificationDetailsComponent } from './classification-details.component';
|
import { ClassificationDetailsComponent } from './classification-details.component';
|
||||||
import { SpinnerComponent } from 'app/shared/spinner/spinner.component';
|
import { SpinnerComponent } from 'app/shared/spinner/spinner.component';
|
||||||
|
import { ClassificationDefinition } from 'app/models/classification-definition';
|
||||||
|
import { LinksClassification } from 'app/models/links-classfication';
|
||||||
|
|
||||||
import { MasterAndDetailService } from 'app/services/masterAndDetail/master-and-detail.service';
|
import { MasterAndDetailService } from 'app/services/masterAndDetail/master-and-detail.service';
|
||||||
import { RequestInProgressService } from 'app/services/requestInProgress/request-in-progress.service';
|
import { RequestInProgressService } from 'app/services/requestInProgress/request-in-progress.service';
|
||||||
import { ClassificationsService } from 'app/services/classifications/classifications.service';
|
import { ClassificationsService } from 'app/services/classifications/classifications.service';
|
||||||
import { TreeNodeModel } from 'app/models/tree-node';
|
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 '../../../services/alert/alert.service';
|
import { AlertService } from 'app/services/alert/alert.service';
|
||||||
|
import { TreeService } from 'app/services/tree/tree.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-dummy-detail',
|
selector: 'taskana-dummy-detail',
|
||||||
|
@ -25,8 +27,7 @@ class DummyDetailComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: ':id', component: DummyDetailComponent, outlet: 'detail' },
|
{ path: 'administration/classifications', component: DummyDetailComponent }
|
||||||
{ path: 'classifications', component: DummyDetailComponent }
|
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('ClassificationDetailsComponent', () => {
|
describe('ClassificationDetailsComponent', () => {
|
||||||
|
@ -36,12 +37,14 @@ describe('ClassificationDetailsComponent', () => {
|
||||||
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;
|
||||||
|
let treeService;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
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]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
}));
|
}));
|
||||||
|
@ -52,10 +55,22 @@ describe('ClassificationDetailsComponent', () => {
|
||||||
classificationsService = TestBed.get(ClassificationsService);
|
classificationsService = TestBed.get(ClassificationsService);
|
||||||
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(classificationsService, 'getClassificationTypes').and.returnValue(Observable.of(classificationTypes));
|
||||||
|
spyOn(classificationsService, 'deleteClassification').and.returnValue(Observable.of(true));
|
||||||
|
|
||||||
|
treeService = TestBed.get(TreeService);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should trigger treeService remove node id after removing a node', () => {
|
||||||
|
const treeServiceSpy = spyOn(treeService, 'setRemovedNodeId');
|
||||||
|
component.classification = new ClassificationDefinition('id1', undefined, undefined, undefined, undefined, undefined, undefined,
|
||||||
|
undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined,
|
||||||
|
undefined, undefined, undefined, new LinksClassification({ 'self': '' }));
|
||||||
|
component.removeClassification();
|
||||||
|
expect(treeServiceSpy).toHaveBeenCalledWith('id1');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { MasterAndDetailService } from 'app/services/masterAndDetail/master-and-
|
||||||
import { ErrorModalService } from 'app/services/errorModal/error-modal.service';
|
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';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-classification-details',
|
selector: 'taskana-classification-details',
|
||||||
|
@ -46,7 +47,8 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
||||||
private masterAndDetailService: MasterAndDetailService,
|
private masterAndDetailService: MasterAndDetailService,
|
||||||
private errorModalService: ErrorModalService,
|
private errorModalService: ErrorModalService,
|
||||||
private requestInProgressService: RequestInProgressService,
|
private requestInProgressService: RequestInProgressService,
|
||||||
private alertService: AlertService) { }
|
private alertService: AlertService,
|
||||||
|
private treeService: TreeService) { }
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -97,6 +99,8 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
removeClassification() {
|
removeClassification() {
|
||||||
this.requestInProgressService.setRequestInProgress(true);
|
this.requestInProgressService.setRequestInProgress(true);
|
||||||
|
this.treeService.setRemovedNodeId(this.classification.classificationId);
|
||||||
|
|
||||||
this.classificationRemoveSubscription = this.classificationsService
|
this.classificationRemoveSubscription = this.classificationsService
|
||||||
.deleteClassification(this.classification._links.self.href)
|
.deleteClassification(this.classification._links.self.href)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { AlertService } from 'app/services/alert/alert.service';
|
||||||
import { ClassificationsService } from 'app/services/classifications/classifications.service';
|
import { ClassificationsService } from 'app/services/classifications/classifications.service';
|
||||||
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';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-tree',
|
selector: 'taskana-tree',
|
||||||
|
@ -37,8 +37,8 @@ class DummyDetailComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: ':id', component: DummyDetailComponent, outlet: 'detail' },
|
|
||||||
{ path: 'classifications', component: DummyDetailComponent }
|
{ path: ':id', component: DummyDetailComponent }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ describe('ClassificationListComponent', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(ClassificationListComponent);
|
fixture = TestBed.createComponent(ClassificationListComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
|
||||||
classificationsService = TestBed.get(ClassificationsService);
|
classificationsService = TestBed.get(ClassificationsService);
|
||||||
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(classificationsService, 'getClassificationTypes').and.returnValue(Observable.of(classificationTypes));
|
||||||
|
|
|
@ -33,7 +33,7 @@ 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) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
|
@ -55,6 +55,7 @@ import { ClassificationDefinitionService } from './services/classification-defin
|
||||||
import { WorkbasketDefinitionService } from './services/workbasket-definition/workbasket-definition.service';
|
import { WorkbasketDefinitionService } from './services/workbasket-definition/workbasket-definition.service';
|
||||||
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';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pipes
|
* Pipes
|
||||||
|
@ -129,7 +130,8 @@ const DECLARATIONS = [
|
||||||
SavingWorkbasketService,
|
SavingWorkbasketService,
|
||||||
OrientationService,
|
OrientationService,
|
||||||
SelectedRouteService,
|
SelectedRouteService,
|
||||||
ClassificationsService
|
ClassificationsService,
|
||||||
|
TreeService
|
||||||
],
|
],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import { Subject } from 'rxjs/Subject';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TreeService {
|
||||||
|
|
||||||
|
public removedNodeId = new Subject<string>();
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
setRemovedNodeId(value: string) {
|
||||||
|
this.removedNodeId.next(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
getRemovedNodeId() {
|
||||||
|
return this.removedNodeId.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,12 +1,13 @@
|
||||||
import { Input, Component } from '@angular/core';
|
import { Input, Component } from '@angular/core';
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { TaskanaTreeComponent } from './tree.component';
|
|
||||||
|
|
||||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { HttpModule } from '@angular/http';
|
import { HttpModule } from '@angular/http';
|
||||||
|
|
||||||
|
import { TaskanaTreeComponent } from './tree.component';
|
||||||
|
|
||||||
|
import { TreeService } from 'app/services/tree/tree.service';
|
||||||
|
|
||||||
// tslint:disable:component-selector
|
// tslint:disable:component-selector
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tree-root',
|
selector: 'tree-root',
|
||||||
|
@ -29,7 +30,8 @@ describe('TaskanaTreeComponent', () => {
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [AngularSvgIconModule, HttpClientModule, HttpModule],
|
imports: [AngularSvgIconModule, HttpClientModule, HttpModule],
|
||||||
declarations: [TaskanaTreeComponent, TreeVendorComponent]
|
declarations: [TaskanaTreeComponent, TreeVendorComponent],
|
||||||
|
providers: [TreeService]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { Component, OnInit, Input, Output, EventEmitter, ViewChild, AfterViewChecked } from '@angular/core';
|
import { Component, OnInit, Input, Output, EventEmitter, ViewChild, AfterViewChecked, OnChanges, SimpleChanges } from '@angular/core';
|
||||||
import { TreeNodeModel } from 'app/models/tree-node';
|
import { TreeNodeModel } from 'app/models/tree-node';
|
||||||
|
|
||||||
import { TREE_ACTIONS, KEYS, IActionMapping, ITreeOptions, ITreeState, TreeComponent, TreeNode } from 'angular-tree-component';
|
import { TREE_ACTIONS, KEYS, IActionMapping, ITreeOptions, ITreeState, TreeComponent, TreeNode } from 'angular-tree-component';
|
||||||
|
import { TreeService } from '../../services/tree/tree.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-tree',
|
selector: 'taskana-tree',
|
||||||
|
@ -34,12 +35,19 @@ export class TaskanaTreeComponent implements OnInit, AfterViewChecked {
|
||||||
levelPadding: 20
|
levelPadding: 20
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() { }
|
constructor(private treeService: TreeService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.selectNode(this.selectNodeId);
|
this.selectNode(this.selectNodeId);
|
||||||
|
this.treeService.getRemovedNodeId().subscribe(value => {
|
||||||
|
const removedNode = this.getNode(value);
|
||||||
|
if (removedNode.parent) {
|
||||||
|
removedNode.parent.collapse();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngAfterViewChecked(): void {
|
ngAfterViewChecked(): void {
|
||||||
if (this.selectNodeId && !this.tree.treeModel.getActiveNode()) {
|
if (this.selectNodeId && !this.tree.treeModel.getActiveNode()) {
|
||||||
this.selectNode(this.selectNodeId);
|
this.selectNode(this.selectNodeId);
|
||||||
|
@ -58,7 +66,7 @@ export class TaskanaTreeComponent implements OnInit, AfterViewChecked {
|
||||||
|
|
||||||
private selectNode(nodeId: string) {
|
private selectNode(nodeId: string) {
|
||||||
if (nodeId) {
|
if (nodeId) {
|
||||||
const selectedNode = this.getSelectedNode(nodeId)
|
const selectedNode = this.getNode(nodeId)
|
||||||
if (selectedNode) {
|
if (selectedNode) {
|
||||||
selectedNode.setIsActive(true)
|
selectedNode.setIsActive(true)
|
||||||
this.expandParent(selectedNode);
|
this.expandParent(selectedNode);
|
||||||
|
@ -72,7 +80,7 @@ export class TaskanaTreeComponent implements OnInit, AfterViewChecked {
|
||||||
activeNode.blur();
|
activeNode.blur();
|
||||||
}
|
}
|
||||||
|
|
||||||
private getSelectedNode(nodeId: string) {
|
private getNode(nodeId: string) {
|
||||||
return this.tree.treeModel.getNodeById(nodeId);
|
return this.tree.treeModel.getNodeById(nodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue