Skip to content

Commit

Permalink
Fix #3439: form field regression.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnXLivingston authored and jcbrand committed Jul 19, 2024
1 parent 183afab commit 1afde2a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
"max-depth": "error",
"max-len": ["error", {
"code": 120,
"comments": 120,
"ignoreStrings": true,
"ignoreComments": true,
"ignoreUrls": true
}],
"max-lines": "off",
Expand Down
3 changes: 2 additions & 1 deletion src/headless/shared/parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ export function isArchived (original_stanza) {
* @typedef {'list-single'|'list-multi'} XFormListTypes
* @typedef {'jid-single'|'jid-multi'} XFormJIDTypes
* @typedef {'text-multi'|'text-private'|'text-single'} XFormTextTypes
* @typedef {XFormListTypes|XFormJIDTypes|XFormTextTypes|'fixed'|'boolean'|'url'|'hidden'} XFormFieldTypes
* @typedef {'date'|'datetime'} XFormDateTypes
* @typedef {XFormListTypes|XFormJIDTypes|XFormTextTypes|XFormDateTypes|'fixed'|'boolean'|'url'|'hidden'} XFormFieldTypes
*
* @typedef {Object} XFormField
* @property {string} var
Expand Down
3 changes: 2 additions & 1 deletion src/headless/types/shared/parsers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export type XFormCaptchaURI = {
export type XFormListTypes = 'list-single' | 'list-multi';
export type XFormJIDTypes = 'jid-single' | 'jid-multi';
export type XFormTextTypes = 'text-multi' | 'text-private' | 'text-single';
export type XFormFieldTypes = XFormListTypes | XFormJIDTypes | XFormTextTypes | 'fixed' | 'boolean' | 'url' | 'hidden';
export type XFormDateTypes = 'date' | 'datetime';
export type XFormFieldTypes = XFormListTypes | XFormJIDTypes | XFormTextTypes | XFormDateTypes | 'fixed' | 'boolean' | 'url' | 'hidden';
export type XFormField = {
var: string;
label: string;
Expand Down
19 changes: 10 additions & 9 deletions src/utils/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,16 +510,17 @@ export function xFormField2TemplateResult(xfield, options = {}) {
});
} else if (xfield.type !== 'hidden' && (xfield.var === 'url' || xfield.var === 'uri' || isValidURL(xfield.value))) {
return tplFormUrl(xfield);

} else {
} else if (xfield.type === 'datetime' || xfield.type === 'date') {
const date = xfield.value ? dayjs(xfield.value) : null;
if (date?.isValid()) {
return tplDateInput({
...default_vals,
...xfield,
value: date.format('YYYY-MM-DDTHH:mm:ss'),
});
}
const value = date?.isValid()
? (xfield.type === 'datetime' ? date.format('YYYY-MM-DDTHH:mm:ss') : date.format('YYYY-MM-DD'))
: null;
return tplDateInput({
...default_vals,
...xfield,
value
});
} else {

return tplFormInput({
...default_vals,
Expand Down

0 comments on commit 1afde2a

Please sign in to comment.