diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d4b274..45e76d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change history for ui-plugin-query-builder +## IN PROGRESS + +* [UIPQB-168](https://folio-org.atlassian.net/browse/UIPQB-168) Allow editing queries containing no fields. + ## [1.2.6](https://github.com/folio-org/ui-plugin-query-builder/tree/v1.2.6) (2024-12-11) * [UIPQB-128](https://folio-org.atlassian.net/browse/UIPQB-128) Invalid fields handling > Errors when query includes a deleted custom field. diff --git a/src/QueryBuilder/QueryBuilder/helpers/upgradeInitialValues.js b/src/QueryBuilder/QueryBuilder/helpers/upgradeInitialValues.js index 2481a05..b21d194 100644 --- a/src/QueryBuilder/QueryBuilder/helpers/upgradeInitialValues.js +++ b/src/QueryBuilder/QueryBuilder/helpers/upgradeInitialValues.js @@ -7,6 +7,8 @@ * queries edited/created here are the latest version, as we only have the latest version of entity types available. * In the future, it might be neat to send a request to /fqm/migrate if we see initialValues are out of date, but that's * outside the scope of UIPQB-125 as we already upgrade queries in the background in mod-lists. + * + * Returns undefined if there is no initial value (new query). */ export default function upgradeInitialValues(initialValues, entityType) { if (!initialValues) { @@ -17,6 +19,13 @@ export default function upgradeInitialValues(initialValues, entityType) { delete withoutVersion._version; + if (Object.keys(withoutVersion).length === 0) { + // if the query is {}, treat it as a new query + // (all add buttons are displayed on existing rows except for the "new list" state, so if we do + // not simulate this state, the user will be unable to add anything) + return undefined; + } + if (!entityType) { return withoutVersion; } diff --git a/src/QueryBuilder/QueryBuilder/helpers/valueBuilder.js b/src/QueryBuilder/QueryBuilder/helpers/valueBuilder.js index 5999fef..d030086 100644 --- a/src/QueryBuilder/QueryBuilder/helpers/valueBuilder.js +++ b/src/QueryBuilder/QueryBuilder/helpers/valueBuilder.js @@ -28,6 +28,7 @@ export const getFormattedUUID = (value, isInRelatedOperator) => { const formatDateToPreview = (dateString, intl, timezone) => { const formattedDate = dayjs.utc(dateString); + console.log('formatDateToPreview', dateString, 'timezone', timezone, 'formattedDate', formattedDate) if (formattedDate.isValid()) { return intl.formatDate(formattedDate.toDate(), { day: '2-digit', month: '2-digit', year: 'numeric', timeZone: timezone }); diff --git a/src/hooks/useTenantTimezone.js b/src/hooks/useTenantTimezone.js index 13b1c4a..1b51c1b 100644 --- a/src/hooks/useTenantTimezone.js +++ b/src/hooks/useTenantTimezone.js @@ -76,6 +76,8 @@ export default function useTenantTimezone() { refetchOnMount: false, }); + console.log('user timezone', userTimezone.data, 'tenant timezone', tenantTimezone.data); + return { userTimezone: userTimezone.data ?? tenantTimezone.data, tenantTimezone: tenantTimezone.data,