Skip to content

Commit

Permalink
feat: Add InlineError Property to global ConfigurationService (simple…
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjenni authored Aug 2, 2024
1 parent 1f10fb1 commit a52698d
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ <h2>Form</h2>
name="subformField1"
label="field 1"
[isrequired]="true"
[inlineerrorenabled]="false"
></sac-input>
<div ngModelGroup="MyGroup2">
<sac-input
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<div style="border: 1px solid" sacInheritForm #formaccess="sacinheritform">
<div
style="border: 1px solid"
sacInheritForm
sacFormLayout
[inlineError]="false"
#formaccess="sacinheritform"
>
<div>SubForm</div>
<div>
<sac-input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export class CustomConfigurationService extends SacAbstractConfigurationService
return 'CHF';
}

public get InlineErrorEnabled(): boolean {
return true;
}

public get LabelSizeLg(): number | null {
return 3;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ <h2>Form</h2>
name="subformField1"
label="field 1"
[isrequired]="true"
[inlineerrorenabled]="false"
></sac-input>
<div ngModelGroup="MyGroup2">
<sac-input
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<div style="border: 1px solid" sacInheritForm #formaccess="sacinheritform">
<div
style="border: 1px solid"
sacInheritForm
sacFormLayout
[inlineError]="false"
#formaccess="sacinheritform"
>
<div>SubForm</div>
<div>
<sac-input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export class CustomConfigurationService extends SacAbstractConfigurationService
return 'CHF';
}

public get InlineErrorEnabled(): boolean {
return true;
}

public get LabelSizeLg(): number | null {
return 3;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ <h2>Form</h2>
name="subformField1"
label="field 1"
[isrequired]="true"
[inlineerrorenabled]="false"
></sac-input>
<div ngModelGroup="MyGroup2">
<sac-input
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<div style="border: 1px solid" sacInheritForm #formaccess="sacinheritform">
<div
style="border: 1px solid"
sacInheritForm
sacFormLayout
[inlineError]="false"
#formaccess="sacinheritform"
>
<div>SubForm</div>
<div>
<sac-input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export class CustomConfigurationService extends SacAbstractConfigurationService
return 'CHF';
}

public get InlineErrorEnabled(): boolean {
return true;
}

public get LabelSizeLg(): number | null {
return 3;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,22 @@ export abstract class SacBaseModelControl<VALUE>
* 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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export abstract class SacAbstractConfigurationService
* @inheritdoc
*/
public abstract get CurrencyText(): string;
/**
* @inheritdoc
*/
public abstract get InlineErrorEnabled(): boolean;
/**
* @inheritdoc
*/
Expand Down Expand Up @@ -70,6 +74,13 @@ export class SacDefaultConfigurationService extends SacAbstractConfigurationServ
return 'CHF';
}

/**
* @inheritdoc
*/
public get InlineErrorEnabled(): boolean {
return true;
}

/**
* @inheritdoc
*/
Expand Down

0 comments on commit a52698d

Please sign in to comment.