Fixes bug on required "Order" field, adds auto-generated "Section Unique Identifier" for each field child.

This commit is contained in:
apapachristou 2019-10-17 18:23:19 +03:00
parent 66b3b0bd86
commit 8b376ecbd9
4 changed files with 64 additions and 67 deletions

View File

@ -67,7 +67,7 @@ export class FieldEditorModel extends BaseFormModel {
id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('FieldEditorModel.id')) }, [Validators.required, Validators.pattern('^[^<_>]+$')]], id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('FieldEditorModel.id')) }, [Validators.required, Validators.pattern('^[^<_>]+$')]],
// title: [this.title], // title: [this.title],
page: [{ value: this.page, disabled: (disabled && !skipDisable.includes('FieldEditorModel.page')) }], page: [{ value: this.page, disabled: (disabled && !skipDisable.includes('FieldEditorModel.page')) }],
ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('FieldEditorModel.ordinal')) }, [Validators.required]], ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('FieldEditorModel.ordinal')) }],
validations: [{ value: this.validations, disabled: (disabled && !skipDisable.includes('FieldEditorModel.validations')) }], validations: [{ value: this.validations, disabled: (disabled && !skipDisable.includes('FieldEditorModel.validations')) }],
rdaCommonStandard: [{value: this.rdaCommonStandard, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.rdaCommonStandard')) }] rdaCommonStandard: [{value: this.rdaCommonStandard, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.rdaCommonStandard')) }]
}); });

View File

@ -1,6 +1,7 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormArray, FormControl, FormGroup } from '@angular/forms'; import { FormArray, FormControl, FormGroup } from '@angular/forms';
import { FieldEditorModel } from '../../../admin/field-editor-model'; import { FieldEditorModel } from '../../../admin/field-editor-model';
import { Guid } from '../../../../../../common/types/guid';
@Component({ @Component({
selector: 'app-dataset-profile-editor-composite-field-component', selector: 'app-dataset-profile-editor-composite-field-component',
@ -54,6 +55,7 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit {
addNewField() { addNewField() {
const field: FieldEditorModel = new FieldEditorModel(); const field: FieldEditorModel = new FieldEditorModel();
field.id=Guid.create().toString();
(<FormArray>this.form.get('fields')).push(field.buildForm()); (<FormArray>this.form.get('fields')).push(field.buildForm());
} }

View File

@ -1,84 +1,79 @@
<div class="row"> <div class="row">
<!-- BooleanDecision --> <!-- BooleanDecision -->
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.BooleanDecision"> <mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.BooleanDecision">
<mat-select [formControl]="form" [placeholder]="placeHolder" [required]="required"> <mat-select [formControl]="form" [placeholder]="placeHolder" [required]="required">
<mat-option [value]="null">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | <mat-option [value]="null">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' |
translate}}</mat-option> translate}}</mat-option>
<mat-option [value]="'true'">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' <mat-option [value]="'true'">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES'
| |
translate}}</mat-option> translate}}</mat-option>
<mat-option [value]="'false'">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO' <mat-option [value]="'false'">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO'
| |
translate}}</mat-option> translate}}</mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<!-- CheckBox --> <!-- CheckBox -->
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.CheckBox"> <mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.CheckBox">
<mat-select [formControl]="form" [placeholder]="placeHolder" [required]="required"> <mat-select [formControl]="form" [placeholder]="placeHolder" [required]="required">
<mat-option [value]="'true'">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.CHECKED' | <mat-option [value]="'true'">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.CHECKED' | translate}}</mat-option>
translate}}</mat-option> <mat-option [value]="'false'">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.UNCHECKED' | translate}}</mat-option>
<mat-option [value]="'false'">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.UNCHECKED' </mat-select>
| <mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
translate}}</mat-option> </mat-form-field>
</mat-select>
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<!-- ComboBox --> <!-- ComboBox -->
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.ComboBox && comboBoxType === comboBoxTypeEnum.Autocomplete"> <mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.ComboBox && comboBoxType === comboBoxTypeEnum.Autocomplete">
<input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required"> <input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required">
</mat-form-field> </mat-form-field>
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.ComboBox && comboBoxType === comboBoxTypeEnum.WordList"> <mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.ComboBox && comboBoxType === comboBoxTypeEnum.WordList">
<mat-select [formControl]="form" [placeholder]="placeHolder" [required]="required"> <mat-select [formControl]="form" [placeholder]="placeHolder" [required]="required">
<mat-option [value]="null">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate }}</mat-option> <mat-option [value]="null">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate }}</mat-option>
<mat-option *ngFor="let opt of formArrayOptions['controls']" [value]="opt.get('value').value">{{opt.get('label').value}}</mat-option> <mat-option *ngFor="let opt of formArrayOptions['controls']" [value]="opt.get('value').value">{{opt.get('label').value}}</mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<!-- InternalDmpEntities --> <!-- InternalDmpEntities -->
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.InternalDmpEntities && internalDmpEntitiesType === internalDmpEntitiesTypeEnum.Researchers"> <mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.InternalDmpEntities && internalDmpEntitiesType === internalDmpEntitiesTypeEnum.Researchers">
<input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required"> <input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required">
</mat-form-field> </mat-form-field>
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.InternalDmpEntities && internalDmpEntitiesType === internalDmpEntitiesTypeEnum.Datasets"> <mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.InternalDmpEntities && internalDmpEntitiesType === internalDmpEntitiesTypeEnum.Datasets">
<input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required"> <input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required">
</mat-form-field> </mat-form-field>
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.InternalDmpEntities && internalDmpEntitiesType === internalDmpEntitiesTypeEnum.Dmps"> <mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.InternalDmpEntities && internalDmpEntitiesType === internalDmpEntitiesTypeEnum.Dmps">
<input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required"> <input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required">
</mat-form-field> </mat-form-field>
<!-- FreeText --> <!-- FreeText -->
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.FreeText"> <mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.FreeText">
<input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required"> <input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required">
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<!-- RadioBox --> <!-- RadioBox -->
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.RadioBox"> <mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.RadioBox">
<mat-select [formControl]="form" [placeholder]="placeHolder" [required]="required"> <mat-select [formControl]="form" [placeholder]="placeHolder" [required]="required">
<mat-option [value]="null">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate}}</mat-option> <mat-option [value]="null">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate}}</mat-option>
<mat-option *ngFor="let opt of formArrayOptions['controls']" [value]="opt.get('value').value">{{opt.get('label').value}}</mat-option> <mat-option *ngFor="let opt of formArrayOptions['controls']" [value]="opt.get('value').value">{{opt.get('label').value}}</mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<!-- TextArea --> <!-- TextArea -->
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.TextArea"> <mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.TextArea">
<input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required"> <input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required">
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<!-- DatePicker --> <!-- DatePicker -->
<mat-form-field class="col-12" *ngIf="viewStyle === viewStyleEnum.DatePicker"> <mat-form-field class="col-12" *ngIf="viewStyle === viewStyleEnum.DatePicker">
<!--(focus)="date.open()" (click)="date.open()"--> <!--(focus)="date.open()" (click)="date.open()"-->
<input matInput <input matInput [placeholder]="placeHolder" class="table-input" [matDatepicker]="date" [formControl]="form" [required]="required">
[placeholder]="placeHolder" class="table-input" [matDatepicker]="date" <mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle>
[formControl]="form" [required]="required"> <mat-datepicker #date></mat-datepicker>
<mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle> <mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}
<mat-datepicker #date></mat-datepicker> </mat-error>
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}} </mat-form-field>
</mat-error>
</mat-form-field>
</div> </div>

View File

@ -23,7 +23,7 @@
<!-- Combo Box --> <!-- Combo Box -->
<mat-form-field *ngIf="showOrdinal" class="col"> <mat-form-field *ngIf="showOrdinal" class="col">
<input matInput type="number" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.ORDER' | translate}}" [formControl]="this.form.get('ordinal')"> <input matInput type="number" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.ORDER' | translate}}" [formControl]="this.form.get('ordinal')" required>
</mat-form-field> </mat-form-field>
<!-- Default Value --> <!-- Default Value -->