0
0
Fork 0

Merge branch 'dev' of https://gitea.verdnatura.es/hyervoni/salix-front-mindshore into feature/SupplierSubmodules-2

This commit is contained in:
William Buezas 2024-01-05 11:07:22 -03:00
commit aa1f8c4f3b
1 changed files with 22 additions and 28 deletions

View File

@ -50,41 +50,35 @@ const toggleMarkAll = (val) => {
formattedCols.value.forEach((col) => (col.active = val)); formattedCols.value.forEach((col) => (col.active = val));
}; };
const getConfig = async (url, filter) => {
const response = await axios.get(url, {
params: { filter: filter },
});
return response.data && response.data.length > 0 ? response.data[0] : null;
};
const fetchViewConfigData = async () => { const fetchViewConfigData = async () => {
try { try {
const userConfigFilter = { const userConfigFilter = {
where: { where: { tableCode: $props.tableCode, userFk: user.id },
tableCode: $props.tableCode,
userFk: user.id,
},
}; };
const userConfig = await getConfig('UserConfigViews', userConfigFilter);
const userViewConfigResponse = await axios.get('UserConfigViews', { if (userConfig) {
params: { filter: userConfigFilter }, initialUserConfigViewData.value = userConfig;
}); setUserConfigViewData(userConfig.configuration);
if (userViewConfigResponse.data && userViewConfigResponse.data.length > 0) {
initialUserConfigViewData.value = userViewConfigResponse.data[0];
setUserConfigViewData(userViewConfigResponse.data[0].configuration);
return; return;
} }
const defaultConfigFilter = { const defaultConfigFilter = { where: { tableCode: $props.tableCode } };
where: { const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter);
tableCode: $props.tableCode,
},
};
const defaultViewConfigResponse = await axios.get('DefaultViewConfigs', { if (defaultConfig) {
params: { filter: defaultConfigFilter }, setUserConfigViewData(defaultConfig.columns);
});
if (defaultViewConfigResponse.data && defaultViewConfigResponse.data.length > 0) {
setUserConfigViewData(defaultViewConfigResponse.data[0].columns);
return; return;
} }
} catch (err) { } catch (err) {
console.err('Error fetching config view data'); console.err('Error fetching config view data', err);
} }
}; };
@ -127,17 +121,17 @@ const saveConfig = async () => {
} }
emitSavedConfig(); emitSavedConfig();
notify('globals.dataSaved', 'positive'); notify('globals.dataSaved', 'positive');
popupProxyRef.value.hide(); popupProxyRef.value.hide();
} catch (err) { } catch (err) {
console.error('Error saving user view config'); console.error('Error saving user view config', err);
} }
}; };
const emitSavedConfig = () => { const emitSavedConfig = () => {
const filteredCols = formattedCols.value.filter((col) => col.active); const activeColumns = formattedCols.value
const mappedCols = filteredCols.map((col) => col.name); .filter((col) => col.active)
emit('onConfigSaved', mappedCols); .map((col) => col.name);
emit('onConfigSaved', activeColumns);
}; };
onMounted(async () => { onMounted(async () => {