TSK-541 Fix access items validation error when add/remove new access items and use ReactiveForms
This commit is contained in:
parent
38a9e82309
commit
63c3b7ee53
|
@ -1,7 +1,7 @@
|
|||
// tslint:enable:max-line-length
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { Ng2AutoCompleteModule } from 'ng2-auto-complete';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { AlertModule } from 'ngx-bootstrap';
|
||||
|
@ -42,6 +42,7 @@ import { ClassificationCategoriesService } from './services/classification-categ
|
|||
const MODULES = [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
Ng2AutoCompleteModule,
|
||||
AngularSvgIconModule,
|
||||
AlertModule,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div *ngIf="workbasket" id="wb-information" class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<div class="pull-right">
|
||||
<button type="button" (click)="onSave()" [disabled]="!AccessItemsForm.form.valid || action === 'COPY'" class="btn btn-default btn-primary">Save</button>
|
||||
<button type="button" (click)="onSave()" [disabled]="!AccessItemsForm.valid || action === 'COPY'" class="btn btn-default btn-primary">Save</button>
|
||||
<button type="button" (click)="clear()" class="btn btn-default">Undo</button>
|
||||
</div>
|
||||
<h4 class="panel-header">{{workbasket.name}}
|
||||
|
@ -9,8 +9,8 @@
|
|||
</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<form #AccessItemsForm="ngForm">
|
||||
<table id="table-access-items" class="table table-striped table-center">
|
||||
<form [formGroup]="AccessItemsForm">
|
||||
<table formArrayName="accessItemsGroups" id="table-access-items" class="table table-striped table-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
|
@ -36,98 +36,95 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let accessItem of accessItems; let index = index;" ngModelGroup="accessItems">
|
||||
<tr *ngFor="let accessItem of accessItemsGroups.controls; let index = index;" [formGroupName]="index">
|
||||
<td>
|
||||
<button type="button" (click)="remove(index)" data-toggle="tooltip" title="Remove" class="btn btn-default remove">
|
||||
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
|
||||
</button>
|
||||
</td>
|
||||
<td *ngIf="accessIdField.lookupField else accessIdInput" class="input-group text-align text-width taskana-type-ahead" [ngClass]="{
|
||||
'has-warning': (accessItemsClone[index].accessId !== accessItem.accessId),
|
||||
'has-error': !accessItem.accessId } ">
|
||||
<taskana-type-ahead required #accessItemName="ngModel" [(ngModel)]="accessItem.accessId" name="accessItem.accessId-{{index}}"
|
||||
[(ngModel)]="accessItem.accessId" placeHolderMessage="Access id is required"></taskana-type-ahead>
|
||||
'has-warning': (accessItemsClone[index].accessId !== accessItem.value.accessId),
|
||||
'has-error': !accessItem.value.accessId } ">
|
||||
<taskana-type-ahead [(ngModel)]="accessItem.value.accessId" formControlName="accessId" placeHolderMessage="Access id is required"></taskana-type-ahead>
|
||||
</td>
|
||||
<ng-template #accessIdInput>
|
||||
<td class="input-group text-align text-width ">
|
||||
<div [ngClass]="{ 'has-warning': (accessItemsClone[index].accessId !== accessItem.accessId),
|
||||
'has-error': !accessItem.accessId }">
|
||||
<input type="text" required #accessItemName="ngModel" class="form-control" name="accessItem.accessId-{{index}}" [(ngModel)]="accessItem.accessId"
|
||||
placeholder="{{accessItemName.invalid? 'Access id is required': ''}}">
|
||||
<div [ngClass]="{ 'has-warning': (accessItemsClone[index].accessId !== accessItem.value.accessId),
|
||||
'has-error': !accessItem.value.accessId }">
|
||||
<input type="text" class="form-control" formControlName="accessId" placeholder="{{accessItem.invalid? 'Access id is required': ''}}">
|
||||
</div>
|
||||
</td>
|
||||
</ng-template>
|
||||
<td>
|
||||
<input id="checkbox-{{index}}-00" type="checkbox" (click)="checkAll(index)">
|
||||
<input id="checkbox-{{index}}-00" type="checkbox" (change)="checkAll(index, $event)">
|
||||
<label for="checkbox-{{index}}-00"></label>
|
||||
</td>
|
||||
<td [ngClass]="{'has-changes': (accessItemsClone[index].permRead !== accessItem.permRead)}">
|
||||
<input id="checkbox-{{index}}-0" type="checkbox" disabled="disabled" name="accessItem.permRead-{{index}}" [(ngModel)]="accessItem.permRead"
|
||||
class="regular-checkbox">
|
||||
<td [ngClass]="{'has-changes': (accessItemsClone[index].permRead !== accessItem.value.permRead)}">
|
||||
<input id="checkbox-{{index}}-0" type="checkbox" formControlName="permRead" class="regular-checkbox">
|
||||
<label for="checkbox-{{index}}-0"></label>
|
||||
</td>
|
||||
<td [ngClass]="{'has-changes': (accessItemsClone[index].permOpen !== accessItem.permOpen)}">
|
||||
<input id="checkbox-{{index}}-1" type="checkbox" name="accessItem.permOpen-{{index}}" [(ngModel)]="accessItem.permOpen">
|
||||
<td [ngClass]="{'has-changes': (accessItemsClone[index].permOpen !== accessItem.value.permOpen)}">
|
||||
<input id="checkbox-{{index}}-1" type="checkbox" formControlName="permOpen">
|
||||
<label for="checkbox-{{index}}-1"></label>
|
||||
</td>
|
||||
<td [ngClass]="{'has-changes': (accessItemsClone[index].permAppend !== accessItem.permAppend)}">
|
||||
<input id="checkbox-{{index}}-2" type="checkbox" name="accessItem.permAppend-{{index}}" [(ngModel)]="accessItem.permAppend">
|
||||
<td [ngClass]="{'has-changes': (accessItemsClone[index].permAppend !== accessItem.value.permAppend)}">
|
||||
<input id="checkbox-{{index}}-2" type="checkbox" formControlName="permAppend">
|
||||
<label for="checkbox-{{index}}-2"></label>
|
||||
</td>
|
||||
<td [ngClass]="{'has-changes': (accessItemsClone[index].permTransfer !== accessItem.permTransfer)}">
|
||||
<input id="checkbox-{{index}}-3" type="checkbox" name="accessItem.permTransfer-{{index}}" [(ngModel)]="accessItem.permTransfer">
|
||||
<td [ngClass]="{'has-changes': (accessItemsClone[index].permTransfer !== accessItem.value.permTransfer)}">
|
||||
<input id="checkbox-{{index}}-3" type="checkbox" formControlName="permTransfer">
|
||||
<label for="checkbox-{{index}}-3"></label>
|
||||
</td>
|
||||
<td [ngClass]="{'has-changes': (accessItemsClone[index].permDistribute !== accessItem.permDistribute)}">
|
||||
<input id="checkbox-{{index}}-4" type="checkbox" name="accessItem.permDistribute-{{index}}" [(ngModel)]="accessItem.permDistribute">
|
||||
<td [ngClass]="{'has-changes': (accessItemsClone[index].permDistribute !== accessItem.value.permDistribute)}">
|
||||
<input id="checkbox-{{index}}-4" type="checkbox" formControlName="permDistribute">
|
||||
<label for="checkbox-{{index}}-4"></label>
|
||||
</td>
|
||||
<td *ngIf="custom1Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom1 !== accessItem.permCustom1)}">
|
||||
<input id="checkbox-{{index}}-5" type="checkbox" name="accessItem.permCustom1-{{index}}" [(ngModel)]="accessItem.permCustom1">
|
||||
<td *ngIf="custom1Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom1 !== accessItem.value.permCustom1)}">
|
||||
<input id="checkbox-{{index}}-5" type="checkbox" formControlName="permCustom1">
|
||||
<label for="checkbox-{{index}}-5"></label>
|
||||
</td>
|
||||
<td *ngIf="custom2Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom2 !== accessItem.permCustom2)}">
|
||||
<input id="checkbox-{{index}}-6" type="checkbox" name="accessItem.permCustom2-{{index}}" [(ngModel)]="accessItem.permCustom2">
|
||||
<td *ngIf="custom2Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom2 !== accessItem.value.permCustom2)}">
|
||||
<input id="checkbox-{{index}}-6" type="checkbox" formControlName="permCustom2">
|
||||
<label for="checkbox-{{index}}-6"></label>
|
||||
</td>
|
||||
<td *ngIf="custom3Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom3 !== accessItem.permCustom3)}">
|
||||
<input id="checkbox-{{index}}-7" type="checkbox" name="accessItem.permCustom3-{{index}}" [(ngModel)]="accessItem.permCustom3">
|
||||
<td *ngIf="custom3Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom3 !== accessItem.value.permCustom3)}">
|
||||
<input id="checkbox-{{index}}-7" type="checkbox" formControlName="permCustom3">
|
||||
<label for="checkbox-{{index}}-7"></label>
|
||||
</td>
|
||||
<td *ngIf="custom4Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom4 !== accessItem.permCustom4)}">
|
||||
<input id="checkbox-{{index}}-8" type="checkbox" name="accessItem.permCustom4-{{index}}" [(ngModel)]="accessItem.permCustom4">
|
||||
<td *ngIf="custom4Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom4 !== accessItem.value.permCustom4)}">
|
||||
<input id="checkbox-{{index}}-8" type="checkbox" formControlName="permCustom4">
|
||||
<label for="checkbox-{{index}}-8"></label>
|
||||
</td>
|
||||
<td *ngIf="custom5Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom5 !== accessItem.permCustom5)}">
|
||||
<input id="checkbox-{{index}}-9" type="checkbox" name="accessItem.permCustom5-{{index}}" [(ngModel)]="accessItem.permCustom5">
|
||||
<td *ngIf="custom5Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom5 !== accessItem.value.permCustom5)}">
|
||||
<input id="checkbox-{{index}}-9" type="checkbox" formControlName="permCustom5">
|
||||
<label for="checkbox-{{index}}-9"></label>
|
||||
</td>
|
||||
<td *ngIf="custom6Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom6 !== accessItem.permCustom6)}">
|
||||
<input id="checkbox-{{index}}-10" type="checkbox" name="accessItem.permCustom6-{{index}}" [(ngModel)]="accessItem.permCustom6">
|
||||
<td *ngIf="custom6Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom6 !== accessItem.value.permCustom6)}">
|
||||
<input id="checkbox-{{index}}-10" type="checkbox" formControlName="permCustom6">
|
||||
<label for="checkbox-{{index}}-10"></label>
|
||||
</td>
|
||||
<td *ngIf="custom7Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom7 !== accessItem.permCustom7)}">
|
||||
<input id="checkbox-{{index}}-11" type="checkbox" name="accessItem.permCustom7-{{index}}" [(ngModel)]="accessItem.permCustom7">
|
||||
<td *ngIf="custom7Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom7 !== accessItem.value.permCustom7)}">
|
||||
<input id="checkbox-{{index}}-11" type="checkbox" formControlName="permCustom7">
|
||||
<label for="checkbox-{{index}}-11"></label>
|
||||
</td>
|
||||
<td *ngIf="custom8Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom8 !== accessItem.permCustom8)}">
|
||||
<input id="checkbox-{{index}}-12" type="checkbox" name="accessItem.permCustom8-{{index}}" [(ngModel)]="accessItem.permCustom8">
|
||||
<td *ngIf="custom8Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom8 !== accessItem.value.permCustom8)}">
|
||||
<input id="checkbox-{{index}}-12" type="checkbox" formControlName="permCustom8">
|
||||
<label for="checkbox-{{index}}-12"></label>
|
||||
</td>
|
||||
<td *ngIf="custom9Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom9 !== accessItem.permCustom9)}">
|
||||
<input id="checkbox-{{index}}-13" type="checkbox" name="accessItem.permCustom9-{{index}}" [(ngModel)]="accessItem.permCustom9">
|
||||
<td *ngIf="custom9Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom9 !== accessItem.value.permCustom9)}">
|
||||
<input id="checkbox-{{index}}-13" type="checkbox" formControlName="permCustom9">
|
||||
<label for="checkbox-{{index}}-13"></label>
|
||||
</td>
|
||||
<td *ngIf="custom10Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom10 !== accessItem.permCustom10)}">
|
||||
<input id="checkbox-{{index}}-14" type="checkbox" name="accessItem.permCustom10-{{index}}" [(ngModel)]="accessItem.permCustom10">
|
||||
<td *ngIf="custom10Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom10 !== accessItem.value.permCustom10)}">
|
||||
<input id="checkbox-{{index}}-14" type="checkbox" formControlName="permCustom10">
|
||||
<label for="checkbox-{{index}}-14"></label>
|
||||
</td>
|
||||
<td *ngIf="custom11Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom11 !== accessItem.permCustom11)}">
|
||||
<input id="checkbox-{{index}}-15" type="checkbox" name="accessItem.permCustom11-{{index}}" [(ngModel)]="accessItem.permCustom11">
|
||||
<td *ngIf="custom11Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom11 !== accessItem.value.permCustom11)}">
|
||||
<input id="checkbox-{{index}}-15" type="checkbox" formControlName="permCustom11">
|
||||
<label for="checkbox-{{index}}-15"></label>
|
||||
</td>
|
||||
<td *ngIf="custom12Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom12 !== accessItem.permCustom12)}">
|
||||
<input id="checkbox-{{index}}-16" type="checkbox" name="accessItem.permCustom12-{{index}}" [(ngModel)]="accessItem.permCustom12">
|
||||
<td *ngIf="custom12Field.visible" [ngClass]="{'has-changes': (accessItemsClone[index].permCustom12 !== accessItem.value.permCustom12)}">
|
||||
<input id="checkbox-{{index}}-16" type="checkbox" formControlName="permCustom12">
|
||||
<label for="checkbox-{{index}}-16"></label>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { Component, OnInit, Input, AfterViewInit, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { Component, OnInit, Input, AfterViewInit, OnDestroy, OnChanges, SimpleChanges, ViewChild } from '@angular/core';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import { NgForm, FormGroup, FormControl, FormBuilder, Validators, FormArray } from '@angular/forms';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { Workbasket } from 'app/models/workbasket';
|
||||
import { WorkbasketAccessItems } from 'app/models/workbasket-access-items';
|
||||
|
@ -14,8 +16,7 @@ import { WorkbasketService } from 'app/services/workbasket/workbasket.service';
|
|||
import { AlertService } from 'app/services/alert/alert.service';
|
||||
import { RequestInProgressService } from 'app/services/requestInProgress/request-in-progress.service';
|
||||
import { TitlesService } from 'app/services/titles/titles.service';
|
||||
import { CustomFieldsService } from '../../../../services/custom-fields/custom-fields.service';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { CustomFieldsService } from 'app/services/custom-fields/custom-fields.service';
|
||||
import { TypeaheadMatch } from 'ngx-bootstrap/typeahead';
|
||||
|
||||
declare var $: any;
|
||||
|
@ -49,7 +50,6 @@ export class AccessItemsComponent implements OnChanges, OnDestroy {
|
|||
custom12Field = this.customFieldService.getCustomField('Custom 12', 'workbaskets.access-items.custom12');
|
||||
|
||||
accessItemsResource: WorkbasketAccessItemsResource;
|
||||
accessItems: Array<WorkbasketAccessItems>;
|
||||
accessItemsClone: Array<WorkbasketAccessItems>;
|
||||
accessItemsResetClone: Array<WorkbasketAccessItems>;
|
||||
requestInProgress = false;
|
||||
|
@ -57,8 +57,25 @@ export class AccessItemsComponent implements OnChanges, OnDestroy {
|
|||
modalErrorMessage: string;
|
||||
accessItemsubscription: Subscription;
|
||||
savingAccessItemsSubscription: Subscription;
|
||||
AccessItemsForm = this.formBuilder.group({
|
||||
accessItemsGroups: this.formBuilder.array([
|
||||
])
|
||||
});
|
||||
|
||||
private initialized = false;
|
||||
|
||||
setAccessItemsGroups(accessItems: Array<WorkbasketAccessItems>) {
|
||||
const AccessItemsFormGroups = accessItems.map(accessItem => this.formBuilder.group(accessItem));
|
||||
AccessItemsFormGroups.map(accessItemGroup => {
|
||||
accessItemGroup.controls['accessId'].setValidators(Validators.required);
|
||||
});
|
||||
const AccessItemsFormArray = this.formBuilder.array(AccessItemsFormGroups);
|
||||
this.AccessItemsForm.setControl('accessItemsGroups', AccessItemsFormArray);
|
||||
};
|
||||
|
||||
get accessItemsGroups(): FormArray {
|
||||
return this.AccessItemsForm.get('accessItemsGroups') as FormArray;
|
||||
};
|
||||
|
||||
constructor(
|
||||
private workbasketService: WorkbasketService,
|
||||
|
@ -66,7 +83,8 @@ export class AccessItemsComponent implements OnChanges, OnDestroy {
|
|||
private errorModalService: ErrorModalService,
|
||||
private savingWorkbaskets: SavingWorkbasketService,
|
||||
private requestInProgressService: RequestInProgressService,
|
||||
private customFieldService: CustomFieldsService) {
|
||||
private customFieldService: CustomFieldsService,
|
||||
private formBuilder: FormBuilder) {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
|
@ -87,9 +105,9 @@ export class AccessItemsComponent implements OnChanges, OnDestroy {
|
|||
this.accessItemsubscription = this.workbasketService.getWorkBasketAccessItems(this.workbasket._links.accessItems.href)
|
||||
.subscribe((accessItemsResource: WorkbasketAccessItemsResource) => {
|
||||
this.accessItemsResource = accessItemsResource;
|
||||
this.accessItems = accessItemsResource._embedded ? accessItemsResource._embedded.accessItems : [];
|
||||
this.accessItemsClone = this.cloneAccessItems(this.accessItems);
|
||||
this.accessItemsResetClone = this.cloneAccessItems(this.accessItems);
|
||||
this.setAccessItemsGroups(accessItemsResource._embedded ? accessItemsResource._embedded.accessItems : []);
|
||||
this.accessItemsClone = this.cloneAccessItems(accessItemsResource._embedded ? accessItemsResource._embedded.accessItems : []);
|
||||
this.accessItemsResetClone = this.cloneAccessItems(accessItemsResource._embedded ? accessItemsResource._embedded.accessItems : []);
|
||||
this.requestInProgress = false;
|
||||
})
|
||||
this.savingAccessItemsSubscription = this.savingWorkbaskets.triggeredAccessItemsSaving()
|
||||
|
@ -104,57 +122,47 @@ export class AccessItemsComponent implements OnChanges, OnDestroy {
|
|||
}
|
||||
|
||||
addAccessItem() {
|
||||
this.accessItems.push(new WorkbasketAccessItems(undefined, this.workbasket.workbasketId, undefined, true));
|
||||
this.accessItemsClone.push(new WorkbasketAccessItems());
|
||||
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.alertService.triggerAlert(new AlertModel(AlertType.INFO, 'Reset edited fields'))
|
||||
this.accessItems = this.cloneAccessItems(this.accessItemsResetClone);
|
||||
this.accessItemsClone = this.cloneAccessItems(this.accessItemsResetClone);
|
||||
this.AccessItemsForm.reset();
|
||||
this.setAccessItemsGroups(this.accessItemsResetClone);
|
||||
}
|
||||
|
||||
remove(index: number) {
|
||||
this.accessItems.splice(index, 1);
|
||||
this.accessItemsGroups.removeAt(index);
|
||||
this.accessItemsClone.splice(index, 1);
|
||||
}
|
||||
|
||||
onSave(): boolean {
|
||||
onSave() {
|
||||
this.requestInProgressService.setRequestInProgress(true);
|
||||
this.workbasketService.updateWorkBasketAccessItem(this.accessItemsResource._links.self.href, this.accessItems)
|
||||
this.workbasketService.updateWorkBasketAccessItem(this.accessItemsResource._links.self.href, this.AccessItemsForm.value.accessItemsGroups)
|
||||
.subscribe(response => {
|
||||
this.accessItemsClone = this.cloneAccessItems(this.accessItems);
|
||||
this.accessItemsResetClone = this.cloneAccessItems(this.accessItems);
|
||||
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);
|
||||
return true;
|
||||
}, error => {
|
||||
this.errorModalService.triggerError(new ErrorModel(`There was error while saving your workbasket's access items`, error))
|
||||
this.requestInProgressService.setRequestInProgress(false);
|
||||
return false;
|
||||
})
|
||||
return false;
|
||||
}
|
||||
|
||||
checkAll(row: number) {
|
||||
this.accessItems[row].permCustom1 = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permCustom2 = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permCustom3 = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permCustom4 = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permCustom5 = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permCustom6 = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permCustom7 = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permCustom8 = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permCustom9 = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permCustom10 = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permCustom11 = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permCustom12 = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permAppend = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permDistribute = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permOpen = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permTransfer = !this.accessItems[row].permRead;
|
||||
this.accessItems[row].permRead = !this.accessItems[row].permRead;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private setBadge() {
|
||||
|
@ -164,14 +172,12 @@ export class AccessItemsComponent implements OnChanges, OnDestroy {
|
|||
}
|
||||
|
||||
private cloneAccessItems(inputaccessItem): Array<WorkbasketAccessItems> {
|
||||
const accessItemClone = new Array<WorkbasketAccessItems>();
|
||||
inputaccessItem.forEach(accessItem => {
|
||||
accessItemClone.push({ ...accessItem });
|
||||
});
|
||||
return accessItemClone;
|
||||
return this.AccessItemsForm.value.accessItemsGroups.map(
|
||||
(accessItems: WorkbasketAccessItems) => Object.assign({}, accessItems)
|
||||
);
|
||||
}
|
||||
private setWorkbasketIdForCopy(workbasketId: string) {
|
||||
this.accessItems.forEach(element => {
|
||||
this.accessItemsGroups.value.forEach(element => {
|
||||
element.accessItemId = undefined;
|
||||
element.workbasketId = workbasketId;
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Component, Input, forwardRef } from '@angular/core';
|
|||
import { async, ComponentFixture, TestBed, } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { Router, Routes } from '@angular/router';
|
||||
import { FormsModule, NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';
|
||||
import { FormsModule, ReactiveFormsModule, NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { HttpModule } from '@angular/http';
|
||||
|
@ -106,7 +106,7 @@ describe('WorkbasketDetailsComponent', () => {
|
|||
beforeEach(done => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [RouterTestingModule.withRoutes(routes), FormsModule, AngularSvgIconModule, HttpClientModule, HttpModule],
|
||||
imports: [RouterTestingModule.withRoutes(routes), FormsModule, AngularSvgIconModule, HttpClientModule, HttpModule, ReactiveFormsModule],
|
||||
declarations: [WorkbasketDetailsComponent, WorkbasketInformationComponent, SpinnerComponent,
|
||||
IconTypeComponent, MapValuesPipe, RemoveNoneTypePipe, AlertComponent, GeneralMessageModalComponent, AccessItemsComponent,
|
||||
DistributionTargetsComponent, FilterComponent, DualListComponent, DummyDetailComponent,
|
||||
|
|
|
@ -38,7 +38,7 @@ export class TypeAheadComponent implements OnInit, ControlValueAccessor {
|
|||
typeaheadOptionsInScrollableView = 6;
|
||||
|
||||
// The internal data model
|
||||
private innerValue: any = '';
|
||||
private innerValue: any = undefined;
|
||||
|
||||
// Placeholders for the callbacks which are later provided
|
||||
// by the Control Value Accessor
|
||||
|
|
Loading…
Reference in New Issue