refactor(VnLog): refs #8449 clear filters when has userParams
gitea/salix-front/pipeline/pr-dev Something is wrong with the build of this commit
Details
gitea/salix-front/pipeline/pr-dev Something is wrong with the build of this commit
Details
This commit is contained in:
parent
5066cd8179
commit
497eb3a8bb
|
@ -15,6 +15,7 @@ import VnUserLink from '../ui/VnUserLink.vue';
|
||||||
import VnPaginate from '../ui/VnPaginate.vue';
|
import VnPaginate from '../ui/VnPaginate.vue';
|
||||||
import VnLogFilter from 'src/components/common/VnLogFilter.vue';
|
import VnLogFilter from 'src/components/common/VnLogFilter.vue';
|
||||||
import RightMenu from './RightMenu.vue';
|
import RightMenu from './RightMenu.vue';
|
||||||
|
import { useFilterParams } from 'src/composables/useFilterParams';
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const validationsStore = useValidator();
|
const validationsStore = useValidator();
|
||||||
|
@ -71,8 +72,8 @@ const filter = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const paginate = ref();
|
const paginate = ref();
|
||||||
const searchInput = ref();
|
const dataKey = computed(() => `${props.model}Log`);
|
||||||
const selectedFilters = ref({});
|
const userParams = ref(useFilterParams(dataKey.value).params);
|
||||||
|
|
||||||
let validations = models;
|
let validations = models;
|
||||||
let pointRecord = ref(null);
|
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,
|
/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) {
|
function castJsonValue(value) {
|
||||||
return typeof value === 'string' && validDate.test(value) ? new Date(value) : value;
|
return typeof value === 'string' && validDate.test(value) ? new Date(value) : value;
|
||||||
}
|
}
|
||||||
|
@ -216,29 +215,14 @@ async function setLogTree(data) {
|
||||||
function filterByRecord(modelLog) {
|
function filterByRecord(modelLog) {
|
||||||
byRecord.value = true;
|
byRecord.value = true;
|
||||||
const { id, model } = modelLog;
|
const { id, model } = modelLog;
|
||||||
|
applyFilter({ changedModelId: id, changedModel: model });
|
||||||
searchInput.value = id;
|
|
||||||
selectedFilters.value.changedModelId = id;
|
|
||||||
selectedFilters.value.changedModel = model;
|
|
||||||
applyFilter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function applyFilter() {
|
async function applyFilter(params = {}) {
|
||||||
filter.where = { and: [] };
|
paginate.value.arrayData.applyFilter({
|
||||||
if (
|
filter: {},
|
||||||
!selectedFilters.value.changedModel ||
|
params: { originFk: route.params.id, ...params },
|
||||||
(!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 });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function exprBuilder(param, value) {
|
function exprBuilder(param, value) {
|
||||||
|
@ -272,9 +256,7 @@ function exprBuilder(param, value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clearFilter() {
|
async function clearFilter() {
|
||||||
selectedFilters.value = {};
|
|
||||||
byRecord.value = false;
|
byRecord.value = false;
|
||||||
searchInput.value = undefined;
|
|
||||||
await applyFilter();
|
await applyFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,7 +582,7 @@ watch(
|
||||||
</RightMenu>
|
</RightMenu>
|
||||||
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="Object.values(selectedFilters).some((filter) => filter !== undefined)"
|
v-if="Object.keys(userParams).some((filter) => filter !== 'originFk')"
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="filter_alt_off"
|
icon="filter_alt_off"
|
||||||
size="md"
|
size="md"
|
||||||
|
|
|
@ -219,15 +219,10 @@ const getLocale = (label) => {
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
<QForm @submit="search" id="filterPanelForm" @keyup.enter="search()">
|
<QForm @submit="search" id="filterPanelForm" @keyup.enter="search()">
|
||||||
<QList dense>
|
<QList dense v-if="showTagChips">
|
||||||
<QItem class="q-mt-xs">
|
<QItem class="q-mt-xs">
|
||||||
<QItemSection top>
|
<QItemSection top>
|
||||||
<QItemLabel
|
<QItemLabel header lines="1" class="text-uppercase q-py-xs q-px-none">
|
||||||
header
|
|
||||||
lines="1"
|
|
||||||
class="text-uppercase q-py-xs q-px-none"
|
|
||||||
v-if="showTagChips"
|
|
||||||
>
|
|
||||||
{{ t('Applied filters') }}
|
{{ t('Applied filters') }}
|
||||||
</QItemLabel>
|
</QItemLabel>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
|
@ -246,7 +241,7 @@ const getLocale = (label) => {
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem class="q-mb-sm" v-if="showTagChips">
|
<QItem class="q-mb-sm">
|
||||||
<div
|
<div
|
||||||
v-if="tagsList.length === 0"
|
v-if="tagsList.length === 0"
|
||||||
class="text-grey font-xs text-center full-width"
|
class="text-grey font-xs text-center full-width"
|
||||||
|
|
|
@ -215,6 +215,7 @@ defineExpose({
|
||||||
paginate,
|
paginate,
|
||||||
userParams: arrayData.store.userParams,
|
userParams: arrayData.store.userParams,
|
||||||
currentFilter: arrayData.store.currentFilter,
|
currentFilter: arrayData.store.currentFilter,
|
||||||
|
arrayData,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue