remove dmp blueprint editor old code

This commit is contained in:
amentis 2024-02-07 16:03:45 +02:00
parent 8bf262693f
commit 3deb17dbea
2 changed files with 16 additions and 356 deletions

View File

@ -87,7 +87,19 @@ public class DescriptionTemplatePersist {
return Arrays.asList(
this.spec()
.must(() -> this.isValidGuid(item.getDescriptionTemplateGroupId()))
.failOn(DescriptionTemplatePersist._descriptionTemplateGroupId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._descriptionTemplateGroupId}, LocaleContextHolder.getLocale()))
.failOn(DescriptionTemplatePersist._descriptionTemplateGroupId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._descriptionTemplateGroupId}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isNull(item.getMinMultiplicity()))
.must(() -> item.getMinMultiplicity() >= 0)
.failOn(DescriptionTemplatePersist._minMultiplicity).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{DescriptionTemplatePersist._minMultiplicity}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isNull(item.getMaxMultiplicity()))
.must(() -> item.getMaxMultiplicity() > 0)
.failOn(DescriptionTemplatePersist._maxMultiplicity).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{DescriptionTemplatePersist._maxMultiplicity}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isNull(item.getMaxMultiplicity()))
.must(() -> !this.isNull(item.getMinMultiplicity()) && (item.getMaxMultiplicity() >= item.getMinMultiplicity()))
.failOn(DescriptionTemplatePersist._maxMultiplicity).failWith(messageSource.getMessage("Validation.LowerThanMin", new Object[]{DescriptionTemplatePersist._minMultiplicity}, LocaleContextHolder.getLocale()))
);
}
}

View File

@ -213,9 +213,9 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
formSubmit(): void {
this.formService.touchAllFormFields(this.formGroup);
// if (!this.isFormValid()) {
// return;
// }
if (!this.isFormValid()) {
return;
}
this.persistEntity();
}
@ -461,240 +461,6 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
(this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates').markAsDirty();
}
//
//
// Autocomplete configuration
//
//
// onRemoveDescritionTemplate(event, sectionIndex: number) {
// const descriptionTemplateFormArray = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates') as FormArray;
// const foundIndex = descriptionTemplateFormArray.controls.findIndex(blueprint => blueprint.get('descriptionTemplateId').value === event.id);
// if (foundIndex !== -1) {
// descriptionTemplateFormArray.removeAt(foundIndex);
// DmpBlueprintEditorModel.reApplySectionValidators(
// {
// formGroup: this.formGroup,
// validationErrorModel: this.editorModel.validationErrorModel
// }
// )
// this.formGroup.get('definition').get('sections').markAsDirty();
// }
// }
// onSelectDescritionTemplate(item, sectionIndex) {
// ((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates') as FormArray)
// .push(this.editorModel.createChildDescriptionTemplate(item, sectionIndex, ((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates') as FormArray).length));
// }
// ngAfterViewInit() {
// this.route.params
// .pipe(takeUntil(this._destroyed))
// .subscribe((params: Params) => {
// this.dmpBlueprintId = params['id'];
// const cloneId = params['cloneid'];
// if (this.dmpBlueprintId != null) {
// this.isNew = false;
// this.dmpBlueprintService.getSingleBlueprint(this.dmpBlueprintId).pipe(map(data => data as any))
// .pipe(takeUntil(this._destroyed))
// .subscribe(data => {
// this.dmpBlueprintEditor = new DmpBlueprintEditor().fromModel(data);
// this.formGroup = this.dmpBlueprintEditor.buildForm();
// this.buildSystemFields();
// this.fillDescriptionTemplatesInMultAutocomplete();
// if (this.dmpBlueprintEditor.status == DmpBlueprintStatus.Finalized) {
// this.formGroup.disable();
// this.viewOnly = true
// }
// // this.breadCrumbs = observableOf([{
// // parentComponentName: 'DmpBlueprintListingComponent',
// // label: this.language.instant('NAV-BAR.TEMPLATE'),
// // url: '/dmp-blueprints/' + this.dmpBlueprintId
// // }]);
// });
// } else if (cloneId != null) {
// this.isClone = true;
// this.dmpBlueprintService.clone(cloneId).pipe(map(data => data as any), takeUntil(this._destroyed))
// .subscribe(
// data => {
// this.dmpBlueprintEditor = new DmpBlueprintEditor().fromModel(data);
// this.dmpBlueprintEditor.id = null;
// this.dmpBlueprintEditor.status = DmpBlueprintStatus.Draft;
// this.formGroup = this.dmpBlueprintEditor.buildForm();
// this.buildSystemFields();
// this.fillDescriptionTemplatesInMultAutocomplete();
// },
// error => this.onCallbackError(error)
// );
// } else {
// this.dmpBlueprintEditorModel = new DmpBlueprintEditorModel();
// this.dmpBlueprintEditor = new DmpBlueprintEditor();
// setTimeout(() => {
// // this.formGroup = this.dmpBlueprintModel.buildForm();
// // this.addField();
// this.dmpBlueprintEditor.status = DmpBlueprintStatus.Draft;
// this.formGroup = this.dmpBlueprintEditor.buildForm();
// });
// // this.breadCrumbs = observableOf([{
// // parentComponentName: 'DmpBlueprintListingComponent',
// // label: this.language.instant('NAV-BAR.TEMPLATE'),
// // url: '/dmp-blueprints/' + this.dmpBlueprintId
// // }]);
// }
// });
// }
// buildSystemFields() {
// const sections = this.sectionsArray().controls.length;
// for (let i = 0; i < sections; i++) {
// let systemFieldsInSection = new Array();
// this.fieldsArray(i).controls.forEach((field) => {
// if ((field.get('category').value == FieldCategory.SYSTEM || field.get('category').value == DmpBlueprintSectionFieldCategory.SYSTEM)) {
// systemFieldsInSection.push(this.fieldList.find(f => f.type == field.get('type').value).type);
// }
// })
// this.systemFieldListPerSection.push(systemFieldsInSection);
// }
// }
// fillDescriptionTemplatesInMultAutocomplete() {
// const sections = this.sectionsArray().controls.length;
// for (let i = 0; i < sections; i++) {
// let descriptionTemplatesInSection = new Array<DatasetProfileModel>();
// this.descriptionTemplatesArray(i).controls.forEach((template) => {
// descriptionTemplatesInSection.push({ id: template.value.descriptionTemplateId, label: template.value.label, description: "" });
// })
// this.descriptionTemplatesPerSection.push(descriptionTemplatesInSection);
// }
// }
// checkForProfiles(event, sectionIndex: number) {
// if (event.checked === false) {
// this.descriptionTemplatesPerSection[sectionIndex] = new Array<DatasetProfileModel>();
// this.descriptionTemplatesArray(sectionIndex).clear();
// }
// }
// sectionsArray(): UntypedFormArray {
// //return this.dmpBlueprintsFormGroup.get('sections') as FormArray;
// return this.formGroup.get('definition').get('sections') as UntypedFormArray;
// }
// fieldsArray(sectionIndex: number): UntypedFormArray {
// return this.sectionsArray().at(sectionIndex).get('fields') as UntypedFormArray;
// }
// removeField(sectionIndex: number, fieldIndex: number): void {
// this.fieldsArray(sectionIndex).removeAt(fieldIndex);
// }
// systemFieldsArray(sectionIndex: number): UntypedFormArray {
// return this.sectionsArray().at(sectionIndex).get('systemFields') as UntypedFormArray;
// }
// initSystemField(systemField?: SystemFieldType): UntypedFormGroup {
// return this.fb.group({
// id: this.fb.control(Guid.create().toString()),
// type: this.fb.control(systemField),
// label: this.fb.control(''),
// placeholder: this.fb.control(''),
// description: this.fb.control(''),
// required: this.fb.control(true),
// ordinal: this.fb.control('')
// });
// }
// addSystemField(sectionIndex: number, systemField?: SystemFieldType): void {
// this.addField(sectionIndex, FieldCategory.SYSTEM, systemField);
// }
// transfromEnumToString(type: SystemFieldType): string {
// return this.fieldList.find(f => f.type == type).label;
// }
// selectedFieldType(type: SystemFieldType, sectionIndex: number): void {
// let index = this.systemFieldListPerSection[sectionIndex].indexOf(type);
// if (index == -1) {
// this.systemFieldListPerSection[sectionIndex].push(type);
// this.addSystemField(sectionIndex, type);
// }
// else {
// this.systemFieldListPerSection[sectionIndex].splice(index, 1);
// this.removeSystemField(sectionIndex, type);
// }
// }
// descriptionTemplatesArray(sectionIndex: number): UntypedFormArray {
// return this.sectionsArray().at(sectionIndex).get('descriptionTemplates') as UntypedFormArray;
// }
// addDescriptionTemplate(descriptionTemplate, sectionIndex: number): void {
// this.descriptionTemplatesArray(sectionIndex).push(this.fb.group({
// label: this.fb.control(descriptionTemplate.value)
// }));
// }
// removeDescriptionTemplate(sectionIndex: number, templateIndex: number): void {
// this.descriptionTemplatesArray(sectionIndex).removeAt(templateIndex);
// }
// extraFieldsArray(sectionIndex: number): UntypedFormArray {
// return this.sectionsArray().at(sectionIndex).get('extraFields') as UntypedFormArray;
// }
// getExtraFieldTypes(): Number[] {
// let keys: string[] = Object.keys(ExtraFieldType);
// keys = keys.slice(0, keys.length / 2);
// const values: Number[] = keys.map(Number);
// return values;
// }
// getExtraFieldTypeValue(extraFieldType: ExtraFieldType): string {
// switch (extraFieldType) {
// case ExtraFieldType.TEXT: return 'Text';
// case ExtraFieldType.RICH_TEXT: return 'Rich Text';
// case ExtraFieldType.DATE: return 'Date';
// case ExtraFieldType.NUMBER: return 'Number';
// }
// }
// moveItemInFormArray(formArray: UntypedFormArray, fromIndex: number, toIndex: number): void {
// const dir = toIndex > fromIndex ? 1 : -1;
// const item = formArray.at(fromIndex);
// for (let i = fromIndex; i * dir < toIndex * dir; i = i + dir) {
// const current = formArray.at(i + dir);
// formArray.setControl(i, current);
// }
// formArray.setControl(toIndex, item);
// }
// // clearForm(): void{
// // this.dmpBlueprintsFormGroup.reset();
// // }
onPreviewDescriptionTemplate(event: DescriptionTemplate, sectionId: Guid) {
const dialogRef = this.dialog.open(DescriptionTemplatePreviewDialogComponent, {
@ -749,15 +515,6 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
return true;
}
// formSubmit(): void {
// if (this.checkValidity())
// this.onSubmit();
// }
// public isFormValid() {
// return this.formGroup.valid;
// }
hasTitle(): boolean {
const dmpBlueprint: DmpBlueprintPersist = this.formGroup.value;
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => (field.category === DmpBlueprintSectionFieldCategory.SYSTEM || field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM) && field.systemFieldType === DmpBlueprintSystemFieldType.TEXT));
@ -787,119 +544,10 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
}
// onSubmit(): void {
// this.dmpBlueprintService.createBlueprint(this.formGroup.value)
// .pipe(takeUntil(this._destroyed))
// .subscribe(
// complete => this.onCallbackSuccess(),
// error => this.onCallbackError(error)
// );
// }
// onCallbackSuccess(): void {
// this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
// this.router.navigate(['/dmp-blueprints']);
// }
// onCallbackError(errorResponse: any) {
// this.setErrorModel(errorResponse.error);
// this.formService.validateAllFormFields(this.formGroup);
// }
// public setErrorModel(validationErrorModel: ValidationErrorModel) {
// Object.keys(validationErrorModel).forEach(item => {
// (<any>this.dmpBlueprintEditor.validationErrorModel)[item] = (<any>validationErrorModel)[item];
// });
// }
public cancel(): void {
this.router.navigate(['/dmp-blueprints']);
}
// // addField() {
// // (<FormArray>this.formGroup.get('definition').get('fields')).push(new DmpBlueprintFieldEditorModel().buildForm());
// // }
// // removeField(index: number) {
// // (<FormArray>this.formGroup.get('definition').get('fields')).controls.splice(index, 1);
// // }
// getDmpBlueprintFieldDataTypeValues(): Number[] {
// let keys: string[] = Object.keys(DmpBlueprintFieldDataType);
// keys = keys.slice(0, keys.length / 2);
// const values: Number[] = keys.map(Number);
// return values;
// }
// getDmpBlueprintFieldDataTypeWithLanguage(fieldType: DmpBlueprintFieldDataType): string {
// let result = '';
// this.language.get(this.enumUtils.toDmpBlueprintExtraFieldDataTypeString(fieldType))
// .pipe(takeUntil(this._destroyed))
// .subscribe((value: string) => {
// result = value;
// });
// return result;
// }
// getDmpBlueprintFieldTypeValues(): Number[] {
// let keys: string[] = Object.keys(DmpBlueprintType);
// keys = keys.slice(0, keys.length / 2);
// const values: Number[] = keys.map(Number);
// return values;
// }
// getDmpBlueprintFieldTypeWithLanguage(blueprintType: DmpBlueprintType): string {
// let result = '';
// this.language.get(this.enumUtils.toDmpBlueprintTypeString(blueprintType))
// .pipe(takeUntil(this._destroyed))
// .subscribe((value: string) => {
// result = value;
// });
// return result;
// }
// delete() {
// this.dialog.open(ConfirmationDialogComponent, {
// data: {
// isDeleteConfirmation: true,
// confirmButton: this.language.instant('DMP-BLUEPRINT-EDITOR.CONFIRM-DELETE-DIALOG.CONFIRM-BUTTON'),
// cancelButton: this.language.instant("DMP-BLUEPRINT-EDITOR.CONFIRM-DELETE-DIALOG.CANCEL-BUTTON"),
// message: this.language.instant("DMP-BLUEPRINT-EDITOR.CONFIRM-DELETE-DIALOG.MESSAGE")
// }
// })
// .afterClosed()
// .subscribe(
// confirmed => {
// if (confirmed) {
// if (this.formGroup.get('status').value == DmpBlueprintStatus.Draft) {
// // this.formGroup.get('status').setValue(DmpBlueprintStatus.Deleted);
// this.dmpBlueprintService.createBlueprint(this.formGroup.value)
// .pipe(takeUntil(this._destroyed))
// .subscribe(
// complete => this.onCallbackSuccess(),
// error => this.onCallbackError(error)
// );
// }
// else {
// // this.dmpBlueprintService.delete(this.dmpBlueprintId)
// // .pipe(takeUntil(this._destroyed))
// // .subscribe(
// // complete => this.onCallbackSuccess(),
// // error => {
// // if (error.error.statusCode == 674) {
// // this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DMP-BLUEPRINT-DELETE'), SnackBarNotificationLevel.Error);
// // } else {
// // this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error);
// // }
// // }
// // );
// }
// }
// }
// )
// }
finalize() {
if (this.checkValidity()) {
this.formGroup.get('status').setValue(DmpBlueprintStatus.Finalized);