From bd3c685044aa71bfa5e7b511cebc8b47b86b1395 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sun, 29 Dec 2024 22:37:08 +0530 Subject: [PATCH] fix: set userSettings if does not exist --- frontend/src/components/Controls/Grid.vue | 4 +++- .../src/components/Controls/GridFieldsEditorModal.vue | 9 ++++++++- frontend/src/stores/meta.js | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Controls/Grid.vue b/frontend/src/components/Controls/Grid.vue index 9aff91332..efa22317f 100644 --- a/frontend/src/components/Controls/Grid.vue +++ b/frontend/src/components/Controls/Grid.vue @@ -251,7 +251,9 @@ const fields = computed(() => { ) return d } - return gridFields?.map((f) => getFieldObj(f)) || [] + return ( + gridFields?.filter((f) => f.in_list_view).map((f) => getFieldObj(f)) || [] + ) }) function getFieldObj(field) { diff --git a/frontend/src/components/Controls/GridFieldsEditorModal.vue b/frontend/src/components/Controls/GridFieldsEditorModal.vue index 28639ad08..b76a74012 100644 --- a/frontend/src/components/Controls/GridFieldsEditorModal.vue +++ b/frontend/src/components/Controls/GridFieldsEditorModal.vue @@ -176,7 +176,14 @@ function update() { saveUserSettings(props.parentDoctype, 'GridView', updateFields, () => { loading.value = false show.value = false - userSettings[props.parentDoctype]['GridView'][props.doctype] = updateFields + if (userSettings[props.parentDoctype]?['GridView']) { + userSettings[props.parentDoctype]['GridView'][props.doctype] = + updateFields + } else { + userSettings[props.parentDoctype] = { + GridView: { [props.doctype]: updateFields }, + } + } }) } diff --git a/frontend/src/stores/meta.js b/frontend/src/stores/meta.js index 8b34777fd..6042ba817 100644 --- a/frontend/src/stores/meta.js +++ b/frontend/src/stores/meta.js @@ -80,7 +80,11 @@ export function getMeta(doctype) { let oldUserSettings = userSettings[parentDoctype] let newUserSettings = JSON.parse(JSON.stringify(oldUserSettings)) - newUserSettings[key][doctype] = value + if (newUserSettings[key] === undefined) { + newUserSettings[key] = { [doctype]: value } + } else { + newUserSettings[key][doctype] = value + } if (JSON.stringify(oldUserSettings) !== JSON.stringify(newUserSettings)) { return createResource({