diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 100% rename from .eslintrc.js rename to .eslintrc.cjs diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index f10dee61a..69e2b87d3 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -262,7 +262,7 @@ defineExpose({ \ No newline at end of file diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 218e28600..9eff3d322 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -7,8 +7,11 @@ import toDate from 'filters/toDate'; import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue'; const { t } = useI18n(); -const params = defineModel({ default: {}, required: true, type: Object }); const $props = defineProps({ + modelValue: { + type: Object, + default: () => {} + }, dataKey: { type: String, required: true, @@ -60,13 +63,14 @@ const emit = defineEmits(['refresh', 'clear', 'search', 'init', 'remove']); const arrayData = useArrayData($props.dataKey, { exprBuilder: $props.exprBuilder, searchUrl: $props.searchUrl, - navigate: {}, + navigate: $props.redirect ? {} : null, }); const route = useRoute(); const store = arrayData.store; - +const userParams = ref({}) onMounted(() => { - emit('init', { params: params.value }); + userParams.value = $props.modelValue ?? {} + emit('init', { params: userParams.value }); }); function setUserParams(watchedParams) { @@ -75,7 +79,7 @@ function setUserParams(watchedParams) { if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams); watchedParams = { ...watchedParams, ...watchedParams.filter?.where }; delete watchedParams.filter; - params.value = { ...params.value, ...watchedParams }; + userParams.value = { ...userParams.value, ...watchedParams }; } watch( @@ -94,12 +98,12 @@ async function search(evt) { store.filter.where = {}; isLoading.value = true; - const filter = { ...params.value }; + const filter = { ...userParams.value }; store.userParamsChanged = true; store.filter.skip = 0; store.skip = 0; - const { params: newParams } = await arrayData.addFilter({ params: params.value }); - params.value = newParams; + const { params: newParams } = await arrayData.addFilter({ params: userParams.value }); + userParams.value = newParams; if (!$props.showAll && !Object.values(filter).length) store.data = []; @@ -109,7 +113,7 @@ async function search(evt) { async function reload() { isLoading.value = true; - const params = Object.values(params.value).filter((param) => param); + const params = Object.values(userParams.value).filter((param) => param); await arrayData.fetch({ append: false }); if (!$props.showAll && !params.length) store.data = []; @@ -123,17 +127,17 @@ async function clearFilters() { store.filter.skip = 0; store.skip = 0; // Filtrar los params no removibles - const removableFilters = Object.keys(params.value).filter((param) => + const removableFilters = Object.keys(userParams.value).filter((param) => $props.unremovableParams.includes(param) ); const newParams = {}; // Conservar solo los params que no son removibles for (const key of removableFilters) { - newParams[key] = params.value[key]; + newParams[key] = userParams.value[key]; } - params.value = {}; - params.value = { ...newParams }; // Actualizar los params con los removibles - await arrayData.applyFilter({ params: params.value }); + userParams.value = {}; + userParams.value = { ...newParams }; // Actualizar los params con los removibles + await arrayData.applyFilter({ params: userParams.value }); if (!$props.showAll) { store.data = []; @@ -145,8 +149,8 @@ async function clearFilters() { const tagsList = computed(() => { const tagList = []; - for (const key of Object.keys(params.value)) { - const value = params.value[key]; + for (const key of Object.keys(userParams.value)) { + const value = userParams.value[key]; if (value == null || ($props.hiddenTags || []).includes(key)) continue; tagList.push({ label: key, value }); } @@ -161,7 +165,7 @@ const customTags = computed(() => ); async function remove(key) { - params.value[key] = undefined; + userParams.value[key] = undefined; search(); emit('remove', key); } @@ -236,7 +240,7 @@ function formatValue(value) { - +