Skip to content

Commit a194bec

Browse files
vaszigsergei-maertens
authored andcommitted
[#3382] Fixed translation warnings for date,datetime placeholders
In the new form builder (see types as well) Date and Datetime schemas do not have placeholder as a property. So, this is handled here for the warnings in the admin. Co-authored-by: @Viicos
1 parent 4343365 commit a194bec

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/openforms/js/components/formio_builder/translation.js

+4
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ export const extractComponentLiterals = component => {
124124
...ALWAYS_TRANSLATABLE_PROPERTIES,
125125
...(ADDITIONAL_PROPERTIES_BY_COMPONENT_TYPE[component.type] || []),
126126
];
127+
128+
const isDateOrDatetimeComponent = ['date', 'datetime'].includes(component.type);
127129
const literals = allTranslatableProperties
130+
// Do not show warnings for date/datetime placeholders, they are not translatable:
131+
.filter(property => (isDateOrDatetimeComponent ? property !== 'placeholder' : property))
128132
.filter(property => !isRegex(property))
129133
.map(property => get(component, property));
130134

src/openforms/js/components/formio_builder/translation.spec.js

+28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
clearObsoleteLiterals,
3+
extractComponentLiterals,
34
handleComponentValueLiterals,
45
isTranslatableProperty,
56
persistComponentTranslations,
@@ -195,3 +196,30 @@ describe('Component value label literals', () => {
195196
]);
196197
});
197198
});
199+
200+
describe('Checking date/datetime translation literals', () => {
201+
it('removes placeholder translation from date and datetime', () => {
202+
const dateComponent = {
203+
type: 'date',
204+
key: 'date',
205+
label: 'Date',
206+
description: '',
207+
placeholder: 'dd-mm-yyyy',
208+
tooltip: '',
209+
format: 'dd-MM-yyyy',
210+
};
211+
212+
const dateTimeComponent = {
213+
type: 'datetime',
214+
key: 'dateTime',
215+
label: 'Date / Time',
216+
description: '',
217+
placeholder: 'dd-MM-yyyy HH:mm',
218+
tooltip: '',
219+
format: 'dd-MM-yyyy HH:mm',
220+
};
221+
222+
expect(extractComponentLiterals(dateComponent)).toStrictEqual(['Date']);
223+
expect(extractComponentLiterals(dateTimeComponent)).toStrictEqual(['Date / Time']);
224+
});
225+
});

0 commit comments

Comments
 (0)