diff --git a/src/components/common/VnLog.vue b/src/components/common/VnLog.vue index ec72c799c..0f5a162e3 100644 --- a/src/components/common/VnLog.vue +++ b/src/components/common/VnLog.vue @@ -15,6 +15,7 @@ import VnUserLink from '../ui/VnUserLink.vue'; import VnPaginate from '../ui/VnPaginate.vue'; import VnLogFilter from 'src/components/common/VnLogFilter.vue'; import RightMenu from './RightMenu.vue'; +import { useFilterParams } from 'src/composables/useFilterParams'; const stateStore = useStateStore(); const validationsStore = useValidator(); @@ -71,8 +72,8 @@ const filter = { }; const paginate = ref(); -const searchInput = ref(); -const selectedFilters = ref({}); +const dataKey = computed(() => `${props.model}Log`); +const userParams = ref(useFilterParams(dataKey.value).params); let validations = models; let pointRecord = ref(null); @@ -102,8 +103,6 @@ const validDate = new RegExp( /T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/.source, ); -const dataKey = computed(() => `${props.model}Log`); - function castJsonValue(value) { return typeof value === 'string' && validDate.test(value) ? new Date(value) : value; } @@ -216,29 +215,14 @@ async function setLogTree(data) { function filterByRecord(modelLog) { byRecord.value = true; const { id, model } = modelLog; - - searchInput.value = id; - selectedFilters.value.changedModelId = id; - selectedFilters.value.changedModel = model; - applyFilter(); + applyFilter({ changedModelId: id, changedModel: model }); } -async function applyFilter() { - filter.where = { and: [] }; - if ( - !selectedFilters.value.changedModel || - (!selectedFilters.value.changedModelValue && - !selectedFilters.value.changedModelId) - ) - byRecord.value = false; - - if (!byRecord.value) filter.where.and.push({ originFk: route.params.id }); - - if (Object.keys(selectedFilters.value).length) { - filter.where.and.push(selectedFilters.value); - } - - paginate.value.fetch({ filter }); +async function applyFilter(params = {}) { + paginate.value.arrayData.applyFilter({ + filter: {}, + params: { originFk: route.params.id, ...params }, + }); } function exprBuilder(param, value) { @@ -272,9 +256,7 @@ function exprBuilder(param, value) { } async function clearFilter() { - selectedFilters.value = {}; byRecord.value = false; - searchInput.value = undefined; await applyFilter(); } @@ -600,7 +582,7 @@ watch( { - + - + {{ t('Applied filters') }} @@ -246,7 +241,7 @@ const getLocale = (label) => { - +