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.'); 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.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts index c5220ea9a..2ccb3b3e6 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 @@ -14,7 +14,7 @@ import { IsActive } from '@app/core/common/enum/is-active.enum'; import { AppPermission } from '@app/core/common/enum/permission.enum'; import { UserDescriptionTemplateRole } from '@app/core/common/enum/user-description-template-role'; 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 { LanguageInfo } from '@app/core/model/language-info'; import { User } from '@app/core/model/user/user'; import { AuthService } from '@app/core/services/auth/auth.service'; @@ -201,13 +201,23 @@ export class DescriptionTemplateEditorComponent extends BaseEditor void): void { - const formData = this.formService.getValue(this.formGroup.value) as DescriptionTemplatePersist; + if (this.isNew && !this.isClone && !this.isNewVersion){ + const formData = this.formService.getValue(this.formGroup.value) as DescriptionTemplatePersist; - this.descriptionTemplateService.persist(formData) - .pipe(takeUntil(this._destroyed)).subscribe( - complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete), - error => this.onCallbackError(error) - ); + this.descriptionTemplateService.persist(formData) + .pipe(takeUntil(this._destroyed)).subscribe( + complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete), + error => this.onCallbackError(error) + ); + } else if (this.isNewVersion && !this.isNew && !this.isClone) { + const formData = this.formService.getValue(this.formGroup.value) as NewVersionDescriptionTemplatePersist; + + this.descriptionTemplateService.newVersion(formData) + .pipe(takeUntil(this._destroyed)).subscribe( + complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete), + error => this.onCallbackError(error) + ); + } } formSubmit(): void { 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..011595c30 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,20 @@ more_horiz - - - - - -