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: {
|
||||
fetchAllData() {
|
||||
this.fetchBotSummary();
|
||||
this.fetchChartData();
|
||||
},
|
||||
fetchInboxes() {
|
||||
this.$store.dispatch('inboxes/get');
|
||||
},
|
||||
fetchBotSummary() {
|
||||
try {
|
||||
this.$store.dispatch('fetchBotSummary', this.getRequestPayload());
|
||||
@ -105,6 +111,7 @@ export default {
|
||||
filter-type="inboxes"
|
||||
show-group-by
|
||||
:show-business-hours="false"
|
||||
:navigate-on-entity-filter="false"
|
||||
@filter-change="onFilterChange"
|
||||
/>
|
||||
|
||||
|
||||
@ -12,7 +12,9 @@ import ToggleSwitch from 'dashboard/components-next/switch/Switch.vue';
|
||||
import { GROUP_BY_FILTER } from '../constants';
|
||||
import { DATE_RANGE_TYPES } from 'dashboard/components/ui/DatePicker/helpers/DatePickerHelper';
|
||||
import {
|
||||
generateFilterURLParams,
|
||||
generateReportURLParams,
|
||||
parseFilterURLParams,
|
||||
parseReportURLParams,
|
||||
} from '../helpers/reportFilterHelper';
|
||||
|
||||
@ -40,6 +42,10 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
navigateOnEntityFilter: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['filterChange']);
|
||||
@ -176,8 +182,11 @@ const updateURLParams = () => {
|
||||
groupBy: isGroupByPossible.value ? groupBy.value.id : null,
|
||||
range: selectedDateRange.value,
|
||||
});
|
||||
const filterParams = props.showEntityFilter
|
||||
? generateFilterURLParams(appliedFilters.value)
|
||||
: {};
|
||||
|
||||
router.replace({ query: { ...params } });
|
||||
router.replace({ query: { ...params, ...filterParams } });
|
||||
};
|
||||
|
||||
const emitChange = () => {
|
||||
@ -235,6 +244,10 @@ const addFilter = item => {
|
||||
agents: 'agent_reports_show',
|
||||
};
|
||||
|
||||
if (!props.navigateOnEntityFilter) {
|
||||
return;
|
||||
}
|
||||
|
||||
const routeName = routeNameMap[props.filterType];
|
||||
if (routeName) {
|
||||
router.push({
|
||||
@ -308,6 +321,12 @@ const initializeFromURL = () => {
|
||||
if (props.showEntityFilter && route.params.id) {
|
||||
const filterKey = getFilterKey();
|
||||
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