Add Validator to Id on DatasetProfile

Fix DafaultValue on WordListComponent
set On DeleteDataset To Return Back
This commit is contained in:
Diamantis Tziotzios 2019-02-04 18:10:22 +02:00
parent 8a07e98d9e
commit 5f2646c98f
12 changed files with 17 additions and 18 deletions

View File

@ -1,4 +1,4 @@
import { FormArray, FormControl, FormGroup } from '@angular/forms';
import { FormArray, FormControl, FormGroup, Validators } from '@angular/forms';
import { ValidationType } from '../../../../core/common/enum/validation-type';
import { Field } from '../../../../core/model/admin/dataset-profile/dataset-profile';
import { BaseFormModel } from '../../../../core/model/base-form-model';
@ -52,7 +52,7 @@ export class FieldEditorModel extends BaseFormModel {
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
id: [this.id],
id:[this.id,[Validators.required,Validators.pattern('^[^<_>]+$')]],
// title: [this.title],
page: [this.page],
ordinal: [this.ordinal]
@ -62,7 +62,7 @@ export class FieldEditorModel extends BaseFormModel {
formGroup.addControl('validations', new FormControl(this.validations));
formGroup.addControl('defaultValue', this.defaultValue.buildForm());
formGroup.addControl('viewStyle', this.viewStyle.buildForm());
formGroup.addControl('visible', this.visible.buildForm());
formGroup.addControl('visible', this.visible.buildForm());
//formGroup.addControl("data",this.data? this.data.buildForm():this.formBuilder.group({}));
if (this.data) { formGroup.addControl('data', this.data.buildForm()); }
else { formGroup.addControl('data', new WordListFieldDataEditorModel().buildForm()); }

View File

@ -1,5 +1,5 @@

import { FormGroup } from '@angular/forms';
import { FormGroup, Validators } from '@angular/forms';
import { FieldSet } from '../../../../core/model/admin/dataset-profile/dataset-profile';
import { BaseFormModel } from '../../../../core/model/base-form-model';
import { FieldEditorModel } from './field-editor-model';
@ -31,14 +31,13 @@ export class FieldSetEditorModel extends BaseFormModel {
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
id: [this.id],
id:[this.id,[Validators.required,Validators.pattern('^[^<_>]+$')]],
ordinal: [this.ordinal],
title: [this.title],
description: [this.description],
extendedDescription: [this.extendedDescription],
hasCommentField: [this.hasCommentField]
});
const fieldsFormArray = new Array<FormGroup>();
this.fields.forEach(item => {
const form: FormGroup = item.buildForm();

View File

@ -24,7 +24,7 @@ export class PageEditorModel extends BaseFormModel {
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
title: [this.title, [Validators.required]],
id: [this.id, [Validators.required]],
id: [this.id, [Validators.required,Validators.pattern('^[^<_>]+$')]],
ordinal: [this.ordinal]
});
return formGroup;

View File

@ -46,7 +46,7 @@ export class SectionEditorModel extends BaseFormModel {
formGroup.addControl('fieldSets', this.formBuilder.array(compositeFieldsFormArray));
formGroup.addControl('defaultVisibility', new FormControl(this.defaultVisibility));
formGroup.addControl('page', new FormControl(this.page, [Validators.required]));
formGroup.addControl('id', new FormControl(this.id));
formGroup.addControl('id', new FormControl(this.id, [Validators.required,Validators.pattern('^[^<_>]+$')]));
formGroup.addControl('title', new FormControl(this.title));
formGroup.addControl('description', new FormControl(this.description));
formGroup.addControl('ordinal', new FormControl(this.ordinal));

View File

@ -14,6 +14,7 @@
<mat-form-field *ngIf="isComposite" class="col">
<input matInput type="string" placeholder="Id" [formControl]="form.get('id')" required>
<mat-error *ngIf="form.get('id').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="form.get('id').hasError('pattern')">{{'GENERAL.VALIDATION.PATTERN-_' | translate}}</mat-error>
</mat-form-field>
<mat-form-field *ngIf="isComposite" class="col">
<input matInput type="text" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMPOSITE-TITLE' | translate}}"

View File

@ -3,6 +3,7 @@
<input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.ID' | translate}}" type="text"
[formControl]="this.form.get('id')" required>
<mat-error *ngIf="this.form.get('id').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="this.form.get('id').hasError('pattern')">{{'GENERAL.VALIDATION.PATTERN-_' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col">

View File

@ -4,7 +4,8 @@
<mat-form-field class="col-md-3">
<input matInput type="text" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.SECTION.FIELDS.ID' | translate}}"
formControlName="id" required>
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="form.get('id').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="form.get('id').hasError('pattern')">{{'GENERAL.VALIDATION.PATTERN-_' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-3">
<input matInput type="text" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.SECTION.FIELDS.TITLE' | translate}}"
@ -15,7 +16,7 @@
required>
<mat-option *ngFor="let pageGroup of form.root.get('pages')['controls'];" [value]="pageGroup.get('id').value">{{pageGroup.get('title').value}}</mat-option>
</mat-select>
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="form.get('page').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-3">
<input matInput type="number" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.SECTION.FIELDS.ORDER' | translate}}"

View File

@ -404,7 +404,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.datasetWizardService.delete(id)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => { this.onCallbackSuccess() },
complete => { this.onCallbackSuccess(); this.router.navigateByUrl('/datasets/dmp/' + this.formGroup.get('dmp').value.id);},
error => this.onCallbackError(error)
);
}

View File

@ -23,7 +23,7 @@
<mat-form-field *ngIf="form.get('data').value.type === datasetProfileComboBoxTypeEnum.WordList" class="col-md-12">
<mat-select [formControl]="form.get('value')" placeholder="{{ form.get('data').value.label | translate }}"
[required]="form.get('validationRequired').value">
<mat-option *ngFor="let opt of form.get('data').value.options" [value]="assignDropdownItem(opt)">{{opt.label}}</mat-option>
<mat-option *ngFor="let opt of form.get('data').value.options" [value]="opt.value">{{opt.label}}</mat-option>
</mat-select>
<mat-error *ngIf="form.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>

View File

@ -69,8 +69,4 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
return this.datasetExternalAutocompleteService.queryAutocomplete(autocompleteRequestItem);
}
assignDropdownItem(item: any) {
if (!item) { return null; }
return (typeof item === 'string') ? JSON.parse(item) : JSON.stringify(item);
}
}

View File

@ -225,7 +225,7 @@ export class DatasetDescriptionFieldEditorModel extends BaseFormModel {
this.validations = item.validations;
if (item.multiplicity) this.multiplicity = new DatasetDescriptionMultiplicityEditorModel().fromModel(item.multiplicity);
if (item.defaultValue) this.defaultValue = new DatasetDescriptionDefaultValueEditorModel().fromModel(item.defaultValue);
this.value = this.defaultValue.value && !item.value ? this.defaultValue.value : item.value;
this.value = item.value ? item.value : (this.defaultValue.value ? this.defaultValue.value : undefined);
if (this.viewStyle.renderStyle === 'checkBox') { this.value = this.value === 'true'; }
if (item.multiplicityItems) { item.multiplicityItems.map(x => this.multiplicityItems.push(new DatasetDescriptionFieldEditorModel().fromModel(x))); }
this.data = item.data;

View File

@ -2,7 +2,8 @@
"GENERAL": {
"VALIDATION": {
"REQUIRED": "Required",
"PROJECT-START-AFTER-END": "Project start date cannot be after the end date"
"PROJECT-START-AFTER-END": "Project start date cannot be after the end date",
"PATTERN-_":"Caracter \"_\" is not allowed"
},
"DELETE-CONFIRMATION": {
"TITLE": "Warning",