From f255f61ee6390857662f5f6e9b75e3d5f2de3f5a Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Thu, 8 Feb 2024 16:48:29 +0200 Subject: [PATCH 1/5] Adding all versions listing and new version form for description templates --- .../description-template-persist.ts | 10 ++++++ .../description-template.service.ts | 11 +++++- .../description-template.routing.ts | 36 ++++++++++++++++--- .../description-template-editor.resolver.ts | 3 ++ ...escription-template-listing.component.html | 12 +++---- .../description-template-listing.component.ts | 10 ++++++ dmp-frontend/src/assets/i18n/en.json | 1 + 7 files changed, 71 insertions(+), 12 deletions(-) diff --git a/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts b/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts index b9b31b98e..22b780f64 100644 --- a/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts +++ b/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts @@ -17,6 +17,16 @@ export interface DescriptionTemplatePersist extends BaseEntityPersist { users: UserDescriptionTemplatePersist[]; } +export interface NewVersionDescriptionTemplatePersist extends BaseEntityPersist { + label: string; + description: string; + language: string; + type: Guid; + status: DescriptionTemplateStatus; + definition: DescriptionTemplateDefinitionPersist; + users: UserDescriptionTemplatePersist[]; +} + export interface UserDescriptionTemplatePersist { userId?: Guid; role?: UserDescriptionTemplateRole; diff --git a/dmp-frontend/src/app/core/services/description-template/description-template.service.ts b/dmp-frontend/src/app/core/services/description-template/description-template.service.ts index 9b7245e4f..02e4f4946 100644 --- a/dmp-frontend/src/app/core/services/description-template/description-template.service.ts +++ b/dmp-frontend/src/app/core/services/description-template/description-template.service.ts @@ -2,7 +2,7 @@ import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; -import { DescriptionTemplatePersist } from '@app/core/model/description-template/description-template-persist'; +import { DescriptionTemplatePersist, NewVersionDescriptionTemplatePersist } from '@app/core/model/description-template/description-template-persist'; import { DescriptionTemplateLookup } from '@app/core/query/description-template.lookup'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; @@ -68,6 +68,15 @@ export class DescriptionTemplateService { catchError((error: any) => throwError(error))); } + newVersion(item: NewVersionDescriptionTemplatePersist, reqFields: string[] = []): Observable { + const url = `${this.apiBase}/new-version`; + const options = { params: { f: reqFields } }; + + return this.http + .post(url, item).pipe( + catchError((error: any) => throwError(error))); + } + downloadXML(id: Guid): Observable> { const url = `${this.apiBase}/xml/export/${id}`; let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml'); diff --git a/dmp-frontend/src/app/ui/admin/description-template/description-template.routing.ts b/dmp-frontend/src/app/ui/admin/description-template/description-template.routing.ts index b687b8c33..f5f15f030 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/description-template.routing.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/description-template.routing.ts @@ -14,6 +14,14 @@ const routes: Routes = [ component: DescriptionTemplateListingComponent, canActivate: [AuthGuard] }, + { + path: 'versions/:groupid', + component: DescriptionTemplateListingComponent, + canActivate: [AuthGuard], + data: { + mode: 'versions-listing' + } + }, { path: 'new', canActivate: [AuthGuard], @@ -24,7 +32,7 @@ const routes: Routes = [ permissions: [AppPermission.EditDescriptionTemplate] }, ...BreadcrumbService.generateRouteDataConfiguration({ - title: 'BREADCRUMBS.NEW-DMP-BLUEPRINT' + title: 'BREADCRUMBS.NEW-DESCRIPTION-TEMPLATES' }) } }, @@ -38,13 +46,31 @@ const routes: Routes = [ }, data: { ...BreadcrumbService.generateRouteDataConfiguration({ - title: 'BREADCRUMBS.EDIT-DMP-BLUEPRINT' + title: 'BREADCRUMBS.EDIT-DESCRIPTION-TEMPLATES' }), authContext: { permissions: [AppPermission.EditDescriptionTemplate] - } + }, + action: 'clone' + } + }, + { + path: 'new-version/:newversionid', + canActivate: [AuthGuard], + component: DescriptionTemplateEditorComponent, + canDeactivate: [PendingChangesGuard], + resolve: { + 'entity': DescriptionTemplateEditorResolver + }, + data: { + ...BreadcrumbService.generateRouteDataConfiguration({ + title: 'BREADCRUMBS.EDIT-DESCRIPTION-TEMPLATES' + }), + authContext: { + permissions: [AppPermission.EditDescriptionTemplate] + }, + action: 'new-version' } - }, { path: ':id', @@ -56,7 +82,7 @@ const routes: Routes = [ }, data: { ...BreadcrumbService.generateRouteDataConfiguration({ - title: 'BREADCRUMBS.EDIT-DMP-BLUEPRINT' + title: 'BREADCRUMBS.EDIT-DESCRIPTION-TEMPLATES' }), authContext: { permissions: [AppPermission.EditDescriptionTemplate] diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts index 3914bdda2..b89976b71 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts @@ -103,10 +103,13 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver { ]; const id = route.paramMap.get('id'); const cloneid = route.paramMap.get('cloneid'); + const newversion = route.paramMap.get('newversionid'); if (id != null) { return this.descriptionTemplateService.getSingle(Guid.parse(id), fieldSets).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed)); } else if (cloneid != null) { return this.descriptionTemplateService.clone(Guid.parse(cloneid), fieldSets).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed)); + } else if (newversion != null) { + return this.descriptionTemplateService.getSingle(Guid.parse(newversion), fieldSets).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed)); } } } diff --git a/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.html b/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.html index 51a38b8d4..cfdc9ca31 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.html @@ -23,7 +23,7 @@ - + @@ -95,23 +95,23 @@ more_horiz - - - - - - diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 0458c6e05..2d4d2d305 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -1098,7 +1098,6 @@ "CLONE": "Clone", "DOWNLOAD-XML": "Download XML", "NEW-VERSION": "New Version", - "NEW-VERSION-FROM-FILE": "New Version from File", "VIEW-VERSIONS": "All Description Template Versions" }, "IMPORT": { From 45c8eb9768c53b5fab0b82a23ac5da9938b723da Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Thu, 8 Feb 2024 17:10:56 +0200 Subject: [PATCH 4/5] Removing default value on version column on description template migration script (00.01.010) --- .../updates/00.01.010_Align_DescriptionTemplate_table.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dmp-db-scema/updates/00.01.010_Align_DescriptionTemplate_table.sql b/dmp-db-scema/updates/00.01.010_Align_DescriptionTemplate_table.sql index 026bed58a..02bccec45 100644 --- a/dmp-db-scema/updates/00.01.010_Align_DescriptionTemplate_table.sql +++ b/dmp-db-scema/updates/00.01.010_Align_DescriptionTemplate_table.sql @@ -55,6 +55,8 @@ BEGIN ); ALTER TABLE public."DescriptionTemplate" ALTER COLUMN version_status SET NOT NULL; + + ALTER TABLE public."DescriptionTemplate" ALTER COLUMN version DROP DEFAULT; INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.010', '2023-11-02 12:00:00.000000+02', now(), 'Aling DescriptionTemplate table.'); From 98d663685588a7b3c5aad99ef658653b6397eb75 Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Thu, 8 Feb 2024 17:14:25 +0200 Subject: [PATCH 5/5] description template ui changes --- ...late-editor-composite-field.component.html | 4 +- ...mplate-editor-composite-field.component.ts | 30 ++++---- ...ption-template-editor-field.component.html | 13 ++-- ...ription-template-editor-field.component.ts | 8 +-- ...dataset-profile-editor-page.component.html | 14 ---- ...dataset-profile-editor-page.component.scss | 7 -- .../dataset-profile-editor-page.component.ts | 17 ----- ...ate-editor-section-fieldset.component.html | 2 +- ...plate-editor-section-fieldset.component.ts | 3 +- ...ption-template-editor-section.component.ts | 59 +--------------- ...description-template-editor.component.html | 20 +++++- .../description-template-editor.component.ts | 69 ++++++++++--------- ...iption-template-table-of-contents-entry.ts | 2 + .../editor/description-editor.model.ts | 4 +- 14 files changed, 89 insertions(+), 163 deletions(-) delete mode 100644 dmp-frontend/src/app/ui/admin/description-template/editor/components/page/dataset-profile-editor-page.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/description-template/editor/components/page/dataset-profile-editor-page.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/description-template/editor/components/page/dataset-profile-editor-page.component.ts diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html index b37172d6b..a9c4c74e5 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html @@ -65,8 +65,8 @@
- +
  • diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts index 8eab8ec08..782407c90 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild } from '@angular/core'; +import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'; import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; import { MatCheckboxChange } from '@angular/material/checkbox'; import { MatDialog } from '@angular/material/dialog'; @@ -39,7 +39,6 @@ import { ValidationErrorModel } from '@common/forms/validation/error-model/valid export class DescriptionTemplateEditorCompositeFieldComponent extends BaseComponent implements OnInit, OnChanges { @Input() form: UntypedFormGroup; - @Input() indexPath: string; @Input() viewOnly: boolean; @Input() datasetProfileId?: string; @@ -48,7 +47,7 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon @Input() hasFocus: boolean = false; @ViewChild("inputs") inputs: TransitionGroupComponent; @Input() validationErrorModel: ValidationErrorModel; - @Input() rootPath: string; + @Input() validationRootPath: string; showPreview: boolean = true; previewDirty: boolean = false; @@ -65,6 +64,7 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon private myCustomValidators: EditorCustomValidators = new EditorCustomValidators(); + isMultiplicityEnabled = false; constructor( private dialog: MatDialog, @@ -321,22 +321,22 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon } - addNewField() { - const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(); - field.id = Guid.create().toString(); + // addNewField() { + // const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(); + // field.id = Guid.create().toString(); - field.ordinal = (this.form.get('fields') as UntypedFormArray).length; + // field.ordinal = (this.form.get('fields') as UntypedFormArray).length; - const fieldForm = field.buildForm(); - // fieldForm.setValidators(this.customFieldValidator()); + // const fieldForm = field.buildForm(); + // // fieldForm.setValidators(this.customFieldValidator()); - // fieldForm.get('viewStyle').get('renderStyle').setValidators(Validators.required); + // // fieldForm.get('viewStyle').get('renderStyle').setValidators(Validators.required); - (this.form.get('fields')).push(fieldForm); + // (this.form.get('fields')).push(fieldForm); - this.setTargetField(fieldForm); - fieldForm.updateValueAndValidity(); - } + // this.setTargetField(fieldForm); + // fieldForm.updateValueAndValidity(); + // } DeleteField(index) { @@ -573,7 +573,7 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon } } - (this.form.get('fields')).push(new DescriptionTemplateFieldEditorModel(this.validationErrorModel).fromModel(field).buildForm({rootPath: this.rootPath + 'fields[' + this.fieldsArray.length + '].'})); + (this.form.get('fields')).push(new DescriptionTemplateFieldEditorModel(this.validationErrorModel).fromModel(field).buildForm({rootPath: this.validationRootPath + '.fields[' + this.fieldsArray.length + ']'})); this.inputs.init(); // fieldForm.get('viewStyle').get('renderStyle').updateValueAndValidity(); // fieldForm.get('data').updateValueAndValidity(); diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html index 74d5f6247..00e7960ab 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html @@ -1,3 +1,4 @@ +{{validationRootPath}} @@ -201,18 +202,18 @@

    {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.RULES-TITLE' | translate}}

    - +
-
+
- - - - + + + + diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts index 7bebac7f2..efa628322 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts @@ -35,8 +35,6 @@ import { ValidationErrorModel } from '@common/forms/validation/error-model/valid export class DescriptionTemplateEditorFieldComponent extends BaseComponent implements OnInit, ErrorStateMatcher { @Input() viewOnly: boolean; @Input() form: UntypedFormGroup; - @Input() showOrdinal = true; - @Input() indexPath: string; validationTypeEnum = ValidationType; // isFieldMultiplicityEnabled = false; @@ -48,7 +46,7 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple @Output() delete = new EventEmitter(); @Input() validationErrorModel: ValidationErrorModel; - @Input() rootPath: string; + @Input() validationRootPath: string; readonly separatorKeysCodes: number[] = [ENTER, COMMA]; @@ -96,7 +94,7 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple addNewRule() { const rule: DescriptionTemplateRuleEditorModel = new DescriptionTemplateRuleEditorModel(this.validationErrorModel); const ruleArray = this.form.get('visibilityRules') as UntypedFormArray; - (this.form.get('visibilityRules')).push(rule.buildForm({rootPath: this.rootPath + 'visibilityRules[' + ruleArray.length +'].'})); + (this.form.get('visibilityRules')).push(rule.buildForm({rootPath: this.validationRootPath + 'visibilityRules[' + ruleArray.length +'].'})); } get canApplyVisibility(): boolean { @@ -219,7 +217,7 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple } const form = (new DescriptionTemplateFieldEditorModel(this.validationErrorModel)).fromModel(field) - .buildForm({rootPath: this.rootPath}); + .buildForm({rootPath: this.validationRootPath}); const fields = this.form.parent as UntypedFormArray; diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/page/dataset-profile-editor-page.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/page/dataset-profile-editor-page.component.html deleted file mode 100644 index 13a795bc9..000000000 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/page/dataset-profile-editor-page.component.html +++ /dev/null @@ -1,14 +0,0 @@ - - {{'DATASET-PROFILE-EDITOR.STEPS.PAGES.PAGE-PREFIX' | translate}} {{i + 1}} -
- - - {{pageControl.get('title').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
-
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/page/dataset-profile-editor-page.component.scss b/dmp-frontend/src/app/ui/admin/description-template/editor/components/page/dataset-profile-editor-page.component.scss deleted file mode 100644 index 135c7a3f6..000000000 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/page/dataset-profile-editor-page.component.scss +++ /dev/null @@ -1,7 +0,0 @@ -.page-card { - margin-bottom: 1em; - - .page-card-title { - text-align: center; - } -} diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/page/dataset-profile-editor-page.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/page/dataset-profile-editor-page.component.ts deleted file mode 100644 index 8ef8a40f2..000000000 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/page/dataset-profile-editor-page.component.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { UntypedFormArray } from '@angular/forms'; - -@Component({ - selector: 'app-dataset-profile-editor-page-component', - templateUrl: './dataset-profile-editor-page.component.html', - styleUrls: ['./dataset-profile-editor-page.component.scss'] -}) -export class DatasetProfileEditorPageComponent { - - @Input() form: UntypedFormArray; - @Input() viewOnly: boolean; - - removePage(index) { - (this.form).removeAt(index); - } -} diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.html index dc1f89400..f5416145c 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.html @@ -65,7 +65,7 @@ [hasFocus]="fieldset.get('id').value === selectedFieldSetId" [datasetProfileId]="datasetProfileId" [validationErrorModel]="validationErrorModel" - [rootPath]="rootPath + 'fieldSets[' + i + '].'"> + [validationRootPath]="validationRootPath + '.fieldSets[' + i + ']'"> diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts index 0815c9fce..f7a1406c5 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts @@ -29,7 +29,7 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit @Output() addNewFieldSet = new EventEmitter(); @Output() cloneFieldSet = new EventEmitter(); @Input() validationErrorModel: ValidationErrorModel; - @Input() rootPath: string; + @Input() validationRootPath: string; idprefix = "id"; @@ -125,7 +125,6 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit // return parent; // } - private initialize() { if (this.tocentry.type === ToCEntryType.Section) { this.form = this.tocentry.form; diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section/description-template-editor-section.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section/description-template-editor-section.component.ts index 90d7edc70..d7b918aac 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section/description-template-editor-section.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section/description-template-editor-section.component.ts @@ -1,8 +1,6 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; +import { Component, Input, OnInit } from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; import { BaseComponent } from '@common/base/base.component'; -import { Guid } from '@common/types/guid'; -import { DescriptionTemplateFieldEditorModel, DescriptionTemplateFieldSetEditorModel, DescriptionTemplateSectionEditorModel } from '../../description-template-editor.model'; @Component({ selector: 'app-description-template-editor-section-component', @@ -13,63 +11,10 @@ import { DescriptionTemplateFieldEditorModel, DescriptionTemplateFieldSetEditorM export class DescriptionTemplateEditorSectionComponent extends BaseComponent implements OnInit { @Input() form: UntypedFormGroup; - @Input() indexPath: string; - @Input() viewOnly: boolean; - @Output() fieldsetAdded = new EventEmitter(); //returns the id of the fieldset added constructor() { super(); } ngOnInit() { } - - addField() { - const fieldSet: DescriptionTemplateFieldSetEditorModel = new DescriptionTemplateFieldSetEditorModel(); - fieldSet.ordinal = (this.form.get('fieldSets') as UntypedFormArray).length; - - const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(); - field.id = Guid.create().toString(); - field.ordinal = 0;//first field in fields - fieldSet.fields.push(field); - fieldSet.id = Guid.create().toString(); - - const fieldsetsArray = this.form.get('fieldSets') as UntypedFormArray; - fieldsetsArray.push(fieldSet.buildForm()); - - const fieldSetForm = fieldsetsArray.at(fieldsetsArray.length - 1); - //emit id inserted - if (fieldSetForm) { - const id: string = fieldSetForm.get('id').value; - this.fieldsetAdded.emit(id); - } - } - - addSectioninSection() { - const section: DescriptionTemplateSectionEditorModel = new DescriptionTemplateSectionEditorModel(); - //this.dataModel.sections.push(section); - (this.form.get('sections')).push(section.buildForm()); - } - - DeleteSectionInSection(index) { - //this.dataModel.sections.splice(index, 1); - (this.form.get('sections')).removeAt(index); - } - - deleteFieldSet(index) { - //this.dataModel.fieldSets.splice(index, 1); - (this.form.get('fieldSets')).removeAt(index); - } - - keepPageSelectionValid(pagesJson: Array) { - const selectedPage = this.form.get('page').value as String; - // const pages: Array = JsonSerializer.fromJSONArray(pagesJson, Page); - if (pagesJson.find(elem => elem.id === selectedPage) === undefined) { - this.form.get('page').reset(); - } - } - - getFieldTile(formGroup: UntypedFormGroup, index: number) { - if (formGroup.get('title') && formGroup.get('title').value && formGroup.get('title').value.length > 0) { return formGroup.get('title').value; } - return "Field " + (index + 1); - } } diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html index f74674613..ecb85e1a5 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html @@ -178,7 +178,15 @@
- +
@@ -213,8 +221,14 @@
- +
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts index e6064e396..c5220ea9a 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts @@ -441,7 +441,8 @@ export class DescriptionTemplateEditorComponent extends BaseEditor 0){ + if (sectionIndexes && sectionIndexes.length > 0) { pageIndex = j; break; } } let parentSectionRootPath = ''; - if(sectionIndexes.length > 0){ + if (sectionIndexes.length > 0) { sectionIndexes.forEach(index => { - parentSectionRootPath = parentSectionRootPath + 'sections[' + index +'].' + parentSectionRootPath = parentSectionRootPath + 'sections[' + index + '].' }); sectionsArray = parent.form.get('sections') as UntypedFormArray; @@ -650,9 +655,9 @@ export class DescriptionTemplateEditorComponent extends BaseEditor 0){ + if (sectionIndexes && sectionIndexes.length > 0) { pageIndex = j; break; } } let parentSectionRootPath = ''; - if(sectionIndexes.length > 0){ + if (sectionIndexes.length > 0) { sectionIndexes.forEach(index => { - parentSectionRootPath = parentSectionRootPath + 'sections[' + index +'].' + parentSectionRootPath = parentSectionRootPath + 'sections[' + index + '].' }); } if (sectionIndexes.length > 0) { @@ -694,7 +699,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor 0){ - const indexes: number[]= this.findSectionIndex(parentSections, parentId); - if (indexes && indexes.length > 0){ + } else if (parentSections && parentSections.length > 0) { + const indexes: number[] = this.findSectionIndex(parentSections, parentId); + if (indexes && indexes.length > 0) { indexes.unshift(i); return indexes; } @@ -747,20 +752,20 @@ export class DescriptionTemplateEditorComponent extends BaseEditor 0){ + } else if (parentSections && parentSections.length > 0) { const currentSectionFormArray = this.getUpdatedSectionFormArray(parentSections, tceId); - if (currentSectionFormArray != null || currentSectionFormArray != undefined){ + if (currentSectionFormArray != null || currentSectionFormArray != undefined) { return currentSectionFormArray; } } @@ -904,7 +909,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor