fix: set userSettings if does not exist

This commit is contained in:
Shariq Ansari 2024-12-29 22:37:08 +05:30
parent 2ffd729ece
commit 25d03c5b12
3 changed files with 16 additions and 3 deletions

View File

@ -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) {

View File

@ -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 },
}
}
})
}

View File

@ -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({