feat(reports): mantém filtros do BotReports na URL sem trocar de rota
BotReports agora carrega inboxes no mount e passa navigate-on-entity-filter=false pro ReportFilters, que ganha prop pra atualizar a URL com os filtros aplicados sem disparar router.push pra outra rota. Permite compartilhar/recuperar visão filtrada do BotReports via URL. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
4e798944cf
commit
d12d8bc0b6
@ -37,11 +37,17 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.fetchInboxes();
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchAllData() {
|
fetchAllData() {
|
||||||
this.fetchBotSummary();
|
this.fetchBotSummary();
|
||||||
this.fetchChartData();
|
this.fetchChartData();
|
||||||
},
|
},
|
||||||
|
fetchInboxes() {
|
||||||
|
this.$store.dispatch('inboxes/get');
|
||||||
|
},
|
||||||
fetchBotSummary() {
|
fetchBotSummary() {
|
||||||
try {
|
try {
|
||||||
this.$store.dispatch('fetchBotSummary', this.getRequestPayload());
|
this.$store.dispatch('fetchBotSummary', this.getRequestPayload());
|
||||||
@ -105,6 +111,7 @@ export default {
|
|||||||
filter-type="inboxes"
|
filter-type="inboxes"
|
||||||
show-group-by
|
show-group-by
|
||||||
:show-business-hours="false"
|
:show-business-hours="false"
|
||||||
|
:navigate-on-entity-filter="false"
|
||||||
@filter-change="onFilterChange"
|
@filter-change="onFilterChange"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,9 @@ import ToggleSwitch from 'dashboard/components-next/switch/Switch.vue';
|
|||||||
import { GROUP_BY_FILTER } from '../constants';
|
import { GROUP_BY_FILTER } from '../constants';
|
||||||
import { DATE_RANGE_TYPES } from 'dashboard/components/ui/DatePicker/helpers/DatePickerHelper';
|
import { DATE_RANGE_TYPES } from 'dashboard/components/ui/DatePicker/helpers/DatePickerHelper';
|
||||||
import {
|
import {
|
||||||
|
generateFilterURLParams,
|
||||||
generateReportURLParams,
|
generateReportURLParams,
|
||||||
|
parseFilterURLParams,
|
||||||
parseReportURLParams,
|
parseReportURLParams,
|
||||||
} from '../helpers/reportFilterHelper';
|
} from '../helpers/reportFilterHelper';
|
||||||
|
|
||||||
@ -40,6 +42,10 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
navigateOnEntityFilter: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['filterChange']);
|
const emit = defineEmits(['filterChange']);
|
||||||
@ -176,8 +182,11 @@ const updateURLParams = () => {
|
|||||||
groupBy: isGroupByPossible.value ? groupBy.value.id : null,
|
groupBy: isGroupByPossible.value ? groupBy.value.id : null,
|
||||||
range: selectedDateRange.value,
|
range: selectedDateRange.value,
|
||||||
});
|
});
|
||||||
|
const filterParams = props.showEntityFilter
|
||||||
|
? generateFilterURLParams(appliedFilters.value)
|
||||||
|
: {};
|
||||||
|
|
||||||
router.replace({ query: { ...params } });
|
router.replace({ query: { ...params, ...filterParams } });
|
||||||
};
|
};
|
||||||
|
|
||||||
const emitChange = () => {
|
const emitChange = () => {
|
||||||
@ -235,6 +244,10 @@ const addFilter = item => {
|
|||||||
agents: 'agent_reports_show',
|
agents: 'agent_reports_show',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!props.navigateOnEntityFilter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const routeName = routeNameMap[props.filterType];
|
const routeName = routeNameMap[props.filterType];
|
||||||
if (routeName) {
|
if (routeName) {
|
||||||
router.push({
|
router.push({
|
||||||
@ -308,6 +321,12 @@ const initializeFromURL = () => {
|
|||||||
if (props.showEntityFilter && route.params.id) {
|
if (props.showEntityFilter && route.params.id) {
|
||||||
const filterKey = getFilterKey();
|
const filterKey = getFilterKey();
|
||||||
appliedFilters.value[filterKey] = Number(route.params.id);
|
appliedFilters.value[filterKey] = Number(route.params.id);
|
||||||
|
} else if (props.showEntityFilter) {
|
||||||
|
const filterKey = getFilterKey();
|
||||||
|
const filterParams = parseFilterURLParams(route.query);
|
||||||
|
if (filterParams[filterKey]) {
|
||||||
|
appliedFilters.value[filterKey] = filterParams[filterKey];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user