Skip to content

Commit e13ce5f

Browse files
[DURACOM-347] make placeholder presence in model configurable,fix wrongly used placeholder in date legend
1 parent 9ea3a67 commit e13ce5f

7 files changed

Lines changed: 18 additions & 10 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
@@ -2,7 +2,7 @@
22
[class.d-none]="model.hidden"
33
[formGroup]="group"
44
[ngClass]="[getClass('element', 'container'), getClass('grid', 'container')]">
5-
@if (!isCheckbox && hasLabel) {
5+
@if (!isCheckbox && hasLabel && !isDateField) {
66
<label
77
[id]="'label_' + model.id"
88
[for]="id"

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
324324
return this.model.type === DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX || this.model.type === DYNAMIC_FORM_CONTROL_TYPE_CUSTOM_SWITCH;
325325
}
326326

327+
get isDateField(): boolean {
328+
return this.model.type === DYNAMIC_FORM_CONTROL_TYPE_DSDATEPICKER;
329+
}
330+
327331
ngOnChanges(changes: SimpleChanges) {
328332
if (changes && !this.isRelationship && hasValue(this.group.get(this.model.id))) {
329333
super.ngOnChanges(changes);

src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
<fieldset class="d-flex justify-content-start flex-wrap gap-2">
33
@if (!model.repeatable) {
44
<legend [id]="'legend_' + model.id" [ngClass]="[getClass('element', 'label'), getClass('grid', 'label')]">
5-
{{ model.placeholder }}
6-
@if (model.required) {
7-
<span>*</span>
8-
}
9-
</legend>
10-
}
5+
{{model.label}} @if (model.required) {
6+
<span>*</span>
7+
}
8+
</legend>
9+
}
1110
<ds-number-picker
1211
tabindex="0"
1312
[id]="model.id + '_year'"

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export class DateFieldParser extends FieldParser {
1111

1212
public modelFactory(fieldValue?: FormFieldMetadataValueObject, label?: boolean): any {
1313
let malformedDate = false;
14-
const inputDateModelConfig: DynamicDsDateControlModelConfig = this.initModel(null, false, true);
15-
inputDateModelConfig.legend = this.configData.label;
14+
const inputDateModelConfig: DynamicDsDatePickerModelConfig = this.initModel(null, label, true);
15+
inputDateModelConfig.legend = this.configData.repeatable ? null : this.configData.label;
1616
inputDateModelConfig.disabled = inputDateModelConfig.readOnly;
1717
inputDateModelConfig.toggleIcon = 'fas fa-calendar';
1818
this.setValues(inputDateModelConfig as any, fieldValue);

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { VisibilityType } from './../../../../submission/sections/visibility-typ
3232
import { setLayout } from './parser.utils';
3333
import { ParserOptions } from './parser-options';
3434
import { ParserType } from './parser-type';
35+
import { environment } from "../../../../../environments/environment";
3536

3637
export const SUBMISSION_ID: InjectionToken<string> = new InjectionToken<string>('submissionId');
3738
export const CONFIG_DATA: InjectionToken<FormFieldModel> = new InjectionToken<FormFieldModel>('configData');
@@ -306,7 +307,9 @@ export abstract class FieldParser {
306307
if (hint) {
307308
controlModel.hint = this.configData.hints || '&nbsp;';
308309
}
309-
controlModel.placeholder = this.configData.label;
310+
if (!environment.submission.hidePlaceholderForBasicFields) {
311+
controlModel.placeholder = this.configData.label;
312+
}
310313

311314
if (this.configData.mandatory && setErrors) {
312315
this.markAsRequired(controlModel);

src/config/default-app-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ export class DefaultAppConfig implements AppConfig {
254254
],
255255
},
256256
},
257+
hidePlaceholderForBasicFields: true
257258
};
258259

259260
// Fallback language in which the UI will be rendered if the user's browser language is not an active language

src/config/submission-config.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ export interface SubmissionConfig extends Config {
3636
duplicateDetection: DuplicateDetectionConfig;
3737
typeBind: TypeBindConfig;
3838
icons: IconsConfig;
39+
hidePlaceholderForBasicFields?: boolean;
3940
}

0 commit comments

Comments
 (0)