diff --git a/src/app/deposit/components/form/form.component.ts b/src/app/deposit/components/form/form.component.ts index 13305d1cf5f9a1878b5cad552e307ee3e57599ed..40239fac59a29b40b6ad25be7efc61ddd0cee962 100644 --- a/src/app/deposit/components/form/form.component.ts +++ b/src/app/deposit/components/form/form.component.ts @@ -1,5 +1,6 @@ import {ChangeDetectionStrategy, Component, Input} from "@angular/core"; import {FormBuilder, Validators} from "@angular/forms"; +import {DateUtil} from "@app/core/utils/date.util"; import { DepositsModel, LanguagesModel, @@ -9,8 +10,8 @@ import { SubmissionPoliciesModel, } from "@app/generated-api"; import {AbstractFormComponent} from "@app/shared/components/abstract-form/abstract-form.component"; +import {PropertyName} from "@app/shared/decorators/property-name.decorator"; import {BaseFormDefinition} from "@app/shared/models/base-form-definition.model"; -import {DateUtil} from "@app/core/utils/date.util"; import AccessModelEnum = DepositsModel.AccessModelEnum; @Component({ @@ -89,17 +90,17 @@ export class FormComponent extends AbstractFormComponent<DepositsModel> { } class FormComponentFormDefinition extends BaseFormDefinition { - organizationalUnitId: string = "organizationalUnitId"; - title: string = "title"; - description: string = "description"; - languageId: string = "languageId"; - publicationDate: string = "publicationDate"; - collectionBegin: string = "collectionBegin"; - collectionEnd: string = "collectionEnd"; - author: string = "author"; - accessLevel: string = "accessLevel"; - hasEmbargo: string = "hasEmbargo"; - licenseId: string = "licenseId"; - submissionPolicyId: string = "submissionPolicyId"; - preservationPolicyId: string = "preservationPolicyId"; + @PropertyName() organizationalUnitId: string; + @PropertyName() title: string; + @PropertyName() description: string; + @PropertyName() languageId: string; + @PropertyName() publicationDate: string; + @PropertyName() collectionBegin: string; + @PropertyName() collectionEnd: string; + @PropertyName() author: string; + @PropertyName() accessLevel: string; + @PropertyName() hasEmbargo: string; + @PropertyName() licenseId: string; + @PropertyName() submissionPolicyId: string; + @PropertyName() preservationPolicyId: string; } diff --git a/src/app/organizational-unit/components/form/form.component.ts b/src/app/organizational-unit/components/form/form.component.ts index aadbe706a6c70fe2e7f7bee9ea6c3de64ac581dd..dce6828e1e2b873b38c52bc83533a40af11b983a 100644 --- a/src/app/organizational-unit/components/form/form.component.ts +++ b/src/app/organizational-unit/components/form/form.component.ts @@ -1,10 +1,11 @@ import {ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges} from "@angular/core"; import {FormBuilder, Validators} from "@angular/forms"; +import {DateUtil} from "@app/core/utils/date.util"; import {OrganizationalUnitsModel, PreservationPoliciesModel, SubmissionPoliciesModel} from "@app/generated-api"; import {AbstractFormComponent} from "@app/shared/components/abstract-form/abstract-form.component"; +import {PropertyName} from "@app/shared/decorators/property-name.decorator"; import {ModelAttributeEnum} from "@app/shared/enums/model-attribute.enum"; import {BaseFormDefinition} from "@app/shared/models/base-form-definition.model"; -import {DateUtil} from "@app/core/utils/date.util"; import _ from "lodash"; @Component({ @@ -72,11 +73,11 @@ export class FormComponent extends AbstractFormComponent<OrganizationalUnitsMode } class FormComponentFormDefinition extends BaseFormDefinition { - name: string = "name"; - description: string = "description"; - isEmpty: string = "isEmpty"; - closingDate: string = "closingDate"; - openingDate: string = "openingDate"; - submissionPolicies: string = ModelAttributeEnum.submissionPolicies; - open: string = "open"; + @PropertyName() name: string; + @PropertyName() description: string; + @PropertyName() isEmpty: string; + @PropertyName() closingDate: string; + @PropertyName() openingDate: string; + @PropertyName() submissionPolicies: string; + @PropertyName() open: string; } diff --git a/src/app/shared/decorators/property-name.decorator.ts b/src/app/shared/decorators/property-name.decorator.ts new file mode 100644 index 0000000000000000000000000000000000000000..91681761c7da5c09fca113b222a385d9bb1658da --- /dev/null +++ b/src/app/shared/decorators/property-name.decorator.ts @@ -0,0 +1,5 @@ +export function PropertyName(prefix: string = "", suffix: string = ""): PropertyDecorator { + return (target: Object, propertyKey: string | symbol) => { + target[propertyKey] = prefix + propertyKey.toString() + suffix; + }; +} diff --git a/src/app/shared/models/base-form-definition.model.ts b/src/app/shared/models/base-form-definition.model.ts index ca26294af24e75a1ed86ccdd6f5718c330917224..3c9e8771aea73663a59beea306b149c9781a3737 100644 --- a/src/app/shared/models/base-form-definition.model.ts +++ b/src/app/shared/models/base-form-definition.model.ts @@ -1,3 +1,2 @@ export abstract class BaseFormDefinition { - }