diff --git a/src/components/VnTable/VnVisibleColumn.vue b/src/components/VnTable/VnVisibleColumn.vue index 57b1fdf21..f5c3458cd 100644 --- a/src/components/VnTable/VnVisibleColumn.vue +++ b/src/components/VnTable/VnVisibleColumn.vue @@ -57,27 +57,31 @@ async function getConfig(url, filter) { } async function fetchViewConfigData() { - const defaultFilter = { - where: { tableCode: $props.tableCode }, - }; + try { + const defaultFilter = { + where: { tableCode: $props.tableCode }, + }; - const userConfig = await getConfig('UserConfigViews', { - where: { - ...defaultFilter.where, - ...{ userFk: user.value.id }, - }, - }); + const userConfig = await getConfig('UserConfigViews', { + where: { + ...defaultFilter.where, + ...{ userFk: user.value.id }, + }, + }); - if (userConfig) { - initialUserConfigViewData.value = userConfig; - setUserConfigViewData(userConfig.configuration); - return; - } + if (userConfig) { + initialUserConfigViewData.value = userConfig; + setUserConfigViewData(userConfig.configuration); + return; + } - const defaultConfig = await getConfig('DefaultViewConfigs', defaultFilter); - if (defaultConfig) { - setUserConfigViewData(defaultConfig.columns); - return; + const defaultConfig = await getConfig('DefaultViewConfigs', defaultFilter); + if (defaultConfig) { + setUserConfigViewData(defaultConfig.columns); + return; + } + } catch (err) { + console.error('Error fetching config view data', err); } } @@ -88,6 +92,7 @@ async function saveConfig() { setUserConfigViewData(configuration, true); if (!$props.tableCode) return popupProxyRef.value.hide(); + try { const params = {}; // Si existe una view config del usuario hacemos un update si no la creamos if (initialUserConfigViewData.value) { @@ -118,7 +123,10 @@ async function saveConfig() { } notify('globals.dataSaved', 'positive'); popupProxyRef.value.hide(); - + } catch (err) { + console.error('Error saving user view config', err); + notify('errors.writeRequest', 'negative'); + } } onMounted(async () => { diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 84f2b43d7..812ba908d 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -74,6 +74,9 @@ const arrayData = useArrayData($props.dataKey, { const route = useRoute(); const store = arrayData.store; const userParams = ref({}); + +defineExpose({ search, sanitizer, params: userParams }); + onMounted(() => { userParams.value = $props.modelValue ?? {}; emit('init', { params: userParams.value }); @@ -197,7 +200,7 @@ const customTags = computed(() => async function remove(key) { userParams.value[key] = undefined; - search(); + await search(); emit('remove', key); emit('update:modelValue', userParams.value); } diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index ac0c1da08..da62eee3e 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -87,7 +87,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { const params = { filter }; Object.assign(params, userParams); - params.filter.skip = store.skip; + if (params.filter) params.filter.skip = store.skip; if (store?.order && typeof store?.order == 'string') store.order = [store.order]; if (store.order?.length) params.filter.order = [...store.order]; else delete params.filter.order; diff --git a/src/pages/Order/Card/OrderCatalog.vue b/src/pages/Order/Card/OrderCatalog.vue index 66a1a132d..90bce38fd 100644 --- a/src/pages/Order/Card/OrderCatalog.vue +++ b/src/pages/Order/Card/OrderCatalog.vue @@ -1,14 +1,13 @@