From 87a1c4d2ff0465e02a638ca8e3c4fcfd6741416c Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 31 Jul 2023 14:30:15 +0200 Subject: [PATCH] feat(core): EditDescriptionOnly field to display additional text in forms (#1945) Co-authored-by: Simon --- src/app/core/config/config-fix.ts | 5 +++- src/app/core/core-components.ts | 19 ++++++++++----- .../edit-description-only.component.spec.ts | 23 +++++++++++++++++++ .../edit-description-only.component.ts | 13 +++++++++++ 4 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 src/app/core/entity-components/entity-utils/dynamic-form-components/edit-description-only/edit-description-only.component.spec.ts create mode 100644 src/app/core/entity-components/entity-utils/dynamic-form-components/edit-description-only/edit-description-only.component.ts diff --git a/src/app/core/config/config-fix.ts b/src/app/core/config/config-fix.ts index 5887f767e8..e837fc8b7e 100644 --- a/src/app/core/config/config-fix.ts +++ b/src/app/core/config/config-fix.ts @@ -664,7 +664,10 @@ export const defaultJsonConfig = { "config": { "cols": [ ["health_bloodGroup"], - ["health_lastDentalCheckup"] + [ + { "id": "_description_health", "edit": "EditDescriptionOnly", "label": $localize`:description section:Health checkups are to be done regularly, at least every 6 months according to the program guidelines.`}, + "health_lastDentalCheckup" + ] ] } }, diff --git a/src/app/core/core-components.ts b/src/app/core/core-components.ts index decf964c2d..caa4865db2 100644 --- a/src/app/core/core-components.ts +++ b/src/app/core/core-components.ts @@ -26,7 +26,7 @@ export const coreComponents: ComponentTuple[] = [ "Form", () => import("./entity-components/entity-details/form/form.component").then( - (c) => c.FormComponent + (c) => c.FormComponent, ), ], [ @@ -113,6 +113,13 @@ export const coreComponents: ComponentTuple[] = [ "./entity-components/entity-utils/dynamic-form-components/edit-number/edit-number.component" ).then((c) => c.EditNumberComponent), ], + [ + "EditDescriptionOnly", + () => + import( + "./entity-components/entity-utils/dynamic-form-components/edit-description-only/edit-description-only.component" + ).then((c) => c.EditDescriptionOnlyComponent), + ], [ "DisplayCheckmark", () => @@ -173,21 +180,21 @@ export const coreComponents: ComponentTuple[] = [ "UserSecurity", () => import("./user/user-security/user-security.component").then( - (c) => c.UserSecurityComponent + (c) => c.UserSecurityComponent, ), ], [ "Dashboard", () => import("./dashboard/dashboard/dashboard.component").then( - (c) => c.DashboardComponent + (c) => c.DashboardComponent, ), ], [ "EntityList", () => import("./entity-components/entity-list/entity-list.component").then( - (c) => c.EntityListComponent + (c) => c.EntityListComponent, ), ], [ @@ -205,14 +212,14 @@ export const coreComponents: ComponentTuple[] = [ "ConfigImport", () => import("./config-setup/config-import/config-import.component").then( - (c) => c.ConfigImportComponent + (c) => c.ConfigImportComponent, ), ], [ "MarkdownPage", () => import("./markdown-page/markdown-page/markdown-page.component").then( - (c) => c.MarkdownPageComponent + (c) => c.MarkdownPageComponent, ), ], [ diff --git a/src/app/core/entity-components/entity-utils/dynamic-form-components/edit-description-only/edit-description-only.component.spec.ts b/src/app/core/entity-components/entity-utils/dynamic-form-components/edit-description-only/edit-description-only.component.spec.ts new file mode 100644 index 0000000000..1661e6a37f --- /dev/null +++ b/src/app/core/entity-components/entity-utils/dynamic-form-components/edit-description-only/edit-description-only.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { EditDescriptionOnlyComponent } from "./edit-description-only.component"; + +describe("EditDescriptionOnlyComponent", () => { + let component: EditDescriptionOnlyComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [EditDescriptionOnlyComponent], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(EditDescriptionOnlyComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it("should create", () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/core/entity-components/entity-utils/dynamic-form-components/edit-description-only/edit-description-only.component.ts b/src/app/core/entity-components/entity-utils/dynamic-form-components/edit-description-only/edit-description-only.component.ts new file mode 100644 index 0000000000..b400107471 --- /dev/null +++ b/src/app/core/entity-components/entity-utils/dynamic-form-components/edit-description-only/edit-description-only.component.ts @@ -0,0 +1,13 @@ +import { Component, Input } from "@angular/core"; +import { DynamicComponent } from "../../../../view/dynamic-components/dynamic-component.decorator"; +import { FormFieldConfig } from "../../../entity-form/entity-form/FormConfig"; + +@DynamicComponent("EditDescriptionOnly") +@Component({ + selector: "app-edit-description-only", + template: "{{formFieldConfig?.label}}", + standalone: true, +}) +export class EditDescriptionOnlyComponent { + @Input() formFieldConfig: FormFieldConfig; +}