Skip to content

Commit 744bcae

Browse files
committed
94031: Hide error messages of concat field inputs
Hint/error is shown at the group level, shouldn't be repeated in the inner inputs
1 parent 5a0ad41 commit 744bcae

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<div *ngIf="context?.index !== null
2323
&& (!showErrorMessages || errorMessages.length === 0)" class="clearfix w-100 mb-2"></div>
2424

25-
<div *ngIf="showErrorMessages" [id]="id + '_errors'"
25+
<div *ngIf="!model.hideRequiredHint && showErrorMessages" [id]="id + '_errors'"
2626
[ngClass]="[getClass('element', 'errors'), getClass('grid', 'errors')]">
2727
<small *ngFor="let message of errorMessages" class="invalid-feedback d-block">{{ message | translate: model.validators }}</small>
2828
</div>

src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-input.model.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface DsDynamicInputModelConfig extends DynamicInputModelConfig {
2727
hasSelectableMetadata: boolean;
2828
metadataValue?: FormFieldMetadataValueObject;
2929
isModelOfInnerForm?: boolean;
30-
30+
hideRequiredHint?: boolean;
3131
}
3232

3333
export class DsDynamicInputModel extends DynamicInputModel {
@@ -46,6 +46,7 @@ export class DsDynamicInputModel extends DynamicInputModel {
4646
@serializable() hasSelectableMetadata: boolean;
4747
@serializable() metadataValue: FormFieldMetadataValueObject;
4848
@serializable() isModelOfInnerForm: boolean;
49+
@serializable() hideRequiredHint?: boolean;
4950

5051

5152
constructor(config: DsDynamicInputModelConfig, layout?: DynamicFormControlLayout) {
@@ -61,6 +62,7 @@ export class DsDynamicInputModel extends DynamicInputModel {
6162
this.metadataValue = config.metadataValue;
6263
this.place = config.place;
6364
this.isModelOfInnerForm = (hasValue(config.isModelOfInnerForm) ? config.isModelOfInnerForm : false);
65+
this.hideRequiredHint = config.hideRequiredHint;
6466

6567
this.language = config.language;
6668
if (!this.language) {

src/app/shared/form/builder/parsers/concat-field-parser.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import {Inject} from '@angular/core';
22
import { FormFieldModel } from '../models/form-field.model';
33
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
4-
import {
5-
DynamicFormControlLayout,
6-
DynamicInputModel,
7-
DynamicInputModelConfig
8-
} from '@ng-dynamic-forms/core';
4+
import { DynamicFormControlLayout, } from '@ng-dynamic-forms/core';
95
import {
106
CONCAT_FIRST_INPUT_SUFFIX,
117
CONCAT_GROUP_SUFFIX,
@@ -22,6 +18,7 @@ import {
2218
PARSER_OPTIONS,
2319
SUBMISSION_ID
2420
} from './field-parser';
21+
import { DsDynamicInputModel, DsDynamicInputModelConfig } from '../ds-dynamic-form-ui/models/ds-dynamic-input.model';
2522

2623
export class ConcatFieldParser extends FieldParser {
2724

@@ -58,21 +55,24 @@ export class ConcatFieldParser extends FieldParser {
5855
concatGroup.group = [];
5956
concatGroup.separator = this.separator;
6057

61-
const input1ModelConfig: DynamicInputModelConfig = this.initModel(
58+
const input1ModelConfig: DsDynamicInputModelConfig = this.initModel(
6259
id + CONCAT_FIRST_INPUT_SUFFIX,
6360
false,
6461
true,
6562
true,
6663
false
6764
);
68-
const input2ModelConfig: DynamicInputModelConfig = this.initModel(
65+
const input2ModelConfig: DsDynamicInputModelConfig = this.initModel(
6966
id + CONCAT_SECOND_INPUT_SUFFIX,
7067
false,
7168
true,
7269
true,
7370
false
7471
);
7572

73+
input1ModelConfig.hideRequiredHint = true;
74+
input2ModelConfig.hideRequiredHint = true;
75+
7676
if (hasNoValue(concatGroup.hint) && hasValue(input1ModelConfig.hint) && hasNoValue(input2ModelConfig.hint)) {
7777
concatGroup.hint = input1ModelConfig.hint;
7878
input1ModelConfig.hint = undefined;
@@ -98,8 +98,8 @@ export class ConcatFieldParser extends FieldParser {
9898
input2ModelConfig.placeholder = placeholder[1];
9999
}
100100

101-
const model1 = new DynamicInputModel(input1ModelConfig, clsInput);
102-
const model2 = new DynamicInputModel(input2ModelConfig, clsInput);
101+
const model1 = new DsDynamicInputModel(input1ModelConfig, clsInput);
102+
const model2 = new DsDynamicInputModel(input2ModelConfig, clsInput);
103103
concatGroup.group.push(model1);
104104
concatGroup.group.push(model2);
105105

0 commit comments

Comments
 (0)