forked from verdnatura/salix-front
Merge branch 'dev' of https://gitea.verdnatura.es/hyervoni/salix-front-mindshore into feature/SupplierSubmodules-2
This commit is contained in:
commit
aa1f8c4f3b
|
@ -50,41 +50,35 @@ const toggleMarkAll = (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 () => {
|
||||
try {
|
||||
const userConfigFilter = {
|
||||
where: {
|
||||
tableCode: $props.tableCode,
|
||||
userFk: user.id,
|
||||
},
|
||||
where: { tableCode: $props.tableCode, userFk: user.id },
|
||||
};
|
||||
const userConfig = await getConfig('UserConfigViews', userConfigFilter);
|
||||
|
||||
const userViewConfigResponse = await axios.get('UserConfigViews', {
|
||||
params: { filter: userConfigFilter },
|
||||
});
|
||||
|
||||
if (userViewConfigResponse.data && userViewConfigResponse.data.length > 0) {
|
||||
initialUserConfigViewData.value = userViewConfigResponse.data[0];
|
||||
setUserConfigViewData(userViewConfigResponse.data[0].configuration);
|
||||
if (userConfig) {
|
||||
initialUserConfigViewData.value = userConfig;
|
||||
setUserConfigViewData(userConfig.configuration);
|
||||
return;
|
||||
}
|
||||
|
||||
const defaultConfigFilter = {
|
||||
where: {
|
||||
tableCode: $props.tableCode,
|
||||
},
|
||||
};
|
||||
const defaultConfigFilter = { where: { tableCode: $props.tableCode } };
|
||||
const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter);
|
||||
|
||||
const defaultViewConfigResponse = await axios.get('DefaultViewConfigs', {
|
||||
params: { filter: defaultConfigFilter },
|
||||
});
|
||||
|
||||
if (defaultViewConfigResponse.data && defaultViewConfigResponse.data.length > 0) {
|
||||
setUserConfigViewData(defaultViewConfigResponse.data[0].columns);
|
||||
if (defaultConfig) {
|
||||
setUserConfigViewData(defaultConfig.columns);
|
||||
return;
|
||||
}
|
||||
} 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();
|
||||
notify('globals.dataSaved', 'positive');
|
||||
|
||||
popupProxyRef.value.hide();
|
||||
} catch (err) {
|
||||
console.error('Error saving user view config');
|
||||
console.error('Error saving user view config', err);
|
||||
}
|
||||
};
|
||||
|
||||
const emitSavedConfig = () => {
|
||||
const filteredCols = formattedCols.value.filter((col) => col.active);
|
||||
const mappedCols = filteredCols.map((col) => col.name);
|
||||
emit('onConfigSaved', mappedCols);
|
||||
const activeColumns = formattedCols.value
|
||||
.filter((col) => col.active)
|
||||
.map((col) => col.name);
|
||||
emit('onConfigSaved', activeColumns);
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
|
|
Loading…
Reference in New Issue