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/4] 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/4] 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.');