From 533fcd95874dfb636043d4ec21445fcb811d0e52 Mon Sep 17 00:00:00 2001 From: dtziotzios Date: Tue, 12 Feb 2019 14:19:03 +0200 Subject: [PATCH] set Correct Value to Composite Profile editor value fix Dmp Version Editor To Disable Name --- ...rofile-editor-default-value.component.html | 17 +- .../dataset-wizard.component.html | 56 ++++-- .../dataset-wizard.component.ts | 2 +- .../editor/dmp-wizard-editor.component.html | 2 +- .../editor/dmp-wizard-editor.component.ts | 6 +- .../form-progress-indication.component.ts | 188 ++++++++++++++---- .../dataset-description-form.component.html | 3 +- 7 files changed, 203 insertions(+), 71 deletions(-) diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html index 434eff09f..f06d9aaa3 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html @@ -4,9 +4,11 @@ {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' | + {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' + | translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO' | + {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO' + | translate}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -15,9 +17,10 @@ - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.CHECKED' | + {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.CHECKED' | translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.UNCHECKED' | + {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.UNCHECKED' + | translate}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -25,7 +28,7 @@ - + @@ -38,7 +41,7 @@ - + {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -53,7 +56,7 @@ - + {{'GENERAL.VALIDATION.REQUIRED' | translate}} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html index 1978f9134..5fc4e84d7 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html @@ -2,25 +2,35 @@

{{ 'DATASET-WIZARD.TITLE.NEW' | translate }}

-

{{datasetWizardModel?.label}} {{ 'GENERAL.NAMES.DATASET' | translate }} - {{ 'GENERAL.STATUSES.EDIT' | translate }}

-

{{'GENERAL.STATUSES.FINALISED' | translate }}

+

{{datasetWizardModel?.label}} {{ 'GENERAL.NAMES.DATASET' | translate }} + - {{ 'GENERAL.STATUSES.EDIT' | translate }}

+

{{'GENERAL.STATUSES.FINALISED' + | translate }}

-
- - +
- - + - - - + +
@@ -30,7 +40,8 @@
- + @@ -45,7 +56,8 @@
-
+
@@ -59,7 +71,8 @@
-
+
@@ -68,10 +81,13 @@ {{'DATASET-WIZARD.THIRD-STEP.TITLE' | translate}}
- +
-
+
@@ -88,4 +104,4 @@
--> - + \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts index 5e478ef80..78357dd11 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts @@ -382,7 +382,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr public disableForm() { this.editMode = false; - this.viewOnly = true; + //this.viewOnly = true; this.formGroup.disable(); } diff --git a/dmp-frontend/src/app/ui/dmp/wizard/editor/dmp-wizard-editor.component.html b/dmp-frontend/src/app/ui/dmp/wizard/editor/dmp-wizard-editor.component.html index 8ec9977eb..7c386518a 100644 --- a/dmp-frontend/src/app/ui/dmp/wizard/editor/dmp-wizard-editor.component.html +++ b/dmp-frontend/src/app/ui/dmp/wizard/editor/dmp-wizard-editor.component.html @@ -4,7 +4,7 @@
- + {{formGroup.get('label').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} diff --git a/dmp-frontend/src/app/ui/dmp/wizard/editor/dmp-wizard-editor.component.ts b/dmp-frontend/src/app/ui/dmp/wizard/editor/dmp-wizard-editor.component.ts index 45514cbfc..5a8fb1d4d 100644 --- a/dmp-frontend/src/app/ui/dmp/wizard/editor/dmp-wizard-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/wizard/editor/dmp-wizard-editor.component.ts @@ -56,7 +56,7 @@ export class DmpWizardEditorComponent extends BaseComponent implements OnInit { public language: TranslateService, private _service: DmpService, private languageResolverService: LanguageResolverService, - private uiNotificationService:UiNotificationService + private uiNotificationService: UiNotificationService ) { super(); } @@ -101,6 +101,8 @@ export class DmpWizardEditorComponent extends BaseComponent implements OnInit { .subscribe(value => { if (value.clone === false && this.formGroup.get('label').value) { this.labelDisabled = true; + this.formGroup.controls['label'].disable(); + this.formGroup.controls['project'].disable(); } this.formGroup.controls['version'].disable(); }); @@ -138,7 +140,7 @@ export class DmpWizardEditorComponent extends BaseComponent implements OnInit { } onCallbackError(error: any) { - + } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.ts index c704e231d..b16663c49 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.ts @@ -1,8 +1,9 @@ import { Component, Input, OnInit } from '@angular/core'; -import { FormArray, FormGroup } from '@angular/forms'; +import { FormArray, FormGroup, AbstractControl } from '@angular/forms'; import { takeUntil } from 'rxjs/operators'; import { BaseComponent } from '../../../../../core/common/base/base.component'; import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service'; +import { FooterRowOutlet } from '@angular/cdk/table'; @Component({ selector: 'app-form-progress-indication', @@ -10,7 +11,7 @@ import { VisibilityRulesService } from '../../visibility-rules/visibility-rules. }) export class FormProgressIndicationComponent extends BaseComponent implements OnInit { @Input() formGroup: FormGroup; - @Input() public progressValueAccuracy = 1; + @Input() public progressValueAccuracy = 2; determinateProgressValue: number; constructor(private visibilityRulesService: VisibilityRulesService) { super(); } @@ -27,52 +28,161 @@ export class FormProgressIndicationComponent extends BaseComponent implements On } calculateValueForProgressbar() { - const progressSoFar = this.countFormControlsWithValue(this.formGroup); - const total = this.getFormControlDepthLength(this.formGroup); + const progressSoFar = this.countFormControlsWithValueForProgress(this.formGroup); + const total = this.CountFormControlDepthLengthFotTotal(this.formGroup); const perc = (progressSoFar / total) * 100; // const perc = ((progressSoFar-this.StandarValues) / total) * 100; this.value = Number.parseFloat(perc.toPrecision(this.progressValueAccuracy)); } - countFormControlsWithValue(form: FormGroup): number { - let value = 0; - Object.keys(form.controls).forEach(key => { - const control = form.controls[key]; - if (control instanceof FormGroup) { - value += this.countFormControlsWithValue(control); - } else if (control instanceof FormArray) { - const formArray = (control); - for (let i = 0; i < formArray.length; i++) { - value += this.countFormControlsWithValue(formArray.get('' + i)); - } - } else if (key === 'value' && control.value != null && control.value !== '' && this.visibilityRulesService.checkElementVisibility(form.controls['id'].value)) { - value++; + // countFormControlsWithValue(form: FormGroup): number { + // let valueCurent = 0; + // Object.keys(form.controls).forEach(key => { + // const control = form.controls[key]; + // if (control instanceof FormGroup && this.visibilityRulesService.checkElementVisibility(control.value.id)) { + // valueCurent += this.countFormControlsWithValue(control); + // } else if (control instanceof FormArray) { + // const formArray = (control); + // for (let i = 0; i < formArray.length; i++) { + // if (this.visibilityRulesService.checkElementVisibility(formArray.get('' + i).value.id)) + // valueCurent += this.countFormControlsWithValue(formArray.get('' + i)); + // } + // } else if (key === 'value' && control.value != null && control.value !== '' && this.visibilityRulesService.checkElementVisibility(form.controls['id'].value)) { + // valueCurent++; + // } + // }); + // return valueCurent; + // } + // + countFormControlsWithValueForProgress(formControl: AbstractControl): number { + let valueCurent = 0; + if (formControl instanceof FormGroup) { + if (this.checkFormsIfIsFieldsAndVisible(formControl)) { + if (this.haseValue(formControl)) + valueCurent++; } - }); - return value; + if (this.chechFieldIfIsFieldSetAndVisible((formControl as FormGroup))) { + valueCurent = valueCurent + this.compositeFieldsGetChildsForProgress(formControl); + } else { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + valueCurent = valueCurent + this.countFormControlsWithValueForProgress(control); + }); + } + } else if (formControl instanceof FormArray) { + formControl.controls.forEach(item => { + valueCurent = valueCurent + this.countFormControlsWithValueForProgress(item); + }); + } + + return valueCurent; + } + private haseValue(formGroup: FormGroup): boolean { + if (formGroup.get('value').value != null && formGroup.get('value').value !== '' && this.visibilityRulesService.checkElementVisibility(formGroup.get('id').value)) { + return true; + } + return false; + } + + private compositeFieldsGetChildsForProgress(formGroup: FormGroup): number { + let valueCurent = 0; + if (this.visibilityRulesService.checkElementVisibility(formGroup.get('id').value)) { + (formGroup.get('fields') as FormArray).controls.forEach((element: FormGroup) => { + valueCurent = valueCurent + this.countFormControlsWithValueForProgress(element); + }); + + (formGroup.get('multiplicityItems') as FormArray).controls.forEach((element: FormGroup) => { + valueCurent = valueCurent + this.countFormControlsWithValueForProgress(element); + }); + } + return valueCurent; } - - - getFormControlDepthLength(form: FormGroup): number { - let value = 0; - Object.keys(form.controls).forEach(key => { - const control = form.controls[key]; - if (control instanceof FormGroup) { - value += this.getFormControlDepthLength(control); - } else if (control instanceof FormArray) { - const formArray = (control); - for (let i = 0; i < formArray.length; i++) { - if (formArray.get('' + i).value && this.visibilityRulesService.checkElementVisibility(formArray.get('' + i).value.id)) { - value += this.getFormControlDepthLength(formArray.get('' + i)); - } - } - } else if (key === 'value' && this.visibilityRulesService.checkElementVisibility(form.controls['id'].value)) { - value++; - } - }); - return value; + private checkFormsIfIsFieldsAndVisible(formControl: FormGroup): boolean { + if (formControl.contains('id') && formControl.contains('value')) { + return true; + } + return false; } + private chechFieldIfIsFieldSetAndVisible(formControl: FormGroup): boolean { + if (formControl.contains('id') && formControl.contains('fields')) { + return true; + } + return false; + } + + // getFormControlDepthLength(form: FormGroup): number { + // let value = 0; + // Object.keys(form.controls).forEach(key => { + // const control = form.controls[key]; + // if (control instanceof FormGroup && this.visibilityRulesService.checkElementVisibility(control.value.id)) { + // value += this.getFormControlDepthLength(control); + // } else if (control instanceof FormArray) { + // const formArray = (control); + // for (let i = 0; i < formArray.length; i++) { + // if (formArray.get('' + i).value && this.visibilityRulesService.checkElementVisibility(formArray.get('' + i).value.id)) { + // value += this.getFormControlDepthLength(formArray.get('' + i)); + // } + // } + // } else if (key === 'value' && this.visibilityRulesService.checkElementVisibility(form.controls['id'].value)) { + // value++; + // } + // }); + // return value; + // } + CountFormControlDepthLengthFotTotal(formControl: AbstractControl): number { + let valueCurent = 0; + if (formControl instanceof FormArray) { + formControl.controls.forEach(item => { + valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(item); + }); + } else if (formControl instanceof FormGroup) { + if ((formControl as FormGroup).contains('id') && (formControl as FormGroup).contains('value') && (this.visibilityRulesService.checkElementVisibility((formControl as FormGroup).get('id').value))) { + valueCurent++; + } else if ((formControl as FormGroup).contains('id') && (formControl as FormGroup).contains('fields')) { + valueCurent = valueCurent + this.compositeFieldsGetChildsForTotal(formControl); + } else { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(control); + }); + } + } + + return valueCurent; + } + + // CountFormControlDepthLengthFotTotal(formControl: AbstractControl): number { + // let valueCurent = 0; + // if (formControl instanceof FormArray) { + // return formControl.controls.map(item => this.CountFormControlDepthLengthFotTotal(item)); + // } else if (formControl instanceof FormGroup) { + // if ((formControl as FormGroup).contains('id') && (formControl as FormGroup).contains('value') && (this.visibilityRulesService.checkElementVisibility((formControl as FormGroup).get('id').value))) { + // return 1; + // } else if ((formControl as FormGroup).contains('id') && (formControl as FormGroup).contains('fields') && (this.visibilityRulesService.checkElementVisibility((formControl as FormGroup).get('id').value))) { + // return this.CountFormControlDepthLengthFotTotal(formControl); + // } else { + // return formControl.controls.map(item => this.CountFormControlDepthLengthFotTotal(item)); + // } + // } + + // return valueCurent; + // } + + private compositeFieldsGetChildsForTotal(formGroup: FormGroup): number { + let valueCurent = 0; + if (this.visibilityRulesService.checkElementVisibility(formGroup.get('id').value)) { + (formGroup.get('fields') as FormArray).controls.forEach((element: FormGroup) => { + valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(element); + }); + + (formGroup.get('multiplicityItems') as FormArray).controls.forEach((element: FormGroup) => { + valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(element); + }); + } + return valueCurent; + } + } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.html index 205640833..e0ad30eb6 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.html +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.html @@ -8,7 +8,8 @@
{{pageFormGroup.get('title').value}} -
+ +