TSK-974: Fix some small Errors
This commit is contained in:
parent
010632537f
commit
8b7c8027e0
|
|
@ -8,7 +8,7 @@ import { TreeNodeModel } from 'app/models/tree-node';
|
||||||
|
|
||||||
import { ClassificationsService } from 'app/shared/services/classifications/classifications.service';
|
import { ClassificationsService } from 'app/shared/services/classifications/classifications.service';
|
||||||
import {
|
import {
|
||||||
ClassificationCategoriesService
|
ClassificationCategoriesService
|
||||||
} from 'app/shared/services/classifications/classification-categories.service';
|
} from 'app/shared/services/classifications/classification-categories.service';
|
||||||
import { Pair } from 'app/models/pair';
|
import { Pair } from 'app/models/pair';
|
||||||
import { ClassificationDefinition } from '../../../../models/classification-definition';
|
import { ClassificationDefinition } from '../../../../models/classification-definition';
|
||||||
|
|
@ -17,116 +17,116 @@ import {AlertModel, AlertType} from '../../../../models/alert';
|
||||||
import {AlertService} from '../../../../services/alert/alert.service';
|
import {AlertService} from '../../../../services/alert/alert.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-classification-list',
|
selector: 'taskana-classification-list',
|
||||||
templateUrl: './classification-list.component.html',
|
templateUrl: './classification-list.component.html',
|
||||||
styleUrls: ['./classification-list.component.scss']
|
styleUrls: ['./classification-list.component.scss']
|
||||||
})
|
})
|
||||||
export class ClassificationListComponent implements OnInit, OnDestroy {
|
export class ClassificationListComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
|
|
||||||
selectedCategory = '';
|
selectedCategory = '';
|
||||||
selectedId: string;
|
selectedId: string;
|
||||||
selectionToImport = TaskanaType.CLASSIFICATIONS;
|
selectionToImport = TaskanaType.CLASSIFICATIONS;
|
||||||
requestInProgress = false;
|
requestInProgress = false;
|
||||||
initialized = false;
|
initialized = false;
|
||||||
inputValue: string;
|
inputValue: string;
|
||||||
categories: Array<string> = [];
|
categories: Array<string> = [];
|
||||||
classifications: Array<Classification> = [];
|
classifications: Array<Classification> = [];
|
||||||
classificationsTypes: Array<string> = [];
|
classificationsTypes: Array<string> = [];
|
||||||
classificationTypeSelected: string;
|
classificationTypeSelected: string;
|
||||||
classificationServiceSubscription: Subscription;
|
classificationServiceSubscription: Subscription;
|
||||||
classificationTypeServiceSubscription: Subscription;
|
classificationTypeServiceSubscription: Subscription;
|
||||||
classificationSelectedSubscription: Subscription;
|
classificationSelectedSubscription: Subscription;
|
||||||
classificationSavedSubscription: Subscription;
|
classificationSavedSubscription: Subscription;
|
||||||
selectedClassificationSubscription: Subscription;
|
selectedClassificationSubscription: Subscription;
|
||||||
categoriesSubscription: Subscription;
|
categoriesSubscription: Subscription;
|
||||||
importingExportingSubscription: Subscription;
|
importingExportingSubscription: Subscription;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private classificationService: ClassificationsService,
|
private classificationService: ClassificationsService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private categoryService: ClassificationCategoriesService,
|
private categoryService: ClassificationCategoriesService,
|
||||||
private importExportService: ImportExportService,
|
private importExportService: ImportExportService,
|
||||||
private alertService: AlertService) {
|
private alertService: AlertService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.classificationSavedSubscription = this.classificationService
|
this.classificationSavedSubscription = this.classificationService
|
||||||
.classificationSavedTriggered()
|
.classificationSavedTriggered()
|
||||||
.subscribe(value => {
|
.subscribe(value => {
|
||||||
this.performRequest(true);
|
this.performRequest(true);
|
||||||
});
|
});
|
||||||
this.selectedClassificationSubscription = this.categoryService.getSelectedClassificationType().subscribe(value => {
|
this.selectedClassificationSubscription = this.categoryService.getSelectedClassificationType().subscribe(value => {
|
||||||
this.classificationTypeSelected = value;
|
this.classificationTypeSelected = value;
|
||||||
this.performRequest();
|
this.performRequest();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.categoriesSubscription =
|
this.categoriesSubscription =
|
||||||
this.categoryService.getCategories(this.classificationTypeSelected).subscribe((categories: Array<string>) => {
|
this.categoryService.getCategories(this.classificationTypeSelected).subscribe((categories: Array<string>) => {
|
||||||
this.categories = categories;
|
this.categories = categories;
|
||||||
});
|
});
|
||||||
this.importingExportingSubscription = this.importExportService.getImportingFinished().subscribe((value: Boolean) => {
|
this.importingExportingSubscription = this.importExportService.getImportingFinished().subscribe((value: Boolean) => {
|
||||||
this.performRequest(true);
|
this.performRequest(true);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
selectClassificationType(classificationTypeSelected: string) {
|
selectClassificationType(classificationTypeSelected: string) {
|
||||||
this.classifications = [];
|
this.classifications = [];
|
||||||
this.categoryService.selectClassificationType(classificationTypeSelected);
|
this.categoryService.selectClassificationType(classificationTypeSelected);
|
||||||
this.getClassifications();
|
this.getClassifications();
|
||||||
this.selectClassification(undefined);
|
this.selectClassification(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
selectClassification(id: string) {
|
selectClassification(id: string) {
|
||||||
this.selectedId = id;
|
this.selectedId = id;
|
||||||
if (!id) {
|
if (!id) {
|
||||||
this.router.navigate(['taskana/administration/classifications']);
|
this.router.navigate(['taskana/administration/classifications']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.router.navigate([{ outlets: { detail: [this.selectedId] } }], { relativeTo: this.route });
|
this.router.navigate([{ outlets: { detail: [this.selectedId] } }], { relativeTo: this.route });
|
||||||
}
|
}
|
||||||
|
|
||||||
addClassification() {
|
addClassification() {
|
||||||
this.router.navigate([{ outlets: { detail: [`new-classification/${this.selectedId}`] } }], { relativeTo: this.route });
|
this.router.navigate([{ outlets: { detail: [`new-classification/${this.selectedId}`] } }], { relativeTo: this.route });
|
||||||
}
|
}
|
||||||
|
|
||||||
selectCategory(category: string) {
|
selectCategory(category: string) {
|
||||||
this.selectedCategory = category;
|
this.selectedCategory = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
getCategoryIcon(category: string): Pair {
|
getCategoryIcon(category: string): Pair {
|
||||||
return this.categoryService.getCategoryIcon(category);
|
return this.categoryService.getCategoryIcon(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
private performRequest(forceRequest = false) {
|
private performRequest(forceRequest = false) {
|
||||||
if (this.initialized && !forceRequest) {
|
if (this.initialized && !forceRequest) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.requestInProgress = true;
|
this.requestInProgress = true;
|
||||||
this.classifications = [];
|
this.classifications = [];
|
||||||
|
|
||||||
if (this.classificationServiceSubscription) { this.classificationServiceSubscription.unsubscribe() }
|
if (this.classificationServiceSubscription) { this.classificationServiceSubscription.unsubscribe() }
|
||||||
if (this.classificationSelectedSubscription) { this.classificationSelectedSubscription.unsubscribe() }
|
if (this.classificationSelectedSubscription) { this.classificationSelectedSubscription.unsubscribe() }
|
||||||
|
|
||||||
this.classificationServiceSubscription = this.classificationService.getClassifications()
|
this.classificationServiceSubscription = this.classificationService.getClassifications()
|
||||||
.subscribe((classifications: Array<TreeNodeModel>) => {
|
.subscribe((classifications: Array<TreeNodeModel>) => {
|
||||||
this.requestInProgress = false;
|
this.requestInProgress = false;
|
||||||
this.classifications = classifications;
|
this.classifications = classifications;
|
||||||
this.classificationTypeServiceSubscription = this.categoryService.getClassificationTypes()
|
this.classificationTypeServiceSubscription = this.categoryService.getClassificationTypes()
|
||||||
.subscribe((classificationsTypes: Array<string>) => {
|
.subscribe((classificationsTypes: Array<string>) => {
|
||||||
this.classificationsTypes = classificationsTypes;
|
this.classificationsTypes = classificationsTypes;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.classificationSelectedSubscription = this.classificationService.getSelectedClassification()
|
this.classificationSelectedSubscription = this.classificationService.getSelectedClassification()
|
||||||
.subscribe((classificationSelected: ClassificationDefinition) => {
|
.subscribe((classificationSelected: ClassificationDefinition) => {
|
||||||
this.selectedId = classificationSelected ? classificationSelected.classificationId : undefined;
|
this.selectedId = classificationSelected ? classificationSelected.classificationId : undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getClassifications(key: string = undefined) {
|
private getClassifications(key: string = undefined) {
|
||||||
this.requestInProgress = true;
|
this.requestInProgress = true;
|
||||||
|
|
@ -145,11 +145,11 @@ export class ClassificationListComponent implements OnInit, OnDestroy {
|
||||||
this.requestInProgress = $event;
|
this.requestInProgress = $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
if (this.classificationServiceSubscription) { this.classificationServiceSubscription.unsubscribe(); }
|
if (this.classificationServiceSubscription) { this.classificationServiceSubscription.unsubscribe(); }
|
||||||
if (this.classificationTypeServiceSubscription) { this.classificationTypeServiceSubscription.unsubscribe(); }
|
if (this.classificationTypeServiceSubscription) { this.classificationTypeServiceSubscription.unsubscribe(); }
|
||||||
if (this.classificationSelectedSubscription) { this.classificationSelectedSubscription.unsubscribe(); }
|
if (this.classificationSelectedSubscription) { this.classificationSelectedSubscription.unsubscribe(); }
|
||||||
if (this.classificationSavedSubscription) { this.classificationSavedSubscription.unsubscribe(); }
|
if (this.classificationSavedSubscription) { this.classificationSavedSubscription.unsubscribe(); }
|
||||||
if (this.importingExportingSubscription) { this.importingExportingSubscription.unsubscribe(); }
|
if (this.importingExportingSubscription) { this.importingExportingSubscription.unsubscribe(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,40 +2,40 @@ import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { ICONTYPES } from 'app/models/type';
|
import { ICONTYPES } from 'app/models/type';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-icon-type',
|
selector: 'taskana-icon-type',
|
||||||
templateUrl: './icon-type.component.html',
|
templateUrl: './icon-type.component.html',
|
||||||
styleUrls: ['./icon-type.component.scss']
|
styleUrls: ['./icon-type.component.scss']
|
||||||
})
|
})
|
||||||
export class IconTypeComponent implements OnInit {
|
export class IconTypeComponent implements OnInit {
|
||||||
|
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
type: ICONTYPES = ICONTYPES.ALL;
|
type: ICONTYPES = ICONTYPES.ALL;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
selected = false;
|
selected = false;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
tooltip = false;
|
tooltip = false;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
text: string = undefined;
|
text: string = undefined;
|
||||||
|
|
||||||
public static get allTypes(): Map<string, string> {
|
public static get allTypes(): Map<string, string> {
|
||||||
return new Map([['PERSONAL', 'Personal'], ['GROUP', 'Group'], ['CLEARANCE', 'Clearance'], ['TOPIC', 'Topic']])
|
return new Map([['PERSONAL', 'Personal'], ['GROUP', 'Group'], ['CLEARANCE', 'Clearance'], ['TOPIC', 'Topic']])
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getIconPath(type: string) {
|
getIconPath(type: string) {
|
||||||
return type === 'PERSONAL' ? 'user.svg' :
|
return type === 'PERSONAL' ? 'user.svg' :
|
||||||
type === 'GROUP' ? 'users.svg' :
|
type === 'GROUP' ? 'users.svg' :
|
||||||
type === 'TOPIC' ? 'topic.svg' :
|
type === 'TOPIC' ? 'topic.svg' :
|
||||||
type === 'CLEARANCE' ? 'clearance.svg' : 'asterisk.svg';
|
type === 'CLEARANCE' ? 'clearance.svg' : 'asterisk.svg';
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@ export class ImportExportService {
|
||||||
|
|
||||||
public importingFinished = new Subject<boolean>();
|
public importingFinished = new Subject<boolean>();
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
setImportingFinished(value: boolean) {
|
setImportingFinished(value: boolean) {
|
||||||
this.importingFinished.next(value);
|
this.importingFinished.next(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
getImportingFinished(): Observable<boolean> {
|
getImportingFinished(): Observable<boolean> {
|
||||||
return this.importingFinished.asObservable();
|
return this.importingFinished.asObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,91 +25,91 @@ import { AccessIdsService } from 'app/shared/services/access-ids/access-ids.serv
|
||||||
import { FormsValidatorService } from 'app/shared/services/forms/forms-validator.service';
|
import { FormsValidatorService } from 'app/shared/services/forms/forms-validator.service';
|
||||||
|
|
||||||
describe('AccessItemsComponent', () => {
|
describe('AccessItemsComponent', () => {
|
||||||
let component: AccessItemsComponent;
|
let component: AccessItemsComponent;
|
||||||
let fixture: ComponentFixture<AccessItemsComponent>;
|
let fixture: ComponentFixture<AccessItemsComponent>;
|
||||||
let workbasketService, debugElement, alertService, accessIdsService, formsValidatorService;
|
let workbasketService, debugElement, alertService, accessIdsService, formsValidatorService;
|
||||||
|
|
||||||
|
|
||||||
beforeEach(done => {
|
beforeEach(done => {
|
||||||
const configure = (testBed: TestBed) => {
|
const configure = (testBed: TestBed) => {
|
||||||
testBed.configureTestingModule({
|
testBed.configureTestingModule({
|
||||||
declarations: [AccessItemsComponent],
|
declarations: [AccessItemsComponent],
|
||||||
imports: [FormsModule, AngularSvgIconModule, HttpClientModule, ReactiveFormsModule],
|
imports: [FormsModule, AngularSvgIconModule, HttpClientModule, ReactiveFormsModule],
|
||||||
providers: [WorkbasketService, AlertService, GeneralModalService, SavingWorkbasketService, RequestInProgressService,
|
providers: [WorkbasketService, AlertService, GeneralModalService, SavingWorkbasketService, RequestInProgressService,
|
||||||
CustomFieldsService, AccessIdsService, FormsValidatorService]
|
CustomFieldsService, AccessIdsService, FormsValidatorService]
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
configureTests(configure).then(testBed => {
|
configureTests(configure).then(testBed => {
|
||||||
fixture = TestBed.createComponent(AccessItemsComponent);
|
fixture = TestBed.createComponent(AccessItemsComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
component.workbasket = new Workbasket('1', '', '', '', ICONTYPES.TOPIC, '', '', '', '', '', '', '', '', '', '', '', '',
|
component.workbasket = new Workbasket('1', '', '', '', ICONTYPES.TOPIC, '', '', '', '', '', '', '', '', '', '', '', '',
|
||||||
new Links(undefined, undefined, { 'href': 'someurl' }));
|
new Links(undefined, undefined, { 'href': 'someurl' }));
|
||||||
workbasketService = TestBed.get(WorkbasketService);
|
workbasketService = TestBed.get(WorkbasketService);
|
||||||
alertService = TestBed.get(AlertService);
|
alertService = TestBed.get(AlertService);
|
||||||
spyOn(workbasketService, 'getWorkBasketAccessItems').and.returnValue(of(new WorkbasketAccessItemsResource(
|
spyOn(workbasketService, 'getWorkBasketAccessItems').and.returnValue(of(new WorkbasketAccessItemsResource(
|
||||||
new Array<WorkbasketAccessItems>(
|
new Array<WorkbasketAccessItems>(
|
||||||
new WorkbasketAccessItems('id1', '1', 'accessID1', '', false, false, false, false, false, false, false, false,
|
new WorkbasketAccessItems('id1', '1', 'accessID1', '', false, false, false, false, false, false, false, false,
|
||||||
false, false, false, false, false, false, false, false, false),
|
false, false, false, false, false, false, false, false, false),
|
||||||
new WorkbasketAccessItems('id2', '1', 'accessID2'))
|
new WorkbasketAccessItems('id2', '1', 'accessID2'))
|
||||||
, new Links({ 'href': 'someurl' })
|
, new Links({ 'href': 'someurl' })
|
||||||
)));
|
)));
|
||||||
spyOn(workbasketService, 'updateWorkBasketAccessItem').and.returnValue(of(true)),
|
spyOn(workbasketService, 'updateWorkBasketAccessItem').and.returnValue(of(true)),
|
||||||
spyOn(alertService, 'triggerAlert').and.returnValue(of(true)),
|
spyOn(alertService, 'triggerAlert').and.returnValue(of(true)),
|
||||||
debugElement = fixture.debugElement.nativeElement;
|
debugElement = fixture.debugElement.nativeElement;
|
||||||
accessIdsService = TestBed.get(AccessIdsService);
|
accessIdsService = TestBed.get(AccessIdsService);
|
||||||
spyOn(accessIdsService, 'getAccessItemsInformation').and.returnValue(of(new Array<string>(
|
spyOn(accessIdsService, 'getAccessItemsInformation').and.returnValue(of(new Array<string>(
|
||||||
'accessID1', 'accessID2'
|
'accessID1', 'accessID2'
|
||||||
)));
|
)));
|
||||||
formsValidatorService = TestBed.get(FormsValidatorService);
|
formsValidatorService = TestBed.get(FormsValidatorService);
|
||||||
component.ngOnChanges({
|
component.ngOnChanges({
|
||||||
active: new SimpleChange(undefined, 'accessItems', true)
|
active: new SimpleChange(undefined, 'accessItems', true)
|
||||||
});
|
});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
document.body.removeChild(debugElement);
|
document.body.removeChild(debugElement);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show two access items if server returns two entries', () => {
|
it('should show two access items if server returns two entries', () => {
|
||||||
expect(debugElement.querySelectorAll('#table-access-items > tbody > tr').length).toBe(2);
|
expect(debugElement.querySelectorAll('#table-access-items > tbody > tr').length).toBe(2);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should remove an access item if remove button is clicked', () => {
|
it('should remove an access item if remove button is clicked', () => {
|
||||||
expect(debugElement.querySelectorAll('#table-access-items > tbody > tr').length).toBe(2);
|
expect(debugElement.querySelectorAll('#table-access-items > tbody > tr').length).toBe(2);
|
||||||
debugElement.querySelectorAll('#table-access-items > tbody > tr')[0].querySelector('td > button').click();
|
debugElement.querySelectorAll('#table-access-items > tbody > tr')[0].querySelector('td > button').click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(debugElement.querySelectorAll('#table-access-items > tbody > tr').length).toBe(1);
|
expect(debugElement.querySelectorAll('#table-access-items > tbody > tr').length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show alert successfull after saving', async(() => {
|
it('should show alert successfull after saving', async(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
spyOn(formsValidatorService, 'validateFormAccess').and.returnValue(Promise.resolve(true));
|
spyOn(formsValidatorService, 'validateFormAccess').and.returnValue(Promise.resolve(true));
|
||||||
component.onSubmit();
|
component.onSubmit();
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(alertService.triggerAlert).toHaveBeenCalledWith(
|
expect(alertService.triggerAlert).toHaveBeenCalledWith(
|
||||||
new AlertModel(AlertType.SUCCESS, `Workbasket ${component.workbasket.key} Access items were saved successfully`));
|
new AlertModel(AlertType.SUCCESS, `Workbasket ${component.workbasket.key} Access items were saved successfully`));
|
||||||
})
|
})
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should keep accessItemsClone length to previous value after clearing the form.', () => {
|
it('should keep accessItemsClone length to previous value after clearing the form.', () => {
|
||||||
expect(component.accessItemsClone.length).toBe(2);
|
expect(component.accessItemsClone.length).toBe(2);
|
||||||
component.remove(1);
|
component.remove(1);
|
||||||
expect(component.accessItemsClone.length).toBe(1);
|
expect(component.accessItemsClone.length).toBe(1);
|
||||||
component.clear();
|
component.clear();
|
||||||
expect(component.accessItemsClone.length).toBe(2);
|
expect(component.accessItemsClone.length).toBe(2);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -20,192 +20,193 @@ import { FormsValidatorService } from 'app/shared/services/forms/forms-validator
|
||||||
import { AccessIdDefinition } from 'app/models/access-id';
|
import { AccessIdDefinition } from 'app/models/access-id';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-workbasket-access-items',
|
selector: 'taskana-workbasket-access-items',
|
||||||
templateUrl: './access-items.component.html',
|
templateUrl: './access-items.component.html',
|
||||||
animations: [highlight],
|
animations: [highlight],
|
||||||
styleUrls: ['./access-items.component.scss']
|
styleUrls: ['./access-items.component.scss']
|
||||||
})
|
})
|
||||||
export class AccessItemsComponent implements OnChanges, OnDestroy {
|
export class AccessItemsComponent implements OnChanges, OnDestroy {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
workbasket: Workbasket;
|
workbasket: Workbasket;
|
||||||
@Input()
|
@Input()
|
||||||
action: string;
|
action: string;
|
||||||
@Input()
|
@Input()
|
||||||
active: string;
|
active: string;
|
||||||
badgeMessage = '';
|
badgeMessage = '';
|
||||||
|
|
||||||
accessIdField = this.customFieldsService.getCustomField('Owner', 'workbaskets.access-items.accessId');
|
accessIdField = this.customFieldsService.getCustomField('Owner', 'workbaskets.access-items.accessId');
|
||||||
custom1Field = this.customFieldsService.getCustomField('Custom 1', 'workbaskets.access-items.custom1');
|
custom1Field = this.customFieldsService.getCustomField('Custom 1', 'workbaskets.access-items.custom1');
|
||||||
custom2Field = this.customFieldsService.getCustomField('Custom 2', 'workbaskets.access-items.custom2');
|
custom2Field = this.customFieldsService.getCustomField('Custom 2', 'workbaskets.access-items.custom2');
|
||||||
custom3Field = this.customFieldsService.getCustomField('Custom 3', 'workbaskets.access-items.custom3');
|
custom3Field = this.customFieldsService.getCustomField('Custom 3', 'workbaskets.access-items.custom3');
|
||||||
custom4Field = this.customFieldsService.getCustomField('Custom 4', 'workbaskets.access-items.custom4');
|
custom4Field = this.customFieldsService.getCustomField('Custom 4', 'workbaskets.access-items.custom4');
|
||||||
custom5Field = this.customFieldsService.getCustomField('Custom 5', 'workbaskets.access-items.custom5');
|
custom5Field = this.customFieldsService.getCustomField('Custom 5', 'workbaskets.access-items.custom5');
|
||||||
custom6Field = this.customFieldsService.getCustomField('Custom 6', 'workbaskets.access-items.custom6');
|
custom6Field = this.customFieldsService.getCustomField('Custom 6', 'workbaskets.access-items.custom6');
|
||||||
custom7Field = this.customFieldsService.getCustomField('Custom 7', 'workbaskets.access-items.custom7');
|
custom7Field = this.customFieldsService.getCustomField('Custom 7', 'workbaskets.access-items.custom7');
|
||||||
custom8Field = this.customFieldsService.getCustomField('Custom 8', 'workbaskets.access-items.custom8');
|
custom8Field = this.customFieldsService.getCustomField('Custom 8', 'workbaskets.access-items.custom8');
|
||||||
custom9Field = this.customFieldsService.getCustomField('Custom 9', 'workbaskets.access-items.custom9');
|
custom9Field = this.customFieldsService.getCustomField('Custom 9', 'workbaskets.access-items.custom9');
|
||||||
custom10Field = this.customFieldsService.getCustomField('Custom 10', 'workbaskets.access-items.custom10');
|
custom10Field = this.customFieldsService.getCustomField('Custom 10', 'workbaskets.access-items.custom10');
|
||||||
custom11Field = this.customFieldsService.getCustomField('Custom 11', 'workbaskets.access-items.custom11');
|
custom11Field = this.customFieldsService.getCustomField('Custom 11', 'workbaskets.access-items.custom11');
|
||||||
custom12Field = this.customFieldsService.getCustomField('Custom 12', 'workbaskets.access-items.custom12');
|
custom12Field = this.customFieldsService.getCustomField('Custom 12', 'workbaskets.access-items.custom12');
|
||||||
|
|
||||||
accessItemsResource: WorkbasketAccessItemsResource;
|
accessItemsResource: WorkbasketAccessItemsResource;
|
||||||
accessItemsClone: Array<WorkbasketAccessItems>;
|
accessItemsClone: Array<WorkbasketAccessItems>;
|
||||||
accessItemsResetClone: Array<WorkbasketAccessItems>;
|
accessItemsResetClone: Array<WorkbasketAccessItems>;
|
||||||
requestInProgress = false;
|
requestInProgress = false;
|
||||||
modalTitle: string;
|
modalTitle: string;
|
||||||
modalErrorMessage: string;
|
modalErrorMessage: string;
|
||||||
accessItemsubscription: Subscription;
|
accessItemsubscription: Subscription;
|
||||||
savingAccessItemsSubscription: Subscription;
|
savingAccessItemsSubscription: Subscription;
|
||||||
AccessItemsForm = this.formBuilder.group({
|
AccessItemsForm = this.formBuilder.group({
|
||||||
accessItemsGroups: this.formBuilder.array([
|
accessItemsGroups: this.formBuilder.array([
|
||||||
])
|
])
|
||||||
});
|
});
|
||||||
toogleValidationAccessIdMap = new Map<number, boolean>();
|
toogleValidationAccessIdMap = new Map<number, boolean>();
|
||||||
private initialized = false;
|
private initialized = false;
|
||||||
|
|
||||||
setAccessItemsGroups(accessItems: Array<WorkbasketAccessItems>) {
|
setAccessItemsGroups(accessItems: Array<WorkbasketAccessItems>) {
|
||||||
const AccessItemsFormGroups = accessItems.map(accessItem => this.formBuilder.group(accessItem));
|
const AccessItemsFormGroups = accessItems.map(accessItem => this.formBuilder.group(accessItem));
|
||||||
AccessItemsFormGroups.map(accessItemGroup => {
|
AccessItemsFormGroups.map(accessItemGroup => {
|
||||||
accessItemGroup.controls['accessId'].setValidators(Validators.required);
|
accessItemGroup.controls['accessId'].setValidators(Validators.required);
|
||||||
});
|
});
|
||||||
const AccessItemsFormArray = this.formBuilder.array(AccessItemsFormGroups);
|
const AccessItemsFormArray = this.formBuilder.array(AccessItemsFormGroups);
|
||||||
this.AccessItemsForm.setControl('accessItemsGroups', AccessItemsFormArray);
|
this.AccessItemsForm.setControl('accessItemsGroups', AccessItemsFormArray);
|
||||||
};
|
};
|
||||||
|
|
||||||
get accessItemsGroups(): FormArray {
|
get accessItemsGroups(): FormArray {
|
||||||
return this.AccessItemsForm.get('accessItemsGroups') as FormArray;
|
return this.AccessItemsForm.get('accessItemsGroups') as FormArray;
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private workbasketService: WorkbasketService,
|
private workbasketService: WorkbasketService,
|
||||||
private alertService: AlertService,
|
private alertService: AlertService,
|
||||||
private generalModalService: GeneralModalService,
|
private generalModalService: GeneralModalService,
|
||||||
private savingWorkbaskets: SavingWorkbasketService,
|
private savingWorkbaskets: SavingWorkbasketService,
|
||||||
private requestInProgressService: RequestInProgressService,
|
private requestInProgressService: RequestInProgressService,
|
||||||
private customFieldsService: CustomFieldsService,
|
private customFieldsService: CustomFieldsService,
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private formsValidatorService: FormsValidatorService) {
|
private formsValidatorService: FormsValidatorService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
if (!this.initialized && changes.active && changes.active.currentValue === 'accessItems') {
|
if (!this.initialized && changes.active && changes.active.currentValue === 'accessItems') {
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
if (changes.action) {
|
if (changes.action) {
|
||||||
this.setBadge();
|
this.setBadge();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private init() {
|
private init() {
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
if (!this.workbasket._links.accessItems) {
|
if (!this.workbasket._links.accessItems) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.requestInProgress = true;
|
this.requestInProgress = true;
|
||||||
this.accessItemsubscription = this.workbasketService.getWorkBasketAccessItems(this.workbasket._links.accessItems.href)
|
this.accessItemsubscription = this.workbasketService.getWorkBasketAccessItems(this.workbasket._links.accessItems.href)
|
||||||
.subscribe((accessItemsResource: WorkbasketAccessItemsResource) => {
|
.subscribe((accessItemsResource: WorkbasketAccessItemsResource) => {
|
||||||
this.accessItemsResource = accessItemsResource;
|
this.accessItemsResource = accessItemsResource;
|
||||||
this.setAccessItemsGroups(accessItemsResource.accessItems);
|
this.setAccessItemsGroups(accessItemsResource.accessItems);
|
||||||
this.accessItemsClone = this.cloneAccessItems(accessItemsResource.accessItems);
|
this.accessItemsClone = this.cloneAccessItems(accessItemsResource.accessItems);
|
||||||
this.accessItemsResetClone = this.cloneAccessItems(accessItemsResource.accessItems);
|
this.accessItemsResetClone = this.cloneAccessItems(accessItemsResource.accessItems);
|
||||||
this.requestInProgress = false;
|
this.requestInProgress = false;
|
||||||
})
|
})
|
||||||
this.savingAccessItemsSubscription = this.savingWorkbaskets.triggeredAccessItemsSaving()
|
this.savingAccessItemsSubscription = this.savingWorkbaskets.triggeredAccessItemsSaving()
|
||||||
.subscribe((savingInformation: SavingInformation) => {
|
.subscribe((savingInformation: SavingInformation) => {
|
||||||
if (this.action === ACTION.COPY) {
|
if (this.action === ACTION.COPY) {
|
||||||
this.accessItemsResource._links.self.href = savingInformation.url;
|
this.accessItemsResource._links.self.href = savingInformation.url;
|
||||||
this.setWorkbasketIdForCopy(savingInformation.workbasketId);
|
this.setWorkbasketIdForCopy(savingInformation.workbasketId);
|
||||||
this.onSave();
|
this.onSave();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addAccessItem() {
|
addAccessItem() {
|
||||||
const newForm = this.formBuilder.group(
|
const newForm = this.formBuilder.group(
|
||||||
new WorkbasketAccessItems(undefined, this.workbasket.workbasketId, '', '', true));
|
new WorkbasketAccessItems(undefined, this.workbasket.workbasketId, '', '', true));
|
||||||
newForm.controls['accessId'].setValidators(Validators.required);
|
newForm.controls['accessId'].setValidators(Validators.required);
|
||||||
this.accessItemsGroups.push(newForm);
|
this.accessItemsGroups.push(newForm);
|
||||||
this.accessItemsClone.push(new WorkbasketAccessItems(undefined, this.workbasket.workbasketId, '', '', true));
|
this.accessItemsClone.push(new WorkbasketAccessItems(undefined, this.workbasket.workbasketId, '', '', true));
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
this.formsValidatorService.formSubmitAttempt = false;
|
this.formsValidatorService.formSubmitAttempt = false;
|
||||||
this.AccessItemsForm.reset();
|
this.AccessItemsForm.reset();
|
||||||
this.setAccessItemsGroups(this.accessItemsResetClone);
|
this.setAccessItemsGroups(this.accessItemsResetClone);
|
||||||
this.accessItemsClone = this.cloneAccessItems(this.accessItemsResetClone);
|
this.accessItemsClone = this.cloneAccessItems(this.accessItemsResetClone);
|
||||||
this.alertService.triggerAlert(new AlertModel(AlertType.INFO, 'Reset edited fields'))
|
this.alertService.triggerAlert(new AlertModel(AlertType.INFO, 'Reset edited fields'))
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(index: number) {
|
remove(index: number) {
|
||||||
this.accessItemsGroups.removeAt(index);
|
this.accessItemsGroups.removeAt(index);
|
||||||
this.accessItemsClone.splice(index, 1);
|
this.accessItemsClone.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
isFieldValid(field: string, index: number): boolean {
|
isFieldValid(field: string, index: number): boolean {
|
||||||
return this.formsValidatorService.isFieldValid(this.accessItemsGroups[index], field);
|
return this.formsValidatorService.isFieldValid(this.accessItemsGroups[index], field);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.formsValidatorService.formSubmitAttempt = true;
|
this.formsValidatorService.formSubmitAttempt = true;
|
||||||
this.formsValidatorService.validateFormAccess(this.accessItemsGroups, this.toogleValidationAccessIdMap).then(value => {
|
this.formsValidatorService.validateFormAccess(this.accessItemsGroups, this.toogleValidationAccessIdMap).then(value => {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.onSave();
|
this.onSave();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
checkAll(row: number, value: any) {
|
checkAll(row: number, value: any) {
|
||||||
const checkAll = value.target.checked;
|
const checkAll = value.target.checked;
|
||||||
const workbasketAccessItemsObj = new WorkbasketAccessItems();
|
const workbasketAccessItemsObj = new WorkbasketAccessItems();
|
||||||
for (const property in workbasketAccessItemsObj) {
|
for (const property in workbasketAccessItemsObj) {
|
||||||
if (property !== 'accessId' && property !== '_links' && property !== 'workbasketId' && property !== 'accessItemId') {
|
if (property !== 'accessId' && property !== '_links' && property !== 'workbasketId' && property !== 'accessItemId') {
|
||||||
this.accessItemsGroups.controls[row].get(property).setValue(checkAll);
|
this.accessItemsGroups.controls[row].get(property).setValue(checkAll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
accessItemSelected(accessItem: AccessIdDefinition, row: number) {
|
accessItemSelected(accessItem: AccessIdDefinition, row: number) {
|
||||||
this.accessItemsGroups.controls[row].get('accessId').setValue(accessItem.accessId);
|
this.accessItemsGroups.controls[row].get('accessId').setValue(accessItem.accessId);
|
||||||
this.accessItemsGroups.controls[row].get('accessName').setValue(accessItem.name);
|
this.accessItemsGroups.controls[row].get('accessName').setValue(accessItem.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onSave() {
|
private onSave() {
|
||||||
this.requestInProgressService.setRequestInProgress(true);
|
this.requestInProgressService.setRequestInProgress(true);
|
||||||
this.workbasketService.updateWorkBasketAccessItem(this.accessItemsResource._links.self.href, this.AccessItemsForm.value.accessItemsGroups)
|
this.workbasketService.updateWorkBasketAccessItem(
|
||||||
.subscribe(response => {
|
this.accessItemsResource._links.self.href, this.AccessItemsForm.value.accessItemsGroups)
|
||||||
this.accessItemsClone = this.cloneAccessItems(this.AccessItemsForm.value.accessItemsGroups);
|
.subscribe(response => {
|
||||||
this.accessItemsResetClone = this.cloneAccessItems(this.AccessItemsForm.value.accessItemsGroups);
|
this.accessItemsClone = this.cloneAccessItems(this.AccessItemsForm.value.accessItemsGroups);
|
||||||
this.alertService.triggerAlert(new AlertModel(
|
this.accessItemsResetClone = this.cloneAccessItems(this.AccessItemsForm.value.accessItemsGroups);
|
||||||
AlertType.SUCCESS, `Workbasket ${this.workbasket.name} Access items were saved successfully`));
|
this.alertService.triggerAlert(new AlertModel(
|
||||||
this.requestInProgressService.setRequestInProgress(false);
|
AlertType.SUCCESS, `Workbasket ${this.workbasket.name} Access items were saved successfully`));
|
||||||
}, error => {
|
this.requestInProgressService.setRequestInProgress(false);
|
||||||
this.generalModalService.triggerMessage(new MessageModal(`There was error while saving your workbasket's access items`, error))
|
}, error => {
|
||||||
this.requestInProgressService.setRequestInProgress(false);
|
this.generalModalService.triggerMessage(new MessageModal(`There was error while saving your workbasket's access items`, error))
|
||||||
})
|
this.requestInProgressService.setRequestInProgress(false);
|
||||||
}
|
})
|
||||||
|
}
|
||||||
|
|
||||||
private setBadge() {
|
private setBadge() {
|
||||||
if (this.action === ACTION.COPY) {
|
if (this.action === ACTION.COPY) {
|
||||||
this.badgeMessage = `Copying workbasket: ${this.workbasket.key}`;
|
this.badgeMessage = `Copying workbasket: ${this.workbasket.key}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private cloneAccessItems(inputaccessItem): Array<WorkbasketAccessItems> {
|
private cloneAccessItems(inputaccessItem): Array<WorkbasketAccessItems> {
|
||||||
return this.AccessItemsForm.value.accessItemsGroups.map(
|
return this.AccessItemsForm.value.accessItemsGroups.map(
|
||||||
(accessItems: WorkbasketAccessItems) => Object.assign({}, accessItems)
|
(accessItems: WorkbasketAccessItems) => Object.assign({}, accessItems)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
private setWorkbasketIdForCopy(workbasketId: string) {
|
private setWorkbasketIdForCopy(workbasketId: string) {
|
||||||
this.accessItemsGroups.value.forEach(element => {
|
this.accessItemsGroups.value.forEach(element => {
|
||||||
element.accessItemId = undefined;
|
element.accessItemId = undefined;
|
||||||
element.workbasketId = workbasketId;
|
element.workbasketId = workbasketId;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
if (this.accessItemsubscription) { this.accessItemsubscription.unsubscribe(); }
|
if (this.accessItemsubscription) { this.accessItemsubscription.unsubscribe(); }
|
||||||
if (this.savingAccessItemsSubscription) { this.savingAccessItemsSubscription.unsubscribe(); }
|
if (this.savingAccessItemsSubscription) { this.savingAccessItemsSubscription.unsubscribe(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,42 +20,42 @@ import { OrientationService } from 'app/services/orientation/orientation.service
|
||||||
import { Orientation } from 'app/models/orientation';
|
import { Orientation } from 'app/models/orientation';
|
||||||
|
|
||||||
export enum Side {
|
export enum Side {
|
||||||
LEFT,
|
LEFT,
|
||||||
RIGHT
|
RIGHT
|
||||||
}
|
}
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-workbaskets-distribution-targets',
|
selector: 'taskana-workbaskets-distribution-targets',
|
||||||
templateUrl: './distribution-targets.component.html',
|
templateUrl: './distribution-targets.component.html',
|
||||||
styleUrls: ['./distribution-targets.component.scss']
|
styleUrls: ['./distribution-targets.component.scss']
|
||||||
})
|
})
|
||||||
export class DistributionTargetsComponent implements OnChanges, OnDestroy {
|
export class DistributionTargetsComponent implements OnChanges, OnDestroy {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
workbasket: Workbasket;
|
workbasket: Workbasket;
|
||||||
@Input()
|
@Input()
|
||||||
action: string;
|
action: string;
|
||||||
@Input()
|
@Input()
|
||||||
active: string;
|
active: string;
|
||||||
badgeMessage = '';
|
badgeMessage = '';
|
||||||
|
|
||||||
distributionTargetsSubscription: Subscription;
|
distributionTargetsSubscription: Subscription;
|
||||||
workbasketSubscription: Subscription;
|
workbasketSubscription: Subscription;
|
||||||
workbasketFilterSubscription: Subscription;
|
workbasketFilterSubscription: Subscription;
|
||||||
savingDistributionTargetsSubscription: Subscription;
|
savingDistributionTargetsSubscription: Subscription;
|
||||||
orientationSubscription: Subscription;
|
orientationSubscription: Subscription;
|
||||||
|
|
||||||
distributionTargetsSelectedResource: WorkbasketDistributionTargetsResource;
|
distributionTargetsSelectedResource: WorkbasketDistributionTargetsResource;
|
||||||
distributionTargetsLeft: Array<WorkbasketSummary>;
|
distributionTargetsLeft: Array<WorkbasketSummary>;
|
||||||
distributionTargetsRight: Array<WorkbasketSummary>;
|
distributionTargetsRight: Array<WorkbasketSummary>;
|
||||||
distributionTargetsSelected: Array<WorkbasketSummary>;
|
distributionTargetsSelected: Array<WorkbasketSummary>;
|
||||||
distributionTargetsClone: Array<WorkbasketSummary>;
|
distributionTargetsClone: Array<WorkbasketSummary>;
|
||||||
distributionTargetsSelectedClone: Array<WorkbasketSummary>;
|
distributionTargetsSelectedClone: Array<WorkbasketSummary>;
|
||||||
|
|
||||||
requestInProgressLeft = false;
|
requestInProgressLeft = false;
|
||||||
requestInProgressRight = false;
|
requestInProgressRight = false;
|
||||||
loadingItems = false;
|
loadingItems = false;
|
||||||
modalErrorMessage: string;
|
modalErrorMessage: string;
|
||||||
side = Side;
|
side = Side;
|
||||||
private initialized = false;
|
private initialized = false;
|
||||||
page: Page;
|
page: Page;
|
||||||
cards: number;
|
cards: number;
|
||||||
|
|
@ -65,22 +65,22 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy {
|
||||||
@ViewChild('panelBody', { static: false })
|
@ViewChild('panelBody', { static: false })
|
||||||
private panelBody: ElementRef;
|
private panelBody: ElementRef;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private workbasketService: WorkbasketService,
|
private workbasketService: WorkbasketService,
|
||||||
private alertService: AlertService,
|
private alertService: AlertService,
|
||||||
private savingWorkbaskets: SavingWorkbasketService,
|
private savingWorkbaskets: SavingWorkbasketService,
|
||||||
private generalModalService: GeneralModalService,
|
private generalModalService: GeneralModalService,
|
||||||
private requestInProgressService: RequestInProgressService,
|
private requestInProgressService: RequestInProgressService,
|
||||||
private orientationService: OrientationService) { }
|
private orientationService: OrientationService) { }
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
if (!this.initialized && changes.active && changes.active.currentValue === 'distributionTargets') {
|
if (!this.initialized && changes.active && changes.active.currentValue === 'distributionTargets') {
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
if (changes.action) {
|
if (changes.action) {
|
||||||
this.setBadge();
|
this.setBadge();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onScroll(side: Side) {
|
onScroll(side: Side) {
|
||||||
if (side === this.side.LEFT && this.page.totalPages > TaskanaQueryParameters.page) {
|
if (side === this.side.LEFT && this.page.totalPages > TaskanaQueryParameters.page) {
|
||||||
this.loadingItems = true;
|
this.loadingItems = true;
|
||||||
|
|
@ -88,100 +88,102 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
moveDistributionTargets(side: number) {
|
moveDistributionTargets(side: number) {
|
||||||
if (side === Side.LEFT) {
|
if (side === Side.LEFT) {
|
||||||
const itemsLeft = this.distributionTargetsLeft.length;
|
const itemsLeft = this.distributionTargetsLeft.length;
|
||||||
const itemsRight = this.distributionTargetsRight.length;
|
const itemsRight = this.distributionTargetsRight.length;
|
||||||
const itemsSelected = this.getSelectedItems(this.distributionTargetsLeft, this.distributionTargetsRight);
|
const itemsSelected = this.getSelectedItems(this.distributionTargetsLeft);
|
||||||
this.distributionTargetsSelected = this.distributionTargetsSelected.concat(itemsSelected);
|
this.distributionTargetsSelected = this.distributionTargetsSelected.concat(itemsSelected);
|
||||||
this.distributionTargetsRight = this.distributionTargetsRight.concat(itemsSelected);
|
this.distributionTargetsRight = this.distributionTargetsRight.concat(itemsSelected);
|
||||||
if (((itemsLeft - itemsSelected.length) <= TaskanaQueryParameters.pageSize) && ((itemsLeft + itemsRight) < this.page.totalElements)) {
|
if (((itemsLeft - itemsSelected.length) <= TaskanaQueryParameters.pageSize) && ((itemsLeft + itemsRight) < this.page.totalElements)) {
|
||||||
this.getNextPage(side);
|
this.getNextPage(side);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const itemsSelected = this.getSelectedItems(this.distributionTargetsRight, this.distributionTargetsLeft);
|
const itemsSelected = this.getSelectedItems(this.distributionTargetsRight);
|
||||||
this.distributionTargetsSelected = this.removeSeletedItems(this.distributionTargetsSelected, itemsSelected);
|
this.distributionTargetsSelected = this.removeSeletedItems(this.distributionTargetsSelected, itemsSelected);
|
||||||
this.distributionTargetsRight = this.removeSeletedItems(this.distributionTargetsRight, itemsSelected);
|
this.distributionTargetsRight = this.removeSeletedItems(this.distributionTargetsRight, itemsSelected);
|
||||||
this.distributionTargetsLeft = this.distributionTargetsLeft.concat(itemsSelected);
|
this.distributionTargetsLeft = this.distributionTargetsLeft.concat(itemsSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.uncheckSelectAll(side);
|
this.uncheckSelectAll(side);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSave() {
|
onSave() {
|
||||||
this.requestInProgressService.setRequestInProgress(true);
|
this.requestInProgressService.setRequestInProgress(true);
|
||||||
this.workbasketService.updateWorkBasketsDistributionTargets(
|
this.workbasketService.updateWorkBasketsDistributionTargets(
|
||||||
this.distributionTargetsSelectedResource._links.self.href, this.getSeletedIds()).subscribe(response => {
|
this.distributionTargetsSelectedResource._links.self.href, this.getSeletedIds()).subscribe(response => {
|
||||||
this.requestInProgressService.setRequestInProgress(false);
|
this.requestInProgressService.setRequestInProgress(false);
|
||||||
this.distributionTargetsSelected = response.distributionTargets;
|
this.distributionTargetsSelected = response.distributionTargets;
|
||||||
this.distributionTargetsSelectedClone = Object.assign([], this.distributionTargetsSelected);
|
this.distributionTargetsSelectedClone = Object.assign([], this.distributionTargetsSelected);
|
||||||
this.distributionTargetsClone = Object.assign([], this.distributionTargetsLeft);
|
this.distributionTargetsClone = Object.assign([], this.distributionTargetsLeft);
|
||||||
this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS,
|
this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS,
|
||||||
`Workbasket ${this.workbasket.name} : Distribution targets were saved successfully`));
|
`Workbasket ${this.workbasket.name} : Distribution targets were saved successfully`));
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
this.generalModalService.triggerMessage(new MessageModal(`There was error while saving your workbasket's distribution targets`, error));
|
this.generalModalService.triggerMessage(
|
||||||
this.requestInProgressService.setRequestInProgress(false);
|
new MessageModal(`There was error while saving your workbasket's distribution targets`, error)
|
||||||
return false;
|
);
|
||||||
}
|
this.requestInProgressService.setRequestInProgress(false);
|
||||||
);
|
return false;
|
||||||
return false;
|
}
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onClear() {
|
onClear() {
|
||||||
this.alertService.triggerAlert(new AlertModel(AlertType.INFO, 'Reset edited fields'));
|
this.alertService.triggerAlert(new AlertModel(AlertType.INFO, 'Reset edited fields'));
|
||||||
this.distributionTargetsLeft = Object.assign([], this.distributionTargetsClone);
|
this.distributionTargetsLeft = Object.assign([], this.distributionTargetsClone);
|
||||||
this.distributionTargetsRight = Object.assign([], this.distributionTargetsSelectedClone);
|
this.distributionTargetsRight = Object.assign([], this.distributionTargetsSelectedClone);
|
||||||
this.distributionTargetsSelected = Object.assign([], this.distributionTargetsSelectedClone);
|
this.distributionTargetsSelected = Object.assign([], this.distributionTargetsSelectedClone);
|
||||||
}
|
}
|
||||||
|
|
||||||
performFilter(dualListFilter: any) {
|
performFilter(dualListFilter: any) {
|
||||||
dualListFilter.side === Side.RIGHT ? this.distributionTargetsRight = undefined : this.distributionTargetsLeft = undefined;
|
dualListFilter.side === Side.RIGHT ? this.distributionTargetsRight = undefined : this.distributionTargetsLeft = undefined;
|
||||||
this.onRequest(dualListFilter.side, false);
|
this.onRequest(dualListFilter.side, false);
|
||||||
this.workbasketFilterSubscription = this.workbasketService.getWorkBasketsSummary(true, undefined, undefined, undefined,
|
this.workbasketFilterSubscription = this.workbasketService.getWorkBasketsSummary(true, undefined, undefined, undefined,
|
||||||
dualListFilter.filterBy.filterParams.name, dualListFilter.filterBy.filterParams.description, undefined,
|
dualListFilter.filterBy.filterParams.name, dualListFilter.filterBy.filterParams.description, undefined,
|
||||||
dualListFilter.filterBy.filterParams.owner, dualListFilter.filterBy.filterParams.type, undefined,
|
dualListFilter.filterBy.filterParams.owner, dualListFilter.filterBy.filterParams.type, undefined,
|
||||||
dualListFilter.filterBy.filterParams.key, undefined, true).subscribe(resultList => {
|
dualListFilter.filterBy.filterParams.key, undefined, true).subscribe(resultList => {
|
||||||
(dualListFilter.side === Side.RIGHT) ?
|
(dualListFilter.side === Side.RIGHT) ?
|
||||||
this.distributionTargetsRight = (resultList.workbaskets) :
|
this.distributionTargetsRight = (resultList.workbaskets) :
|
||||||
this.distributionTargetsLeft = (resultList.workbaskets);
|
this.distributionTargetsLeft = (resultList.workbaskets);
|
||||||
this.onRequest(dualListFilter.side, true);
|
this.onRequest(dualListFilter.side, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
if (this.distributionTargetsSubscription) { this.distributionTargetsSubscription.unsubscribe(); }
|
if (this.distributionTargetsSubscription) { this.distributionTargetsSubscription.unsubscribe(); }
|
||||||
if (this.workbasketSubscription) { this.workbasketSubscription.unsubscribe(); }
|
if (this.workbasketSubscription) { this.workbasketSubscription.unsubscribe(); }
|
||||||
if (this.workbasketFilterSubscription) { this.workbasketFilterSubscription.unsubscribe(); }
|
if (this.workbasketFilterSubscription) { this.workbasketFilterSubscription.unsubscribe(); }
|
||||||
if (this.savingDistributionTargetsSubscription) { this.savingDistributionTargetsSubscription.unsubscribe(); }
|
if (this.savingDistributionTargetsSubscription) { this.savingDistributionTargetsSubscription.unsubscribe(); }
|
||||||
if (this.orientationSubscription) { this.orientationSubscription.unsubscribe(); }
|
if (this.orientationSubscription) { this.orientationSubscription.unsubscribe(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
private init() {
|
private init() {
|
||||||
this.onRequest(undefined);
|
this.onRequest(undefined);
|
||||||
if (!this.workbasket._links.distributionTargets) {
|
if (!this.workbasket._links.distributionTargets) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.distributionTargetsSubscription = this.workbasketService.getWorkBasketsDistributionTargets(
|
this.distributionTargetsSubscription = this.workbasketService.getWorkBasketsDistributionTargets(
|
||||||
this.workbasket._links.distributionTargets.href).subscribe(
|
this.workbasket._links.distributionTargets.href).subscribe(
|
||||||
(distributionTargetsSelectedResource: WorkbasketDistributionTargetsResource) => {
|
(distributionTargetsSelectedResource: WorkbasketDistributionTargetsResource) => {
|
||||||
this.distributionTargetsSelectedResource = distributionTargetsSelectedResource;
|
this.distributionTargetsSelectedResource = distributionTargetsSelectedResource;
|
||||||
this.distributionTargetsSelected = distributionTargetsSelectedResource.distributionTargets;
|
this.distributionTargetsSelected = distributionTargetsSelectedResource.distributionTargets;
|
||||||
this.distributionTargetsSelectedClone = Object.assign([], this.distributionTargetsSelected);
|
this.distributionTargetsSelectedClone = Object.assign([], this.distributionTargetsSelected);
|
||||||
TaskanaQueryParameters.page = 1;
|
TaskanaQueryParameters.page = 1;
|
||||||
this.calculateNumberItemsList();
|
this.calculateNumberItemsList();
|
||||||
this.getWorkbaskets();
|
this.getWorkbaskets();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.savingDistributionTargetsSubscription = this.savingWorkbaskets.triggeredDistributionTargetsSaving()
|
this.savingDistributionTargetsSubscription = this.savingWorkbaskets.triggeredDistributionTargetsSaving()
|
||||||
.subscribe((savingInformation: SavingInformation) => {
|
.subscribe((savingInformation: SavingInformation) => {
|
||||||
if (this.action === ACTION.COPY) {
|
if (this.action === ACTION.COPY) {
|
||||||
this.distributionTargetsSelectedResource._links.self.href = savingInformation.url;
|
this.distributionTargetsSelectedResource._links.self.href = savingInformation.url;
|
||||||
this.onSave();
|
this.onSave();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.orientationSubscription = this.orientationService.getOrientation().subscribe((orientation: Orientation) => {
|
this.orientationSubscription = this.orientationService.getOrientation().subscribe((orientation: Orientation) => {
|
||||||
this.calculateNumberItemsList();
|
this.calculateNumberItemsList();
|
||||||
|
|
@ -234,44 +236,44 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private setBadge() {
|
private setBadge() {
|
||||||
if (this.action === ACTION.COPY) {
|
if (this.action === ACTION.COPY) {
|
||||||
this.badgeMessage = `Copying workbasket: ${this.workbasket.key}`;
|
this.badgeMessage = `Copying workbasket: ${this.workbasket.key}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getSelectedItems(originList: any, destinationList: any): Array<any> {
|
private getSelectedItems(originList: any): Array<any> {
|
||||||
return originList.filter((item: any) => { return (item.selected === true) });
|
return originList.filter((item: any) => (item.selected === true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeSeletedItems(originList: any, selectedItemList) {
|
private removeSeletedItems(originList: any, selectedItemList) {
|
||||||
for (let index = originList.length - 1; index >= 0; index--) {
|
for (let index = originList.length - 1; index >= 0; index--) {
|
||||||
if (selectedItemList.some(itemToRemove => { return originList[index].workbasketId === itemToRemove.workbasketId })) {
|
if (selectedItemList.some(itemToRemove => (originList[index].workbasketId === itemToRemove.workbasketId))) {
|
||||||
originList.splice(index, 1);
|
originList.splice(index, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return originList;
|
return originList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private onRequest(side: Side = undefined, finished: boolean = false) {
|
private onRequest(side: Side = undefined, finished: boolean = false) {
|
||||||
if (this.loadingItems) {
|
if (this.loadingItems) {
|
||||||
this.loadingItems = false;
|
this.loadingItems = false;
|
||||||
}
|
}
|
||||||
if (finished) {
|
if (finished) {
|
||||||
side === undefined ? (this.requestInProgressLeft = false, this.requestInProgressRight = false) :
|
side === undefined ? (this.requestInProgressLeft = false, this.requestInProgressRight = false) :
|
||||||
side === Side.LEFT ? this.requestInProgressLeft = false : this.requestInProgressRight = false;
|
side === Side.LEFT ? this.requestInProgressLeft = false : this.requestInProgressRight = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
side === undefined ? (this.requestInProgressLeft = true, this.requestInProgressRight = true) :
|
side === undefined ? (this.requestInProgressLeft = true, this.requestInProgressRight = true) :
|
||||||
side === Side.LEFT ? this.requestInProgressLeft = true : this.requestInProgressRight = true;
|
side === Side.LEFT ? this.requestInProgressLeft = true : this.requestInProgressRight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getSeletedIds(): Array<string> {
|
private getSeletedIds(): Array<string> {
|
||||||
const distributionTargetsSelelected: Array<string> = [];
|
const distributionTargetsSelelected: Array<string> = [];
|
||||||
this.distributionTargetsSelected.forEach(item => {
|
this.distributionTargetsSelected.forEach(item => {
|
||||||
distributionTargetsSelelected.push(item.workbasketId);
|
distributionTargetsSelelected.push(item.workbasketId);
|
||||||
});
|
});
|
||||||
return distributionTargetsSelelected;
|
return distributionTargetsSelelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
private uncheckSelectAll(side: number) {
|
private uncheckSelectAll(side: number) {
|
||||||
|
|
|
||||||
|
|
@ -5,34 +5,34 @@ import { Side } from '../distribution-targets.component';
|
||||||
import { expandDown } from 'app/shared/animations/expand.animation';
|
import { expandDown } from 'app/shared/animations/expand.animation';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-dual-list',
|
selector: 'taskana-dual-list',
|
||||||
templateUrl: './dual-list.component.html',
|
templateUrl: './dual-list.component.html',
|
||||||
styleUrls: ['./dual-list.component.scss'],
|
styleUrls: ['./dual-list.component.scss'],
|
||||||
animations: [expandDown]
|
animations: [expandDown]
|
||||||
})
|
})
|
||||||
export class DualListComponent implements OnInit {
|
export class DualListComponent implements OnInit {
|
||||||
|
|
||||||
@Input() distributionTargets: Array<WorkbasketSummary>;
|
@Input() distributionTargets: Array<WorkbasketSummary>;
|
||||||
@Input() distributionTargetsSelected: Array<WorkbasketSummary>;
|
@Input() distributionTargetsSelected: Array<WorkbasketSummary>;
|
||||||
@Output() performDualListFilter = new EventEmitter<{ filterBy: FilterModel, side: Side }>();
|
@Output() performDualListFilter = new EventEmitter<{ filterBy: FilterModel, side: Side }>();
|
||||||
@Input() requestInProgress = false;
|
@Input() requestInProgress = false;
|
||||||
@Input() loadingItems ? = false;
|
@Input() loadingItems ? = false;
|
||||||
@Input() side: Side;
|
@Input() side: Side;
|
||||||
@Input() header: string;
|
@Input() header: string;
|
||||||
@Output() scrolling = new EventEmitter<Side>();
|
@Output() scrolling = new EventEmitter<Side>();
|
||||||
@Input() allSelected;
|
@Input() allSelected;
|
||||||
@Output() allSelectedChange = new EventEmitter<boolean>();
|
@Output() allSelectedChange = new EventEmitter<boolean>();
|
||||||
|
|
||||||
sideNumber = 0;
|
sideNumber = 0;
|
||||||
toolbarState = false;
|
toolbarState = false;
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.sideNumber = this.side === Side.LEFT ? 0 : 1;
|
this.sideNumber = this.side === Side.LEFT ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectAll(selected: boolean) {
|
selectAll(selected: boolean) {
|
||||||
this.distributionTargets.forEach((element: any) => {
|
this.distributionTargets.forEach((element: any) => {
|
||||||
element.selected = selected;
|
element.selected = selected;
|
||||||
});
|
});
|
||||||
this.allSelectedChange.emit(this.allSelected);
|
this.allSelectedChange.emit(this.allSelected);
|
||||||
}
|
}
|
||||||
|
|
@ -41,7 +41,7 @@ export class DualListComponent implements OnInit {
|
||||||
this.scrolling.emit(this.side);
|
this.scrolling.emit(this.side);
|
||||||
}
|
}
|
||||||
|
|
||||||
performAvailableFilter(filterModel: FilterModel) {
|
performAvailableFilter(filterModel: FilterModel) {
|
||||||
this.performDualListFilter.emit({ filterBy: filterModel, side: this.side });
|
this.performDualListFilter.emit({ filterBy: filterModel, side: this.side });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,109 +23,109 @@ import { configureTests } from 'app/app.test.configuration';
|
||||||
import { FormsValidatorService } from 'app/shared/services/forms/forms-validator.service';
|
import { FormsValidatorService } from 'app/shared/services/forms/forms-validator.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-dummy-detail',
|
selector: 'taskana-dummy-detail',
|
||||||
template: 'dummydetail'
|
template: 'dummydetail'
|
||||||
})
|
})
|
||||||
export class DummyDetailComponent {
|
export class DummyDetailComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: ':id', component: DummyDetailComponent, outlet: 'detail' },
|
{ path: ':id', component: DummyDetailComponent, outlet: 'detail' },
|
||||||
{ path: 'someNewId', component: DummyDetailComponent }
|
{ path: 'someNewId', component: DummyDetailComponent }
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('WorkbasketInformationComponent', () => {
|
describe('WorkbasketInformationComponent', () => {
|
||||||
let component: WorkbasketInformationComponent;
|
let component: WorkbasketInformationComponent;
|
||||||
let fixture: ComponentFixture<WorkbasketInformationComponent>;
|
let fixture: ComponentFixture<WorkbasketInformationComponent>;
|
||||||
let debugElement, workbasketService, alertService, savingWorkbasketService, requestInProgressService, formsValidatorService;
|
let debugElement, workbasketService, alertService, savingWorkbasketService, requestInProgressService, formsValidatorService;
|
||||||
|
|
||||||
beforeEach(done => {
|
beforeEach(done => {
|
||||||
const configure = (testBed: TestBed) => {
|
const configure = (testBed: TestBed) => {
|
||||||
testBed.configureTestingModule({
|
testBed.configureTestingModule({
|
||||||
declarations: [WorkbasketInformationComponent, DummyDetailComponent],
|
declarations: [WorkbasketInformationComponent, DummyDetailComponent],
|
||||||
imports: [FormsModule,
|
imports: [FormsModule,
|
||||||
AngularSvgIconModule,
|
AngularSvgIconModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
RouterTestingModule.withRoutes(routes)],
|
RouterTestingModule.withRoutes(routes)],
|
||||||
providers: [WorkbasketService, AlertService, SavingWorkbasketService, GeneralModalService, RequestInProgressService,
|
providers: [WorkbasketService, AlertService, SavingWorkbasketService, GeneralModalService, RequestInProgressService,
|
||||||
CustomFieldsService, FormsValidatorService]
|
CustomFieldsService, FormsValidatorService]
|
||||||
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
configureTests(configure).then(testBed => {
|
configureTests(configure).then(testBed => {
|
||||||
fixture = TestBed.createComponent(WorkbasketInformationComponent);
|
fixture = TestBed.createComponent(WorkbasketInformationComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
debugElement = fixture.debugElement.nativeElement;
|
debugElement = fixture.debugElement.nativeElement;
|
||||||
workbasketService = TestBed.get(WorkbasketService);
|
workbasketService = TestBed.get(WorkbasketService);
|
||||||
alertService = TestBed.get(AlertService);
|
alertService = TestBed.get(AlertService);
|
||||||
savingWorkbasketService = TestBed.get(SavingWorkbasketService);
|
savingWorkbasketService = TestBed.get(SavingWorkbasketService);
|
||||||
requestInProgressService = TestBed.get(RequestInProgressService);
|
requestInProgressService = TestBed.get(RequestInProgressService);
|
||||||
|
|
||||||
formsValidatorService = TestBed.get(FormsValidatorService);
|
formsValidatorService = TestBed.get(FormsValidatorService);
|
||||||
|
|
||||||
spyOn(alertService, 'triggerAlert');
|
spyOn(alertService, 'triggerAlert');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
document.body.removeChild(debugElement);
|
document.body.removeChild(debugElement);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a panel with heading and form with all fields', async(() => {
|
it('should create a panel with heading and form with all fields', async(() => {
|
||||||
component.workbasket = new Workbasket('id', 'created', 'keyModified', 'domain', ICONTYPES.TOPIC,
|
component.workbasket = new Workbasket('id', 'created', 'keyModified', 'domain', ICONTYPES.TOPIC,
|
||||||
'modified', 'name', 'description', 'owner', 'custom1', 'custom2', 'custom3', 'custom4',
|
'modified', 'name', 'description', 'owner', 'custom1', 'custom2', 'custom3', 'custom4',
|
||||||
'orgLevel1', 'orgLevel2', 'orgLevel3', 'orgLevel4', null);
|
'orgLevel1', 'orgLevel2', 'orgLevel3', 'orgLevel4', null);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(debugElement.querySelector('#wb-information')).toBeDefined();
|
expect(debugElement.querySelector('#wb-information')).toBeDefined();
|
||||||
expect(debugElement.querySelector('#wb-information > .panel-heading > h4').textContent.trim()).toBe('name');
|
expect(debugElement.querySelector('#wb-information > .panel-heading > h4').textContent.trim()).toBe('name');
|
||||||
expect(debugElement.querySelectorAll('#wb-information > .panel-body > form').length).toBe(1);
|
expect(debugElement.querySelectorAll('#wb-information > .panel-body > form').length).toBe(1);
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
expect(debugElement.querySelector('#wb-information > .panel-body > form > div > div > input ').value).toBe('keyModified');
|
expect(debugElement.querySelector('#wb-information > .panel-body > form > div > div > input ').value).toBe('keyModified');
|
||||||
});
|
});
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('selectType should set workbasket.type to personal with 0 and group in other case', () => {
|
it('selectType should set workbasket.type to personal with 0 and group in other case', () => {
|
||||||
component.workbasket = new Workbasket('id1');
|
component.workbasket = new Workbasket('id1');
|
||||||
expect(component.workbasket.type).toEqual('PERSONAL');
|
expect(component.workbasket.type).toEqual('PERSONAL');
|
||||||
component.selectType(ICONTYPES.GROUP);
|
component.selectType(ICONTYPES.GROUP);
|
||||||
expect(component.workbasket.type).toEqual('GROUP');
|
expect(component.workbasket.type).toEqual('GROUP');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a copy of workbasket when workbasket is selected', () => {
|
it('should create a copy of workbasket when workbasket is selected', () => {
|
||||||
expect(component.workbasketClone).toBeUndefined();
|
expect(component.workbasketClone).toBeUndefined();
|
||||||
component.workbasket = new Workbasket('id', 'created', 'keyModified', 'domain', ICONTYPES.TOPIC, 'modified', 'name', 'description',
|
component.workbasket = new Workbasket('id', 'created', 'keyModified', 'domain', ICONTYPES.TOPIC, 'modified', 'name', 'description',
|
||||||
'owner', 'custom1', 'custom2', 'custom3', 'custom4', 'orgLevel1', 'orgLevel2', 'orgLevel3', 'orgLevel4', null);
|
'owner', 'custom1', 'custom2', 'custom3', 'custom4', 'orgLevel1', 'orgLevel2', 'orgLevel3', 'orgLevel4', null);
|
||||||
component.ngOnChanges(
|
component.ngOnChanges(
|
||||||
undefined
|
undefined
|
||||||
);
|
);
|
||||||
fixture.detectChanges();
|
|
||||||
expect(component.workbasket.workbasketId).toEqual(component.workbasketClone.workbasketId);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reset requestInProgress after saving request is done', () => {
|
|
||||||
component.workbasket = new Workbasket('id', 'created', 'keyModified', 'domain', ICONTYPES.TOPIC, 'modified', 'name', 'description',
|
|
||||||
'owner', 'custom1', 'custom2', 'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
|
||||||
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }));
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
spyOn(workbasketService, 'updateWorkbasket').and.returnValue(of(component.workbasket));
|
expect(component.workbasket.workbasketId).toEqual(component.workbasketClone.workbasketId);
|
||||||
spyOn(workbasketService, 'triggerWorkBasketSaved').and.returnValue(of(component.workbasket));
|
});
|
||||||
component.onSubmit();
|
|
||||||
expect(component.requestInProgress).toBeFalsy();
|
|
||||||
|
|
||||||
});
|
it('should reset requestInProgress after saving request is done', () => {
|
||||||
|
component.workbasket = new Workbasket('id', 'created', 'keyModified', 'domain', ICONTYPES.TOPIC, 'modified', 'name', 'description',
|
||||||
|
'owner', 'custom1', 'custom2', 'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
||||||
|
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }));
|
||||||
|
fixture.detectChanges();
|
||||||
|
spyOn(workbasketService, 'updateWorkbasket').and.returnValue(of(component.workbasket));
|
||||||
|
spyOn(workbasketService, 'triggerWorkBasketSaved').and.returnValue(of(component.workbasket));
|
||||||
|
component.onSubmit();
|
||||||
|
expect(component.requestInProgress).toBeFalsy();
|
||||||
|
|
||||||
it('should trigger triggerWorkBasketSaved method after saving request is done', async(() => {
|
});
|
||||||
component.workbasket = new Workbasket('id', 'created', 'keyModified', 'domain', ICONTYPES.TOPIC, 'modified', 'name', 'description',
|
|
||||||
'owner', 'custom1', 'custom2', 'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
it('should trigger triggerWorkBasketSaved method after saving request is done', async(() => {
|
||||||
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }));
|
component.workbasket = new Workbasket('id', 'created', 'keyModified', 'domain', ICONTYPES.TOPIC, 'modified', 'name', 'description',
|
||||||
spyOn(workbasketService, 'updateWorkbasket').and.returnValue(of(component.workbasket));
|
'owner', 'custom1', 'custom2', 'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
||||||
|
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }));
|
||||||
|
spyOn(workbasketService, 'updateWorkbasket').and.returnValue(of(component.workbasket));
|
||||||
spyOn(workbasketService, 'triggerWorkBasketSaved').and.returnValue(of(component.workbasket));
|
spyOn(workbasketService, 'triggerWorkBasketSaved').and.returnValue(of(component.workbasket));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
|
@ -133,19 +133,19 @@ describe('WorkbasketInformationComponent', () => {
|
||||||
component.onSubmit();
|
component.onSubmit();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(workbasketService.triggerWorkBasketSaved).toHaveBeenCalled();
|
expect(workbasketService.triggerWorkBasketSaved).toHaveBeenCalled();
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should post a new workbasket when no workbasketId is defined and update workbasket', async(() => {
|
it('should post a new workbasket when no workbasketId is defined and update workbasket', async(() => {
|
||||||
const workbasket = new Workbasket(undefined, 'created', 'keyModified', 'domain', ICONTYPES.TOPIC, 'modified', 'name', 'description',
|
const workbasket = new Workbasket(undefined, 'created', 'keyModified', 'domain', ICONTYPES.TOPIC, 'modified', 'name', 'description',
|
||||||
'owner', 'custom1', 'custom2', 'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
'owner', 'custom1', 'custom2', 'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
||||||
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }));
|
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }));
|
||||||
component.workbasket = workbasket
|
component.workbasket = workbasket
|
||||||
spyOn(workbasketService, 'createWorkbasket').and.returnValue(of(
|
spyOn(workbasketService, 'createWorkbasket').and.returnValue(of(
|
||||||
new Workbasket('someNewId', 'created', 'keyModified', 'domain', ICONTYPES.TOPIC, 'modified', 'name', 'description',
|
new Workbasket('someNewId', 'created', 'keyModified', 'domain', ICONTYPES.TOPIC, 'modified', 'name', 'description',
|
||||||
'owner', 'custom1', 'custom2', 'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
'owner', 'custom1', 'custom2', 'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
||||||
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }))));
|
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }))));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
spyOn(formsValidatorService, 'validateFormAccess').and.returnValue(Promise.resolve(true));
|
spyOn(formsValidatorService, 'validateFormAccess').and.returnValue(Promise.resolve(true));
|
||||||
component.onSubmit();
|
component.onSubmit();
|
||||||
|
|
@ -154,24 +154,24 @@ describe('WorkbasketInformationComponent', () => {
|
||||||
expect(alertService.triggerAlert).toHaveBeenCalled();
|
expect(alertService.triggerAlert).toHaveBeenCalled();
|
||||||
expect(component.workbasket.workbasketId).toBe('someNewId');
|
expect(component.workbasket.workbasketId).toBe('someNewId');
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should post a new workbasket, new distribution targets and new access ' +
|
it('should post a new workbasket, new distribution targets and new access ' +
|
||||||
'items when no workbasketId is defined and action is copy', async(() => {
|
'items when no workbasketId is defined and action is copy', async(() => {
|
||||||
const workbasket = new Workbasket(undefined, 'created', 'keyModified', 'domain', ICONTYPES.TOPIC,
|
const workbasket = new Workbasket(undefined, 'created', 'keyModified', 'domain', ICONTYPES.TOPIC,
|
||||||
'modified', 'name', 'description', 'owner', 'custom1', 'custom2',
|
'modified', 'name', 'description', 'owner', 'custom1', 'custom2',
|
||||||
'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
||||||
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }));
|
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }));
|
||||||
component.workbasket = workbasket
|
component.workbasket = workbasket
|
||||||
component.action = ACTION.COPY;
|
component.action = ACTION.COPY;
|
||||||
|
|
||||||
spyOn(workbasketService, 'createWorkbasket').and.returnValue(of(
|
spyOn(workbasketService, 'createWorkbasket').and.returnValue(of(
|
||||||
new Workbasket('someNewId', 'created', 'keyModified', 'domain', ICONTYPES.TOPIC, 'modified', 'name', 'description',
|
new Workbasket('someNewId', 'created', 'keyModified', 'domain', ICONTYPES.TOPIC, 'modified', 'name', 'description',
|
||||||
'owner', 'custom1', 'custom2', 'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
'owner', 'custom1', 'custom2', 'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
||||||
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }, { 'href': 'someUrl' }, { 'href': 'someUrl' }))));
|
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }, { 'href': 'someUrl' }, { 'href': 'someUrl' }))));
|
||||||
|
|
||||||
spyOn(savingWorkbasketService, 'triggerDistributionTargetSaving');
|
spyOn(savingWorkbasketService, 'triggerDistributionTargetSaving');
|
||||||
spyOn(savingWorkbasketService, 'triggerAccessItemsSaving');
|
spyOn(savingWorkbasketService, 'triggerAccessItemsSaving');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
spyOn(formsValidatorService, 'validateFormAccess').and.returnValue(Promise.resolve(true));
|
spyOn(formsValidatorService, 'validateFormAccess').and.returnValue(Promise.resolve(true));
|
||||||
component.onSubmit();
|
component.onSubmit();
|
||||||
|
|
@ -182,24 +182,24 @@ describe('WorkbasketInformationComponent', () => {
|
||||||
expect(savingWorkbasketService.triggerDistributionTargetSaving).toHaveBeenCalled();
|
expect(savingWorkbasketService.triggerDistributionTargetSaving).toHaveBeenCalled();
|
||||||
expect(savingWorkbasketService.triggerAccessItemsSaving).toHaveBeenCalled();
|
expect(savingWorkbasketService.triggerAccessItemsSaving).toHaveBeenCalled();
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should trigger requestInProgress service true before and requestInProgress false after remove a workbasket', () => {
|
it('should trigger requestInProgress service true before and requestInProgress false after remove a workbasket', () => {
|
||||||
const workbasket = new Workbasket(undefined, 'created', 'keyModified', 'domain', ICONTYPES.TOPIC,
|
const workbasket = new Workbasket(undefined, 'created', 'keyModified', 'domain', ICONTYPES.TOPIC,
|
||||||
'modified', 'name', 'description', 'owner', 'custom1', 'custom2',
|
'modified', 'name', 'description', 'owner', 'custom1', 'custom2',
|
||||||
'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
'custom3', 'custom4', 'orgLevel1', 'orgLevel2',
|
||||||
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }, undefined, undefined, undefined, { 'href': 'someUrl' }));
|
'orgLevel3', 'orgLevel4', new Links({ 'href': 'someUrl' }, undefined, undefined, undefined, { 'href': 'someUrl' }));
|
||||||
component.workbasket = workbasket;
|
component.workbasket = workbasket;
|
||||||
spyOn(workbasketService, 'removeDistributionTarget').and.returnValue(of(''));
|
spyOn(workbasketService, 'removeDistributionTarget').and.returnValue(of(''));
|
||||||
const requestInProgressServiceSpy = spyOn(requestInProgressService, 'setRequestInProgress');
|
const requestInProgressServiceSpy = spyOn(requestInProgressService, 'setRequestInProgress');
|
||||||
|
|
||||||
component.removeDistributionTargets();
|
component.removeDistributionTargets();
|
||||||
expect(requestInProgressServiceSpy).toHaveBeenCalledWith(true);
|
expect(requestInProgressServiceSpy).toHaveBeenCalledWith(true);
|
||||||
workbasketService.removeDistributionTarget().subscribe(() => {
|
workbasketService.removeDistributionTarget().subscribe(() => {
|
||||||
|
|
||||||
}, error => { }, complete => {
|
}, error => { }, complete => {
|
||||||
expect(requestInProgressServiceSpy).toHaveBeenCalledWith(false);
|
expect(requestInProgressServiceSpy).toHaveBeenCalledWith(false);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,8 @@ describe('WorkbasketDetailsComponent', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
masterAndDetailService = TestBed.get(MasterAndDetailService);
|
masterAndDetailService = TestBed.get(MasterAndDetailService);
|
||||||
workbasketService = TestBed.get(WorkbasketService);
|
workbasketService = TestBed.get(WorkbasketService);
|
||||||
spyOn(masterAndDetailService, 'getShowDetail').and.callFake(() => { return of(true) })
|
spyOn(masterAndDetailService, 'getShowDetail').and.callFake(() => of(true))
|
||||||
spyOn(workbasketService, 'getSelectedWorkBasket').and.callFake(() => { return of('id1') })
|
spyOn(workbasketService, 'getSelectedWorkBasket').and.callFake(() => of('id1'))
|
||||||
spyOn(workbasketService, 'getWorkBasketsSummary').and.callFake(() => {
|
spyOn(workbasketService, 'getWorkBasketsSummary').and.callFake(() => {
|
||||||
return of(new WorkbasketSummaryResource(
|
return of(new WorkbasketSummaryResource(
|
||||||
new Array<WorkbasketSummary>(
|
new Array<WorkbasketSummary>(
|
||||||
|
|
@ -84,7 +84,7 @@ describe('WorkbasketDetailsComponent', () => {
|
||||||
, new LinksWorkbasketSummary({ 'href': 'someurl' })))
|
, new LinksWorkbasketSummary({ 'href': 'someurl' })))
|
||||||
})
|
})
|
||||||
|
|
||||||
spyOn(workbasketService, 'getWorkBasket').and.callFake(() => { return of(workbasket) })
|
spyOn(workbasketService, 'getWorkBasket').and.callFake(() => of(workbasket))
|
||||||
spyOn(workbasketService, 'getWorkBasketAccessItems').and.callFake(() => {
|
spyOn(workbasketService, 'getWorkBasketAccessItems').and.callFake(() => {
|
||||||
return of(new WorkbasketAccessItemsResource(
|
return of(new WorkbasketAccessItemsResource(
|
||||||
new Array<WorkbasketAccessItems>(), new Links({ 'href': 'url' })))
|
new Array<WorkbasketAccessItems>(), new Links({ 'href': 'url' })))
|
||||||
|
|
|
||||||
|
|
@ -13,132 +13,132 @@ import { GeneralModalService } from '../../../services/general-modal/general-mod
|
||||||
import { ImportExportService } from 'app/administration/services/import-export/import-export.service';
|
import { ImportExportService } from 'app/administration/services/import-export/import-export.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-workbasket-details',
|
selector: 'taskana-workbasket-details',
|
||||||
templateUrl: './workbasket-details.component.html'
|
templateUrl: './workbasket-details.component.html'
|
||||||
})
|
})
|
||||||
export class WorkbasketDetailsComponent implements OnInit, OnDestroy {
|
export class WorkbasketDetailsComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
workbasket: Workbasket;
|
workbasket: Workbasket;
|
||||||
workbasketCopy: Workbasket;
|
workbasketCopy: Workbasket;
|
||||||
selectedId: string = undefined;
|
selectedId: string = undefined;
|
||||||
showDetail = false;
|
showDetail = false;
|
||||||
requestInProgress = false;
|
requestInProgress = false;
|
||||||
action: string;
|
action: string;
|
||||||
tabSelected = 'information';
|
tabSelected = 'information';
|
||||||
|
|
||||||
private workbasketSelectedSubscription: Subscription;
|
private workbasketSelectedSubscription: Subscription;
|
||||||
private workbasketSubscription: Subscription;
|
private workbasketSubscription: Subscription;
|
||||||
private routeSubscription: Subscription;
|
private routeSubscription: Subscription;
|
||||||
private masterAndDetailSubscription: Subscription;
|
private masterAndDetailSubscription: Subscription;
|
||||||
private permissionSubscription: Subscription;
|
private permissionSubscription: Subscription;
|
||||||
private domainSubscription: Subscription;
|
private domainSubscription: Subscription;
|
||||||
private importingExportingSubscription: Subscription;
|
private importingExportingSubscription: Subscription;
|
||||||
|
|
||||||
constructor(private service: WorkbasketService,
|
constructor(private service: WorkbasketService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private masterAndDetailService: MasterAndDetailService,
|
private masterAndDetailService: MasterAndDetailService,
|
||||||
private domainService: DomainService,
|
private domainService: DomainService,
|
||||||
private generalModalService: GeneralModalService,
|
private generalModalService: GeneralModalService,
|
||||||
private importExportService: ImportExportService) { }
|
private importExportService: ImportExportService) { }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.workbasketSelectedSubscription = this.service.getSelectedWorkBasket().subscribe(workbasketIdSelected => {
|
this.workbasketSelectedSubscription = this.service.getSelectedWorkBasket().subscribe(workbasketIdSelected => {
|
||||||
this.workbasket = undefined;
|
this.workbasket = undefined;
|
||||||
this.getWorkbasketInformation(workbasketIdSelected);
|
this.getWorkbasketInformation(workbasketIdSelected);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.routeSubscription = this.route.params.subscribe(params => {
|
this.routeSubscription = this.route.params.subscribe(params => {
|
||||||
let id = params['id'];
|
let id = params['id'];
|
||||||
this.action = undefined;
|
this.action = undefined;
|
||||||
if (id && id.indexOf('new-workbasket') !== -1) {
|
if (id && id.indexOf('new-workbasket') !== -1) {
|
||||||
this.tabSelected = 'information';
|
this.tabSelected = 'information';
|
||||||
this.action = ACTION.CREATE;
|
this.action = ACTION.CREATE;
|
||||||
id = undefined;
|
id = undefined;
|
||||||
this.getWorkbasketInformation(id);
|
this.getWorkbasketInformation(id);
|
||||||
} else if (id && id.indexOf('copy-workbasket') !== -1) {
|
} else if (id && id.indexOf('copy-workbasket') !== -1) {
|
||||||
if (!this.selectedId) {
|
if (!this.selectedId) {
|
||||||
this.router.navigate(['./'], { relativeTo: this.route.parent });
|
this.router.navigate(['./'], { relativeTo: this.route.parent });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.action = ACTION.COPY;
|
this.action = ACTION.COPY;
|
||||||
this.workbasket.key = undefined;
|
this.workbasket.key = undefined;
|
||||||
this.workbasketCopy = this.workbasket;
|
this.workbasketCopy = this.workbasket;
|
||||||
id = undefined;
|
id = undefined;
|
||||||
this.getWorkbasketInformation(id, this.selectedId);
|
this.getWorkbasketInformation(id, this.selectedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id && id !== '') {
|
if (id && id !== '') {
|
||||||
this.selectWorkbasket(id);
|
this.selectWorkbasket(id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.masterAndDetailSubscription = this.masterAndDetailService.getShowDetail().subscribe(showDetail => {
|
this.masterAndDetailSubscription = this.masterAndDetailService.getShowDetail().subscribe(showDetail => {
|
||||||
this.showDetail = showDetail;
|
this.showDetail = showDetail;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.importingExportingSubscription = this.importExportService.getImportingFinished().subscribe((value: Boolean) => {
|
this.importingExportingSubscription = this.importExportService.getImportingFinished().subscribe((value: Boolean) => {
|
||||||
if (this.workbasket) { this.getWorkbasketInformation(this.workbasket.workbasketId); }
|
if (this.workbasket) { this.getWorkbasketInformation(this.workbasket.workbasketId); }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
backClicked(): void {
|
backClicked(): void {
|
||||||
this.service.selectWorkBasket(undefined);
|
this.service.selectWorkBasket(undefined);
|
||||||
this.router.navigate(['./'], { relativeTo: this.route.parent });
|
this.router.navigate(['./'], { relativeTo: this.route.parent });
|
||||||
}
|
}
|
||||||
|
|
||||||
selectTab(tab) {
|
selectTab(tab) {
|
||||||
this.tabSelected = this.action === ACTION.CREATE ? 'information' : tab;
|
this.tabSelected = this.action === ACTION.CREATE ? 'information' : tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
private selectWorkbasket(id: string) {
|
private selectWorkbasket(id: string) {
|
||||||
this.selectedId = id;
|
this.selectedId = id;
|
||||||
this.service.selectWorkBasket(id);
|
this.service.selectWorkBasket(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getWorkbasketInformation(workbasketIdSelected: string, copyId: string = undefined) {
|
private getWorkbasketInformation(workbasketIdSelected: string, copyId: string = undefined) {
|
||||||
this.requestInProgress = true;
|
this.requestInProgress = true;
|
||||||
|
|
||||||
if (!workbasketIdSelected && this.action === ACTION.CREATE) { // CREATE
|
if (!workbasketIdSelected && this.action === ACTION.CREATE) { // CREATE
|
||||||
this.workbasket = new Workbasket(undefined);
|
this.workbasket = new Workbasket(undefined);
|
||||||
this.domainSubscription = this.domainService.getSelectedDomain().subscribe(domain => {
|
this.domainSubscription = this.domainService.getSelectedDomain().subscribe(domain => {
|
||||||
this.workbasket.domain = domain;
|
this.workbasket.domain = domain;
|
||||||
});
|
});
|
||||||
this.requestInProgress = false;
|
this.requestInProgress = false;
|
||||||
} else if (!workbasketIdSelected && this.action === ACTION.COPY) { // COPY
|
} else if (!workbasketIdSelected && this.action === ACTION.COPY) { // COPY
|
||||||
this.workbasket = { ...this.workbasketCopy };
|
this.workbasket = { ...this.workbasketCopy };
|
||||||
this.workbasket.workbasketId = undefined;
|
this.workbasket.workbasketId = undefined;
|
||||||
this.requestInProgress = false;
|
this.requestInProgress = false;
|
||||||
}
|
}
|
||||||
if (workbasketIdSelected) {
|
if (workbasketIdSelected) {
|
||||||
this.workbasketSubscription = this.service.getWorkBasket(workbasketIdSelected).subscribe(workbasket => {
|
this.workbasketSubscription = this.service.getWorkBasket(workbasketIdSelected).subscribe(workbasket => {
|
||||||
this.workbasket = workbasket;
|
this.workbasket = workbasket;
|
||||||
this.requestInProgress = false;
|
this.requestInProgress = false;
|
||||||
this.checkDomainAndRedirect();
|
this.checkDomainAndRedirect();
|
||||||
}, err => {
|
}, err => {
|
||||||
this.generalModalService.triggerMessage(
|
this.generalModalService.triggerMessage(
|
||||||
new MessageModal('An error occurred while fetching the workbasket', err));
|
new MessageModal('An error occurred while fetching the workbasket', err));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkDomainAndRedirect() {
|
private checkDomainAndRedirect() {
|
||||||
this.domainSubscription = this.domainService.getSelectedDomain().subscribe(domain => {
|
this.domainSubscription = this.domainService.getSelectedDomain().subscribe(domain => {
|
||||||
if (domain !== '' && this.workbasket && this.workbasket.domain !== domain) {
|
if (domain !== '' && this.workbasket && this.workbasket.domain !== domain) {
|
||||||
this.backClicked();
|
this.backClicked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
if (this.workbasketSelectedSubscription) { this.workbasketSelectedSubscription.unsubscribe(); }
|
if (this.workbasketSelectedSubscription) { this.workbasketSelectedSubscription.unsubscribe(); }
|
||||||
if (this.workbasketSubscription) { this.workbasketSubscription.unsubscribe(); }
|
if (this.workbasketSubscription) { this.workbasketSubscription.unsubscribe(); }
|
||||||
if (this.routeSubscription) { this.routeSubscription.unsubscribe(); }
|
if (this.routeSubscription) { this.routeSubscription.unsubscribe(); }
|
||||||
if (this.masterAndDetailSubscription) { this.masterAndDetailSubscription.unsubscribe(); }
|
if (this.masterAndDetailSubscription) { this.masterAndDetailSubscription.unsubscribe(); }
|
||||||
if (this.permissionSubscription) { this.permissionSubscription.unsubscribe(); }
|
if (this.permissionSubscription) { this.permissionSubscription.unsubscribe(); }
|
||||||
if (this.domainSubscription) { this.domainSubscription.unsubscribe(); }
|
if (this.domainSubscription) { this.domainSubscription.unsubscribe(); }
|
||||||
if (this.importingExportingSubscription) { this.importingExportingSubscription.unsubscribe(); }
|
if (this.importingExportingSubscription) { this.importingExportingSubscription.unsubscribe(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,86 +25,86 @@ import { configureTests } from 'app/app.test.configuration';
|
||||||
import { ImportExportService } from 'app/administration/services/import-export/import-export.service';
|
import { ImportExportService } from 'app/administration/services/import-export/import-export.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-dummy-detail',
|
selector: 'taskana-dummy-detail',
|
||||||
template: 'dummydetail'
|
template: 'dummydetail'
|
||||||
})
|
})
|
||||||
export class DummyDetailComponent {
|
export class DummyDetailComponent {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('WorkbasketListToolbarComponent', () => {
|
describe('WorkbasketListToolbarComponent', () => {
|
||||||
let component: WorkbasketListToolbarComponent;
|
let component: WorkbasketListToolbarComponent;
|
||||||
let fixture: ComponentFixture<WorkbasketListToolbarComponent>;
|
let fixture: ComponentFixture<WorkbasketListToolbarComponent>;
|
||||||
let debugElement, workbasketService, router;
|
let debugElement, workbasketService, router;
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: ':id', component: DummyDetailComponent, outlet: 'detail' }
|
{ path: ':id', component: DummyDetailComponent, outlet: 'detail' }
|
||||||
];
|
];
|
||||||
|
|
||||||
beforeEach(done => {
|
beforeEach(done => {
|
||||||
const configure = (testBed: TestBed) => {
|
const configure = (testBed: TestBed) => {
|
||||||
testBed.configureTestingModule({
|
testBed.configureTestingModule({
|
||||||
imports: [FormsModule, ReactiveFormsModule, AngularSvgIconModule,
|
imports: [FormsModule, ReactiveFormsModule, AngularSvgIconModule,
|
||||||
HttpClientModule, RouterTestingModule.withRoutes(routes), SharedModule, AppModule],
|
HttpClientModule, RouterTestingModule.withRoutes(routes), SharedModule, AppModule],
|
||||||
declarations: [WorkbasketListToolbarComponent, DummyDetailComponent, ImportExportComponent],
|
declarations: [WorkbasketListToolbarComponent, DummyDetailComponent, ImportExportComponent],
|
||||||
providers: [
|
providers: [
|
||||||
WorkbasketService,
|
WorkbasketService,
|
||||||
ClassificationDefinitionService,
|
ClassificationDefinitionService,
|
||||||
WorkbasketDefinitionService,
|
WorkbasketDefinitionService,
|
||||||
ImportExportService
|
ImportExportService
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
configureTests(configure).then(testBed => {
|
configureTests(configure).then(testBed => {
|
||||||
fixture = TestBed.createComponent(WorkbasketListToolbarComponent);
|
fixture = TestBed.createComponent(WorkbasketListToolbarComponent);
|
||||||
workbasketService = TestBed.get(WorkbasketService);
|
workbasketService = TestBed.get(WorkbasketService);
|
||||||
router = TestBed.get(Router);
|
router = TestBed.get(Router);
|
||||||
spyOn(workbasketService, 'markWorkbasketForDeletion').and.returnValue(of(''));
|
spyOn(workbasketService, 'markWorkbasketForDeletion').and.returnValue(of(''));
|
||||||
spyOn(workbasketService, 'triggerWorkBasketSaved');
|
spyOn(workbasketService, 'triggerWorkBasketSaved');
|
||||||
|
|
||||||
debugElement = fixture.debugElement.nativeElement;
|
debugElement = fixture.debugElement.nativeElement;
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
component.workbaskets = new Array<WorkbasketSummary>(
|
component.workbaskets = new Array<WorkbasketSummary>(
|
||||||
new WorkbasketSummary('1', 'key1', 'NAME1', 'description 1', 'owner 1',
|
new WorkbasketSummary('1', 'key1', 'NAME1', 'description 1', 'owner 1',
|
||||||
undefined, undefined, undefined, undefined, undefined, undefined, undefined, false, new Links({ 'href': 'selfLink' })));
|
undefined, undefined, undefined, undefined, undefined, undefined, undefined, false, new Links({ 'href': 'selfLink' })));
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
document.body.removeChild(debugElement);
|
document.body.removeChild(debugElement);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate to new-workbasket when click on add new workbasket', () => {
|
it('should navigate to new-workbasket when click on add new workbasket', () => {
|
||||||
const spy = spyOn(router, 'navigate');
|
const spy = spyOn(router, 'navigate');
|
||||||
component.addWorkbasket();
|
component.addWorkbasket();
|
||||||
expect(spy.calls.first().args[0][0].outlets.detail[0]).toBe('new-workbasket');
|
expect(spy.calls.first().args[0][0].outlets.detail[0]).toBe('new-workbasket');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should emit performSorting when sorting is triggered', () => {
|
it('should emit performSorting when sorting is triggered', () => {
|
||||||
let sort: SortingModel;
|
let sort: SortingModel;
|
||||||
const compareSort = new SortingModel();
|
const compareSort = new SortingModel();
|
||||||
|
|
||||||
component.performSorting.subscribe((value) => { sort = value })
|
component.performSorting.subscribe((value) => { sort = value })
|
||||||
component.sorting(compareSort);
|
component.sorting(compareSort);
|
||||||
expect(sort).toBe(compareSort);
|
expect(sort).toBe(compareSort);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit performFilter when filter is triggered', () => {
|
it('should emit performFilter when filter is triggered', () => {
|
||||||
let filter: FilterModel;
|
let filter: FilterModel;
|
||||||
const compareFilter = new FilterModel();
|
const compareFilter = new FilterModel();
|
||||||
|
|
||||||
component.performFilter.subscribe((value) => { filter = value })
|
component.performFilter.subscribe((value) => { filter = value })
|
||||||
component.filtering(compareFilter);
|
component.filtering(compareFilter);
|
||||||
expect(filter).toBe(compareFilter);
|
expect(filter).toBe(compareFilter);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,8 @@ export class WorkbasketListComponent implements OnInit, OnDestroy {
|
||||||
this.refreshWorkbasketList();
|
this.refreshWorkbasketList();
|
||||||
});
|
});
|
||||||
this.importingExportingSubscription = this.importExportService.getImportingFinished().subscribe((value: Boolean) => {
|
this.importingExportingSubscription = this.importExportService.getImportingFinished().subscribe((value: Boolean) => {
|
||||||
this.refreshWorkbasketList();
|
this.refreshWorkbasketList();
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,51 +10,51 @@ import { NavBarComponent } from './components/nav-bar/nav-bar.component';
|
||||||
|
|
||||||
describe('AppComponent', () => {
|
describe('AppComponent', () => {
|
||||||
|
|
||||||
let app, fixture, debugElement;
|
let app, fixture, debugElement;
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: 'classifications', component: AppComponent }
|
{ path: 'classifications', component: AppComponent }
|
||||||
];
|
];
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent, NavBarComponent
|
AppComponent, NavBarComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
AngularSvgIconModule,
|
AngularSvgIconModule,
|
||||||
RouterTestingModule.withRoutes(routes),
|
RouterTestingModule.withRoutes(routes),
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
SharedModule
|
SharedModule
|
||||||
]
|
]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(AppComponent);
|
fixture = TestBed.createComponent(AppComponent);
|
||||||
app = fixture.debugElement.componentInstance;
|
app = fixture.debugElement.componentInstance;
|
||||||
debugElement = fixture.debugElement.nativeElement;
|
debugElement = fixture.debugElement.nativeElement;
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(async(() => {
|
afterEach(async(() => {
|
||||||
document.body.removeChild(debugElement);
|
document.body.removeChild(debugElement);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should create the app', (() => {
|
it('should create the app', (() => {
|
||||||
expect(app).toBeTruthy();
|
expect(app).toBeTruthy();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should render title in a <a> tag', (() => {
|
it('should render title in a <a> tag', (() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(debugElement.querySelector('ul p a').textContent).toContain('Taskana administration');
|
expect(debugElement.querySelector('ul p a').textContent).toContain('Taskana administration');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should call Router.navigateByUrl("classifications") and workbasketRoute should be false', (inject([Router], (router: Router) => {
|
it('should call Router.navigateByUrl("classifications") and workbasketRoute should be false', (inject([Router], (router: Router) => {
|
||||||
|
|
||||||
expect(app.workbasketsRoute).toBe(true);
|
expect(app.workbasketsRoute).toBe(true);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
router.navigateByUrl(`/classifications`);
|
router.navigateByUrl(`/classifications`);
|
||||||
expect(app.workbasketsRoute).toBe(false);
|
expect(app.workbasketsRoute).toBe(false);
|
||||||
|
|
||||||
})));
|
})));
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -12,85 +12,85 @@ import { FormsValidatorService } from 'app/shared/services/forms/forms-validator
|
||||||
import { UploadService } from './shared/services/upload/upload.service';
|
import { UploadService } from './shared/services/upload/upload.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-root',
|
selector: 'taskana-root',
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrls: ['./app.component.scss']
|
styleUrls: ['./app.component.scss']
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnInit, OnDestroy {
|
export class AppComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
workbasketsRoute = true;
|
workbasketsRoute = true;
|
||||||
|
|
||||||
modalMessage = '';
|
modalMessage = '';
|
||||||
modalTitle = '';
|
modalTitle = '';
|
||||||
modalType;
|
modalType;
|
||||||
selectedRoute = '';
|
selectedRoute = '';
|
||||||
|
|
||||||
requestInProgress = false;
|
requestInProgress = false;
|
||||||
currentProgressValue = 0;
|
currentProgressValue = 0;
|
||||||
|
|
||||||
modalSubscription: Subscription;
|
modalSubscription: Subscription;
|
||||||
requestInProgressSubscription: Subscription;
|
requestInProgressSubscription: Subscription;
|
||||||
selectedRouteSubscription: Subscription;
|
selectedRouteSubscription: Subscription;
|
||||||
routerSubscription: Subscription;
|
routerSubscription: Subscription;
|
||||||
uploadingFileSubscription: Subscription;
|
uploadingFileSubscription: Subscription;
|
||||||
|
|
||||||
@HostListener('window:resize', ['$event'])
|
@HostListener('window:resize', ['$event'])
|
||||||
onResize(event) {
|
onResize(event) {
|
||||||
this.orientationService.onResize();
|
this.orientationService.onResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private generalModalService: GeneralModalService,
|
private generalModalService: GeneralModalService,
|
||||||
private requestInProgressService: RequestInProgressService,
|
private requestInProgressService: RequestInProgressService,
|
||||||
private orientationService: OrientationService,
|
private orientationService: OrientationService,
|
||||||
private selectedRouteService: SelectedRouteService,
|
private selectedRouteService: SelectedRouteService,
|
||||||
private formsValidatorService: FormsValidatorService,
|
private formsValidatorService: FormsValidatorService,
|
||||||
public uploadService: UploadService) {
|
public uploadService: UploadService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.routerSubscription = this.router.events.subscribe(event => {
|
this.routerSubscription = this.router.events.subscribe(event => {
|
||||||
if (event instanceof NavigationStart) {
|
if (event instanceof NavigationStart) {
|
||||||
this.selectedRouteService.selectRoute(event);
|
this.selectedRouteService.selectRoute(event);
|
||||||
this.formsValidatorService.formSubmitAttempt = false;
|
this.formsValidatorService.formSubmitAttempt = false;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
this.modalSubscription = this.generalModalService.getMessage().subscribe((messageModal: MessageModal) => {
|
this.modalSubscription = this.generalModalService.getMessage().subscribe((messageModal: MessageModal) => {
|
||||||
if (typeof messageModal.message === 'string') {
|
if (typeof messageModal.message === 'string') {
|
||||||
this.modalMessage = messageModal.message
|
this.modalMessage = messageModal.message
|
||||||
} else if (messageModal.message.error instanceof ProgressEvent) {
|
} else if (messageModal.message.error instanceof ProgressEvent) {
|
||||||
this.modalMessage = messageModal.message.message;
|
this.modalMessage = messageModal.message.message;
|
||||||
} else {
|
} else {
|
||||||
this.modalMessage = messageModal.message.error ?
|
this.modalMessage = messageModal.message.error ?
|
||||||
(messageModal.message.error.error + ' ' + messageModal.message.error.message)
|
(messageModal.message.error.error + ' ' + messageModal.message.error.message)
|
||||||
: messageModal.message.message;
|
: messageModal.message.message;
|
||||||
}
|
}
|
||||||
this.modalTitle = messageModal.title;
|
this.modalTitle = messageModal.title;
|
||||||
this.modalType = messageModal.type;
|
this.modalType = messageModal.type;
|
||||||
})
|
})
|
||||||
|
|
||||||
this.requestInProgressSubscription = this.requestInProgressService.getRequestInProgress().subscribe((value: boolean) => {
|
this.requestInProgressSubscription = this.requestInProgressService.getRequestInProgress().subscribe((value: boolean) => {
|
||||||
this.requestInProgress = value;
|
this.requestInProgress = value;
|
||||||
})
|
})
|
||||||
|
|
||||||
this.selectedRouteSubscription = this.selectedRouteService.getSelectedRoute().subscribe((value: string) => {
|
this.selectedRouteSubscription = this.selectedRouteService.getSelectedRoute().subscribe((value: string) => {
|
||||||
if (value.indexOf('classifications') !== -1) {
|
if (value.indexOf('classifications') !== -1) {
|
||||||
this.workbasketsRoute = false;
|
this.workbasketsRoute = false;
|
||||||
}
|
}
|
||||||
this.selectedRoute = value;
|
this.selectedRoute = value;
|
||||||
})
|
})
|
||||||
this.uploadingFileSubscription = this.uploadService.getCurrentProgressValue().subscribe(value => {
|
this.uploadingFileSubscription = this.uploadService.getCurrentProgressValue().subscribe(value => {
|
||||||
this.currentProgressValue = value;
|
this.currentProgressValue = value;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
if (this.routerSubscription) { this.routerSubscription.unsubscribe(); }
|
if (this.routerSubscription) { this.routerSubscription.unsubscribe(); }
|
||||||
if (this.modalSubscription) { this.modalSubscription.unsubscribe(); }
|
if (this.modalSubscription) { this.modalSubscription.unsubscribe(); }
|
||||||
if (this.requestInProgressSubscription) { this.requestInProgressSubscription.unsubscribe(); }
|
if (this.requestInProgressSubscription) { this.requestInProgressSubscription.unsubscribe(); }
|
||||||
if (this.selectedRouteSubscription) { this.selectedRouteSubscription.unsubscribe(); }
|
if (this.selectedRouteSubscription) { this.selectedRouteSubscription.unsubscribe(); }
|
||||||
if (this.uploadingFileSubscription) { this.uploadingFileSubscription.unsubscribe(); }
|
if (this.uploadingFileSubscription) { this.uploadingFileSubscription.unsubscribe(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,32 +7,32 @@ import { HttpClientModule } from '@angular/common/http';
|
||||||
import { configureTests } from 'app/app.test.configuration';
|
import { configureTests } from 'app/app.test.configuration';
|
||||||
|
|
||||||
describe('NoAccessComponent', () => {
|
describe('NoAccessComponent', () => {
|
||||||
let component: NoAccessComponent;
|
let component: NoAccessComponent;
|
||||||
let fixture: ComponentFixture<NoAccessComponent>;
|
let fixture: ComponentFixture<NoAccessComponent>;
|
||||||
let debugElement;
|
let debugElement;
|
||||||
|
|
||||||
|
|
||||||
beforeEach(done => {
|
beforeEach(done => {
|
||||||
const configure = (testBed: TestBed) => {
|
const configure = (testBed: TestBed) => {
|
||||||
testBed.configureTestingModule({
|
testBed.configureTestingModule({
|
||||||
imports: [RouterTestingModule, AngularSvgIconModule, HttpClientModule],
|
imports: [RouterTestingModule, AngularSvgIconModule, HttpClientModule],
|
||||||
declarations: [NoAccessComponent]
|
declarations: [NoAccessComponent]
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
configureTests(configure).then(testBed => {
|
configureTests(configure).then(testBed => {
|
||||||
fixture = TestBed.createComponent(NoAccessComponent);
|
fixture = TestBed.createComponent(NoAccessComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
debugElement = fixture.debugElement.nativeElement;
|
debugElement = fixture.debugElement.nativeElement;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
document.body.removeChild(debugElement);
|
document.body.removeChild(debugElement);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
export enum AlertType {
|
export enum AlertType {
|
||||||
SUCCESS = 'success',
|
SUCCESS = 'success',
|
||||||
INFO = 'info',
|
INFO = 'info',
|
||||||
WARNING = 'warning',
|
WARNING = 'warning',
|
||||||
DANGER = 'danger',
|
DANGER = 'danger',
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AlertModel {
|
export class AlertModel {
|
||||||
|
|
||||||
constructor(public type: string = AlertType.SUCCESS,
|
constructor(public type: string = AlertType.SUCCESS,
|
||||||
public text: string = 'Success',
|
public text: string = 'Success',
|
||||||
public autoClosing: boolean = true,
|
public autoClosing: boolean = true,
|
||||||
public closingDelay: number = 2500) {
|
public closingDelay: number = 2500) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
export enum Orientation {
|
export enum Orientation {
|
||||||
landscape = 'landscape',
|
landscape = 'landscape',
|
||||||
portrait = 'portrait'
|
portrait = 'portrait'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
|
|
||||||
export enum ICONTYPES {
|
export enum ICONTYPES {
|
||||||
ALL = 'ALL',
|
ALL = 'ALL',
|
||||||
PERSONAL = 'PERSONAL',
|
PERSONAL = 'PERSONAL',
|
||||||
GROUP = 'GROUP',
|
GROUP = 'GROUP',
|
||||||
CLEARANCE = 'CLEARANCE',
|
CLEARANCE = 'CLEARANCE',
|
||||||
TOPIC = 'TOPIC'
|
TOPIC = 'TOPIC'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,15 @@ import { AlertModel } from 'app/models/alert';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlertService {
|
export class AlertService {
|
||||||
|
|
||||||
public alertTriggered = new Subject<AlertModel>();
|
public alertTriggered = new Subject<AlertModel>();
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
triggerAlert(alert: AlertModel) {
|
triggerAlert(alert: AlertModel) {
|
||||||
this.alertTriggered.next(alert);
|
this.alertTriggered.next(alert);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAlert(): Observable<AlertModel> {
|
getAlert(): Observable<AlertModel> {
|
||||||
return this.alertTriggered.asObservable();
|
return this.alertTriggered.asObservable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,15 @@ import { MessageModal } from 'app/models/message-modal';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GeneralModalService {
|
export class GeneralModalService {
|
||||||
|
|
||||||
private messageTriggered = new Subject<MessageModal>();
|
private messageTriggered = new Subject<MessageModal>();
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
triggerMessage(message: MessageModal) {
|
triggerMessage(message: MessageModal) {
|
||||||
this.messageTriggered.next(message);
|
this.messageTriggered.next(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
getMessage(): Observable<MessageModal> {
|
getMessage(): Observable<MessageModal> {
|
||||||
return this.messageTriggered.asObservable();
|
return this.messageTriggered.asObservable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,21 +4,21 @@ import { Subject , Observable } from 'rxjs';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RemoveConfirmationService {
|
export class RemoveConfirmationService {
|
||||||
|
|
||||||
private removeConfirmationCallbackSubject = new Subject<{ callback: Function, message: string }>();
|
private removeConfirmationCallbackSubject = new Subject<{ callback: Function, message: string }>();
|
||||||
private removeConfirmationCallback: Function;
|
private removeConfirmationCallback: Function;
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
setRemoveConfirmation(callback: Function, message: string) {
|
setRemoveConfirmation(callback: Function, message: string) {
|
||||||
this.removeConfirmationCallback = callback;
|
this.removeConfirmationCallback = callback;
|
||||||
this.removeConfirmationCallbackSubject.next({ callback: callback, message: message });
|
this.removeConfirmationCallbackSubject.next({ callback: callback, message: message });
|
||||||
}
|
}
|
||||||
|
|
||||||
getRemoveConfirmation(): Observable<{ callback: Function, message: string }> {
|
getRemoveConfirmation(): Observable<{ callback: Function, message: string }> {
|
||||||
return this.removeConfirmationCallbackSubject.asObservable();
|
return this.removeConfirmationCallbackSubject.asObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
runCallbackFunction() {
|
runCallbackFunction() {
|
||||||
this.removeConfirmationCallback();
|
this.removeConfirmationCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,15 @@ import { Subject , Observable } from 'rxjs';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RequestInProgressService {
|
export class RequestInProgressService {
|
||||||
|
|
||||||
public requestInProgressTriggered = new Subject<boolean>();
|
public requestInProgressTriggered = new Subject<boolean>();
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
setRequestInProgress(value: boolean) {
|
setRequestInProgress(value: boolean) {
|
||||||
setTimeout(() => this.requestInProgressTriggered.next(value), 0);
|
setTimeout(() => this.requestInProgressTriggered.next(value), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
getRequestInProgress(): Observable<boolean> {
|
getRequestInProgress(): Observable<boolean> {
|
||||||
return this.requestInProgressTriggered.asObservable();
|
return this.requestInProgressTriggered.asObservable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,69 +6,69 @@ import { AlertService } from 'app/services/alert/alert.service';
|
||||||
import { AlertComponent } from './alert.component';
|
import { AlertComponent } from './alert.component';
|
||||||
|
|
||||||
describe('AlertComponent', () => {
|
describe('AlertComponent', () => {
|
||||||
let component: AlertComponent;
|
let component: AlertComponent;
|
||||||
let fixture: ComponentFixture<AlertComponent>;
|
let fixture: ComponentFixture<AlertComponent>;
|
||||||
let debugElement,
|
let debugElement,
|
||||||
alertService;
|
alertService;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [BrowserAnimationsModule],
|
imports: [BrowserAnimationsModule],
|
||||||
declarations: [AlertComponent],
|
declarations: [AlertComponent],
|
||||||
providers: [AlertService]
|
providers: [AlertService]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
alertService = TestBed.get(AlertService);
|
alertService = TestBed.get(AlertService);
|
||||||
fixture = TestBed.createComponent(AlertComponent);
|
fixture = TestBed.createComponent(AlertComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
debugElement = fixture.debugElement.nativeElement;
|
debugElement = fixture.debugElement.nativeElement;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
document.body.removeChild(debugElement);
|
document.body.removeChild(debugElement);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show alert message', () => {
|
it('should show alert message', () => {
|
||||||
alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, 'some custom text'));
|
alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, 'some custom text'));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(debugElement.querySelector('#alert-icon').innerText).toBe('done');
|
expect(debugElement.querySelector('#alert-icon').innerText).toBe('done');
|
||||||
expect(debugElement.querySelector('#alert-text').innerText).toBe('some custom text');
|
expect(debugElement.querySelector('#alert-text').innerText).toBe('some custom text');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have differents alert types', () => {
|
it('should have differents alert types', () => {
|
||||||
alertService.triggerAlert(new AlertModel(AlertType.DANGER, 'some custom text'));
|
alertService.triggerAlert(new AlertModel(AlertType.DANGER, 'some custom text'));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(debugElement.querySelector('#alert-icon').innerText).toBe('error');
|
expect(debugElement.querySelector('#alert-icon').innerText).toBe('error');
|
||||||
|
|
||||||
alertService.triggerAlert(new AlertModel(AlertType.WARNING, 'some custom text'));
|
alertService.triggerAlert(new AlertModel(AlertType.WARNING, 'some custom text'));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(debugElement.querySelector('#alert-icon').innerText).toBe('warning');
|
expect(debugElement.querySelector('#alert-icon').innerText).toBe('warning');
|
||||||
expect(debugElement.querySelector('#alert-text').innerText).toBe('some custom text');
|
expect(debugElement.querySelector('#alert-text').innerText).toBe('some custom text');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should define a closing timeout if alert has autoclosing property', (done) => {
|
it('should define a closing timeout if alert has autoclosing property', (done) => {
|
||||||
alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, 'some custom text', true, 5));
|
alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, 'some custom text', true, 5));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(component.alert).toBeDefined();
|
expect(component.alert).toBeDefined();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(component.alert).toBeUndefined();
|
expect(component.alert).toBeUndefined();
|
||||||
done();
|
done();
|
||||||
}, 6)
|
}, 6)
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have defined a closing button if alert has no autoclosing property', () => {
|
it('should have defined a closing button if alert has no autoclosing property', () => {
|
||||||
alertService.triggerAlert(new AlertModel(AlertType.DANGER, 'some custom text', false));
|
alertService.triggerAlert(new AlertModel(AlertType.DANGER, 'some custom text', false));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(debugElement.querySelector('.alert > button')).toBeDefined();
|
expect(debugElement.querySelector('.alert > button')).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,28 +5,28 @@ import { AlertService } from 'app/services/alert/alert.service';
|
||||||
import { expandTop } from '../animations/expand.animation';
|
import { expandTop } from '../animations/expand.animation';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-alert',
|
selector: 'taskana-alert',
|
||||||
templateUrl: './alert.component.html',
|
templateUrl: './alert.component.html',
|
||||||
styleUrls: ['./alert.component.scss'],
|
styleUrls: ['./alert.component.scss'],
|
||||||
animations: [expandTop]
|
animations: [expandTop]
|
||||||
})
|
})
|
||||||
|
|
||||||
export class AlertComponent implements OnInit {
|
export class AlertComponent implements OnInit {
|
||||||
alert: AlertModel;
|
alert: AlertModel;
|
||||||
constructor(private alertService: AlertService) { }
|
constructor(private alertService: AlertService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.alertService.getAlert().subscribe((alert: AlertModel) => {
|
this.alertService.getAlert().subscribe((alert: AlertModel) => {
|
||||||
this.alert = alert;
|
this.alert = alert;
|
||||||
if (alert.autoClosing) {
|
if (alert.autoClosing) {
|
||||||
this.setTimeOutForClosing(alert.closingDelay);
|
this.setTimeOutForClosing(alert.closingDelay);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeOutForClosing(time: number) {
|
setTimeOutForClosing(time: number) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.alert = undefined;
|
this.alert = undefined;
|
||||||
}, time);
|
}, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,35 +2,35 @@ import { Component, Input, ViewChild, OnChanges, SimpleChanges, Output, EventEmi
|
||||||
declare var $: any; // jquery
|
declare var $: any; // jquery
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-general-message-modal',
|
selector: 'taskana-general-message-modal',
|
||||||
templateUrl: './general-message-modal.component.html',
|
templateUrl: './general-message-modal.component.html',
|
||||||
styleUrls: ['./general-message-modal.component.scss']
|
styleUrls: ['./general-message-modal.component.scss']
|
||||||
})
|
})
|
||||||
export class GeneralMessageModalComponent implements OnChanges {
|
export class GeneralMessageModalComponent implements OnChanges {
|
||||||
|
|
||||||
@Input() message: string;
|
@Input() message: string;
|
||||||
@Output() messageChange = new EventEmitter<string>();
|
@Output() messageChange = new EventEmitter<string>();
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
title: string;
|
title: string;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
type: string;
|
type: string;
|
||||||
|
|
||||||
@ViewChild('generalModal', { static: true })
|
@ViewChild('generalModal', { static: true })
|
||||||
private modal;
|
private modal;
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (this.message) {
|
if (this.message) {
|
||||||
$(this.modal.nativeElement).modal('toggle');
|
$(this.modal.nativeElement).modal('toggle');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeMessage() {
|
removeMessage() {
|
||||||
this.message = '';
|
this.message = '';
|
||||||
this.messageChange.emit(this.message);
|
this.messageChange.emit(this.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,16 @@ import { MasterAndDetailComponent } from './master-and-detail.component';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-dummy-master',
|
selector: 'taskana-dummy-master',
|
||||||
template: 'dummymaster'
|
template: 'dummymaster'
|
||||||
})
|
})
|
||||||
export class DummyMasterComponent {
|
export class DummyMasterComponent {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-dummy-detail',
|
selector: 'taskana-dummy-detail',
|
||||||
template: 'dummydetail'
|
template: 'dummydetail'
|
||||||
})
|
})
|
||||||
export class DummyDetailComponent {
|
export class DummyDetailComponent {
|
||||||
|
|
||||||
|
|
@ -27,85 +27,85 @@ export class DummyDetailComponent {
|
||||||
|
|
||||||
describe('MasterAndDetailComponent ', () => {
|
describe('MasterAndDetailComponent ', () => {
|
||||||
|
|
||||||
let component, fixture, debugElement, router;
|
let component, fixture, debugElement, router;
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'workbaskets',
|
path: 'workbaskets',
|
||||||
component: MasterAndDetailComponent,
|
component: MasterAndDetailComponent,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: DummyMasterComponent,
|
component: DummyMasterComponent,
|
||||||
outlet: 'master'
|
outlet: 'master'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':id',
|
path: ':id',
|
||||||
component: DummyDetailComponent,
|
component: DummyDetailComponent,
|
||||||
outlet: 'detail'
|
outlet: 'detail'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
MasterAndDetailComponent,
|
MasterAndDetailComponent,
|
||||||
DummyMasterComponent,
|
DummyMasterComponent,
|
||||||
DummyDetailComponent],
|
DummyDetailComponent],
|
||||||
imports: [
|
imports: [
|
||||||
RouterTestingModule.withRoutes(routes),
|
RouterTestingModule.withRoutes(routes),
|
||||||
AngularSvgIconModule,
|
AngularSvgIconModule,
|
||||||
HttpClientModule
|
HttpClientModule
|
||||||
],
|
],
|
||||||
providers: [MasterAndDetailService]
|
providers: [MasterAndDetailService]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(MasterAndDetailComponent);
|
fixture = TestBed.createComponent(MasterAndDetailComponent);
|
||||||
component = fixture.debugElement.componentInstance;
|
component = fixture.debugElement.componentInstance;
|
||||||
debugElement = fixture.debugElement.nativeElement;
|
debugElement = fixture.debugElement.nativeElement;
|
||||||
router = TestBed.get(Router);
|
router = TestBed.get(Router);
|
||||||
router.initialNavigation();
|
router.initialNavigation();
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(async(() => {
|
afterEach(async(() => {
|
||||||
document.body.removeChild(debugElement);
|
document.body.removeChild(debugElement);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should be created', () => {
|
it('should be created', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call Router.navigateByUrl("/wokbaskets") and showDetail property should be false', async(() => {
|
it('should call Router.navigateByUrl("/wokbaskets") and showDetail property should be false', async(() => {
|
||||||
|
|
||||||
expect(component.showDetail).toBe(false);
|
expect(component.showDetail).toBe(false);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
router.navigateByUrl('/workbaskets');
|
router.navigateByUrl('/workbaskets');
|
||||||
expect(component.showDetail).toBe(false);
|
expect(component.showDetail).toBe(false);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should call Router.navigateByUrl("/wokbaskets/(detail:Id)") and showDetail property should be true', async(() => {
|
it('should call Router.navigateByUrl("/wokbaskets/(detail:Id)") and showDetail property should be true', async(() => {
|
||||||
|
|
||||||
expect(component.showDetail).toBe(false);
|
expect(component.showDetail).toBe(false);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
router.navigateByUrl('/workbaskets/(detail:2)');
|
router.navigateByUrl('/workbaskets/(detail:2)');
|
||||||
expect(component.showDetail).toBe(true);
|
expect(component.showDetail).toBe(true);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should navigate to parent state when backIsClicked', async(() => {
|
it('should navigate to parent state when backIsClicked', async(() => {
|
||||||
|
|
||||||
const spy = spyOn(router, 'navigateByUrl');
|
const spy = spyOn(router, 'navigateByUrl');
|
||||||
router.navigateByUrl('/workbaskets/(detail:2)');
|
router.navigateByUrl('/workbaskets/(detail:2)');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(spy.calls.first().args[0]).toBe('/workbaskets/(detail:2)');
|
expect(spy.calls.first().args[0]).toBe('/workbaskets/(detail:2)');
|
||||||
component.backClicked();
|
component.backClicked();
|
||||||
expect(spy.calls.mostRecent().args.length).toBe(2);
|
expect(spy.calls.mostRecent().args.length).toBe(2);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -8,111 +8,111 @@ import { Page } from 'app/models/page';
|
||||||
import { configureTests } from 'app/app.test.configuration';
|
import { configureTests } from 'app/app.test.configuration';
|
||||||
|
|
||||||
describe('PaginationComponent', () => {
|
describe('PaginationComponent', () => {
|
||||||
let component: PaginationComponent;
|
let component: PaginationComponent;
|
||||||
let fixture: ComponentFixture<PaginationComponent>;
|
let fixture: ComponentFixture<PaginationComponent>;
|
||||||
let debugElement;
|
let debugElement;
|
||||||
|
|
||||||
|
|
||||||
beforeEach(done => {
|
beforeEach(done => {
|
||||||
const configure = (testBed: TestBed) => {
|
const configure = (testBed: TestBed) => {
|
||||||
testBed.configureTestingModule({
|
testBed.configureTestingModule({
|
||||||
imports: [FormsModule, SharedModule]
|
imports: [FormsModule, SharedModule]
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
configureTests(configure).then(testBed => {
|
configureTests(configure).then(testBed => {
|
||||||
fixture = TestBed.createComponent(PaginationComponent);
|
fixture = TestBed.createComponent(PaginationComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
debugElement = fixture.debugElement.nativeElement;
|
debugElement = fixture.debugElement.nativeElement;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
document.body.removeChild(debugElement);
|
document.body.removeChild(debugElement);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
expect(debugElement.querySelectorAll('#wb-pagination > li').length).toBe(2);
|
expect(debugElement.querySelectorAll('#wb-pagination > li').length).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create 3 pages if total pages are 3', () => {
|
it('should create 3 pages if total pages are 3', () => {
|
||||||
component.page = new Page(6, 3, 3, 1);
|
component.page = new Page(6, 3, 3, 1);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(debugElement.querySelectorAll('#wb-pagination > li').length).toBe(5);
|
expect(debugElement.querySelectorAll('#wb-pagination > li').length).toBe(5);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit change if previous page was different than current one', () => {
|
it('should emit change if previous page was different than current one', () => {
|
||||||
component.page = new Page(6, 3, 3, 1);
|
component.page = new Page(6, 3, 3, 1);
|
||||||
component.previousPageSelected = 2;
|
component.previousPageSelected = 2;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.changePage.subscribe(value => {
|
component.changePage.subscribe(value => {
|
||||||
expect(value).toBe(1)
|
expect(value).toBe(1)
|
||||||
})
|
})
|
||||||
component.changeToPage(1);
|
component.changeToPage(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not emit change if previous page was the same than current one', () => {
|
it('should not emit change if previous page was the same than current one', () => {
|
||||||
component.page = new Page(6, 3, 3, 1);
|
component.page = new Page(6, 3, 3, 1);
|
||||||
component.previousPageSelected = 2;
|
component.previousPageSelected = 2;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.changePage.subscribe(value => {
|
component.changePage.subscribe(value => {
|
||||||
expect(false).toBe(true)
|
expect(false).toBe(true)
|
||||||
})
|
})
|
||||||
component.changeToPage(2);
|
component.changeToPage(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit totalPages if page is more than page.totalPages', () => {
|
it('should emit totalPages if page is more than page.totalPages', () => {
|
||||||
component.page = new Page(6, 3, 3, 1);
|
component.page = new Page(6, 3, 3, 1);
|
||||||
component.previousPageSelected = 2;
|
component.previousPageSelected = 2;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.changePage.subscribe(value => {
|
component.changePage.subscribe(value => {
|
||||||
expect(value).toBe(3)
|
expect(value).toBe(3)
|
||||||
})
|
})
|
||||||
component.changeToPage(100);
|
component.changeToPage(100);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit 1 if page is less than 1', () => {
|
it('should emit 1 if page is less than 1', () => {
|
||||||
component.page = new Page(6, 3, 3, 1);
|
component.page = new Page(6, 3, 3, 1);
|
||||||
component.previousPageSelected = 2;
|
component.previousPageSelected = 2;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.changePage.subscribe(value => {
|
component.changePage.subscribe(value => {
|
||||||
expect(value).toBe(1)
|
expect(value).toBe(1)
|
||||||
})
|
})
|
||||||
component.changeToPage(0);
|
component.changeToPage(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change pageSelected onChanges', () => {
|
it('should change pageSelected onChanges', () => {
|
||||||
expect(component.pageSelected).toBe(1);
|
expect(component.pageSelected).toBe(1);
|
||||||
component.ngOnChanges({
|
component.ngOnChanges({
|
||||||
page: new SimpleChange(null, new Page(6, 3, 3, 2), true)
|
page: new SimpleChange(null, new Page(6, 3, 3, 2), true)
|
||||||
});
|
});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(component.pageSelected).toBe(2);
|
expect(component.pageSelected).toBe(2);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should getPagesTextToShow return 7 of 13 with size < totalElements', () => {
|
it('should getPagesTextToShow return 7 of 13 with size < totalElements', () => {
|
||||||
component.page = new Page(7, 13, 3, 2);
|
component.page = new Page(7, 13, 3, 2);
|
||||||
component.type = 'workbaskets';
|
component.type = 'workbaskets';
|
||||||
component.numberOfItems = 5;
|
component.numberOfItems = 5;
|
||||||
expect(component.getPagesTextToShow()).toBe(component.numberOfItems.toString().concat(' of 13 workbaskets'));
|
expect(component.getPagesTextToShow()).toBe(component.numberOfItems.toString().concat(' of 13 workbaskets'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should getPagesTextToShow return 6 of 6 with size > totalElements', () => {
|
it('should getPagesTextToShow return 6 of 6 with size > totalElements', () => {
|
||||||
component.page = new Page(7, 6, 3, 2);
|
component.page = new Page(7, 6, 3, 2);
|
||||||
component.type = 'tasks';
|
component.type = 'tasks';
|
||||||
component.numberOfItems = 6;
|
component.numberOfItems = 6;
|
||||||
expect(component.getPagesTextToShow()).toBe(component.numberOfItems.toString().concat(' of 6 tasks'));
|
expect(component.getPagesTextToShow()).toBe(component.numberOfItems.toString().concat(' of 6 tasks'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should getPagesTextToShow return of with totalElements = 0', () => {
|
it('should getPagesTextToShow return of with totalElements = 0', () => {
|
||||||
component.page = new Page(7, 0, 0, 0);
|
component.page = new Page(7, 0, 0, 0);
|
||||||
component.type = 'workbaskets';
|
component.type = 'workbaskets';
|
||||||
component.numberOfItems = 0;
|
component.numberOfItems = 0;
|
||||||
expect(component.getPagesTextToShow()).toBe(component.numberOfItems.toString().concat(' of 0 workbaskets'));
|
expect(component.getPagesTextToShow()).toBe(component.numberOfItems.toString().concat(' of 0 workbaskets'));
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@ import { GeneralModalService } from 'app/services/general-modal/general-modal.se
|
||||||
import { RequestInProgressService } from 'app/services/requestInProgress/request-in-progress.service';
|
import { RequestInProgressService } from 'app/services/requestInProgress/request-in-progress.service';
|
||||||
|
|
||||||
describe('HttpExtensionService', () => {
|
describe('HttpExtensionService', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [HttpClientModule],
|
imports: [HttpClientModule],
|
||||||
providers: [HttpClientInterceptor, GeneralModalService, RequestInProgressService]
|
providers: [HttpClientInterceptor, GeneralModalService, RequestInProgressService]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be created', inject([HttpClientInterceptor], (service: HttpClientInterceptor) => {
|
it('should be created', inject([HttpClientInterceptor], (service: HttpClientInterceptor) => {
|
||||||
expect(service).toBeTruthy();
|
expect(service).toBeTruthy();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -12,28 +12,28 @@ import { tap } from 'rxjs/operators';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class HttpClientInterceptor implements HttpInterceptor {
|
export class HttpClientInterceptor implements HttpInterceptor {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private generalModalService: GeneralModalService,
|
private generalModalService: GeneralModalService,
|
||||||
private requestInProgressService: RequestInProgressService) {
|
private requestInProgressService: RequestInProgressService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||||
req = req.clone({ headers: req.headers.set('Content-Type', 'application/hal+json') });
|
req = req.clone({ headers: req.headers.set('Content-Type', 'application/hal+json') });
|
||||||
if (!environment.production) {
|
if (!environment.production) {
|
||||||
req = req.clone({ headers: req.headers.set('Authorization', 'Basic YWRtaW46YWRtaW4=') });
|
req = req.clone({ headers: req.headers.set('Authorization', 'Basic YWRtaW46YWRtaW4=') });
|
||||||
}
|
}
|
||||||
return next.handle(req).pipe(tap(() => { }, error => {
|
return next.handle(req).pipe(tap(() => { }, error => {
|
||||||
this.requestInProgressService.setRequestInProgress(false);
|
this.requestInProgressService.setRequestInProgress(false);
|
||||||
if (error instanceof HttpErrorResponse && (error.status === 401 || error.status === 403)) {
|
if (error instanceof HttpErrorResponse && (error.status === 401 || error.status === 403)) {
|
||||||
this.generalModalService.triggerMessage(
|
this.generalModalService.triggerMessage(
|
||||||
new MessageModal('You have no access to this resource ', error));
|
new MessageModal('You have no access to this resource ', error));
|
||||||
} else if (error instanceof HttpErrorResponse && (error.status === 404) && error.url.indexOf('environment-information.json')) {
|
} else if (error instanceof HttpErrorResponse && (error.status === 404) && error.url.indexOf('environment-information.json')) {
|
||||||
// ignore this error message
|
// ignore this error message
|
||||||
} else {
|
} else {
|
||||||
this.generalModalService.triggerMessage(
|
this.generalModalService.triggerMessage(
|
||||||
new MessageModal('There was error, please contact with your administrator ', error))
|
new MessageModal('There was error, please contact with your administrator ', error))
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,16 +33,16 @@ describe('SortComponent', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change order when click on order ', () => {
|
it('should change order when click on order ', () => {
|
||||||
expect(component.sort.sortDirection).toBe(Direction.ASC);
|
expect(component.sort.sortDirection).toBe(Direction.ASC);
|
||||||
debugElement.querySelector('#sort-by-direction-desc').click();
|
debugElement.querySelector('#sort-by-direction-desc').click();
|
||||||
expect(component.sort.sortDirection).toBe(Direction.DESC);
|
expect(component.sort.sortDirection).toBe(Direction.DESC);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change sort by when click on sort by ', () => {
|
it('should change sort by when click on sort by ', () => {
|
||||||
component.sortingFields = new Map<string, string>([['name', 'Name']]);
|
component.sortingFields = new Map<string, string>([['name', 'Name']]);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(component.sort.sortBy).toBe('key');
|
expect(component.sort.sortBy).toBe('key');
|
||||||
debugElement.querySelector('#sort-by-name').click();
|
debugElement.querySelector('#sort-by-name').click();
|
||||||
expect(component.sort.sortBy).toBe('name');
|
expect(component.sort.sortBy).toBe('name');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ export class TypeAheadComponent implements OnInit, ControlValueAccessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeDataSource() {
|
initializeDataSource() {
|
||||||
this.dataSource = Observable.create((observer: any) => {
|
this.dataSource = new Observable((observer: any) => {
|
||||||
observer.next(this.value);
|
observer.next(this.value);
|
||||||
}).pipe(mergeMap((token: string) => this.getUsersAsObservable(token)));
|
}).pipe(mergeMap((token: string) => this.getUsersAsObservable(token)));
|
||||||
this.accessIdsService.getAccessItemsInformation(this.value).subscribe(items => {
|
this.accessIdsService.getAccessItemsInformation(this.value).subscribe(items => {
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ import { environment } from 'environments/environment';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CustomHttpClientInterceptor implements HttpInterceptor {
|
export class CustomHttpClientInterceptor implements HttpInterceptor {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||||
if (!environment.production) {
|
if (!environment.production) {
|
||||||
req = req.clone({ headers: req.headers.set('Authorization', 'Basic YWRtaW46YWRtaW4=') });
|
req = req.clone({ headers: req.headers.set('Authorization', 'Basic YWRtaW46YWRtaW4=') });
|
||||||
}
|
}
|
||||||
return next.handle(req);
|
return next.handle(req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ import { WorkplaceService } from 'app/workplace/services/workplace.service';
|
||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-dummy-detail',
|
selector: 'taskana-dummy-detail',
|
||||||
template: 'dummydetail'
|
template: 'dummydetail'
|
||||||
})
|
})
|
||||||
export class DummyDetailComponent {
|
export class DummyDetailComponent {
|
||||||
}
|
}
|
||||||
|
|
@ -32,8 +32,8 @@ xdescribe('TasklistToolbarComponent', () => {
|
||||||
let fixture: ComponentFixture<TaskListToolbarComponent>;
|
let fixture: ComponentFixture<TaskListToolbarComponent>;
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '*', component: DummyDetailComponent }
|
{ path: '*', component: DummyDetailComponent }
|
||||||
];
|
];
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ import { WorkplaceService } from 'app/workplace/services/workplace.service';
|
||||||
import { ObjectReference } from 'app/workplace/models/object-reference';
|
import { ObjectReference } from 'app/workplace/models/object-reference';
|
||||||
|
|
||||||
export enum Search {
|
export enum Search {
|
||||||
byWorkbasket = 'workbasket',
|
byWorkbasket = 'workbasket',
|
||||||
byTypeAndValue = 'type-and-value'
|
byTypeAndValue = 'type-and-value'
|
||||||
}
|
}
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-task-list-toolbar',
|
selector: 'taskana-task-list-toolbar',
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ export class DummyDetailComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
// tslint:disable-next-line: component-selector
|
||||||
selector: 'svg-icon',
|
selector: 'svg-icon',
|
||||||
template: '<p>Mock Icon Component</p>'
|
template: '<p>Mock Icon Component</p>'
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue