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