diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html
index ecae5993f..c6d9198aa 100644
--- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html
+++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html
@@ -81,6 +81,7 @@
+
@@ -88,6 +89,7 @@
+
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts
index 79e5da735..4eee5e892 100644
--- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts
+++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts
@@ -24,6 +24,7 @@ import { DatasetStatus } from '@app/core/common/enum/dataset-status';
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
import { LanguageInfo } from '@app/core/model/language-info';
import { LanguageInfoService } from '@app/core/services/culture/language-info-service';
+import { FormValidationErrorsDialogComponent } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component';
const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.json');
@@ -47,6 +48,9 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
breadCrumbs: Observable
;
@ViewChild('stepper', { static: false }) stepper: MatHorizontalStepper;
viewOnly = false;
+ nestedCount: number[] = [];
+ nestedIndex: number = 0;
+ errorMessages: string[] = [];
constructor(
private datasetProfileService: DatasetProfileService,
@@ -331,4 +335,66 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
getLanguageInfos(): LanguageInfo[] {
return this.languageInfoService.getLanguageInfoValues();
}
+
+ checkFormValidation() {
+ if (!this.form.valid) {
+ this.nestedIndex = -1;
+ this.form.markAllAsTouched();
+ this.printErrors(this.form);
+ this.showValidationErrorsDialog();
+ this.nestedCount = [];
+ this.nestedIndex = 0;
+ this.errorMessages = [];
+ }
+ }
+
+ printErrors(rootform: FormGroup) {
+ if (!rootform.valid) {
+ Object.keys(rootform.controls).forEach(key => {
+ const errors = rootform.get(key).errors;
+ if (errors !== null) {
+ let numbering: string = '';
+ for (let j = 0; j < this.nestedCount.length; j++) {
+ numbering += this.nestedCount[j];
+ if (j < this.nestedIndex) {
+ numbering += '.';
+ } else {
+ break;
+ }
+ }
+ Object.keys(errors).forEach(keyError => {
+ if (typeof errors[keyError] === 'boolean') {
+ this.errorMessages.push(numbering + ' ' + key + ' is ' + keyError);
+ } else {
+ this.errorMessages.push(numbering + ' ' + key + ': ' + keyError + ': ' + errors[keyError]);
+ }
+ });
+ } else {
+ if (rootform.get(key) instanceof FormGroup) {
+ this.printErrors(rootform.get(key));
+ } else if (rootform.get(key) instanceof FormArray) {
+ this.nestedIndex++;
+ this.nestedCount[this.nestedIndex] = 0;
+ for (let childForm of (rootform.get(key)).controls) {
+ this.nestedCount[this.nestedIndex]++;
+ this.printErrors(childForm);
+ }
+ this.nestedCount[this.nestedIndex] = 0;
+ this.nestedIndex--;
+
+ }
+ }
+ });
+ }
+ }
+
+ private showValidationErrorsDialog(projectOnly?: boolean) {
+ const dialogRef = this.dialog.open(FormValidationErrorsDialogComponent, {
+ disableClose: true,
+ data: {
+ errorMessages: this.errorMessages,
+ projectOnly: projectOnly
+ },
+ });
+ }
}
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts
index df86a9ae9..e4beae865 100644
--- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts
+++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts
@@ -44,7 +44,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
// @Input() field: Field;
@Input() form: FormGroup;
- @Input() datasetProfileId: String;
+ @Input() datasetProfileId: any;
@Input() isChild: Boolean = false;
// change: Subscription;
@@ -96,12 +96,17 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.ComboBox && this.form.get('data').value.type === DatasetProfileComboBoxType.WordList) {
if (this.form.get('data').value.multiList) {
const originalValue = this.form.get('value').value;
- let values = (this.form.get('value').value).slice(1, -1).split(', ');
- if (!originalValue.startsWith('[') && !originalValue.endsWith(']')) {
- values = undefined;
- values = [originalValue];
+ if (originalValue !== null && typeof originalValue === 'string') {
+ let values = (this.form.get('value').value).slice(1, -1).split(', ');
+ if (!originalValue.startsWith('[') && !originalValue.endsWith(']')) {
+ values = undefined;
+ values = [originalValue];
+ }
+ this.form.patchValue({ 'value': values });
+ values.forEach(element => {
+ this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, element);
+ });
}
- this.form.patchValue({ 'value': values });
}
}
@@ -233,7 +238,14 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
this.form.get('value').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(item => {
- this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, item);
+ if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.ComboBox && this.form.get('data').value.type === DatasetProfileComboBoxType.WordList && this.form.get('data').value.multiList) {
+ item.forEach(element => {
+ this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, element);
+ });
+
+ } else {
+ this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, item);
+ }
});
}
@@ -253,7 +265,11 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
autocompleteRequestItem.criteria = new DatasetExternalAutocompleteCriteria();
autocompleteRequestItem.criteria.fieldID = this.form.get('id').value;
- autocompleteRequestItem.criteria.profileID = this.datasetProfileId;
+ if (typeof this.datasetProfileId === 'string') {
+ autocompleteRequestItem.criteria.profileID = this.datasetProfileId;
+ } else {
+ autocompleteRequestItem.criteria.profileID = this.datasetProfileId.id;
+ }
autocompleteRequestItem.criteria.like = query;
return this.datasetExternalAutocompleteService.queryAutocomplete(autocompleteRequestItem);
}
diff --git a/dmp-frontend/src/assets/i18n/de.json b/dmp-frontend/src/assets/i18n/de.json
index a962ea327..8a9ffb57d 100644
--- a/dmp-frontend/src/assets/i18n/de.json
+++ b/dmp-frontend/src/assets/i18n/de.json
@@ -371,7 +371,8 @@
"CANCEL": "Cancel",
"DELETE": "Delete",
"ADD-PAGE": "Add Page +",
- "ADD-SECTION": "Add Section +"
+ "ADD-SECTION": "Add Section +",
+ "VALIDATE": "Validate"
}
},
"GRANT-LISTING": {
diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json
index 73e691a34..28dd05a8f 100644
--- a/dmp-frontend/src/assets/i18n/en.json
+++ b/dmp-frontend/src/assets/i18n/en.json
@@ -391,7 +391,8 @@
"CANCEL": "Cancel",
"DELETE": "Delete",
"ADD-PAGE": "Add Page +",
- "ADD-SECTION": "Add Section +"
+ "ADD-SECTION": "Add Section +",
+ "VALIDATE": "Validate"
}
},
"GRANT-LISTING": {
diff --git a/dmp-frontend/src/assets/i18n/es.json b/dmp-frontend/src/assets/i18n/es.json
index 5fbec1181..062aca5f2 100644
--- a/dmp-frontend/src/assets/i18n/es.json
+++ b/dmp-frontend/src/assets/i18n/es.json
@@ -392,7 +392,8 @@
"CANCEL": "Cancelar",
"DELETE": "Borrar",
"ADD-PAGE": "Añadir página +",
- "ADD-SECTION": "Añadir sección +"
+ "ADD-SECTION": "Añadir sección +",
+ "VALIDATE": "Validate"
}
},
"GRANT-LISTING": {
diff --git a/dmp-frontend/src/assets/i18n/gr.json b/dmp-frontend/src/assets/i18n/gr.json
index a1a93a6ff..023614f32 100644
--- a/dmp-frontend/src/assets/i18n/gr.json
+++ b/dmp-frontend/src/assets/i18n/gr.json
@@ -389,7 +389,8 @@
"CANCEL": "Ακύρωση",
"DELETE": "Διαγραφή",
"ADD-PAGE": "Προσθήκη Σελίδας +",
- "ADD-SECTION": "Προσθήκη Ενότητας +"
+ "ADD-SECTION": "Προσθήκη Ενότητας +",
+ "VALIDATE": "Validate"
}
},
"GRANT-LISTING": {
diff --git a/dmp-frontend/src/assets/i18n/tr.json b/dmp-frontend/src/assets/i18n/tr.json
index 3c6306a9b..3f0e94b38 100644
--- a/dmp-frontend/src/assets/i18n/tr.json
+++ b/dmp-frontend/src/assets/i18n/tr.json
@@ -389,7 +389,8 @@
"CANCEL": "İptal",
"DELETE": "Sil",
"ADD-PAGE": "Sayfa Ekle +",
- "ADD-SECTION": "Bölüm Ekle +"
+ "ADD-SECTION": "Bölüm Ekle +",
+ "VALIDATE": "Validate"
}
},
"GRANT-LISTING": {
diff --git a/dmp-frontend/src/common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component.ts b/dmp-frontend/src/common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component.ts
index 2e2b31be6..c0d389bbc 100644
--- a/dmp-frontend/src/common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component.ts
+++ b/dmp-frontend/src/common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component.ts
@@ -17,8 +17,12 @@ export class FormValidationErrorsDialogComponent {
@Inject(MAT_DIALOG_DATA) public data: any,
private language: TranslateService
) {
- this.formGroup = data.formGroup;
- this.errorMessages = this.getErrors(this.formGroup);
+ if (data.formGroup !== undefined && data.formGroup !== null) {
+ this.formGroup = data.formGroup;
+ this.errorMessages = this.getErrors(this.formGroup);
+ } else if (data.errorMessages !== undefined && data.errorMessages !== null) {
+ this.errorMessages = data.errorMessages;
+ }
}
onClose(): void {