Skip to content

Commit

Permalink
[UIPQB-168] Allow editing queries containing no fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ncovercash committed Dec 13, 2024
1 parent 3414815 commit 3a6240f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
9 changes: 9 additions & 0 deletions src/QueryBuilder/QueryBuilder/helpers/upgradeInitialValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/QueryBuilder/QueryBuilder/helpers/valueBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 31 in src/QueryBuilder/QueryBuilder/helpers/valueBuilder.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

Expected blank line before this statement

Check warning on line 31 in src/QueryBuilder/QueryBuilder/helpers/valueBuilder.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

Unexpected console statement

Check failure on line 31 in src/QueryBuilder/QueryBuilder/helpers/valueBuilder.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

Missing semicolon

if (formattedDate.isValid()) {
return intl.formatDate(formattedDate.toDate(), { day: '2-digit', month: '2-digit', year: 'numeric', timeZone: timezone });
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useTenantTimezone.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export default function useTenantTimezone() {
refetchOnMount: false,
});

console.log('user timezone', userTimezone.data, 'tenant timezone', tenantTimezone.data);

Check warning on line 79 in src/hooks/useTenantTimezone.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

Unexpected console statement

return {
userTimezone: userTimezone.data ?? tenantTimezone.data,
tenantTimezone: tenantTimezone.data,
Expand Down

0 comments on commit 3a6240f

Please sign in to comment.