feat: separate prior records behind an owner switch and count last-period questions
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import type {
|
||||
OrgUserDto,
|
||||
TeamDto,
|
||||
@@ -23,6 +24,15 @@ const props = defineProps<{
|
||||
canEdit: boolean;
|
||||
}>();
|
||||
|
||||
const auth = useAuthStore();
|
||||
const showPriorArchive = computed(
|
||||
() =>
|
||||
auth.user?.role === 'owner' &&
|
||||
Boolean(auth.user.enabledModules?.includes('prior_data_archive')),
|
||||
);
|
||||
const priorUsers = computed(() => props.users.filter((u) => u.isActive !== false));
|
||||
const priorSavingId = ref('');
|
||||
|
||||
const emit = defineEmits<{
|
||||
refreshUsers: [];
|
||||
}>();
|
||||
@@ -45,6 +55,25 @@ const editableUsers = computed(() =>
|
||||
props.users.filter((u) => u.isActive !== false && u.role !== 'owner' && u.role !== 'admin'),
|
||||
);
|
||||
|
||||
async function setPriorArchive(userId: string, enabled: boolean) {
|
||||
priorSavingId.value = userId;
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
await api.patch(`/users/${userId}/prior-archive`, { enabled });
|
||||
ok.value = enabled
|
||||
? 'بایگانی اطلاعات قبل برای این کاربر روشن شد.'
|
||||
: 'بایگانی اطلاعات قبل برای این کاربر خاموش شد.';
|
||||
emit('refreshUsers');
|
||||
} catch (e) {
|
||||
error.value = axios.isAxiosError(e)
|
||||
? String((e.response?.data as { message?: string })?.message ?? 'ذخیره ناموفق بود.')
|
||||
: 'ذخیره ناموفق بود.';
|
||||
} finally {
|
||||
priorSavingId.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
@@ -296,6 +325,23 @@ onMounted(() => {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="showPriorArchive" class="card">
|
||||
<h3>بایگانی اطلاعات قبل</h3>
|
||||
<p class="hint">
|
||||
فقط کاربرانی که تیک میخورند سوئیچ کار جاری و بایگانی را میبینند. بقیهٔ محیط مثل قبل همهٔ
|
||||
رکوردها را مطابق سطح دسترسی خودشان میبینند.
|
||||
</p>
|
||||
<label v-for="u in priorUsers" :key="u.id" class="vis-row">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="Boolean(u.priorArchiveEnabled)"
|
||||
:disabled="priorSavingId === u.id"
|
||||
@change="setPriorArchive(u.id, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
<span>{{ u.fullName }}</span>
|
||||
</label>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h3>سطح دسترسی به پروندهها</h3>
|
||||
<p class="hint">
|
||||
|
||||
@@ -71,6 +71,9 @@ function onVoiceTranscript(text: string) {
|
||||
}
|
||||
|
||||
function looksLikeAction(text: string) {
|
||||
if (/[؟?]/.test(text) || /چند|تعداد|چقدر|چنتا|چیست|چیه|کدام|کدوم|چرا|چطور|چگونه/.test(text)) {
|
||||
return false;
|
||||
}
|
||||
return /بساز|بسازید|ثبت کن|ثبت کنید|اضافه کن|ایجاد کن|یک مشتری|مشتری جدید|یک فعالیت|فعالیت جدید|یک لید|لید جدید/.test(
|
||||
text,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user