From 9d7f2b95e8357f00da17811d914385d84488e01e Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 22 Nov 2024 11:21:08 +0100 Subject: [PATCH] revert: VnVisibleColumn try catch --- src/components/VnTable/VnVisibleColumn.vue | 46 +++++++++++++--------- 1 file changed, 27 insertions(+), 19 deletions(-) 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 () => {