Skip to content

Commit edef96b

Browse files
authored
Tobi develop (#1346)
* feat(magazine): implement search functionality in MagazineList and Magazine.vue - Added a search bar in Magazine.vue to allow users to filter magazines based on a search query. - Enhanced MagazineList.vue to handle permalink formats for filtering magazines, improving the search experience. - Implemented debounced search handling to optimize performance and user experience. - Updated the magazine fetching logic to accommodate search parameters from the URL. Overall: This commit enhances the magazine browsing experience by introducing a search feature, allowing users to easily find specific magazines. * refactor(Magazine.vue): reposition search bar for improved layout - Moved the search bar within the Magazine.vue component to enhance the layout and visual flow. - Adjusted the margin of the search bar for better spacing and alignment. Overall: This commit refines the user interface of the Magazine page by optimizing the placement of the search functionality. * feat(WorksiteFilters): add 'claimed by me' checkbox and update filter logic - Introduced a new checkbox in WorksiteFilters.vue for filtering works claimed by the current user. - Updated WorksiteStatusGroupFilter.ts to include logic for handling the new filter option. Overall: This commit enhances the filtering capabilities for works by allowing users to easily view items they have claimed. * feat(dashboard): enhance data fetching and event handling across components - Added a new `dataFetched` event to `AjaxTable.vue` to emit the count of fetched data. - Updated `IncidentApprovalTable.vue` and `OrganizationApprovalTable.vue` to handle the new `dataFetched` event and emit corresponding approval data counts. - Enhanced `AdminDashboard.vue` to manage and emit total counts for incident and organization approvals, improving dashboard data visibility. - Integrated the total count emission into `PageTabBar.vue` and `Index.vue` for better dashboard updates. Overall: This commit improves the data handling and event communication across various components, enhancing the overall functionality and responsiveness of the admin dashboard.
1 parent f90fffd commit edef96b

File tree

9 files changed

+166
-85
lines changed

9 files changed

+166
-85
lines changed

src/components/AjaxTable.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ export default defineComponent({
111111
default: '',
112112
},
113113
},
114-
emits: ['rowClick', 'selectionChanged'],
115-
setup(props) {
114+
emits: ['rowClick', 'selectionChanged', 'dataFetched'],
115+
setup(props, { emit }) {
116116
const { emitter } = useEmitter();
117117
118118
const defaultColumns = ref<any[]>([]);
@@ -158,6 +158,7 @@ export default defineComponent({
158158
...sorter,
159159
};
160160
loading.value = false;
161+
emit('dataFetched', response.data.count);
161162
};
162163
163164
onMounted(async () => {

src/components/admin/IncidentApprovalTable.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
:url="url"
77
@change="$emit('change', $event)"
88
@row-click="showContacts"
9+
@data-fetched="handleDataFetched"
910
>
1011
<template #created_at="slotProps">
1112
<div :title="slotProps.item.created_at">
@@ -217,12 +218,17 @@ export default defineComponent({
217218
emit('reload');
218219
}
219220
221+
function handleDataFetched(count: number) {
222+
emit('onIncidentApprovalDataFetched', count);
223+
}
224+
220225
return {
221226
showContacts,
222227
approveRequest,
223228
rejectRequest,
224229
clearApproval,
225230
momentFromNow,
231+
handleDataFetched,
226232
moment,
227233
url,
228234
columns: [

src/components/admin/OrganizationApprovalTable.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
}"
1111
@change="$emit('change', $event)"
1212
@row-click="showContacts"
13+
@data-fetched="handleDataFetched"
1314
>
1415
<template #statuses="slotProps">
1516
<div class="w-full flex items-center">
@@ -257,6 +258,10 @@ export default defineComponent({
257258
}
258259
}
259260
261+
function handleDataFetched(count: number) {
262+
emit('onOrganizationApprovalDataFetched', count);
263+
}
264+
260265
return {
261266
currentUser,
262267
getIncidentName,
@@ -267,6 +272,7 @@ export default defineComponent({
267272
notifyOrganization,
268273
moment,
269274
url,
275+
handleDataFetched,
270276
columns: [
271277
{
272278
title: t('ID'),

src/components/work/WorksiteFilters.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@
225225
class="block my-1"
226226
>{{ $t('worksiteFilters.claimed_by_my_org') }}
227227
</base-checkbox>
228+
229+
<base-checkbox
230+
v-model="filters.statusGroups.data['claimed_by_me']"
231+
data-testid="testClaimedByMeCheckbox"
232+
class="block my-1"
233+
>{{ $t('worksiteFilters.claimed_by_me') }}
234+
</base-checkbox>
235+
228236
<base-checkbox
229237
v-model="filters.statusGroups.data['reported_by_org']"
230238
data-testid="testReportedByOrgCheckbox"

src/layouts/page/PageTabBar.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ const { selectorStyle, setTab, activeIndex, state } = useTabs({
1919
return route;
2020
},
2121
});
22+
23+
const emit = defineEmits(['onTotalDashboardCountFetched']);
24+
25+
function handleTotalDashboardCountFetched(count: number) {
26+
emit('onTotalDashboardCountFetched', count);
27+
}
2228
</script>
2329

2430
<template>
@@ -47,7 +53,10 @@ const { selectorStyle, setTab, activeIndex, state } = useTabs({
4753
<div class="flex-grow p-3 mb-16">
4854
<router-view v-slot="{ Component }">
4955
<keep-alive>
50-
<component :is="Component" />
56+
<component
57+
:is="Component"
58+
@on-total-dashboard-count-fetched="handleTotalDashboardCountFetched"
59+
/>
5160
</keep-alive>
5261
</router-view>
5362
</div>

src/pages/admin/AdminBugs.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export default defineComponent({
108108
const tableUrl = `${import.meta.env.VITE_APP_API_BASE_URL}/bug_reports`;
109109
const tableQuery = ref({
110110
resolved_at__isnull: true,
111+
created_at__gte: moment().subtract(60, 'day').format('YYYY-MM-DD'),
111112
});
112113
const columns = makeTableColumns([
113114
['title', '0.75fr', 'Title'],

src/pages/admin/AdminDashboard.vue

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@
132132
<OrganizationApprovalTable
133133
:query="organizationApprovalQuery"
134134
@reload="setOrganizationApprovalQuery"
135+
@on-organization-approval-data-fetched="
136+
handleOrganizationApprovalDataFetched
137+
"
135138
></OrganizationApprovalTable>
136139
</div>
137140
</div>
@@ -189,6 +192,9 @@
189192
<IncidentApprovalTable
190193
:query="incidentApprovalQuery"
191194
@reload="setIncidentApprovalQuery"
195+
@on-incident-approval-data-fetched="
196+
handleIncidentApprovalDataFetched
197+
"
192198
></IncidentApprovalTable>
193199
</div>
194200
</div>
@@ -474,13 +480,15 @@ export default defineComponent({
474480
OrganizationApprovalTable,
475481
InviteUsers,
476482
},
477-
setup() {
483+
setup(props, { emit }) {
478484
const { t } = useI18n();
479485
const store = useStore();
480486
const $toasted = useToast();
481487
const { $can } = useAcl();
482488
const { component } = useDialogs();
483489
490+
const organizationApprovalCount = ref(0);
491+
const incidentApprovalCount = ref(0);
484492
const usersToInvite = ref('');
485493
const globalSearch = ref('');
486494
const organizations = ref({
@@ -811,6 +819,29 @@ export default defineComponent({
811819
});
812820
}
813821
822+
function handleOrganizationApprovalDataFetched(count: number) {
823+
if (organizationApprovalView.value === 'default') {
824+
organizationApprovalCount.value = count;
825+
}
826+
}
827+
828+
function handleIncidentApprovalDataFetched(count: number) {
829+
if (redeployView.value === 'default') {
830+
incidentApprovalCount.value = count;
831+
}
832+
}
833+
834+
const totalCount = computed(() => {
835+
return (
836+
(organizationApprovalCount.value || 0) +
837+
(incidentApprovalCount.value || 0)
838+
);
839+
});
840+
841+
watch(totalCount, () => {
842+
emit('onTotalDashboardCountFetched', totalCount.value);
843+
});
844+
814845
onMounted(async () => {
815846
loading.value = true;
816847
await reloadDashBoard();
@@ -828,6 +859,8 @@ export default defineComponent({
828859
reloadDashBoard,
829860
showArcGisUploader,
830861
getInvitations,
862+
handleOrganizationApprovalDataFetched,
863+
handleIncidentApprovalDataFetched,
831864
usersToInvite,
832865
globalSearch,
833866
organizations,
@@ -847,6 +880,8 @@ export default defineComponent({
847880
redeployView,
848881
setApprovalView,
849882
setRedeployViewView,
883+
organizationApprovalCount,
884+
incidentApprovalCount,
850885
};
851886
},
852887
});

src/pages/admin/Index.vue

Lines changed: 92 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,110 @@
11
<template>
2-
<PageTabBar v-if="bugReportsData && ticketCountData" :tabs="tabs" />
2+
<PageTabBar
3+
v-if="bugReportsData && ticketCountData"
4+
:tabs="tabs"
5+
@on-total-dashboard-count-fetched="handleTotalDashboardCountFetched"
6+
/>
37
</template>
48

5-
<script lang="ts">
6-
import { reactive, ref, watch, onMounted } from 'vue';
9+
<script setup lang="ts">
710
import PageTabBar from '../../layouts/page/PageTabBar.vue';
811
import useAcl from '@/hooks/useAcl';
912
import type { Tab } from '@/hooks/useTabs';
1013
import { useCurrentUser } from '@/hooks';
14+
import moment from 'moment';
1115
12-
export default defineComponent({
13-
name: 'AdminPage',
14-
components: { PageTabBar },
15-
setup() {
16-
const tabs = reactive<Tab[]>([
17-
{
18-
key: 'nav.admin_dashboard',
19-
},
20-
// reactive({
21-
// key: 'nav.admin_events',
22-
// }),
23-
{
24-
key: 'nav.admin_event_stream',
25-
},
26-
{
27-
key: 'nav.admin_tickets',
28-
},
29-
{
30-
key: 'nav.bugs',
31-
},
32-
{
33-
key: 'nav.cms',
34-
},
35-
{
36-
key: 'nav.incident_wizard',
37-
},
38-
{
39-
key: 'nav.localizations',
40-
},
41-
{
42-
key: 'nav.rag',
43-
},
44-
{
45-
key: 'nav.reports',
46-
},
47-
]);
48-
49-
const ccuApi = useApi();
50-
const { $can } = useAcl();
16+
const tabs = reactive<Tab[]>([
17+
{
18+
key: 'nav.admin_dashboard',
19+
},
20+
{
21+
key: 'nav.admin_event_stream',
22+
},
23+
{
24+
key: 'nav.admin_tickets',
25+
},
26+
{
27+
key: 'nav.bugs',
28+
},
29+
{
30+
key: 'nav.cms',
31+
},
32+
{
33+
key: 'nav.incident_wizard',
34+
},
35+
{
36+
key: 'nav.localizations',
37+
},
38+
{
39+
key: 'nav.rag',
40+
},
41+
{
42+
key: 'nav.reports',
43+
},
44+
]);
5145
52-
const bugReportsData = ref({ count: 0 });
53-
const ticketCountData = ref({ count: 0 });
54-
const { currentUser } = useCurrentUser();
55-
const router = useRouter();
46+
const ccuApi = useApi();
47+
const { $can } = useAcl();
5648
57-
onMounted(async () => {
58-
if (!currentUser.value?.isAdmin) {
59-
return router.push('/dashboard');
60-
}
61-
if (!$can('development_mode')) {
62-
const bugsData = await ccuApi('/bug_reports', {
63-
method: 'GET',
64-
});
65-
if (bugsData.data) {
66-
bugReportsData.value = bugsData.data;
67-
}
49+
const bugReportsData = ref({ count: 0 });
50+
const ticketCountData = ref({ count: 0 });
51+
const totalDashboardCount = ref(0);
52+
const { currentUser } = useCurrentUser();
53+
const router = useRouter();
6854
69-
const ticketsData = await ccuApi(
70-
'zendesk/search/count.json?query=type:ticket status<solved',
71-
{
72-
method: 'GET',
73-
},
74-
);
75-
if (bugsData.data) {
76-
bugsData.value = ticketsData.data;
77-
}
78-
}
55+
onMounted(async () => {
56+
if (!currentUser.value?.isAdmin) {
57+
return router.push('/dashboard');
58+
}
59+
if (!$can('development_mode')) {
60+
const bugsData = await ccuApi('/bug_reports', {
61+
method: 'GET',
62+
params: {
63+
created_at__gte: moment().subtract(60, 'day').format('YYYY-MM-DD'),
64+
},
7965
});
66+
if (bugsData.data) {
67+
bugReportsData.value = bugsData.data;
68+
}
8069
81-
watch(bugReportsData, () => {
82-
const bugsTab = tabs.find((tab) => tab.key === 'nav.bugs');
83-
bugsTab.title = `Bugs (${bugReportsData.value.count})`;
84-
});
70+
const ticketsData = await ccuApi(
71+
'zendesk/search/count.json?query=type:ticket status<solved',
72+
{
73+
method: 'GET',
74+
},
75+
);
76+
if (ticketsData.data) {
77+
ticketCountData.value = ticketsData.data;
78+
}
79+
}
80+
});
8581
86-
watch(ticketCountData, () => {
87-
const ticketTab = tabs.find((tab) => tab.key === 'nav.admin_tickets');
88-
ticketTab.title = `Tickets (${ticketCountData.value.count})`;
89-
});
82+
function handleTotalDashboardCountFetched(count: number) {
83+
totalDashboardCount.value = count;
84+
console.log('totalDashboardCount', totalDashboardCount.value);
85+
}
9086
91-
return {
92-
tabs,
93-
bugReportsData,
94-
ticketCountData,
95-
};
96-
},
87+
watch(bugReportsData, () => {
88+
const bugsTab = tabs.find((tab: Tab) => tab.key === 'nav.bugs');
89+
if (bugsTab) {
90+
bugsTab.title = `Bugs (${bugReportsData.value.count})`;
91+
}
92+
});
93+
94+
watch(ticketCountData, () => {
95+
const ticketTab = tabs.find((tab: Tab) => tab.key === 'nav.admin_tickets');
96+
if (ticketTab) {
97+
ticketTab.title = `Tickets (${ticketCountData.value.count})`;
98+
}
99+
});
100+
101+
watch(totalDashboardCount, () => {
102+
const dashboardTab = tabs.find(
103+
(tab: Tab) => tab.key === 'nav.admin_dashboard',
104+
);
105+
if (dashboardTab) {
106+
dashboardTab.title = `Dashboard (${totalDashboardCount.value})`;
107+
}
97108
});
98109
</script>
99110

0 commit comments

Comments
 (0)