From f6740c80a78e7b27a136bd0938aaf7f2f10cac06 Mon Sep 17 00:00:00 2001 From: Philipp Jenni Date: Fri, 2 Aug 2024 17:57:45 +0200 Subject: [PATCH] feat: Add InlineError Property to global ConfigurationService (#104) (#116) --- .../src/app/form/form.component.html | 1 + .../src/app/form/subform.component.html | 8 +++++++- .../services/customconfiguration.service.ts | 4 ++++ .../src/app/form/form.component.html | 1 + .../src/app/form/subform.component.html | 8 +++++++- .../services/customconfiguration.service.ts | 4 ++++ .../src/app/form/form.component.html | 1 + .../src/app/form/subform.component.html | 8 +++++++- .../services/customconfiguration.service.ts | 4 ++++ .../sac-common/src/common/basemodelcontrol.ts | 19 ++++++++++++------- .../src/controls/layout/formlayout.ts | 4 ++-- .../interfaces/ISacConfigurationService.ts | 4 ++++ .../src/services/sac-configuration.service.md | 3 +++ .../src/services/sac-configuration.service.ts | 11 +++++++++++ 14 files changed, 68 insertions(+), 12 deletions(-) diff --git a/ch.jnetwork.sac-controls/projects/demo-bootstrap3/src/app/form/form.component.html b/ch.jnetwork.sac-controls/projects/demo-bootstrap3/src/app/form/form.component.html index e31c4690f..7c069d448 100644 --- a/ch.jnetwork.sac-controls/projects/demo-bootstrap3/src/app/form/form.component.html +++ b/ch.jnetwork.sac-controls/projects/demo-bootstrap3/src/app/form/form.component.html @@ -15,6 +15,7 @@

Form

name="subformField1" label="field 1" [isrequired]="true" + [inlineerrorenabled]="false" >
+
SubForm
Form name="subformField1" label="field 1" [isrequired]="true" + [inlineerrorenabled]="false" >
+
SubForm
Form name="subformField1" label="field 1" [isrequired]="true" + [inlineerrorenabled]="false" >
+
SubForm
* Returns whether the inline error messages are active for this control. */ public get isinlineerrorenabled(): boolean { + if (this._inlineerrorenabled !== null) { + return this._inlineerrorenabled; + } + if ( - this.formlayout?.IsInlineErrorEnabled === null || - this.formlayout?.IsInlineErrorEnabled === undefined + this.formlayout !== null && + this.formlayout.IsInlineErrorEnabled !== null ) { - return this._inlineerrorenabled; + return this.formlayout?.IsInlineErrorEnabled; } - return ( - this.formlayout.IsInlineErrorEnabled !== false && - this._inlineerrorenabled !== false - ); + if (this.configurationService.InlineErrorEnabled !== null) { + return this.configurationService.InlineErrorEnabled; + } + + return true; } /** diff --git a/ch.jnetwork.sac-controls/projects/sac-common/src/controls/layout/formlayout.ts b/ch.jnetwork.sac-controls/projects/sac-common/src/controls/layout/formlayout.ts index 9e0db516b..559028cb6 100644 --- a/ch.jnetwork.sac-controls/projects/sac-common/src/controls/layout/formlayout.ts +++ b/ch.jnetwork.sac-controls/projects/sac-common/src/controls/layout/formlayout.ts @@ -15,7 +15,7 @@ export class SacFormLayoutCommon { /** * defines that error messages are displayed under the controls */ - @Input() public inlineError: boolean = true; + @Input() public inlineError: boolean | null = null; /** * defines that the labels are displayed as adaptive labels */ @@ -59,7 +59,7 @@ export class SacFormLayoutCommon { * Returns whether the inline error messages for the form are active. */ public get IsInlineErrorEnabled(): boolean { - return this.inlineError !== false; + return this.inlineError; } // #endregion Public Getters And Setters diff --git a/ch.jnetwork.sac-controls/projects/sac-common/src/interfaces/ISacConfigurationService.ts b/ch.jnetwork.sac-controls/projects/sac-common/src/interfaces/ISacConfigurationService.ts index 5b3841a26..dde0d0b9c 100644 --- a/ch.jnetwork.sac-controls/projects/sac-common/src/interfaces/ISacConfigurationService.ts +++ b/ch.jnetwork.sac-controls/projects/sac-common/src/interfaces/ISacConfigurationService.ts @@ -14,6 +14,10 @@ export interface ISacConfigurationService { * Defines the standard text for currencies. e.g. $, €, CHF */ get CurrencyText(): string; + /** + * Activates the error messages below the controls + */ + InlineErrorEnabled: boolean; /** * default labe size for large devices */ diff --git a/ch.jnetwork.sac-controls/projects/sac-common/src/services/sac-configuration.service.md b/ch.jnetwork.sac-controls/projects/sac-common/src/services/sac-configuration.service.md index 825026b08..c9d487203 100644 --- a/ch.jnetwork.sac-controls/projects/sac-common/src/services/sac-configuration.service.md +++ b/ch.jnetwork.sac-controls/projects/sac-common/src/services/sac-configuration.service.md @@ -19,6 +19,9 @@ export class CustomConfigurationService extends SacAbstractConfigurationService get CurrencyText(): string { return 'CHF'; } + get InlineErrorEnabled(): boolean { + return true; + } get LabelSizeLg(): number | null { return 3; } diff --git a/ch.jnetwork.sac-controls/projects/sac-common/src/services/sac-configuration.service.ts b/ch.jnetwork.sac-controls/projects/sac-common/src/services/sac-configuration.service.ts index 69361ed94..bab6e84ac 100644 --- a/ch.jnetwork.sac-controls/projects/sac-common/src/services/sac-configuration.service.ts +++ b/ch.jnetwork.sac-controls/projects/sac-common/src/services/sac-configuration.service.ts @@ -21,6 +21,10 @@ export abstract class SacAbstractConfigurationService * @inheritdoc */ public abstract get CurrencyText(): string; + /** + * @inheritdoc + */ + public abstract get InlineErrorEnabled(): boolean; /** * @inheritdoc */ @@ -70,6 +74,13 @@ export class SacDefaultConfigurationService extends SacAbstractConfigurationServ return 'CHF'; } + /** + * @inheritdoc + */ + public get InlineErrorEnabled(): boolean { + return true; + } + /** * @inheritdoc */