Skip to content

Commit 8a2aa46

Browse files
[DURACOM-347] make placeholder presence in model configurable,fix wrongly used placeholder in date legend
1 parent f95596b commit 8a2aa46

7 files changed

Lines changed: 14 additions & 5 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
@@ -301,6 +301,10 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
301301
return this.model.type === DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX || this.model.type === DYNAMIC_FORM_CONTROL_TYPE_CUSTOM_SWITCH;
302302
}
303303

304+
get isDateField(): boolean {
305+
return this.model.type === DYNAMIC_FORM_CONTROL_TYPE_DSDATEPICKER;
306+
}
307+
304308
ngOnChanges(changes: SimpleChanges) {
305309
if (changes && !this.isRelationship && hasValue(this.group.get(this.model.id))) {
306310
super.ngOnChanges(changes);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<fieldset class="d-flex">
33
@if (!model.repeatable) {
44
<legend [id]="'legend_' + model.id" [ngClass]="[getClass('element', 'label'), getClass('grid', 'label')]">
5-
{{model.placeholder}} @if (model.required) {
5+
{{model.label}} @if (model.required) {
66
<span>*</span>
77
}
88
</legend>

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
@@ -36,6 +36,7 @@ import { VisibilityType } from './../../../../submission/sections/visibility-typ
3636
import { setLayout } from './parser.utils';
3737
import { ParserOptions } from './parser-options';
3838
import { ParserType } from './parser-type';
39+
import { environment } from "../../../../../environments/environment";
3940

4041
export const SUBMISSION_ID: InjectionToken<string> = new InjectionToken<string>('submissionId');
4142
export const CONFIG_DATA: InjectionToken<FormFieldModel> = new InjectionToken<FormFieldModel>('configData');
@@ -310,7 +311,9 @@ export abstract class FieldParser {
310311
if (hint) {
311312
controlModel.hint = this.configData.hints || '&nbsp;';
312313
}
313-
controlModel.placeholder = this.configData.label;
314+
if (!environment.submission.hidePlaceholderForBasicFields) {
315+
controlModel.placeholder = this.configData.label;
316+
}
314317

315318
if (this.configData.mandatory && setErrors) {
316319
this.markAsRequired(controlModel);

src/config/default-app-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ export class DefaultAppConfig implements AppConfig {
250250
],
251251
},
252252
},
253+
hidePlaceholderForBasicFields: true
253254
};
254255

255256
// Default 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)