From 71923a006e2b851f1298985714f087af6941cdc7 Mon Sep 17 00:00:00 2001 From: "CITE\\amentis" Date: Fri, 26 Jul 2024 17:27:01 +0300 Subject: [PATCH] implement description code --- .../DescriptionTemplateImportExport.java | 20 +++++++++++++ .../data/DescriptionTemplateEntity.java | 13 +++++++++ .../errorcode/ErrorThesaurusProperties.java | 20 +++++++++++++ .../DescriptionTemplateBuilder.java | 2 ++ .../DescriptionTemplate.java | 11 +++++++ .../persist/DescriptionTemplatePersist.java | 22 ++++++++++++++ .../NewVersionDescriptionTemplatePersist.java | 21 ++++++++++++++ .../query/DescriptionTemplateQuery.java | 29 ++++++++++++++++++- .../description/DescriptionServiceImpl.java | 12 +++++--- .../DescriptionTemplateServiceImpl.java | 18 ++++++++++-- .../DescriptionTemplateTypeServiceImpl.java | 2 +- .../web/src/main/resources/config/errors.yml | 8 ++++- ...69_Add_DescriptionTemplate_code_column.sql | 13 +++++++++ .../core/common/enum/respone-error-code.ts | 6 ++++ .../description-template-persist.ts | 2 ++ .../description-template.ts | 1 + ...description-template-editor.component.html | 17 ++++++++--- .../description-template-editor.model.ts | 4 +++ .../description-template-editor.resolver.ts | 1 + .../description-template-listing.component.ts | 6 ++++ .../start-new-plan-dialog.component.ts | 6 ++-- frontend/src/assets/i18n/baq.json | 2 +- frontend/src/assets/i18n/de.json | 2 +- frontend/src/assets/i18n/en.json | 3 +- frontend/src/assets/i18n/es.json | 2 +- frontend/src/assets/i18n/gr.json | 2 +- frontend/src/assets/i18n/hr.json | 2 +- frontend/src/assets/i18n/pl.json | 2 +- frontend/src/assets/i18n/pt.json | 2 +- frontend/src/assets/i18n/sk.json | 2 +- frontend/src/assets/i18n/sr.json | 2 +- frontend/src/assets/i18n/tr.json | 2 +- .../http-error-handling.service.ts | 2 ++ 33 files changed, 233 insertions(+), 26 deletions(-) create mode 100644 dmp-db-scema/updates/00.01.069_Add_DescriptionTemplate_code_column.sql diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateImportExport.java index 7b411ead7..0b9d10c13 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateImportExport.java @@ -14,6 +14,10 @@ public class DescriptionTemplateImportExport { @XmlElement(name = "id") private UUID id; + @XmlElement(name = "label") + private String label; + @XmlElement(name = "code") + private String code; @XmlElement(name = "description") private String description; @XmlElement(name = "language") @@ -36,6 +40,22 @@ public class DescriptionTemplateImportExport { this.id = id; } + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + public List getPages() { return this.pages; } diff --git a/backend/core/src/main/java/org/opencdmp/data/DescriptionTemplateEntity.java b/backend/core/src/main/java/org/opencdmp/data/DescriptionTemplateEntity.java index 356e8fc0b..af97aa754 100644 --- a/backend/core/src/main/java/org/opencdmp/data/DescriptionTemplateEntity.java +++ b/backend/core/src/main/java/org/opencdmp/data/DescriptionTemplateEntity.java @@ -27,6 +27,11 @@ public class DescriptionTemplateEntity extends TenantScopedBaseEntity { public static final String _label = "label"; public static final int _labelLength = 250; + @Column(name = "code", length = _codeLength, nullable = false) + private String code; + public final static String _code = "code"; + public final static int _codeLength = 200; + @Type(SQLXMLType.class) @Column(name = "definition", nullable = false, columnDefinition = "xml") private String definition; @@ -95,6 +100,14 @@ public class DescriptionTemplateEntity extends TenantScopedBaseEntity { this.label = label; } + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + public String getDefinition() { return this.definition; } diff --git a/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java b/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java index aad918df2..cd0b52f2c 100644 --- a/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java +++ b/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java @@ -438,4 +438,24 @@ public class ErrorThesaurusProperties { public void setReferenceTypeImportNotFound(ErrorDescription referenceTypeImportNotFound) { this.referenceTypeImportNotFound = referenceTypeImportNotFound; } + + private ErrorDescription descriptionTemplateCodeExists; + + public ErrorDescription getDescriptionTemplateCodeExists() { + return descriptionTemplateCodeExists; + } + + public void setDescriptionTemplateCodeExists(ErrorDescription descriptionTemplateCodeExists) { + this.descriptionTemplateCodeExists = descriptionTemplateCodeExists; + } + + private ErrorDescription descriptionTemplateImportNotFound; + + public ErrorDescription getDescriptionTemplateImportNotFound() { + return descriptionTemplateImportNotFound; + } + + public void setDescriptionTemplateImportNotFound(ErrorDescription descriptionTemplateImportNotFound) { + this.descriptionTemplateImportNotFound = descriptionTemplateImportNotFound; + } } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplate/DescriptionTemplateBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplate/DescriptionTemplateBuilder.java index b95feedee..9d2f2763b 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplate/DescriptionTemplateBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplate/DescriptionTemplateBuilder.java @@ -90,6 +90,8 @@ public class DescriptionTemplateBuilder extends BaseBuilder !this.isEmpty(item.getLabel())) .must(() -> this.lessEqualLength(item.getLabel(), DescriptionTemplateEntity._labelLength)) .failOn(DescriptionTemplatePersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionTemplatePersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> item.getStatus() == DescriptionTemplateStatus.Finalized) + .must(() -> !this.isEmpty(item.getCode())) + .failOn(DescriptionTemplatePersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._code}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isEmpty(item.getCode())) + .must(() -> this.lessEqualLength(item.getCode(), DescriptionTemplateTypeEntity._codeLength)) + .failOn(DescriptionTemplatePersist._code).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionTemplatePersist._code}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> item.getStatus() == DescriptionTemplateStatus.Finalized) .must(() -> !this.isEmpty(item.getDescription())) diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDescriptionTemplatePersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDescriptionTemplatePersist.java index 2b492c132..6a1d09c7f 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDescriptionTemplatePersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDescriptionTemplatePersist.java @@ -6,6 +6,7 @@ import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.DescriptionTemplateEntity; +import org.opencdmp.data.DescriptionTemplateTypeEntity; import org.opencdmp.errorcode.ErrorThesaurusProperties; import org.opencdmp.model.persist.descriptiontemplatedefinition.DefinitionPersist; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -26,6 +27,10 @@ public class NewVersionDescriptionTemplatePersist { public static final String _label = "label"; + private String code = null; + + public static final String _code = "code"; + private String description = null; public static final String _description = "description"; @@ -70,6 +75,14 @@ public class NewVersionDescriptionTemplatePersist { this.label = label; } + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + public String getDescription() { return description; } @@ -161,6 +174,14 @@ public class NewVersionDescriptionTemplatePersist { .iff(() -> !this.isEmpty(item.getLabel())) .must(() -> this.lessEqualLength(item.getLabel(), DescriptionTemplateEntity._labelLength)) .failOn(NewVersionDescriptionTemplatePersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{NewVersionDescriptionTemplatePersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> item.getStatus() == DescriptionTemplateStatus.Finalized) + .must(() -> !this.isEmpty(item.getCode())) + .failOn(NewVersionDescriptionTemplatePersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDescriptionTemplatePersist._code}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isEmpty(item.getCode())) + .must(() -> this.lessEqualLength(item.getCode(), DescriptionTemplateTypeEntity._codeLength)) + .failOn(NewVersionDescriptionTemplatePersist._code).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{NewVersionDescriptionTemplatePersist._code}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getDescription())) .failOn(NewVersionDescriptionTemplatePersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDescriptionTemplatePersist._description}, LocaleContextHolder.getLocale())), diff --git a/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java b/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java index 85d42eabd..bd50a2e3a 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java @@ -57,6 +57,8 @@ public class DescriptionTemplateQuery extends QueryBase authorize = EnumSet.of(AuthorizationFlags.None); + private Collection codes; + public DescriptionTemplateQuery like(String value) { this.like = value; return this; @@ -212,6 +214,21 @@ public class DescriptionTemplateQuery extends QueryBase values) { + this.codes = values; + return this; + } + public DescriptionTemplateQuery authorize(EnumSet values) { this.authorize = values; return this; @@ -312,7 +329,8 @@ public class DescriptionTemplateQuery extends QueryBase inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateEntity._code)); + for (String item : this.codes) + inClause.value(item); + predicates.add(inClause); + } if (this.onlyCanEdit != null) { boolean canEdit = this.authService.authorize(Permission.EditDescriptionTemplate); @@ -394,6 +418,7 @@ public class DescriptionTemplateQuery extends QueryBase 1) throw new MyValidationException(this.errors.getDescriptionTemplateCodeExists().getCode(), this.errors.getDescriptionTemplateCodeExists().getMessage()); this.entityManager.merge(data); - else { + } else { + if (descriptionTemplateCodes > 0) throw new MyValidationException(this.errors.getDescriptionTemplateCodeExists().getCode(), this.errors.getDescriptionTemplateCodeExists().getMessage()); this.entityManager.persist(data); this.accountingService.increase(UsageLimitTargetMetric.DESCRIPTION_TEMPLATE_COUNT.getValue()); } @@ -544,6 +550,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); model.setLabel(model.getLabel() + " new "); + model.setCode(model.getCode()); model.setId(null); model.setHash(null); model.setStatus(DescriptionTemplateStatus.Draft); @@ -715,11 +722,14 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic data.setVersion((short) (oldDescriptionTemplateEntity.getVersion() + 1)); data.setDescription(model.getDescription()); data.setLabel(model.getLabel()); + data.setCode(model.getCode()); data.setTypeId(model.getType()); data.setLanguage(model.getLanguage()); data.setStatus(model.getStatus()); data.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(model.getDefinition()))); + Long descriptionTemplateCodes = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().codes(model.getCode()).count(); + if (descriptionTemplateCodes > 0) throw new MyValidationException(this.errors.getDescriptionTemplateCodeExists().getCode(), this.errors.getDescriptionTemplateCodeExists().getMessage()); this.entityManager.persist(data); this.persistUsers(data.getId(), model.getUsers()); @@ -756,6 +766,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic if (activeDescriptionTemplatesForTheGroup == 0) { DescriptionTemplatePersist persist = new DescriptionTemplatePersist(); persist.setLabel(label); + persist.setCode(importXml.getCode()); persist.setStatus(DescriptionTemplateStatus.Draft); persist.setDescription(importXml.getDescription()); persist.setLanguage(importXml.getLanguage()); @@ -775,6 +786,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic NewVersionDescriptionTemplatePersist persist = new NewVersionDescriptionTemplatePersist(); persist.setId(latestVersionDescriptionTemplate.getId()); persist.setLabel(label); + persist.setCode(importXml.getCode()); persist.setStatus(DescriptionTemplateStatus.Draft); persist.setDescription(importXml.getDescription()); persist.setLanguage(importXml.getLanguage()); @@ -988,6 +1000,8 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic private DescriptionTemplateImportExport definitionXmlToExport(DescriptionTemplateEntity data, DefinitionEntity entity) throws InvalidApplicationException { DescriptionTemplateImportExport xml = new DescriptionTemplateImportExport(); xml.setId(data.getId()); + xml.setLabel(data.getLabel()); + xml.setCode(data.getCode()); xml.setDescriptionTemplateType(this.descriptionTemplateTypeXmlToExport(data.getTypeId())); xml.setLanguage(data.getLanguage()); xml.setDescription(data.getDescription()); diff --git a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplatetype/DescriptionTemplateTypeServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplatetype/DescriptionTemplateTypeServiceImpl.java index bf9a6febc..f41516b8c 100644 --- a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplatetype/DescriptionTemplateTypeServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplatetype/DescriptionTemplateTypeServiceImpl.java @@ -116,7 +116,7 @@ public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTy data.setStatus(model.getStatus()); data.setUpdatedAt(Instant.now()); - Long descriptionTemplateTypeCodes = this.queryFactory.query(DescriptionTemplateTypeQuery.class).disableTracking().codes(model.getCode()).isActive(IsActive.Active).count(); + Long descriptionTemplateTypeCodes = this.queryFactory.query(DescriptionTemplateTypeQuery.class).disableTracking().codes(model.getCode()).count(); if (isUpdate) { if (descriptionTemplateTypeCodes > 1) throw new MyValidationException(this.errors.getDescriptionTemplateTypeCodeExists().getCode(), this.errors.getDescriptionTemplateTypeCodeExists().getMessage()); diff --git a/backend/web/src/main/resources/config/errors.yml b/backend/web/src/main/resources/config/errors.yml index 105b1ea6d..4af35110b 100644 --- a/backend/web/src/main/resources/config/errors.yml +++ b/backend/web/src/main/resources/config/errors.yml @@ -136,4 +136,10 @@ error-thesaurus: message: Description template type not found referenceTypeImportNotFound: code: 149 - message: Reference type not found \ No newline at end of file + message: Reference type not found + descriptionTemplateCodeExists: + code: 150 + message: Description template code exists + descriptionTemplateImportNotFound: + code: 151 + message: Description template code exists \ No newline at end of file diff --git a/dmp-db-scema/updates/00.01.069_Add_DescriptionTemplate_code_column.sql b/dmp-db-scema/updates/00.01.069_Add_DescriptionTemplate_code_column.sql new file mode 100644 index 000000000..bb24ab1bd --- /dev/null +++ b/dmp-db-scema/updates/00.01.069_Add_DescriptionTemplate_code_column.sql @@ -0,0 +1,13 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.069'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + + ALTER TABLE public."DescriptionTemplate" ADD COLUMN code character varying(200); + UPDATE public."DescriptionTemplate" SET code = uuid_generate_v4(); + ALTER TABLE public."DescriptionTemplate" ALTER COLUMN code SET NOT NULL; + + INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.069', '2024-07-26 12:00:00.000000+02', now(), 'Add DescriptionTemplate code column.'); + +END$$; \ No newline at end of file diff --git a/frontend/src/app/core/common/enum/respone-error-code.ts b/frontend/src/app/core/common/enum/respone-error-code.ts index 02164ba42..16faa20a3 100644 --- a/frontend/src/app/core/common/enum/respone-error-code.ts +++ b/frontend/src/app/core/common/enum/respone-error-code.ts @@ -45,6 +45,8 @@ export enum ResponseErrorCode { DescriptionTemplateTypeCodeExists = 147, descriptionTemplateTypeImportNotFound = 148, referenceTypeImportNotFound = 149, + descriptionTemplateCodeExists = 150, + descriptionTemplateImportNotFound = 151, // Notification & Annotation Errors InvalidApiKey = 200, @@ -169,6 +171,10 @@ export class ResponseErrorCodeHelper { return language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND"); case ResponseErrorCode.referenceTypeImportNotFound: return language.instant("GENERAL.BACKEND-ERRORS.REFERENCE-TYPE-IMPORT-NOT-FOUND"); + case ResponseErrorCode.descriptionTemplateCodeExists: + return language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-CODE-EXISTS"); + case ResponseErrorCode.descriptionTemplateImportNotFound: + return language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-IMPORT-NOT-FOUND"); default: return language.instant("GENERAL.SNACK-BAR.NOT-FOUND"); } diff --git a/frontend/src/app/core/model/description-template/description-template-persist.ts b/frontend/src/app/core/model/description-template/description-template-persist.ts index 389240caf..14f7c1569 100644 --- a/frontend/src/app/core/model/description-template/description-template-persist.ts +++ b/frontend/src/app/core/model/description-template/description-template-persist.ts @@ -10,6 +10,7 @@ import { ReferencePersist } from "../reference/reference"; export interface DescriptionTemplatePersist extends BaseEntityPersist { label: string; + code: string; description: string; language: string; type: Guid; @@ -20,6 +21,7 @@ export interface DescriptionTemplatePersist extends BaseEntityPersist { export interface NewVersionDescriptionTemplatePersist extends BaseEntityPersist { label: string; + code: string; description: string; language: string; type: Guid; diff --git a/frontend/src/app/core/model/description-template/description-template.ts b/frontend/src/app/core/model/description-template/description-template.ts index 1474a37fc..ede5688d0 100644 --- a/frontend/src/app/core/model/description-template/description-template.ts +++ b/frontend/src/app/core/model/description-template/description-template.ts @@ -15,6 +15,7 @@ import { AppPermission } from "@app/core/common/enum/permission.enum"; export interface DescriptionTemplate extends BaseEntity { label?: string; + code?: string; description?: string; groupId?: Guid; version?: string; diff --git a/frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html b/frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html index bc0abcb5d..c5638ed26 100644 --- a/frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html +++ b/frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html @@ -45,7 +45,16 @@
-
1.2 {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-DESCRIPTION'| translate}} *
+
1.2 {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-CODE'| translate}} *
+
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-CODE-HINT'| translate}}
+ + + {{formGroup.get('code').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
+
+
1.3 {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-DESCRIPTION'| translate}} *
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-DESCRIPTION-HINT'| translate}}
@@ -58,7 +67,7 @@
-
1.3 {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-TYPE'| translate}} *
+
1.4 {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-TYPE'| translate}} *
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-TYPE-HINT'| translate}}
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-SELECT-TYPE' | translate}} @@ -69,7 +78,7 @@
-
1.4 {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-LANGUAGE'| translate}} *
+
1.5 {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-LANGUAGE'| translate}} *
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-LANGUAGE-HINT'| translate}}
@@ -82,7 +91,7 @@
-
1.5 {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-USERS'| translate}}
+
1.6 {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-USERS'| translate}}
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-USERS-HINT'| translate}}
diff --git a/frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts b/frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts index 455dff671..81018f6d7 100644 --- a/frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts +++ b/frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts @@ -16,6 +16,7 @@ import { EditorCustomValidators } from "./custom-validators/editor-custom-valida export class DescriptionTemplateEditorModel extends BaseEditorModel implements DescriptionTemplatePersist { label: string; + code: string; description: string; language: string; type: Guid; @@ -33,6 +34,7 @@ export class DescriptionTemplateEditorModel extends BaseEditorModel implements D if (item) { super.fromModel(item); this.label = item.label; + this.code = item.code; this.description = item.description; this.language = item.language; this.type = item.type?.id; @@ -49,6 +51,7 @@ export class DescriptionTemplateEditorModel extends BaseEditorModel implements D return this.formBuilder.group({ id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators], label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], + code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators], description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], language: [{ value: this.language, disabled: disabled }, context.getValidation('language').validators], type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators], @@ -72,6 +75,7 @@ export class DescriptionTemplateEditorModel extends BaseEditorModel implements D const baseValidationArray: Validation[] = new Array(); baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] }); baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); + baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'code')] }); baseValidationArray.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] }); baseValidationArray.push({ key: 'language', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'language')] }); baseValidationArray.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'type')] }); diff --git a/frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts b/frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts index d06bf4c5b..e0e67d2b5 100644 --- a/frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts +++ b/frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts @@ -25,6 +25,7 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver { ...BaseEditorResolver.lookupFields(), nameof(x => x.id), nameof(x => x.label), + nameof(x => x.code), nameof(x => x.status), nameof(x => x.description), nameof(x => x.language), diff --git a/frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts b/frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts index 651f0ba65..cedf1a523 100644 --- a/frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts +++ b/frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts @@ -56,6 +56,7 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent(x => x.id), nameof(x => x.label), + nameof(x => x.code), nameof(x => x.description), nameof(x => x.status), nameof(x => x.version), @@ -140,6 +141,11 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent(x => x.code), + sortable: true, + languageName: 'DESCRIPTION-TEMPLATE-LISTING.FIELDS.CODE' + }, { prop: nameof(x => x.description), sortable: true, diff --git a/frontend/src/app/ui/plan/new/start-new-plan-dialogue/start-new-plan-dialog.component.ts b/frontend/src/app/ui/plan/new/start-new-plan-dialogue/start-new-plan-dialog.component.ts index bbb11b974..5e6a10fa5 100644 --- a/frontend/src/app/ui/plan/new/start-new-plan-dialogue/start-new-plan-dialog.component.ts +++ b/frontend/src/app/ui/plan/new/start-new-plan-dialogue/start-new-plan-dialog.component.ts @@ -10,6 +10,7 @@ import { takeUntil } from 'rxjs/operators'; import { PlanUploadDialogComponent } from '../upload-dialogue/plan-upload-dialog.component'; import { AnalyticsService } from '@app/core/services/matomo/analytics-service'; import { RouterUtilsService } from '@app/core/services/router/router-utils.service'; +import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service'; @Component({ selector: 'app-start-new-plan', @@ -30,7 +31,8 @@ export class StartNewPlanDialogComponent extends BaseComponent { private planService: PlanService, private httpClient: HttpClient, private analyticsService: AnalyticsService, - private routerUtils: RouterUtilsService + private routerUtils: RouterUtilsService, + private httpErrorHandlingService: HttpErrorHandlingService, ) { super(); this.isDialog = data.isDialog; @@ -77,7 +79,7 @@ export class StartNewPlanDialogComponent extends BaseComponent { this.onCallbackImportComplete(); this.dialog.closeAll(); }, - (error) => this.onCallbackImportFail(error.error) + (error) => this.httpErrorHandlingService.handleBackedRequestError(error) ); } else if (file?.type.includes('/json') && result.planCommonModelConfig){ this.planService.uploadJson(result.planCommonModelConfig) diff --git a/frontend/src/assets/i18n/baq.json b/frontend/src/assets/i18n/baq.json index 2e683e77b..fdd2b80e1 100644 --- a/frontend/src/assets/i18n/baq.json +++ b/frontend/src/assets/i18n/baq.json @@ -85,7 +85,7 @@ "DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS": "The description template type code you provided already exists. Please choose a different code.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND": "Description template type {{descriptionTemplateTypeLabel}} not found.", "REFERENCE-TYPE-IMPORT-NOT-FOUND": "Reference type {{referenceTypeCode}} not found.", - "DESCRIPTION-TEMPLATE-CODE-EXISTS": "The description template code you provided already exists. Please choose a different code." + "DESCRIPTION-TEMPLATE-IMPORT-NOT-FOUND": "Description template {{descriptionTemplateLabel}} not found." }, "FORM-VALIDATION-DISPLAY-DIALOG": { "WARNING": "Kontuz!", diff --git a/frontend/src/assets/i18n/de.json b/frontend/src/assets/i18n/de.json index 8ce1eec9e..8d3821ba6 100644 --- a/frontend/src/assets/i18n/de.json +++ b/frontend/src/assets/i18n/de.json @@ -85,7 +85,7 @@ "DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS": "The description template type code you provided already exists. Please choose a different code.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND": "Description template type {{descriptionTemplateTypeLabel}} not found.", "REFERENCE-TYPE-IMPORT-NOT-FOUND": "Reference type {{referenceTypeCode}} not found.", - "DESCRIPTION-TEMPLATE-CODE-EXISTS": "The description template code you provided already exists. Please choose a different code." + "DESCRIPTION-TEMPLATE-IMPORT-NOT-FOUND": "Description template {{descriptionTemplateLabel}} not found." }, "FORM-VALIDATION-DISPLAY-DIALOG": { "WARNING": "Warnung!", diff --git a/frontend/src/assets/i18n/en.json b/frontend/src/assets/i18n/en.json index b6c030c6c..d752de87f 100644 --- a/frontend/src/assets/i18n/en.json +++ b/frontend/src/assets/i18n/en.json @@ -85,7 +85,8 @@ "DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS": "The description template type code you provided already exists. Please choose a different code.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND": "Description template type {{descriptionTemplateTypeLabel}} not found.", "REFERENCE-TYPE-IMPORT-NOT-FOUND": "Reference type {{referenceTypeCode}} not found.", - "DESCRIPTION-TEMPLATE-CODE-EXISTS": "The description template code you provided already exists. Please choose a different code." + "DESCRIPTION-TEMPLATE-CODE-EXISTS": "The description template code you provided already exists. Please choose a different code.", + "DESCRIPTION-TEMPLATE-IMPORT-NOT-FOUND": "Description template {{descriptionTemplateLabel}} not found." }, "FORM-VALIDATION-DISPLAY-DIALOG": { "WARNING": "Warning!", diff --git a/frontend/src/assets/i18n/es.json b/frontend/src/assets/i18n/es.json index f04aa1eac..3d2874966 100644 --- a/frontend/src/assets/i18n/es.json +++ b/frontend/src/assets/i18n/es.json @@ -85,7 +85,7 @@ "DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS": "The description template type code you provided already exists. Please choose a different code.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND": "Description template type {{descriptionTemplateTypeLabel}} not found.", "REFERENCE-TYPE-IMPORT-NOT-FOUND": "Reference type {{referenceTypeCode}} not found.", - "DESCRIPTION-TEMPLATE-CODE-EXISTS": "The description template code you provided already exists. Please choose a different code." + "DESCRIPTION-TEMPLATE-IMPORT-NOT-FOUND": "Description template {{descriptionTemplateLabel}} not found." }, "FORM-VALIDATION-DISPLAY-DIALOG": { "WARNING": "Atención!", diff --git a/frontend/src/assets/i18n/gr.json b/frontend/src/assets/i18n/gr.json index 16272a98d..aafde757c 100644 --- a/frontend/src/assets/i18n/gr.json +++ b/frontend/src/assets/i18n/gr.json @@ -85,7 +85,7 @@ "DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS": "The description template type code you provided already exists. Please choose a different code.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND": "Description template type {{descriptionTemplateTypeLabel}} not found.", "REFERENCE-TYPE-IMPORT-NOT-FOUND": "Reference type {{referenceTypeCode}} not found.", - "DESCRIPTION-TEMPLATE-CODE-EXISTS": "The description template code you provided already exists. Please choose a different code." + "DESCRIPTION-TEMPLATE-IMPORT-NOT-FOUND": "Description template {{descriptionTemplateLabel}} not found." }, "FORM-VALIDATION-DISPLAY-DIALOG": { "WARNING": "Προσοχή!", diff --git a/frontend/src/assets/i18n/hr.json b/frontend/src/assets/i18n/hr.json index e25bfc2a3..a8d58a3a5 100644 --- a/frontend/src/assets/i18n/hr.json +++ b/frontend/src/assets/i18n/hr.json @@ -85,7 +85,7 @@ "DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS": "The description template type code you provided already exists. Please choose a different code.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND": "Description template type {{descriptionTemplateTypeLabel}} not found.", "REFERENCE-TYPE-IMPORT-NOT-FOUND": "Reference type {{referenceTypeCode}} not found.", - "DESCRIPTION-TEMPLATE-CODE-EXISTS": "The description template code you provided already exists. Please choose a different code." + "DESCRIPTION-TEMPLATE-IMPORT-NOT-FOUND": "Description template {{descriptionTemplateLabel}} not found." }, "FORM-VALIDATION-DISPLAY-DIALOG": { "WARNING": "Oprez!", diff --git a/frontend/src/assets/i18n/pl.json b/frontend/src/assets/i18n/pl.json index 44a90191c..39ac709da 100644 --- a/frontend/src/assets/i18n/pl.json +++ b/frontend/src/assets/i18n/pl.json @@ -85,7 +85,7 @@ "DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS": "The description template type code you provided already exists. Please choose a different code.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND": "Description template type {{descriptionTemplateTypeLabel}} not found.", "REFERENCE-TYPE-IMPORT-NOT-FOUND": "Reference type {{referenceTypeCode}} not found.", - "DESCRIPTION-TEMPLATE-CODE-EXISTS": "The description template code you provided already exists. Please choose a different code." + "DESCRIPTION-TEMPLATE-IMPORT-NOT-FOUND": "Description template {{descriptionTemplateLabel}} not found." }, "FORM-VALIDATION-DISPLAY-DIALOG": { "WARNING": "Ostrzeżenie!", diff --git a/frontend/src/assets/i18n/pt.json b/frontend/src/assets/i18n/pt.json index e499fc5c4..b8c3ce02c 100644 --- a/frontend/src/assets/i18n/pt.json +++ b/frontend/src/assets/i18n/pt.json @@ -85,7 +85,7 @@ "DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS": "The description template type code you provided already exists. Please choose a different code.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND": "Description template type {{descriptionTemplateTypeLabel}} not found.", "REFERENCE-TYPE-IMPORT-NOT-FOUND": "Reference type {{referenceTypeCode}} not found.", - "DESCRIPTION-TEMPLATE-CODE-EXISTS": "The description template code you provided already exists. Please choose a different code." + "DESCRIPTION-TEMPLATE-IMPORT-NOT-FOUND": "Description template {{descriptionTemplateLabel}} not found." }, "FORM-VALIDATION-DISPLAY-DIALOG": { "WARNING": "Atenção!", diff --git a/frontend/src/assets/i18n/sk.json b/frontend/src/assets/i18n/sk.json index 1606fc393..1f34a055e 100644 --- a/frontend/src/assets/i18n/sk.json +++ b/frontend/src/assets/i18n/sk.json @@ -85,7 +85,7 @@ "DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS": "The description template type code you provided already exists. Please choose a different code.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND": "Description template type {{descriptionTemplateTypeLabel}} not found.", "REFERENCE-TYPE-IMPORT-NOT-FOUND": "Reference type {{referenceTypeCode}} not found.", - "DESCRIPTION-TEMPLATE-CODE-EXISTS": "The description template code you provided already exists. Please choose a different code." + "DESCRIPTION-TEMPLATE-IMPORT-NOT-FOUND": "Description template {{descriptionTemplateLabel}} not found." }, "FORM-VALIDATION-DISPLAY-DIALOG": { "WARNING": "Upozornenie!", diff --git a/frontend/src/assets/i18n/sr.json b/frontend/src/assets/i18n/sr.json index ed163e48b..245f043b1 100644 --- a/frontend/src/assets/i18n/sr.json +++ b/frontend/src/assets/i18n/sr.json @@ -85,7 +85,7 @@ "DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS": "The description template type code you provided already exists. Please choose a different code.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND": "Description template type {{descriptionTemplateTypeLabel}} not found.", "REFERENCE-TYPE-IMPORT-NOT-FOUND": "Reference type {{referenceTypeCode}} not found.", - "DESCRIPTION-TEMPLATE-CODE-EXISTS": "The description template code you provided already exists. Please choose a different code." + "DESCRIPTION-TEMPLATE-IMPORT-NOT-FOUND": "Description template {{descriptionTemplateLabel}} not found." }, "FORM-VALIDATION-DISPLAY-DIALOG": { "WARNING": "Oprez!", diff --git a/frontend/src/assets/i18n/tr.json b/frontend/src/assets/i18n/tr.json index f36aec9f1..7f85f178e 100644 --- a/frontend/src/assets/i18n/tr.json +++ b/frontend/src/assets/i18n/tr.json @@ -85,7 +85,7 @@ "DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS": "The description template type code you provided already exists. Please choose a different code.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND": "Description template type {{descriptionTemplateTypeLabel}} not found.", "REFERENCE-TYPE-IMPORT-NOT-FOUND": "Reference type {{referenceTypeCode}} not found.", - "DESCRIPTION-TEMPLATE-CODE-EXISTS": "The description template code you provided already exists. Please choose a different code." + "DESCRIPTION-TEMPLATE-IMPORT-NOT-FOUND": "Description template {{descriptionTemplateLabel}} not found." }, "FORM-VALIDATION-DISPLAY-DIALOG": { "WARNING": "Uyarı!", diff --git a/frontend/src/common/modules/errors/error-handling/http-error-handling.service.ts b/frontend/src/common/modules/errors/error-handling/http-error-handling.service.ts index 542a5a881..7d39e3612 100644 --- a/frontend/src/common/modules/errors/error-handling/http-error-handling.service.ts +++ b/frontend/src/common/modules/errors/error-handling/http-error-handling.service.ts @@ -23,6 +23,8 @@ export class HttpErrorHandlingService { this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND', { 'descriptionTemplateTypeLabel': errorResponse.error.error }), SnackBarNotificationLevel.Error); } if (errorResponse.error.code === ResponseErrorCode.referenceTypeImportNotFound){ this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.BACKEND-ERRORS.REFERENCE-TYPE-IMPORT-NOT-FOUND', { 'referenceTypeCode': errorResponse.error.error }), SnackBarNotificationLevel.Error); + } if (errorResponse.error.code === ResponseErrorCode.descriptionTemplateImportNotFound){ + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-IMPORT-NOT-FOUND', { 'descriptionTemplateLabel': errorResponse.error.error }), SnackBarNotificationLevel.Error); } else { this.uiNotificationService.snackBarNotification(ResponseErrorCodeHelper.getErrorMessageByBackendStatusCode(errorResponse.error.code, this.language), SnackBarNotificationLevel.Error); }