Add org-scoped activity priority labels/colors and apply them across forms, boards, and routines.
Also fix activity leave-without-save confirm, kanban due-date labels with tone-colored peek chevron, and rename the types manager button. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -25,6 +25,7 @@ import ActivityDeskFilters from '@/components/activities/ActivityDeskFilters.vue
|
||||
import ActivityStagesManager from '@/components/activities/ActivityStagesManager.vue';
|
||||
import ActivityTypesManager from '@/components/activities/ActivityTypesManager.vue';
|
||||
import { PIPELINE_ACCENT } from '@/lib/pipeline-board';
|
||||
import { useActivityPriorities } from '@/lib/activity-priorities';
|
||||
import { activityTypeView, typeColorStyle, useActivityTypes } from '@/lib/activity-types';
|
||||
import {
|
||||
ACTIVITY_EXCEL_ALIASES,
|
||||
@@ -180,6 +181,7 @@ const boardDeleteOpen = ref(false);
|
||||
|
||||
async function onTypesChanged() {
|
||||
await activityTypes.load(true);
|
||||
await useActivityPriorities().load(true);
|
||||
kanbanReload.value += 1;
|
||||
await refreshAll();
|
||||
}
|
||||
@@ -1217,11 +1219,11 @@ onUnmounted(() => {
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
type="button"
|
||||
title="انواع فعالیت و فیلدها"
|
||||
title="انواع فعالیت و اولویت ها"
|
||||
@click="typesManagerOpen = true"
|
||||
>
|
||||
<UiIcon name="sliders" :size="14" />
|
||||
<span class="manage-label">انواع فعالیت و فیلدها</span>
|
||||
<span class="manage-label">انواع فعالیت و اولویت ها</span>
|
||||
</UiButton>
|
||||
<UiButton
|
||||
v-if="canManageStages"
|
||||
@@ -1380,7 +1382,7 @@ onUnmounted(() => {
|
||||
<hr class="board-menu-sep" />
|
||||
<button type="button" class="menu-row" @click="typesManagerOpen = true">
|
||||
<UiIcon name="sliders" :size="16" />
|
||||
انواع فعالیت و فیلدها
|
||||
انواع فعالیت و اولویت ها
|
||||
</button>
|
||||
<button type="button" class="menu-row" @click="stagesManagerOpen = true">
|
||||
<UiIcon name="settings" :size="16" />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
import { computed, h, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
import { RouterLink, onBeforeRouteLeave, useRoute, useRouter } from 'vue-router';
|
||||
import { api } from '@/lib/api';
|
||||
import {
|
||||
@@ -18,7 +18,7 @@ import ActivityCommentSheet from '@/components/activities/ActivityCommentSheet.v
|
||||
import ActivityPostponeSheet from '@/components/activities/ActivityPostponeSheet.vue';
|
||||
import ActivityFieldsView from '@/components/activities/ActivityFieldsView.vue';
|
||||
import StagePathStrip from '@/components/StagePathStrip.vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { Button as AButton, message, Modal } from 'ant-design-vue';
|
||||
import type {
|
||||
ActivityChecklistItem,
|
||||
ActivityDto,
|
||||
@@ -32,6 +32,7 @@ import { useAuthStore } from '@/stores/auth';
|
||||
import { canCollaborateOnActivity, canMutateActivity } from '@/lib/activity-access';
|
||||
import { canAssignToOthers } from '@/lib/assign-access';
|
||||
import { apiError } from '@/lib/routines';
|
||||
import { useActivityPriorities } from '@/lib/activity-priorities';
|
||||
import { activityTypeView, typeColorStyle, useActivityTypes } from '@/lib/activity-types';
|
||||
import {
|
||||
bindThreadMedia,
|
||||
@@ -631,11 +632,59 @@ async function persistDrafts(): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
/** true = مجاز به ترک صفحه · false = بمان روی جزئیات */
|
||||
async function resolveDirty(): Promise<boolean> {
|
||||
if (!isDirty.value) return true;
|
||||
if (confirm('تغییرات ثبت شود؟')) return persistDrafts();
|
||||
discardDrafts();
|
||||
return true;
|
||||
return new Promise((resolve) => {
|
||||
const modal = Modal.confirm({
|
||||
title: 'تغییرات ذخیرهنشده',
|
||||
content: 'تغییراتی در این فعالیت انجام دادهاید، آیا ذخیره شود؟',
|
||||
centered: true,
|
||||
closable: false,
|
||||
maskClosable: false,
|
||||
keyboard: false,
|
||||
icon: null,
|
||||
footer: () =>
|
||||
h('div', { class: 'ant-modal-confirm-btns' }, [
|
||||
h(
|
||||
AButton,
|
||||
{
|
||||
onClick: () => {
|
||||
modal.destroy();
|
||||
resolve(false);
|
||||
},
|
||||
},
|
||||
() => 'ادامهٔ ویرایش',
|
||||
),
|
||||
h(
|
||||
AButton,
|
||||
{
|
||||
onClick: () => {
|
||||
discardDrafts();
|
||||
modal.destroy();
|
||||
resolve(true);
|
||||
},
|
||||
},
|
||||
() => 'ذخیره نکن',
|
||||
),
|
||||
h(
|
||||
AButton,
|
||||
{
|
||||
type: 'primary',
|
||||
onClick: () => {
|
||||
void (async () => {
|
||||
const ok = await persistDrafts();
|
||||
if (!ok) return;
|
||||
modal.destroy();
|
||||
resolve(true);
|
||||
})();
|
||||
},
|
||||
},
|
||||
() => 'ذخیره',
|
||||
),
|
||||
]),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function onBeforeUnload(event: BeforeUnloadEvent) {
|
||||
@@ -671,13 +720,9 @@ async function toggleChecklistItem(key: string, itemId: string, done: boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
const priorityLabel: Record<ActivityPriority, string> = {
|
||||
very_low: 'خیلی کم',
|
||||
low: 'کم',
|
||||
medium: 'متوسط',
|
||||
high: 'زیاد',
|
||||
very_high: 'خیلی زیاد',
|
||||
};
|
||||
const activityPriorities = useActivityPriorities();
|
||||
void activityPriorities.load();
|
||||
const priorityLabel = computed(() => activityPriorities.labels.value);
|
||||
|
||||
const subtitle = computed(() => {
|
||||
const a = activity.value;
|
||||
@@ -1039,17 +1084,8 @@ watch(id, () => {
|
||||
void load();
|
||||
});
|
||||
watch(() => route.query.nav, () => void loadNav(), { immediate: true });
|
||||
onBeforeRouteLeave(async (_to, _from, next) => {
|
||||
if (!isDirty.value) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
if (confirm('تغییرات ثبت شود؟')) next(await persistDrafts());
|
||||
else {
|
||||
discardDrafts();
|
||||
next();
|
||||
}
|
||||
});
|
||||
/** بدون next() — در Vue Router 4 گارد async+next باعث رد شدن بدون پرسش میشد */
|
||||
onBeforeRouteLeave(async () => resolveDirty());
|
||||
onMounted(() => {
|
||||
window.addEventListener('beforeunload', onBeforeUnload);
|
||||
void load();
|
||||
@@ -1150,12 +1186,17 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<div>
|
||||
<dt>
|
||||
<UiIcon name="flag" :size="15" class="flag" :class="draftPriority" />
|
||||
<UiIcon
|
||||
name="flag"
|
||||
:size="15"
|
||||
class="flag"
|
||||
:style="{ color: activityPriorities.colorOf(draftPriority) }"
|
||||
/>
|
||||
اولویت
|
||||
</dt>
|
||||
<dd>
|
||||
<select v-model="draftPriority" class="meta-control" :disabled="editLocked" aria-label="اولویت">
|
||||
<option v-for="(label, key) in priorityLabel" :key="key" :value="key">{{ label }}</option>
|
||||
<option v-for="(label, key) in priorityLabel" :key="String(key)" :value="key">{{ label }}</option>
|
||||
</select>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
UiTextarea,
|
||||
} from '@/components/ui';
|
||||
import ActivityFieldsEditor from '@/components/activities/ActivityFieldsEditor.vue';
|
||||
import { useActivityPriorities } from '@/lib/activity-priorities';
|
||||
import { typeColorStyle, useActivityTypes } from '@/lib/activity-types';
|
||||
import type {
|
||||
ActivityBoardDto,
|
||||
@@ -89,6 +90,8 @@ const boardId = ref('');
|
||||
const defaultBoardId = computed(() => boards.value.find((b) => b.isDefault)?.id ?? '');
|
||||
|
||||
const activityTypes = useActivityTypes();
|
||||
const activityPriorities = useActivityPriorities();
|
||||
void activityPriorities.load();
|
||||
const title = ref('');
|
||||
const type = ref<ActivityType | ''>('');
|
||||
const typeDefId = ref('');
|
||||
@@ -271,13 +274,13 @@ function isEmptyValue(v: ActivityFieldValue | undefined): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
const priorityOptions: Array<{ value: ActivityPriority; label: string; tone: string }> = [
|
||||
{ value: 'very_high', label: 'خیلی زیاد', tone: 'very-high' },
|
||||
{ value: 'high', label: 'زیاد', tone: 'high' },
|
||||
{ value: 'medium', label: 'متوسط', tone: 'medium' },
|
||||
{ value: 'low', label: 'کم', tone: 'low' },
|
||||
{ value: 'very_low', label: 'خیلی کم', tone: 'very-low' },
|
||||
];
|
||||
const priorityOptions = computed(() =>
|
||||
activityPriorities.items.value.map((row) => ({
|
||||
value: row.key,
|
||||
label: row.label,
|
||||
color: row.color,
|
||||
})),
|
||||
);
|
||||
|
||||
const typeMeta = computed(() => activityTypes.byId.value.get(typeDefId.value) ?? null);
|
||||
const typeFields = computed(() => typeMeta.value?.fields ?? []);
|
||||
@@ -402,7 +405,7 @@ const duePreview = computed(() => {
|
||||
|
||||
const statusText = computed(() => (isDone.value ? 'انجام شده' : 'انجام نشده'));
|
||||
const priorityText = computed(
|
||||
() => priorityOptions.find((p) => p.value === priority.value)?.label || '—',
|
||||
() => priorityOptions.value.find((p) => p.value === priority.value)?.label || '—',
|
||||
);
|
||||
const pageTitle = computed(() => (isNew.value ? 'ایجاد فعالیت جدید' : 'ویرایش فعالیت'));
|
||||
const summaryReady = computed(() => Boolean(title.value.trim() || type.value || selectedPerson.value));
|
||||
@@ -1442,7 +1445,13 @@ watch([id, isNew], () => void load(), { immediate: true });
|
||||
<div class="card">
|
||||
<p class="pri-label">اولویت</p>
|
||||
<div class="priorities">
|
||||
<label v-for="opt in priorityOptions" :key="opt.value" :class="['pri', opt.tone, { on: priority === opt.value }]">
|
||||
<label
|
||||
v-for="opt in priorityOptions"
|
||||
:key="opt.value"
|
||||
class="pri"
|
||||
:class="{ on: priority === opt.value }"
|
||||
:style="{ color: opt.color }"
|
||||
>
|
||||
<input v-model="priority" type="radio" :value="opt.value" />
|
||||
<UiIcon name="flag" :size="16" />
|
||||
<span>{{ opt.label }}</span>
|
||||
@@ -2365,26 +2374,6 @@ watch([id, isNew], () => void load(), { immediate: true });
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.pri.very-high {
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
.pri.high {
|
||||
color: #ea580c;
|
||||
}
|
||||
|
||||
.pri.medium {
|
||||
color: #eab308;
|
||||
}
|
||||
|
||||
.pri.low {
|
||||
color: #16a34a;
|
||||
}
|
||||
|
||||
.pri.very-low {
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.pri.on span {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ import {
|
||||
} from '@/components/ui';
|
||||
import { api } from '@/lib/api';
|
||||
import { toFaDigits } from '@/lib/jalali';
|
||||
import { PRIORITY_LABELS, ROUTINES_CTX, apiError, formatDayNumeric, todayKey } from '@/lib/routines';
|
||||
import { useActivityPriorities } from '@/lib/activity-priorities';
|
||||
import { ROUTINES_CTX, apiError, formatDayNumeric, todayKey } from '@/lib/routines';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
|
||||
const shell = inject(ROUTINES_CTX)!;
|
||||
@@ -73,7 +74,11 @@ const targetOptions = [
|
||||
{ value: 'team' as const, label: 'همه اعضای یک تیم' },
|
||||
];
|
||||
|
||||
const priorities = Object.entries(PRIORITY_LABELS) as Array<[ActivityPriority, string]>;
|
||||
const activityPriorities = useActivityPriorities();
|
||||
void activityPriorities.load();
|
||||
const priorities = computed(() =>
|
||||
activityPriorities.items.value.map((r) => [r.key, r.label] as [ActivityPriority, string]),
|
||||
);
|
||||
const entityLinks = Object.entries(ROUTINE_ENTITY_LINK_LABELS) as Array<[RoutineEntityLink, string]>;
|
||||
const reminderOptions = [
|
||||
{ value: '', label: 'طبق تنظیمات هر کاربر' },
|
||||
|
||||
@@ -7,8 +7,8 @@ import { UiBadge, UiEmptyState, UiSearch } from '@/components/ui';
|
||||
import { api } from '@/lib/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { toFaDigits } from '@/lib/jalali';
|
||||
import { useActivityPriorities } from '@/lib/activity-priorities';
|
||||
import {
|
||||
PRIORITY_LABELS,
|
||||
PRIORITY_VARIANTS,
|
||||
ROUTINES_CTX,
|
||||
apiError,
|
||||
@@ -18,6 +18,8 @@ import {
|
||||
} from '@/lib/routines';
|
||||
|
||||
const shell = inject(ROUTINES_CTX)!;
|
||||
const activityPriorities = useActivityPriorities();
|
||||
void activityPriorities.load();
|
||||
const auth = useAuthStore();
|
||||
const meId = computed(() => auth.user?.id ?? '');
|
||||
|
||||
@@ -80,7 +82,7 @@ const filtered = computed(() => {
|
||||
<p v-if="r.description" class="desc">{{ r.description }}</p>
|
||||
<div class="tags">
|
||||
<UiBadge v-if="r.category" size="sm">{{ r.category.name }}</UiBadge>
|
||||
<UiBadge size="sm" :variant="PRIORITY_VARIANTS[r.priority]">{{ PRIORITY_LABELS[r.priority] }}</UiBadge>
|
||||
<UiBadge size="sm" :variant="PRIORITY_VARIANTS[r.priority]">{{ activityPriorities.labelOf(r.priority) }}</UiBadge>
|
||||
<UiBadge v-if="r.isMandatory" size="sm" variant="warning">اجباری</UiBadge>
|
||||
<UiBadge v-if="r.reportRequired" size="sm" variant="info">گزارش الزامی</UiBadge>
|
||||
<UiBadge v-if="r.team" size="sm" variant="accent">تیم {{ r.team.name }}</UiBadge>
|
||||
|
||||
@@ -9,9 +9,9 @@ import RoutineTaskModals from '@/components/routines/RoutineTaskModals.vue';
|
||||
import { UiBadge, UiButton, UiEmptyState, UiSelect } from '@/components/ui';
|
||||
import { api } from '@/lib/api';
|
||||
import { toFaDigits } from '@/lib/jalali';
|
||||
import { useActivityPriorities } from '@/lib/activity-priorities';
|
||||
import {
|
||||
ENTITY_TYPE_LABELS,
|
||||
PRIORITY_LABELS,
|
||||
PRIORITY_VARIANTS,
|
||||
ROUTINES_CTX,
|
||||
apiError,
|
||||
@@ -24,6 +24,8 @@ import {
|
||||
import { useRoutineTaskActions } from '@/lib/useRoutineTaskActions';
|
||||
|
||||
const shell = inject(ROUTINES_CTX)!;
|
||||
const activityPriorities = useActivityPriorities();
|
||||
void activityPriorities.load();
|
||||
|
||||
const items = ref<RoutineTaskDto[]>([]);
|
||||
const loading = ref(true);
|
||||
@@ -133,7 +135,7 @@ const showAssignee = computed(() => isManager.value && who.value !== '');
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<UiBadge size="sm" :variant="PRIORITY_VARIANTS[t.priority]">{{ PRIORITY_LABELS[t.priority] }}</UiBadge>
|
||||
<UiBadge size="sm" :variant="PRIORITY_VARIANTS[t.priority]">{{ activityPriorities.labelOf(t.priority) }}</UiBadge>
|
||||
</td>
|
||||
<td>
|
||||
<RouterLink
|
||||
|
||||
Reference in New Issue
Block a user