From 5074c6d791dd2c19baf415d3ac21060a3cd56980 Mon Sep 17 00:00:00 2001 From: Mahdi Date: Tue, 6 Oct 2026 13:35:13 +0330 Subject: [PATCH] Add column visibility menu to activities and API keys tables, and make related person optional when creating an activity --- apps/web/src/lib/tableColumns.ts | 9 +++ apps/web/src/views/ActivitiesView.vue | 64 +++++++++++++++----- apps/web/src/views/ActivityFormView.vue | 24 +++++++- apps/web/src/views/PublicApiSettingsView.vue | 5 +- 4 files changed, 84 insertions(+), 18 deletions(-) diff --git a/apps/web/src/lib/tableColumns.ts b/apps/web/src/lib/tableColumns.ts index 9f9e548..3374ccb 100644 --- a/apps/web/src/lib/tableColumns.ts +++ b/apps/web/src/lib/tableColumns.ts @@ -159,6 +159,15 @@ declare module 'vue' { } } +/** برای جدول‌های غیر `` (مثلاً گرید div) که ستون‌هایشان را خودشان پنهان می‌کنند. */ +export function registerTableColumns(key: string, labels: string[]) { + ensureInit(); + const prev = labelsByTable[key]; + if (!prev || prev.length !== labels.length || prev.some((v, i) => v !== labels[i])) { + labelsByTable[key] = labels; + } +} + export function useTableColumns(table: () => string) { ensureInit(); const columns = () => diff --git a/apps/web/src/views/ActivitiesView.vue b/apps/web/src/views/ActivitiesView.vue index df32371..04a53bb 100644 --- a/apps/web/src/views/ActivitiesView.vue +++ b/apps/web/src/views/ActivitiesView.vue @@ -45,6 +45,34 @@ import { brand } from '@mento/shared'; import { useAuthStore } from '@/stores/auth'; import { canViewAllRecords } from '@/lib/roles'; import { PAGE_SIZE_OPTIONS, usePageSize } from '@/lib/pageSize'; +import { registerTableColumns, useTableColumns } from '@/lib/tableColumns'; +import TableColumnsMenu from '@/components/TableColumnsMenu.vue'; + +const ACT_TABLE_KEY = 'activities'; +const ACT_COLUMNS = [ + { key: 'title', label: 'مشتری / عنوان فعالیت', width: 'minmax(0, 2.2fr)' }, + { key: 'type', label: 'نوع فعالیت', width: '7.6rem' }, + { key: 'when', label: 'زمان شروع', width: '7.2rem' }, + { key: 'who', label: 'کارشناس', width: '8.4rem' }, + { key: 'status', label: 'وضعیت', width: '8.6rem' }, +] as const; +type ActColKey = (typeof ACT_COLUMNS)[number]['key']; +registerTableColumns( + ACT_TABLE_KEY, + ACT_COLUMNS.map((c) => c.label), +); +const actCols = useTableColumns(() => ACT_TABLE_KEY); +function colOn(key: ActColKey) { + const col = ACT_COLUMNS.find((c) => c.key === key)!; + return actCols.isVisible(col.label); +} +const actGridStyle = computed(() => ({ + gridTemplateColumns: [ + '2.4rem', + ...ACT_COLUMNS.filter((c) => actCols.isVisible(c.label)).map((c) => c.width), + '2.4rem', + ].join(' '), +})); type TypeFilter = 'all' | ActivityType; type StatusFilter = 'all' | ActivityStatus; @@ -698,19 +726,20 @@ onUnmounted(() => {