From 84a308d97dd768ad2e3392d3d733d67e32714e8a Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Mon, 24 Jun 2024 08:28:51 +0000 Subject: [PATCH] fix(nc-gui): pr review changes --- .../nc-gui/components/workspace/AuditLogs.vue | 156 +++++------------- packages/nc-gui/store/workspace.ts | 4 + 2 files changed, 48 insertions(+), 112 deletions(-) diff --git a/packages/nc-gui/components/workspace/AuditLogs.vue b/packages/nc-gui/components/workspace/AuditLogs.vue index 35809fe4c5..604d3c0de6 100644 --- a/packages/nc-gui/components/workspace/AuditLogs.vue +++ b/packages/nc-gui/components/workspace/AuditLogs.vue @@ -75,7 +75,15 @@ const auditDropdownsSearch = ref({ user: '', }) -console.log('changing') +const focusUserSearchRef: VNodeRef = (el) => { + return el && auditDropdowns.value.user && el?.focus?.() +} +const focusBaseSearchRef: VNodeRef = (el) => { + return el && auditDropdowns.value.base && el?.focus?.() +} +const focusTypeSearchRef: VNodeRef = (el) => { + return el && auditDropdowns.value.type && el?.focus?.() +} const auditTypeOptions = computed(() => { return Object.values(AuditOperationTypes) @@ -131,55 +139,39 @@ const handleRowClick = (audit: AuditType) => { isRowExpanded.value = true } -const toggleOrderBy = (orderBy: 'created_at' | 'user') => { - if (orderBy === 'created_at') { - auditLogsQuery.value.orderBy = { - ...auditLogsQuery.value.orderBy, - created_at: - auditLogsQuery.value.orderBy?.created_at === 'asc' - ? 'desc' - : auditLogsQuery.value.orderBy?.created_at === 'desc' - ? undefined - : 'asc', - } - } - if (orderBy === 'user') { - auditLogsQuery.value.orderBy = { - ...auditLogsQuery.value.orderBy, - user: - auditLogsQuery.value.orderBy?.user === 'asc' ? 'desc' : auditLogsQuery.value.orderBy?.user === 'desc' ? undefined : 'asc', - } +const handleUpdateBaseQuery = (baseId?: string, sourceId?: string) => { + auditLogsQuery.value.base = baseId + auditLogsQuery.value.sourceId = sourceId +} + +const updateOrderBy = (field: 'created_at' | 'user') => { + if (auditLogsQuery.value.orderBy?.[field] === 'asc') { + auditLogsQuery.value.orderBy[field] = 'desc' + } else if (auditLogsQuery.value.orderBy?.[field] === 'desc') { + auditLogsQuery.value.orderBy[field] = undefined + } else { + auditLogsQuery.value.orderBy[field] = 'asc' } loadAudits() } +const handleCloseDropdown = (field: 'user' | 'base' | 'type') => { + auditDropdowns.value[field] = false + loadAudits() +} + +const handleClearDropdownSearch = (isOpen: boolean, field: 'user' | 'base' | 'type') => { + if (isOpen) { + auditDropdownsSearch.value[field] = '' + } +} + onMounted(async () => { if (audits.value === null) { await loadAudits(currentPage.value, currentLimit.value) } }) - -watchEffect(() => { - console.log('auditDropdownsSearch', auditDropdownsSearch.value) -}) -watch( - auditDropdownsSearch, - () => { - console.log('fdlsa', auditDropdownsSearch.value) - }, - { deep: true }, -) - -const focusUserSearchRef: VNodeRef = (el) => { - return el && auditDropdowns.value.user && el?.focus?.() -} -const focusBaseSearchRef: VNodeRef = (el) => { - return el && auditDropdowns.value.base && el?.focus?.() -} -const focusTypeSearchRef: VNodeRef = (el) => { - return el && auditDropdowns.value.type && el?.focus?.() -} - +
@@ -470,15 +415,7 @@ const focusTypeSearchRef: VNodeRef = (el) => {
- + {
-