diff --git a/web/src/app/administration/classification/master/list/classification-list.component.ts b/web/src/app/administration/classification/master/list/classification-list.component.ts index f840d08d2..70bbf4bec 100644 --- a/web/src/app/administration/classification/master/list/classification-list.component.ts +++ b/web/src/app/administration/classification/master/list/classification-list.component.ts @@ -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 = []; - classifications: Array = []; - classificationsTypes: Array = []; - 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 = []; + classifications: Array = []; + classificationsTypes: Array = []; + 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) => { - this.categories = categories; - }); - this.importingExportingSubscription = this.importExportService.getImportingFinished().subscribe((value: Boolean) => { - this.performRequest(true); - }) - } + this.categoriesSubscription = + this.categoryService.getCategories(this.classificationTypeSelected).subscribe((categories: Array) => { + 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) => { - this.requestInProgress = false; - this.classifications = classifications; - this.classificationTypeServiceSubscription = this.categoryService.getClassificationTypes() - .subscribe((classificationsTypes: Array) => { - 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) => { + this.requestInProgress = false; + this.classifications = classifications; + this.classificationTypeServiceSubscription = this.categoryService.getClassificationTypes() + .subscribe((classificationsTypes: Array) => { + 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(); } + } } diff --git a/web/src/app/administration/components/type-icon/icon-type.component.ts b/web/src/app/administration/components/type-icon/icon-type.component.ts index 0b217dc13..933803c02 100644 --- a/web/src/app/administration/components/type-icon/icon-type.component.ts +++ b/web/src/app/administration/components/type-icon/icon-type.component.ts @@ -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 { - return new Map([['PERSONAL', 'Personal'], ['GROUP', 'Group'], ['CLEARANCE', 'Clearance'], ['TOPIC', 'Topic']]) - }; + public static get allTypes(): Map { + 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'; - } + } } diff --git a/web/src/app/administration/services/import-export/import-export.service.ts b/web/src/app/administration/services/import-export/import-export.service.ts index c5c2934e5..12e42b650 100644 --- a/web/src/app/administration/services/import-export/import-export.service.ts +++ b/web/src/app/administration/services/import-export/import-export.service.ts @@ -6,14 +6,14 @@ export class ImportExportService { public importingFinished = new Subject(); - constructor() { } + constructor() { } - setImportingFinished(value: boolean) { - this.importingFinished.next(value); - } + setImportingFinished(value: boolean) { + this.importingFinished.next(value); + } - getImportingFinished(): Observable { - return this.importingFinished.asObservable(); - } + getImportingFinished(): Observable { + return this.importingFinished.asObservable(); + } } diff --git a/web/src/app/administration/workbasket/details/access-items/access-items.component.spec.ts b/web/src/app/administration/workbasket/details/access-items/access-items.component.spec.ts index db5fe07e5..dd91607bf 100644 --- a/web/src/app/administration/workbasket/details/access-items/access-items.component.spec.ts +++ b/web/src/app/administration/workbasket/details/access-items/access-items.component.spec.ts @@ -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; - let workbasketService, debugElement, alertService, accessIdsService, formsValidatorService; + let component: AccessItemsComponent; + let fixture: ComponentFixture; + 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( - 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( - '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( + 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( + '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); - }); + }); }); diff --git a/web/src/app/administration/workbasket/details/access-items/access-items.component.ts b/web/src/app/administration/workbasket/details/access-items/access-items.component.ts index 075b0668e..8602cb721 100644 --- a/web/src/app/administration/workbasket/details/access-items/access-items.component.ts +++ b/web/src/app/administration/workbasket/details/access-items/access-items.component.ts @@ -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; - accessItemsResetClone: Array; - requestInProgress = false; - modalTitle: string; - modalErrorMessage: string; - accessItemsubscription: Subscription; - savingAccessItemsSubscription: Subscription; - AccessItemsForm = this.formBuilder.group({ - accessItemsGroups: this.formBuilder.array([ - ]) - }); - toogleValidationAccessIdMap = new Map(); - private initialized = false; + accessItemsResource: WorkbasketAccessItemsResource; + accessItemsClone: Array; + accessItemsResetClone: Array; + requestInProgress = false; + modalTitle: string; + modalErrorMessage: string; + accessItemsubscription: Subscription; + savingAccessItemsSubscription: Subscription; + AccessItemsForm = this.formBuilder.group({ + accessItemsGroups: this.formBuilder.array([ + ]) + }); + toogleValidationAccessIdMap = new Map(); + private initialized = false; - setAccessItemsGroups(accessItems: Array) { - 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) { + 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 { - 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 { + 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(); } + } } diff --git a/web/src/app/administration/workbasket/details/distribution-targets/distribution-targets.component.ts b/web/src/app/administration/workbasket/details/distribution-targets/distribution-targets.component.ts index 8a7e842a0..ee284780a 100644 --- a/web/src/app/administration/workbasket/details/distribution-targets/distribution-targets.component.ts +++ b/web/src/app/administration/workbasket/details/distribution-targets/distribution-targets.component.ts @@ -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; - distributionTargetsRight: Array; - distributionTargetsSelected: Array; - distributionTargetsClone: Array; - distributionTargetsSelectedClone: Array; + distributionTargetsSelectedResource: WorkbasketDistributionTargetsResource; + distributionTargetsLeft: Array; + distributionTargetsRight: Array; + distributionTargetsSelected: Array; + distributionTargetsClone: Array; + distributionTargetsSelectedClone: Array; - 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 { - return originList.filter((item: any) => { return (item.selected === true) }); - } + private getSelectedItems(originList: any): Array { + 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 { - const distributionTargetsSelelected: Array = []; - this.distributionTargetsSelected.forEach(item => { - distributionTargetsSelelected.push(item.workbasketId); - }); - return distributionTargetsSelelected; + private getSeletedIds(): Array { + const distributionTargetsSelelected: Array = []; + this.distributionTargetsSelected.forEach(item => { + distributionTargetsSelelected.push(item.workbasketId); + }); + return distributionTargetsSelelected; } private uncheckSelectAll(side: number) { diff --git a/web/src/app/administration/workbasket/details/distribution-targets/dual-list/dual-list.component.ts b/web/src/app/administration/workbasket/details/distribution-targets/dual-list/dual-list.component.ts index 1cec06c9c..5f6c0d59f 100644 --- a/web/src/app/administration/workbasket/details/distribution-targets/dual-list/dual-list.component.ts +++ b/web/src/app/administration/workbasket/details/distribution-targets/dual-list/dual-list.component.ts @@ -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; - @Input() distributionTargetsSelected: Array; - @Output() performDualListFilter = new EventEmitter<{ filterBy: FilterModel, side: Side }>(); + @Input() distributionTargets: Array; + @Input() distributionTargetsSelected: Array; + @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(); @Input() allSelected; @Output() allSelectedChange = new EventEmitter(); - 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 }); } diff --git a/web/src/app/administration/workbasket/details/information/workbasket-information.component.spec.ts b/web/src/app/administration/workbasket/details/information/workbasket-information.component.spec.ts index c1f2e11a4..91d9da0e8 100644 --- a/web/src/app/administration/workbasket/details/information/workbasket-information.component.spec.ts +++ b/web/src/app/administration/workbasket/details/information/workbasket-information.component.spec.ts @@ -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; - let debugElement, workbasketService, alertService, savingWorkbasketService, requestInProgressService, formsValidatorService; + let component: WorkbasketInformationComponent; + let fixture: ComponentFixture; + 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); + }); + }) }); diff --git a/web/src/app/administration/workbasket/details/workbasket-details.component.spec.ts b/web/src/app/administration/workbasket/details/workbasket-details.component.spec.ts index 3fc458b66..b47004279 100644 --- a/web/src/app/administration/workbasket/details/workbasket-details.component.spec.ts +++ b/web/src/app/administration/workbasket/details/workbasket-details.component.spec.ts @@ -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( @@ -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(), new Links({ 'href': 'url' }))) diff --git a/web/src/app/administration/workbasket/details/workbasket-details.component.ts b/web/src/app/administration/workbasket/details/workbasket-details.component.ts index fed788442..fbfb10062 100644 --- a/web/src/app/administration/workbasket/details/workbasket-details.component.ts +++ b/web/src/app/administration/workbasket/details/workbasket-details.component.ts @@ -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(); } + } } diff --git a/web/src/app/administration/workbasket/master/workbasket-list-toolbar/workbasket-list-toolbar.component.spec.ts b/web/src/app/administration/workbasket/master/workbasket-list-toolbar/workbasket-list-toolbar.component.spec.ts index c2e661a92..b56dd0a0d 100644 --- a/web/src/app/administration/workbasket/master/workbasket-list-toolbar/workbasket-list-toolbar.component.spec.ts +++ b/web/src/app/administration/workbasket/master/workbasket-list-toolbar/workbasket-list-toolbar.component.spec.ts @@ -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; - let debugElement, workbasketService, router; + let component: WorkbasketListToolbarComponent; + let fixture: ComponentFixture; + 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( - 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( + 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); + }); }); diff --git a/web/src/app/administration/workbasket/master/workbasket-list.component.ts b/web/src/app/administration/workbasket/master/workbasket-list.component.ts index f6fa520aa..53afa8e25 100644 --- a/web/src/app/administration/workbasket/master/workbasket-list.component.ts +++ b/web/src/app/administration/workbasket/master/workbasket-list.component.ts @@ -68,8 +68,8 @@ export class WorkbasketListComponent implements OnInit, OnDestroy { this.refreshWorkbasketList(); }); this.importingExportingSubscription = this.importExportService.getImportingFinished().subscribe((value: Boolean) => { - this.refreshWorkbasketList(); - }) + this.refreshWorkbasketList(); + }) } diff --git a/web/src/app/app.component.spec.ts b/web/src/app/app.component.spec.ts index a2eb9171a..d5b56ed9f 100644 --- a/web/src/app/app.component.spec.ts +++ b/web/src/app/app.component.spec.ts @@ -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 tag', (() => { - fixture.detectChanges(); - expect(debugElement.querySelector('ul p a').textContent).toContain('Taskana administration'); - })); + it('should render title in 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); - }))); + }))); }) diff --git a/web/src/app/app.component.ts b/web/src/app/app.component.ts index b41fb43fb..ba3438f3a 100644 --- a/web/src/app/app.component.ts +++ b/web/src/app/app.component.ts @@ -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(); } + } } diff --git a/web/src/app/components/no-access/no-access.component.spec.ts b/web/src/app/components/no-access/no-access.component.spec.ts index 8e64ac471..7904af5b2 100644 --- a/web/src/app/components/no-access/no-access.component.spec.ts +++ b/web/src/app/components/no-access/no-access.component.spec.ts @@ -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; - let debugElement; + let component: NoAccessComponent; + let fixture: ComponentFixture; + 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(); + }); }); diff --git a/web/src/app/models/alert.ts b/web/src/app/models/alert.ts index 704fcd814..affadd1ca 100644 --- a/web/src/app/models/alert.ts +++ b/web/src/app/models/alert.ts @@ -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) { + } } diff --git a/web/src/app/models/orientation.ts b/web/src/app/models/orientation.ts index 2d60421bf..8936784a9 100644 --- a/web/src/app/models/orientation.ts +++ b/web/src/app/models/orientation.ts @@ -1,4 +1,4 @@ export enum Orientation { - landscape = 'landscape', - portrait = 'portrait' + landscape = 'landscape', + portrait = 'portrait' } diff --git a/web/src/app/models/type.ts b/web/src/app/models/type.ts index 9a3720a4d..653fe7ec3 100644 --- a/web/src/app/models/type.ts +++ b/web/src/app/models/type.ts @@ -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' } diff --git a/web/src/app/services/alert/alert.service.ts b/web/src/app/services/alert/alert.service.ts index a86763bb2..6ca9777ec 100644 --- a/web/src/app/services/alert/alert.service.ts +++ b/web/src/app/services/alert/alert.service.ts @@ -5,15 +5,15 @@ import { AlertModel } from 'app/models/alert'; @Injectable() export class AlertService { - public alertTriggered = new Subject(); + public alertTriggered = new Subject(); - constructor() { } + constructor() { } - triggerAlert(alert: AlertModel) { - this.alertTriggered.next(alert); - } + triggerAlert(alert: AlertModel) { + this.alertTriggered.next(alert); + } - getAlert(): Observable { - return this.alertTriggered.asObservable(); - } + getAlert(): Observable { + return this.alertTriggered.asObservable(); + } } diff --git a/web/src/app/services/general-modal/general-modal.service.ts b/web/src/app/services/general-modal/general-modal.service.ts index 2e3b9cf41..9712a691b 100644 --- a/web/src/app/services/general-modal/general-modal.service.ts +++ b/web/src/app/services/general-modal/general-modal.service.ts @@ -5,15 +5,15 @@ import { MessageModal } from 'app/models/message-modal'; @Injectable() export class GeneralModalService { - private messageTriggered = new Subject(); + private messageTriggered = new Subject(); - constructor() { } + constructor() { } - triggerMessage(message: MessageModal) { - this.messageTriggered.next(message); - } + triggerMessage(message: MessageModal) { + this.messageTriggered.next(message); + } - getMessage(): Observable { - return this.messageTriggered.asObservable(); - } + getMessage(): Observable { + return this.messageTriggered.asObservable(); + } } diff --git a/web/src/app/services/remove-confirmation/remove-confirmation.service.ts b/web/src/app/services/remove-confirmation/remove-confirmation.service.ts index b2a49265b..d555cc1c5 100644 --- a/web/src/app/services/remove-confirmation/remove-confirmation.service.ts +++ b/web/src/app/services/remove-confirmation/remove-confirmation.service.ts @@ -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(); + } } diff --git a/web/src/app/services/requestInProgress/request-in-progress.service.ts b/web/src/app/services/requestInProgress/request-in-progress.service.ts index 678eefdaf..6f9569bfb 100644 --- a/web/src/app/services/requestInProgress/request-in-progress.service.ts +++ b/web/src/app/services/requestInProgress/request-in-progress.service.ts @@ -4,15 +4,15 @@ import { Subject , Observable } from 'rxjs'; @Injectable() export class RequestInProgressService { - public requestInProgressTriggered = new Subject(); + public requestInProgressTriggered = new Subject(); - constructor() { } + constructor() { } - setRequestInProgress(value: boolean) { - setTimeout(() => this.requestInProgressTriggered.next(value), 0); - } + setRequestInProgress(value: boolean) { + setTimeout(() => this.requestInProgressTriggered.next(value), 0); + } - getRequestInProgress(): Observable { - return this.requestInProgressTriggered.asObservable(); - } + getRequestInProgress(): Observable { + return this.requestInProgressTriggered.asObservable(); + } } diff --git a/web/src/app/shared/alert/alert.component.spec.ts b/web/src/app/shared/alert/alert.component.spec.ts index 074d38b9a..def1dd271 100644 --- a/web/src/app/shared/alert/alert.component.spec.ts +++ b/web/src/app/shared/alert/alert.component.spec.ts @@ -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; - let debugElement, - alertService; + let component: AlertComponent; + let fixture: ComponentFixture; + 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(); + }); }); diff --git a/web/src/app/shared/alert/alert.component.ts b/web/src/app/shared/alert/alert.component.ts index f1a05a249..1ef2057f9 100644 --- a/web/src/app/shared/alert/alert.component.ts +++ b/web/src/app/shared/alert/alert.component.ts @@ -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); + } } diff --git a/web/src/app/shared/general-message-modal/general-message-modal.component.ts b/web/src/app/shared/general-message-modal/general-message-modal.component.ts index 98e97a743..ea79bd27e 100644 --- a/web/src/app/shared/general-message-modal/general-message-modal.component.ts +++ b/web/src/app/shared/general-message-modal/general-message-modal.component.ts @@ -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(); + @Input() message: string; + @Output() messageChange = new EventEmitter(); - @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); + } } diff --git a/web/src/app/shared/master-and-detail/master-and-detail.component.spec.ts b/web/src/app/shared/master-and-detail/master-and-detail.component.spec.ts index c2fa02796..29bb78b53 100644 --- a/web/src/app/shared/master-and-detail/master-and-detail.component.spec.ts +++ b/web/src/app/shared/master-and-detail/master-and-detail.component.spec.ts @@ -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); - })); + })); }); diff --git a/web/src/app/shared/pagination/pagination.component.spec.ts b/web/src/app/shared/pagination/pagination.component.spec.ts index 33c4e879c..230747368 100644 --- a/web/src/app/shared/pagination/pagination.component.spec.ts +++ b/web/src/app/shared/pagination/pagination.component.spec.ts @@ -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; - let debugElement; + let component: PaginationComponent; + let fixture: ComponentFixture; + 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')); + }); }); diff --git a/web/src/app/shared/services/httpClientInterceptor/http-client-interceptor.service.spec.ts b/web/src/app/shared/services/httpClientInterceptor/http-client-interceptor.service.spec.ts index 76be4c962..9116b5f9e 100644 --- a/web/src/app/shared/services/httpClientInterceptor/http-client-interceptor.service.spec.ts +++ b/web/src/app/shared/services/httpClientInterceptor/http-client-interceptor.service.spec.ts @@ -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(); + })); }); diff --git a/web/src/app/shared/services/httpClientInterceptor/http-client-interceptor.service.ts b/web/src/app/shared/services/httpClientInterceptor/http-client-interceptor.service.ts index e298770db..b4802cf0c 100644 --- a/web/src/app/shared/services/httpClientInterceptor/http-client-interceptor.service.ts +++ b/web/src/app/shared/services/httpClientInterceptor/http-client-interceptor.service.ts @@ -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, next: HttpHandler): Observable> { - 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, next: HttpHandler): Observable> { + 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)) + } + })) + } } diff --git a/web/src/app/shared/sort/sort.component.spec.ts b/web/src/app/shared/sort/sort.component.spec.ts index 09b83156b..a8574c015 100644 --- a/web/src/app/shared/sort/sort.component.spec.ts +++ b/web/src/app/shared/sort/sort.component.spec.ts @@ -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([['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'); }); }); diff --git a/web/src/app/shared/type-ahead/type-ahead.component.ts b/web/src/app/shared/type-ahead/type-ahead.component.ts index 4fe945b93..e38ceedee 100644 --- a/web/src/app/shared/type-ahead/type-ahead.component.ts +++ b/web/src/app/shared/type-ahead/type-ahead.component.ts @@ -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 => { diff --git a/web/src/app/workplace/services/custom-http-interceptor/custom-http-interceptor.service.ts b/web/src/app/workplace/services/custom-http-interceptor/custom-http-interceptor.service.ts index afd9a04fb..e8cea7d92 100644 --- a/web/src/app/workplace/services/custom-http-interceptor/custom-http-interceptor.service.ts +++ b/web/src/app/workplace/services/custom-http-interceptor/custom-http-interceptor.service.ts @@ -7,13 +7,13 @@ import { environment } from 'environments/environment'; @Injectable() export class CustomHttpClientInterceptor implements HttpInterceptor { - constructor() { - } + constructor() { + } - intercept(req: HttpRequest, next: HttpHandler): Observable> { - if (!environment.production) { - req = req.clone({ headers: req.headers.set('Authorization', 'Basic YWRtaW46YWRtaW4=') }); - } - return next.handle(req); - } + intercept(req: HttpRequest, next: HttpHandler): Observable> { + if (!environment.production) { + req = req.clone({ headers: req.headers.set('Authorization', 'Basic YWRtaW46YWRtaW4=') }); + } + return next.handle(req); + } } diff --git a/web/src/app/workplace/taskmaster/task-list-toolbar/task-list-toolbar.component.spec.ts b/web/src/app/workplace/taskmaster/task-list-toolbar/task-list-toolbar.component.spec.ts index 13e73343d..05214c319 100644 --- a/web/src/app/workplace/taskmaster/task-list-toolbar/task-list-toolbar.component.spec.ts +++ b/web/src/app/workplace/taskmaster/task-list-toolbar/task-list-toolbar.component.spec.ts @@ -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; const routes: Routes = [ - { path: '*', component: DummyDetailComponent } - ]; + { path: '*', component: DummyDetailComponent } + ]; beforeEach(async(() => { TestBed.configureTestingModule({ diff --git a/web/src/app/workplace/taskmaster/task-list-toolbar/task-list-toolbar.component.ts b/web/src/app/workplace/taskmaster/task-list-toolbar/task-list-toolbar.component.ts index 4363bd8d4..2223d18f5 100644 --- a/web/src/app/workplace/taskmaster/task-list-toolbar/task-list-toolbar.component.ts +++ b/web/src/app/workplace/taskmaster/task-list-toolbar/task-list-toolbar.component.ts @@ -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', diff --git a/web/src/app/workplace/taskmaster/task-list/task-list.component.spec.ts b/web/src/app/workplace/taskmaster/task-list/task-list.component.spec.ts index b1bfb9932..dd87142fe 100644 --- a/web/src/app/workplace/taskmaster/task-list/task-list.component.spec.ts +++ b/web/src/app/workplace/taskmaster/task-list/task-list.component.spec.ts @@ -18,6 +18,7 @@ export class DummyDetailComponent { } @Component({ + // tslint:disable-next-line: component-selector selector: 'svg-icon', template: '

Mock Icon Component

' })