Adds basic edit on finalized Dataset profiles. (Ticket #72)

This commit is contained in:
gkolokythas 2019-04-16 13:49:09 +03:00
parent 7ca5568437
commit 0da7fd8441
22 changed files with 112 additions and 103 deletions

View File

@ -12,11 +12,10 @@ export class DefaultValueEditorModel extends BaseFormModel {
return this;
}
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
type: [this.type],
value: [this.value]
type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('DefaultValueEditorModel.type')) }],
value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('DefaultValueEditorModel.value')) }]
});
return formGroup;
}

View File

@ -13,15 +13,15 @@ export class AutoCompleteFieldDataEditorModel extends FieldDataEditorModel<AutoC
public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel();
//public multiAutoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel();
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
label: [this.label],
type: [this.type],
url: [this.url],
optionsRoot: [this.optionsRoot],
multiAutoComplete: [this.multiAutoComplete]
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('AutoCompleteFieldDataEditorModel.label')) }],
type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('AutoCompleteFieldDataEditorModel.type')) }],
url: [{ value: this.url, disabled: (disabled && !skipDisable.includes('AutoCompleteFieldDataEditorModel.url')) }],
optionsRoot: [{ value: this.optionsRoot, disabled: (disabled && !skipDisable.includes('AutoCompleteFieldDataEditorModel.optionsRoot')) }],
multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('AutoCompleteFieldDataEditorModel.multiAutoComplete')) }]
});
formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm());
formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm(disabled, skipDisable));
return formGroup;
}

View File

@ -4,9 +4,9 @@ import { FieldDataEditorModel } from './field-data-editor-model';
export class BooleanDecisionFieldDataEditorModel extends FieldDataEditorModel<BooleanDecisionFieldDataEditorModel> {
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
label: this.label
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('BooleanDecisionFieldDataEditorModel.label')) }]
});
return formGroup;
}

View File

@ -4,9 +4,9 @@ import { FieldDataEditorModel } from './field-data-editor-model';
export class CheckBoxFieldDataEditorModel extends FieldDataEditorModel<CheckBoxFieldDataEditorModel> {
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
label: this.label
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('CheckBoxFieldDataEditorModel.label')) }]
});
return formGroup;
}

View File

@ -5,9 +5,9 @@ import { DatePickerFieldData } from '../../../../../core/model/dataset-profile-d
export class DatePickerDataEditorModel extends FieldDataEditorModel<DatePickerDataEditorModel> {
public label: string;
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
label: [this.label]
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatePickerDataEditorModel.label')) }]
});
return formGroup;
}

View File

@ -5,12 +5,11 @@ export abstract class FieldDataEditorModel<T> extends BaseFormModel {
public label: string;
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
throw new Error('Build Form Is not not correctly overriden');
}
fromJSONObject(item: any): T {
throw new Error('From Json Object is not correctly overriden');
}
}

View File

@ -6,10 +6,10 @@ export class FieldDataOptionEditorModel extends FieldDataEditorModel<FieldDataOp
public label: string;
public value: string;
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
return new FormBuilder().group({
label: [this.label],
value: [this.value]
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.label')) }],
value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.value')) }]
});
}

View File

@ -4,9 +4,9 @@ import { FieldDataEditorModel } from './field-data-editor-model';
export class FreeTextFieldDataEditorModel extends FieldDataEditorModel<FreeTextFieldDataEditorModel> {
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
label: this.label
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('FreeTextFieldDataEditorModel.label')) }]
});
return formGroup;
}

View File

@ -7,14 +7,14 @@ export class RadioBoxFieldDataEditorModel extends FieldDataEditorModel<RadioBoxF
public options: Array<FieldDataOptionEditorModel> = [];
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
label: [this.label]
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('RadioBoxFieldDataEditorModel.label')) }]
});
const optionsFormArray = new Array<FormGroup>();
if (this.options) {
this.options.forEach(item => {
const form: FormGroup = item.buildForm();
const form: FormGroup = item.buildForm(disabled, skipDisable);
optionsFormArray.push(form);
});
}

View File

@ -4,9 +4,9 @@ import { FieldDataEditorModel } from './field-data-editor-model';
export class TextAreaFieldDataEditorModel extends FieldDataEditorModel<TextAreaFieldDataEditorModel> {
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
label: this.label
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('TextAreaFieldDataEditorModel.label')) }]
});
return formGroup;
}

View File

@ -8,15 +8,15 @@ export class WordListFieldDataEditorModel extends FieldDataEditorModel<WordListF
public type: DatasetProfileComboBoxType = DatasetProfileComboBoxType.WordList;
public options: Array<FieldDataOptionEditorModel>;
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
type: [this.type],
label: [this.label]
type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('WordListFieldDataEditorModel.type')) }],
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('WordListFieldDataEditorModel.label')) }]
});
const optionsFormArray = new Array<FormGroup>();
if (this.options) {
this.options.forEach(item => {
const form: FormGroup = item.buildForm();
const form: FormGroup = item.buildForm(disabled, skipDisable);
optionsFormArray.push(form);
});
}

View File

@ -53,22 +53,20 @@ export class FieldEditorModel extends BaseFormModel {
return this;
}
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
id:[this.id,[Validators.required,Validators.pattern('^[^<_>]+$')]],
id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('FieldEditorModel.id')) }, [Validators.required, Validators.pattern('^[^<_>]+$')]],
// title: [this.title],
page: [this.page],
ordinal: [this.ordinal]
page: [{ value: this.page, disabled: (disabled && !skipDisable.includes('FieldEditorModel.page')) }],
ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('FieldEditorModel.ordinal')) }],
validations: [{ value: this.validations, disabled: (disabled && !skipDisable.includes('FieldEditorModel.validations')) }]
});
// formGroup.addControl("multiplicity", this.multiplicity.buildForm());
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("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()); }
formGroup.addControl('defaultValue', this.defaultValue.buildForm(disabled, skipDisable));
formGroup.addControl('viewStyle', this.viewStyle.buildForm(disabled, skipDisable));
formGroup.addControl('visible', this.visible.buildForm(disabled, skipDisable));
if (this.data) { formGroup.addControl('data', this.data.buildForm(disabled, skipDisable)); }
else { formGroup.addControl('data', new WordListFieldDataEditorModel().buildForm(disabled, skipDisable)); }
return formGroup;
}

View File

@ -14,7 +14,7 @@ export class FieldSetEditorModel extends BaseFormModel {
public title: string;
public description: string;
public extendedDescription: string;
public additionalInformation:string;
public additionalInformation: string;
public hasCommentField: boolean;
fromModel(item: FieldSet): FieldSetEditorModel {
@ -26,28 +26,28 @@ export class FieldSetEditorModel extends BaseFormModel {
this.title = item.title;
this.description = item.description;
this.extendedDescription = item.extendedDescription;
this.additionalInformation=item.additionalInformation;
this.additionalInformation = item.additionalInformation;
this.hasCommentField = item.hasCommentField;
return this;
}
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
id:[this.id,[Validators.required,Validators.pattern('^[^<_>]+$')]],
ordinal: [this.ordinal],
title: [this.title],
description: [this.description],
extendedDescription: [this.extendedDescription],
additionalInformation:[this.additionalInformation],
hasCommentField: [this.hasCommentField]
id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.id')) }, [Validators.required, Validators.pattern('^[^<_>]+$')]],
ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.ordinal')) }],
title: [{ value: this.title, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.title')) }],
description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.description')) }],
extendedDescription: [{ value: this.extendedDescription, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.extendedDescription')) }],
additionalInformation: [{ value: this.additionalInformation, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.additionalInformation')) }],
hasCommentField: [{ value: this.hasCommentField, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.hasCommentField')) }]
});
const fieldsFormArray = new Array<FormGroup>();
this.fields.forEach(item => {
const form: FormGroup = item.buildForm();
const form: FormGroup = item.buildForm(disabled, skipDisable);
fieldsFormArray.push(form);
});
formGroup.addControl('fields', this.formBuilder.array(fieldsFormArray));
formGroup.addControl('multiplicity', this.multiplicity.buildForm());
formGroup.addControl('multiplicity', this.multiplicity.buildForm(disabled, skipDisable));
return formGroup;
}

View File

@ -12,10 +12,10 @@ export class MultiplicityEditorModel extends BaseFormModel {
return this;
}
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
min: [this.min],
max: [this.max]
min: [{ value: this.min, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.min')) }],
max: [{ value: this.max, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.max')) }]
});
return formGroup;
}

View File

@ -21,11 +21,11 @@ export class PageEditorModel extends BaseFormModel {
return this;
}
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
title: [this.title, [Validators.required]],
id: [this.id, [Validators.required]],
ordinal: [this.ordinal]
title: [{ value: this.title, disabled: (disabled && !skipDisable.includes('PageEditorModel.title')) }, [Validators.required]],
id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('PageEditorModel.id')) }, [Validators.required]],
ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('PageEditorModel.ordinal')) }]
});
return formGroup;
}

View File

@ -18,14 +18,14 @@ export class RuleEditorModel extends BaseFormModel {
return this;
}
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
// sourceField: [this.sourceField],
target: [this.target],
ruleStyle: [this.ruleStyle],
value: [this.value],
ruleType: [this.ruleType],
valueType: [this.valueType]
target: [{ value: this.target, disabled: (disabled && !skipDisable.includes('RuleEditorModel.target')) }],
ruleStyle: [{ value: this.ruleStyle, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleStyle')) }],
value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('RuleEditorModel.value')) }],
ruleType: [{ value: this.ruleType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleType')) }],
valueType: [{ value: this.valueType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.valueType')) }]
});
return formGroup;
}

View File

@ -25,31 +25,31 @@ export class SectionEditorModel extends BaseFormModel {
return this;
}
buildForm(): FormGroup {
const formGroup: FormGroup = new FormBuilder().group({});
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup: FormGroup = new FormBuilder().group({
id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('SectionEditorModel.id')) }, [Validators.required, Validators.pattern('^[^<_>]+$')]],
page: [{ value: this.page, disabled: (disabled && !skipDisable.includes('SectionEditorModel.page')) }, [Validators.required]],
title: [{ value: this.title, disabled: (disabled && !skipDisable.includes('SectionEditorModel.title')) }],
description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('SectionEditorModel.description')) }],
ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('SectionEditorModel.ordinal')) }],
defaultVisibility: [{ value: this.defaultVisibility, disabled: (disabled && !skipDisable.includes('SectionEditorModel.defaultVisibility')) }]
});
const sectionsFormArray = new Array<FormGroup>();
if (this.sections) {
this.sections.forEach(item => {
const form: FormGroup = item.buildForm();
const form: FormGroup = item.buildForm(disabled, skipDisable);
sectionsFormArray.push(form);
});
}
const compositeFieldsFormArray = new Array<FormGroup>();
if (this.fieldSets) {
this.fieldSets.forEach(item => {
const form: FormGroup = item.buildForm();
const form: FormGroup = item.buildForm(disabled, skipDisable);
compositeFieldsFormArray.push(form);
});
}
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
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, [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));
if (!formGroup.controls['defaultVisibility'].value) { formGroup.controls['defaultVisibility'].setValue(true); }

View File

@ -12,11 +12,10 @@ export class ViewStyleEditorModel extends BaseFormModel {
return this;
}
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
cssClass: [this.cssClass],
renderStyle: [this.renderStyle]
cssClass: [{ value: this.cssClass, disabled: (disabled && !skipDisable.includes('ViewStyleEditorModel.cssClass')) }],
renderStyle: [{ value: this.renderStyle, disabled: (disabled && !skipDisable.includes('ViewStyleEditorModel.renderStyle')) }]
});
return formGroup;
}

View File

@ -15,15 +15,15 @@ export class VisibilityEditorModel extends BaseFormModel {
return this;
}
buildForm(): FormGroup {
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
style: [this.style]
style: [{ value: this.style, disabled: (disabled && !skipDisable.includes('VisibilityEditorModel.style')) }]
});
const rulesFormArray = new Array<FormGroup>();
if (this.rules) {
this.rules.forEach(rule => {
const form: FormGroup = rule.buildForm();
const form: FormGroup = rule.buildForm(disabled, skipDisable);
rulesFormArray.push(form);
});
}

View File

@ -22,25 +22,26 @@ export class DatasetProfileEditorModel extends BaseFormModel {
return this;
}
buildForm(): FormGroup {
const formGroup: FormGroup = new FormBuilder().group({});
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup: FormGroup = new FormBuilder().group({
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.label')) }, [Validators.required]],
status: [{ value: this.status, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.status')) }],
version: [{ value: this.version, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.version')) }]
});
const sectionsFormArray = new Array<FormGroup>();
this.sections.forEach(item => {
const form: FormGroup = item.buildForm();
const form: FormGroup = item.buildForm(disabled, skipDisable);
sectionsFormArray.push(form);
});
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
const pagesFormArray = new Array<FormGroup>();
this.pages.forEach(item => {
const form: FormGroup = item.buildForm();
const form: FormGroup = item.buildForm(disabled, skipDisable);
pagesFormArray.push(form);
});
formGroup.addControl('pages', this.formBuilder.array(pagesFormArray));
formGroup.addControl('label', new FormControl(this.label, Validators.required));
formGroup.addControl('status', new FormControl(this.status));
formGroup.addControl('version', new FormControl(this.version));
return formGroup;
}
}

View File

@ -17,6 +17,9 @@ import { DatasetProfileEditorModel } from './dataset-profile-editor-model';
import { ConfirmationDialogComponent } from '../../../../library/confirmation-dialog/confirmation-dialog.component';
import { DatasetProfileEnum } from '../../../../core/common/enum/dataset-profile';
import * as FileSaver from 'file-saver';
//import * as data from 'src/assets/resources/skipDisable.json';
const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.json');
@Component({
selector: 'app-dataset-profile-editor-component',
@ -65,10 +68,11 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
try {
this.dataModel = new DatasetProfileEditorModel().fromModel(data);
// this.isDeleted = this.masterItem.isActive === IsActive.Inactive;
this.form = this.dataModel.buildForm();
if (this.dataModel.status === DatasetProfileEnum.FINALIZED) {
this.form.disable();
this.form = this.dataModel.buildForm(true, skipDisable);
this.viewOnly = true;
} else {
this.form = this.dataModel.buildForm();
}
this.prepareForm();
} catch {
@ -287,8 +291,4 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
}
return filename;
}
}

View File

@ -0,0 +1,13 @@
[
"DatasetProfileEditorModel.label",
"SectionEditorModel.title",
"SectionEditorModel.description",
"FieldSetEditorModel.title",
"FieldSetEditorModel.description",
"FieldSetEditorModel.extendedDescription",
"FieldSetEditorModel.additionalInformation",
"TextAreaFieldDataEditorModel.label",
"FreeTextFieldDataEditorModel.label",
"WordListFieldDataEditorModel.label",
"FieldDataOptionEditorModel.label"
]