no message

This commit is contained in:
annampak 2018-01-11 13:15:15 +02:00
parent 60b12fe501
commit 2bc57251e0
5 changed files with 31 additions and 20 deletions

View File

@ -28,7 +28,7 @@
<ng-template matStepLabel>{{'DATASET-WIZARD.THIRD-STEP.TITLE' | translate}}</ng-template> <ng-template matStepLabel>{{'DATASET-WIZARD.THIRD-STEP.TITLE' | translate}}</ng-template>
<dynamic-form *ngIf="datasetWizardModel && datasetWizardModel.id" [dataModel]="datasetWizardModel"></dynamic-form> <dynamic-form *ngIf="datasetWizardModel && datasetWizardModel.id" [dataModel]="datasetWizardModel"></dynamic-form>
<div> <div>
<button matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK' | translate}}</button> <button style="margin-top:10px;" matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK' | translate}}</button>
</div> </div>
</mat-step> </mat-step>
</mat-horizontal-stepper> </mat-horizontal-stepper>

View File

@ -53,7 +53,7 @@
</div> --> </div> -->
<div *ngFor="let compositeField of section.compositeFields; let i = index;"> <div *ngFor="let compositeField of section.compositeFields; let i = index;">
<div *ngIf="isVisible(compositeField)"> <div *ngIf="isVisible(pathName+'.compositeFields.'+i, compositeField)">
<div *ngIf="(compositeField?.multiplicity?.max - 1) > (compositeField?.multiplicityItems?.length)"> <div *ngIf="(compositeField?.multiplicity?.max - 1) > (compositeField?.multiplicityItems?.length)">
<a (click)="addMultipleField(i)" style="cursor: pointer"> <a (click)="addMultipleField(i)" style="cursor: pointer">
Add one more fieldset + Add one more fieldset +

View File

@ -31,10 +31,10 @@ export class DynamicFormSectionComponent implements OnInit {
(<FormArray>(this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm()); (<FormArray>(this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
} }
isVisible(fieldSet:CompositeField):boolean{ isVisible(pathname: string, fieldSet: CompositeField): boolean {
if(!this.visibilityRulesService.isElementVisible(null,fieldSet.id)) return false; if (!this.visibilityRulesService.isElementVisible(pathname, fieldSet.id)) return false;
for (var i = 0; i < fieldSet.fields.length; i++) { for (var i = 0; i < fieldSet.fields.length; i++) {
if (!this.visibilityRulesService.isElementVisible(null,fieldSet.fields[i].id)) if (!this.visibilityRulesService.isElementVisible(pathname+'.fields.'+i, fieldSet.fields[i].id))
return false; return false;
} }
return true; return true;

View File

@ -52,16 +52,17 @@ export class ProgressBarComponent implements OnInit {
getFormControlDepthLength(form: FormGroup): number { getFormControlDepthLength(form: FormGroup): number {
let value = 0; let value = 0;
Object.keys(form.controls).forEach(key => { Object.keys(form.controls).forEach(key => {
let control = form.controls[key] let control = form.controls[key];
if (control instanceof FormGroup) if (control instanceof FormGroup) { value += this.getFormControlDepthLength(control); }
{ value += this.getFormControlDepthLength(control);}
else if (control instanceof FormArray) { else if (control instanceof FormArray) {
let formArray = (<FormArray>control); let formArray = (<FormArray>control);
for (let i = 0; i < formArray.length; i++) { for (let i = 0; i < formArray.length; i++) {
if (<FormGroup>formArray.get("" + i).value && this.visibilityRulesService.isElementVisible(null, formArray.get("" + i).value.id))
value += this.getFormControlDepthLength(<FormGroup>formArray.get("" + i)) value += this.getFormControlDepthLength(<FormGroup>formArray.get("" + i))
} }
} }
else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value)) value++; else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value))
value++;
}); });
return value; return value;
} }

View File

@ -17,7 +17,8 @@ export class VisibilityRulesService {
if (this.checkElementVisibility(visibilityRule)) { if (this.checkElementVisibility(visibilityRule)) {
return true return true
} else { } else {
if (pathKey && this.formGroup.get(pathKey + '.value')) this.formGroup.get(pathKey + '.value').patchValue(null) this.clearValues(pathKey)
// if (pathKey && this.formGroup.get(pathKey + '.value')) this.formGroup.get(pathKey + '.value').patchValue(null)
return false; return false;
} }
} }
@ -40,4 +41,13 @@ export class VisibilityRulesService {
private getParentPath(parentId: string): string { private getParentPath(parentId: string): string {
return ''; return '';
} }
private clearValues(pathKey) {
if (pathKey && this.formGroup.get(pathKey + '.value')) this.formGroup.get(pathKey + '.value').patchValue(null)
if (pathKey && this.formGroup.get(pathKey)["controls"].fields){
for (var i = 0; i < this.formGroup.get(pathKey)["controls"].fields.length; i++)
this.clearValues(pathKey+'.fields.'+i);
}
}
} }