Add activity priority desk filter and keep detail browsing inside the same column after stage changes.
When done/reopen/stage moves leave a column, advance to the next activity there or return to the list if empty. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -210,6 +210,7 @@ export class ActivitiesController {
|
|||||||
title: query.title,
|
title: query.title,
|
||||||
customer: query.customer,
|
customer: query.customer,
|
||||||
due: query.due,
|
due: query.due,
|
||||||
|
priority: query.priority,
|
||||||
boardId: query.boardId,
|
boardId: query.boardId,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -246,6 +247,7 @@ export class ActivitiesController {
|
|||||||
title: query.title,
|
title: query.title,
|
||||||
customer: query.customer,
|
customer: query.customer,
|
||||||
due: query.due,
|
due: query.due,
|
||||||
|
priority: query.priority,
|
||||||
boardId: query.boardId,
|
boardId: query.boardId,
|
||||||
},
|
},
|
||||||
query.stageId ? { stageId: query.stageId } : undefined,
|
query.stageId ? { stageId: query.stageId } : undefined,
|
||||||
@@ -279,6 +281,7 @@ export class ActivitiesController {
|
|||||||
title: query.title,
|
title: query.title,
|
||||||
customer: query.customer,
|
customer: query.customer,
|
||||||
due: query.due,
|
due: query.due,
|
||||||
|
priority: query.priority,
|
||||||
boardId: query.boardId,
|
boardId: query.boardId,
|
||||||
},
|
},
|
||||||
query.stageId ? { stageId: query.stageId } : undefined,
|
query.stageId ? { stageId: query.stageId } : undefined,
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ type ListFacets = {
|
|||||||
customer?: string;
|
customer?: string;
|
||||||
/** set = زمان شروع دارد، unset = ندارد */
|
/** set = زمان شروع دارد، unset = ندارد */
|
||||||
due?: 'set' | 'unset';
|
due?: 'set' | 'unset';
|
||||||
|
priority?: ActivityDto['priority'];
|
||||||
/** گروه فعالیت؛ خالی = همهٔ گروهها */
|
/** گروه فعالیت؛ خالی = همهٔ گروهها */
|
||||||
boardId?: string;
|
boardId?: string;
|
||||||
};
|
};
|
||||||
@@ -1369,11 +1370,13 @@ export class ActivitiesService {
|
|||||||
const facetTypeDef = facets?.typeDefId?.trim();
|
const facetTypeDef = facets?.typeDefId?.trim();
|
||||||
const facetTitle = facets?.title?.trim();
|
const facetTitle = facets?.title?.trim();
|
||||||
const facetCustomer = facets?.customer?.trim();
|
const facetCustomer = facets?.customer?.trim();
|
||||||
|
const facetPriority = facets?.priority;
|
||||||
const andParts: Prisma.ActivityWhereInput[] = [
|
const andParts: Prisma.ActivityWhereInput[] = [
|
||||||
scope,
|
scope,
|
||||||
...(facets?.type ? [{ type: facets.type }] : []),
|
...(facets?.type ? [{ type: facets.type }] : []),
|
||||||
...(facetTypeDef ? [this.types.whereForType(typeRows, facetTypeDef)] : []),
|
...(facetTypeDef ? [this.types.whereForType(typeRows, facetTypeDef)] : []),
|
||||||
...(facets?.status ? [{ status: facets.status }] : []),
|
...(facets?.status ? [{ status: facets.status }] : []),
|
||||||
|
...(facetPriority ? [{ priority: facetPriority }] : []),
|
||||||
...(facetTitle ? [{ title: ci(facetTitle) }] : []),
|
...(facetTitle ? [{ title: ci(facetTitle) }] : []),
|
||||||
...(facetCustomer ? [this.customerWhere(facetCustomer)] : []),
|
...(facetCustomer ? [this.customerWhere(facetCustomer)] : []),
|
||||||
...(facetAssignee
|
...(facetAssignee
|
||||||
|
|||||||
@@ -93,6 +93,11 @@ export class ListActivitiesQueryDto {
|
|||||||
@IsString()
|
@IsString()
|
||||||
typeDefId?: string;
|
typeDefId?: string;
|
||||||
|
|
||||||
|
/** اولویت فعالیت (کلید ثابت؛ برچسب در تنظیمات سازمان) */
|
||||||
|
@IsOptional()
|
||||||
|
@IsIn(ACTIVITY_PRIORITIES)
|
||||||
|
priority?: (typeof ACTIVITY_PRIORITIES)[number];
|
||||||
|
|
||||||
/** شناسهٔ مرحله یا 'all' — حالت تب/کانبان مراحل */
|
/** شناسهٔ مرحله یا 'all' — حالت تب/کانبان مراحل */
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
|
|||||||
@@ -511,6 +511,7 @@ function activityQuery(id: string) {
|
|||||||
if (source.typeDefId) query.typeDefId = source.typeDefId;
|
if (source.typeDefId) query.typeDefId = source.typeDefId;
|
||||||
else if (source.type) query.type = source.type;
|
else if (source.type) query.type = source.type;
|
||||||
if (source.status) query.status = source.status;
|
if (source.status) query.status = source.status;
|
||||||
|
if (source.priority) query.priority = source.priority;
|
||||||
if (source.assigneeId) query.assigneeId = source.assigneeId;
|
if (source.assigneeId) query.assigneeId = source.assigneeId;
|
||||||
if (source.title) query.title = source.title;
|
if (source.title) query.title = source.title;
|
||||||
if (source.customer) query.customer = source.customer;
|
if (source.customer) query.customer = source.customer;
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
|
|
||||||
export type DeskFilterField = 'title' | 'who' | 'customer' | 'type' | 'when' | 'status';
|
export type DeskFilterField =
|
||||||
|
| 'title'
|
||||||
|
| 'who'
|
||||||
|
| 'customer'
|
||||||
|
| 'type'
|
||||||
|
| 'priority'
|
||||||
|
| 'when'
|
||||||
|
| 'status';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
/** یک ستون، یا پنل کامل بالای صفحه */
|
/** یک ستون، یا پنل کامل بالای صفحه */
|
||||||
@@ -10,11 +17,13 @@ const props = defineProps<{
|
|||||||
customer: string;
|
customer: string;
|
||||||
due: '' | 'set' | 'unset';
|
due: '' | 'set' | 'unset';
|
||||||
typeKey: string;
|
typeKey: string;
|
||||||
|
priorityKey: string;
|
||||||
statusKey: string;
|
statusKey: string;
|
||||||
assigneeId: string;
|
assigneeId: string;
|
||||||
showAssignee: boolean;
|
showAssignee: boolean;
|
||||||
users: Array<{ id: string; fullName: string }>;
|
users: Array<{ id: string; fullName: string }>;
|
||||||
types: Array<{ key: string; label: string }>;
|
types: Array<{ key: string; label: string }>;
|
||||||
|
priorities: Array<{ key: string; label: string; color?: string }>;
|
||||||
statuses: Array<{ key: string; label: string }>;
|
statuses: Array<{ key: string; label: string }>;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
@@ -23,6 +32,7 @@ const emit = defineEmits<{
|
|||||||
customer: [value: string];
|
customer: [value: string];
|
||||||
due: [value: '' | 'set' | 'unset'];
|
due: [value: '' | 'set' | 'unset'];
|
||||||
type: [value: string];
|
type: [value: string];
|
||||||
|
priority: [value: string];
|
||||||
status: [value: string];
|
status: [value: string];
|
||||||
assignee: [value: string];
|
assignee: [value: string];
|
||||||
clear: [];
|
clear: [];
|
||||||
@@ -86,6 +96,7 @@ const hasAny = computed(
|
|||||||
() =>
|
() =>
|
||||||
Boolean(props.title.trim() || props.customer.trim() || props.due || props.assigneeId) ||
|
Boolean(props.title.trim() || props.customer.trim() || props.due || props.assigneeId) ||
|
||||||
props.typeKey !== 'all' ||
|
props.typeKey !== 'all' ||
|
||||||
|
props.priorityKey !== 'all' ||
|
||||||
props.statusKey !== 'all',
|
props.statusKey !== 'all',
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -101,6 +112,9 @@ const whoLabel = computed(
|
|||||||
const typeLabel = computed(
|
const typeLabel = computed(
|
||||||
() => props.types.find((item) => item.key === props.typeKey)?.label || 'همه',
|
() => props.types.find((item) => item.key === props.typeKey)?.label || 'همه',
|
||||||
);
|
);
|
||||||
|
const priorityLabel = computed(
|
||||||
|
() => props.priorities.find((item) => item.key === props.priorityKey)?.label || 'همه',
|
||||||
|
);
|
||||||
const statusLabel = computed(
|
const statusLabel = computed(
|
||||||
() => props.statuses.find((item) => item.key === props.statusKey)?.label || 'همه',
|
() => props.statuses.find((item) => item.key === props.statusKey)?.label || 'همه',
|
||||||
);
|
);
|
||||||
@@ -144,6 +158,11 @@ function pickType(next: string) {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pickPriority(next: string) {
|
||||||
|
emit('priority', props.priorityKey === next && next !== 'all' ? 'all' : next);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
function pickStatus(next: string) {
|
function pickStatus(next: string) {
|
||||||
emit('status', props.statusKey === next && next !== 'all' ? 'all' : next);
|
emit('status', props.statusKey === next && next !== 'all' ? 'all' : next);
|
||||||
finish();
|
finish();
|
||||||
@@ -282,6 +301,36 @@ function pickAssignee(next: string) {
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section v-if="shows('priority')">
|
||||||
|
<button
|
||||||
|
v-if="field === 'all'"
|
||||||
|
type="button"
|
||||||
|
class="acc"
|
||||||
|
:class="{ on: priorityKey !== 'all' }"
|
||||||
|
@click="toggleSection('priority')"
|
||||||
|
>
|
||||||
|
<span>اولویت</span>
|
||||||
|
<em>{{ priorityLabel }}</em>
|
||||||
|
</button>
|
||||||
|
<div v-if="opened('priority')" class="pick" role="listbox" aria-label="اولویت">
|
||||||
|
<button
|
||||||
|
v-for="opt in priorities"
|
||||||
|
:key="opt.key"
|
||||||
|
type="button"
|
||||||
|
:class="{ on: priorityKey === opt.key }"
|
||||||
|
@click="pickPriority(opt.key)"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
v-if="opt.color && opt.key !== 'all'"
|
||||||
|
class="prio-dot"
|
||||||
|
:style="{ background: opt.color }"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
{{ opt.label }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section v-if="shows('when')">
|
<section v-if="shows('when')">
|
||||||
<button
|
<button
|
||||||
v-if="field === 'all'"
|
v-if="field === 'all'"
|
||||||
@@ -434,6 +483,9 @@ function pickAssignee(next: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.pick button {
|
.pick button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.4rem;
|
||||||
text-align: start;
|
text-align: start;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 0.42rem 0.5rem;
|
padding: 0.42rem 0.5rem;
|
||||||
@@ -450,6 +502,13 @@ function pickAssignee(next: string) {
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.prio-dot {
|
||||||
|
width: 0.55rem;
|
||||||
|
height: 0.55rem;
|
||||||
|
border-radius: 50%;
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
|
||||||
.seg {
|
.seg {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import type {
|
|||||||
ActivityBoardDto,
|
ActivityBoardDto,
|
||||||
ActivityDto,
|
ActivityDto,
|
||||||
ActivityFilter,
|
ActivityFilter,
|
||||||
|
ActivityPriority,
|
||||||
ActivityStageCountsDto,
|
ActivityStageCountsDto,
|
||||||
ActivityStageDto,
|
ActivityStageDto,
|
||||||
ActivityStatus,
|
ActivityStatus,
|
||||||
@@ -51,7 +52,7 @@ import type {
|
|||||||
OrgUserDto,
|
OrgUserDto,
|
||||||
PaginatedResponse,
|
PaginatedResponse,
|
||||||
} from '@mento/shared';
|
} from '@mento/shared';
|
||||||
import { brand } from '@mento/shared';
|
import { ACTIVITY_PRIORITY_KEYS, brand } from '@mento/shared';
|
||||||
import { useAuthStore } from '@/stores/auth';
|
import { useAuthStore } from '@/stores/auth';
|
||||||
import { canMutateActivity } from '@/lib/activity-access';
|
import { canMutateActivity } from '@/lib/activity-access';
|
||||||
import { canManageSettings, canViewAllRecords } from '@/lib/roles';
|
import { canManageSettings, canViewAllRecords } from '@/lib/roles';
|
||||||
@@ -95,6 +96,7 @@ const actGridStyle = computed(() => ({
|
|||||||
|
|
||||||
/** 'all' یا شناسهٔ نوع فعالیت */
|
/** 'all' یا شناسهٔ نوع فعالیت */
|
||||||
type TypeFilter = string;
|
type TypeFilter = string;
|
||||||
|
type PriorityFilter = 'all' | ActivityPriority;
|
||||||
type StatusFilter = 'all' | ActivityStatus;
|
type StatusFilter = 'all' | ActivityStatus;
|
||||||
type UiStatus = 'done' | 'progress' | 'planned' | 'overdue' | 'canceled';
|
type UiStatus = 'done' | 'progress' | 'planned' | 'overdue' | 'canceled';
|
||||||
type DeskScope = 'mine' | 'team';
|
type DeskScope = 'mine' | 'team';
|
||||||
@@ -122,6 +124,18 @@ const STATUS_FILTERS: Array<{ key: StatusFilter; label: string }> = [
|
|||||||
{ key: 'canceled', label: 'لغو شده' },
|
{ key: 'canceled', label: 'لغو شده' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const activityPriorities = useActivityPriorities();
|
||||||
|
const PRIORITY_FILTERS = computed<
|
||||||
|
Array<{ key: PriorityFilter; label: string; color?: string }>
|
||||||
|
>(() => [
|
||||||
|
{ key: 'all', label: 'همه اولویتها' },
|
||||||
|
...activityPriorities.items.value.map((row) => ({
|
||||||
|
key: row.key as PriorityFilter,
|
||||||
|
label: row.label,
|
||||||
|
color: row.color,
|
||||||
|
})),
|
||||||
|
]);
|
||||||
|
|
||||||
const pageSize = usePageSize('activities', 10);
|
const pageSize = usePageSize('activities', 10);
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@@ -181,7 +195,7 @@ const boardDeleteOpen = ref(false);
|
|||||||
|
|
||||||
async function onTypesChanged() {
|
async function onTypesChanged() {
|
||||||
await activityTypes.load(true);
|
await activityTypes.load(true);
|
||||||
await useActivityPriorities().load(true);
|
await activityPriorities.load(true);
|
||||||
kanbanReload.value += 1;
|
kanbanReload.value += 1;
|
||||||
await refreshAll();
|
await refreshAll();
|
||||||
}
|
}
|
||||||
@@ -245,6 +259,13 @@ const statusFilter = computed<StatusFilter>(() => {
|
|||||||
: 'all';
|
: 'all';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const priorityFilter = computed<PriorityFilter>(() => {
|
||||||
|
const value = typeof route.query.priority === 'string' ? route.query.priority : 'all';
|
||||||
|
return ACTIVITY_PRIORITY_KEYS.includes(value as ActivityPriority)
|
||||||
|
? (value as ActivityPriority)
|
||||||
|
: 'all';
|
||||||
|
});
|
||||||
|
|
||||||
const assigneeFilter = computed(() =>
|
const assigneeFilter = computed(() =>
|
||||||
typeof route.query.assigneeId === 'string' ? route.query.assigneeId : '',
|
typeof route.query.assigneeId === 'string' ? route.query.assigneeId : '',
|
||||||
);
|
);
|
||||||
@@ -323,6 +344,7 @@ const sharedParams = computed<Record<string, string | undefined>>(() => ({
|
|||||||
? legacyBaseType.value
|
? legacyBaseType.value
|
||||||
: undefined,
|
: undefined,
|
||||||
status: statusFilter.value === 'all' ? undefined : statusFilter.value,
|
status: statusFilter.value === 'all' ? undefined : statusFilter.value,
|
||||||
|
priority: priorityFilter.value === 'all' ? undefined : priorityFilter.value,
|
||||||
assigneeId: assigneeFilter.value || undefined,
|
assigneeId: assigneeFilter.value || undefined,
|
||||||
title: titleFilter.value.trim() || undefined,
|
title: titleFilter.value.trim() || undefined,
|
||||||
customer: customerFilter.value.trim() || undefined,
|
customer: customerFilter.value.trim() || undefined,
|
||||||
@@ -335,6 +357,7 @@ function stageDotStyle(s: ActivityStageDto) {
|
|||||||
const activeFacetCount = computed(() => {
|
const activeFacetCount = computed(() => {
|
||||||
let n = 0;
|
let n = 0;
|
||||||
if (typeFilter.value !== 'all') n += 1;
|
if (typeFilter.value !== 'all') n += 1;
|
||||||
|
if (priorityFilter.value !== 'all') n += 1;
|
||||||
if (statusFilter.value !== 'all') n += 1;
|
if (statusFilter.value !== 'all') n += 1;
|
||||||
if (assigneeFilter.value) n += 1;
|
if (assigneeFilter.value) n += 1;
|
||||||
if (titleFilter.value.trim()) n += 1;
|
if (titleFilter.value.trim()) n += 1;
|
||||||
@@ -437,6 +460,7 @@ function deskDetailQuery(columnStageId?: string): Record<string, string> {
|
|||||||
if (search) query.q = search;
|
if (search) query.q = search;
|
||||||
if (typeFilter.value !== 'all') query.typeDefId = typeFilter.value;
|
if (typeFilter.value !== 'all') query.typeDefId = typeFilter.value;
|
||||||
if (statusFilter.value !== 'all') query.status = statusFilter.value;
|
if (statusFilter.value !== 'all') query.status = statusFilter.value;
|
||||||
|
if (priorityFilter.value !== 'all') query.priority = priorityFilter.value;
|
||||||
if (assigneeFilter.value) query.assigneeId = assigneeFilter.value;
|
if (assigneeFilter.value) query.assigneeId = assigneeFilter.value;
|
||||||
if (titleFilter.value.trim()) query.title = titleFilter.value.trim();
|
if (titleFilter.value.trim()) query.title = titleFilter.value.trim();
|
||||||
if (customerFilter.value.trim()) query.customer = customerFilter.value.trim();
|
if (customerFilter.value.trim()) query.customer = customerFilter.value.trim();
|
||||||
@@ -775,6 +799,13 @@ function setStatusFilter(next: string) {
|
|||||||
patchFacetQuery({ status: value === 'all' ? undefined : value });
|
patchFacetQuery({ status: value === 'all' ? undefined : value });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setPriorityFilter(next: string) {
|
||||||
|
const value: PriorityFilter = ACTIVITY_PRIORITY_KEYS.includes(next as ActivityPriority)
|
||||||
|
? (next as ActivityPriority)
|
||||||
|
: 'all';
|
||||||
|
patchFacetQuery({ priority: value === 'all' ? undefined : value });
|
||||||
|
}
|
||||||
|
|
||||||
function setAssigneeFilter(next: string) {
|
function setAssigneeFilter(next: string) {
|
||||||
patchFacetQuery({
|
patchFacetQuery({
|
||||||
assigneeId: next || undefined,
|
assigneeId: next || undefined,
|
||||||
@@ -799,6 +830,7 @@ function clearFacets() {
|
|||||||
type: undefined,
|
type: undefined,
|
||||||
typeDefId: undefined,
|
typeDefId: undefined,
|
||||||
status: undefined,
|
status: undefined,
|
||||||
|
priority: undefined,
|
||||||
assigneeId: undefined,
|
assigneeId: undefined,
|
||||||
title: undefined,
|
title: undefined,
|
||||||
customer: undefined,
|
customer: undefined,
|
||||||
@@ -1164,6 +1196,7 @@ onMounted(() => {
|
|||||||
mobileQuery.addEventListener('change', syncMobile);
|
mobileQuery.addEventListener('change', syncMobile);
|
||||||
void loadUsers();
|
void loadUsers();
|
||||||
void activityTypes.load(true);
|
void activityTypes.load(true);
|
||||||
|
void activityPriorities.load();
|
||||||
void loadBoards()
|
void loadBoards()
|
||||||
.then(() => loadStages())
|
.then(() => loadStages())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -1461,16 +1494,19 @@ onUnmounted(() => {
|
|||||||
:customer="customerFilter"
|
:customer="customerFilter"
|
||||||
:due="dueFilter"
|
:due="dueFilter"
|
||||||
:type-key="typeFilter"
|
:type-key="typeFilter"
|
||||||
|
:priority-key="priorityFilter"
|
||||||
:status-key="statusFilter"
|
:status-key="statusFilter"
|
||||||
:assignee-id="assigneeFilter"
|
:assignee-id="assigneeFilter"
|
||||||
:show-assignee="showDeskTabs"
|
:show-assignee="showDeskTabs"
|
||||||
:users="users"
|
:users="users"
|
||||||
:types="TYPE_FILTERS"
|
:types="TYPE_FILTERS"
|
||||||
|
:priorities="PRIORITY_FILTERS"
|
||||||
:statuses="STATUS_FILTERS"
|
:statuses="STATUS_FILTERS"
|
||||||
@title="setTitleFilter"
|
@title="setTitleFilter"
|
||||||
@customer="setCustomerFilter"
|
@customer="setCustomerFilter"
|
||||||
@due="setDueFilter"
|
@due="setDueFilter"
|
||||||
@type="setTypeFilter"
|
@type="setTypeFilter"
|
||||||
|
@priority="setPriorityFilter"
|
||||||
@status="setStatusFilter"
|
@status="setStatusFilter"
|
||||||
@assignee="setAssigneeFilter"
|
@assignee="setAssigneeFilter"
|
||||||
@clear="clearFacets"
|
@clear="clearFacets"
|
||||||
@@ -1680,16 +1716,19 @@ onUnmounted(() => {
|
|||||||
:customer="customerFilter"
|
:customer="customerFilter"
|
||||||
:due="dueFilter"
|
:due="dueFilter"
|
||||||
:type-key="typeFilter"
|
:type-key="typeFilter"
|
||||||
|
:priority-key="priorityFilter"
|
||||||
:status-key="statusFilter"
|
:status-key="statusFilter"
|
||||||
:assignee-id="assigneeFilter"
|
:assignee-id="assigneeFilter"
|
||||||
:show-assignee="showDeskTabs"
|
:show-assignee="showDeskTabs"
|
||||||
:users="users"
|
:users="users"
|
||||||
:types="TYPE_FILTERS"
|
:types="TYPE_FILTERS"
|
||||||
|
:priorities="PRIORITY_FILTERS"
|
||||||
:statuses="STATUS_FILTERS"
|
:statuses="STATUS_FILTERS"
|
||||||
@title="setTitleFilter"
|
@title="setTitleFilter"
|
||||||
@customer="setCustomerFilter"
|
@customer="setCustomerFilter"
|
||||||
@due="setDueFilter"
|
@due="setDueFilter"
|
||||||
@type="setTypeFilter"
|
@type="setTypeFilter"
|
||||||
|
@priority="setPriorityFilter"
|
||||||
@status="setStatusFilter"
|
@status="setStatusFilter"
|
||||||
@assignee="setAssigneeFilter"
|
@assignee="setAssigneeFilter"
|
||||||
@done="onFacetDone"
|
@done="onFacetDone"
|
||||||
|
|||||||
@@ -52,8 +52,33 @@ import {
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const ACTIVITY_LIST_QUERY = ['board', 'view', 'desk', 'filter', 'stage', 'q', 'typeDefId', 'status', 'assigneeId', 'title', 'customer', 'due'] as const;
|
const ACTIVITY_LIST_QUERY = [
|
||||||
const NAV_API_QUERY = ['q', 'desk', 'type', 'typeDefId', 'status', 'assigneeId', 'title', 'customer', 'due'] as const;
|
'board',
|
||||||
|
'view',
|
||||||
|
'desk',
|
||||||
|
'filter',
|
||||||
|
'stage',
|
||||||
|
'q',
|
||||||
|
'typeDefId',
|
||||||
|
'status',
|
||||||
|
'priority',
|
||||||
|
'assigneeId',
|
||||||
|
'title',
|
||||||
|
'customer',
|
||||||
|
'due',
|
||||||
|
] as const;
|
||||||
|
const NAV_API_QUERY = [
|
||||||
|
'q',
|
||||||
|
'desk',
|
||||||
|
'type',
|
||||||
|
'typeDefId',
|
||||||
|
'status',
|
||||||
|
'priority',
|
||||||
|
'assigneeId',
|
||||||
|
'title',
|
||||||
|
'customer',
|
||||||
|
'due',
|
||||||
|
] as const;
|
||||||
|
|
||||||
function activitiesListLocation() {
|
function activitiesListLocation() {
|
||||||
const query: Record<string, string> = {};
|
const query: Record<string, string> = {};
|
||||||
@@ -800,6 +825,7 @@ function moveToStage(stageId: string) {
|
|||||||
if (activity.value.stageId === stageId) return;
|
if (activity.value.stageId === stageId) return;
|
||||||
const target = boardStages.value.find((stage) => stage.id === stageId);
|
const target = boardStages.value.find((stage) => stage.id === stageId);
|
||||||
if (!target) return;
|
if (!target) return;
|
||||||
|
const leftId = id.value;
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: 'جابهجایی مرحله',
|
title: 'جابهجایی مرحله',
|
||||||
content: `به ستون «${target.name}» منتقل میشود. انجام شود؟`,
|
content: `به ستون «${target.name}» منتقل میشود. انجام شود؟`,
|
||||||
@@ -810,7 +836,7 @@ function moveToStage(stageId: string) {
|
|||||||
stageMoving.value = true;
|
stageMoving.value = true;
|
||||||
error.value = '';
|
error.value = '';
|
||||||
try {
|
try {
|
||||||
const { data } = await api.patch<ActivityDto>(`/activities/${id.value}/stage`, { stageId });
|
const { data } = await api.patch<ActivityDto>(`/activities/${leftId}/stage`, { stageId });
|
||||||
if (data.status !== target.kind) {
|
if (data.status !== target.kind) {
|
||||||
message.info(
|
message.info(
|
||||||
'سهم شما ثبت شد. فعالیت وقتی انجامشده میشود که همهٔ مسئولها سهم خود را بزنند.',
|
'سهم شما ثبت شد. فعالیت وقتی انجامشده میشود که همهٔ مسئولها سهم خود را بزنند.',
|
||||||
@@ -818,8 +844,8 @@ function moveToStage(stageId: string) {
|
|||||||
await load();
|
await load();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
activity.value = data;
|
discardDrafts();
|
||||||
hydrateDraft(data);
|
await advanceAfterLeavingColumn(leftId);
|
||||||
} catch {
|
} catch {
|
||||||
error.value = 'جابهجایی مرحله ناموفق بود.';
|
error.value = 'جابهجایی مرحله ناموفق بود.';
|
||||||
throw new Error('stage-move-failed');
|
throw new Error('stage-move-failed');
|
||||||
@@ -877,20 +903,20 @@ async function loadUsers() {
|
|||||||
async function complete(kind: 'share' | 'force' | 'undo' = 'share') {
|
async function complete(kind: 'share' | 'force' | 'undo' = 'share') {
|
||||||
if (!id.value) return;
|
if (!id.value) return;
|
||||||
if (kind !== 'undo' && isDone.value) return;
|
if (kind !== 'undo' && isDone.value) return;
|
||||||
|
const leftId = id.value;
|
||||||
saving.value = true;
|
saving.value = true;
|
||||||
error.value = '';
|
error.value = '';
|
||||||
try {
|
try {
|
||||||
const params =
|
const params =
|
||||||
kind === 'force' ? { force: '1' } : kind === 'undo' ? { undo: '1' } : undefined;
|
kind === 'force' ? { force: '1' } : kind === 'undo' ? { undo: '1' } : undefined;
|
||||||
const { data } = await api.patch<ActivityDto>(
|
const { data } = await api.patch<ActivityDto>(
|
||||||
`/activities/${id.value}/complete`,
|
`/activities/${leftId}/complete`,
|
||||||
undefined,
|
undefined,
|
||||||
{ params },
|
{ params },
|
||||||
);
|
);
|
||||||
if (data.status === 'done') {
|
if (data.status === 'done') {
|
||||||
// مثل بازگشت و پیشنمایش: فیلتر/نمای قبلی حفظ شود
|
|
||||||
discardDrafts();
|
discardDrafts();
|
||||||
leaveToActivitiesList();
|
await advanceAfterLeavingColumn(leftId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
activity.value = data;
|
activity.value = data;
|
||||||
@@ -928,11 +954,13 @@ async function reopen() {
|
|||||||
warnNoMutatePermission();
|
warnNoMutatePermission();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const leftId = id.value;
|
||||||
saving.value = true;
|
saving.value = true;
|
||||||
error.value = '';
|
error.value = '';
|
||||||
try {
|
try {
|
||||||
await api.patch(`/activities/${id.value}`, { status: 'open' });
|
await api.patch(`/activities/${leftId}`, { status: 'open' });
|
||||||
await load();
|
discardDrafts();
|
||||||
|
await advanceAfterLeavingColumn(leftId);
|
||||||
} catch {
|
} catch {
|
||||||
error.value = 'بازگشایی کار ناموفق بود.';
|
error.value = 'بازگشایی کار ناموفق بود.';
|
||||||
} finally {
|
} finally {
|
||||||
@@ -1003,6 +1031,13 @@ const navIds = ref<string[]>([]);
|
|||||||
const deskBrowse = computed(
|
const deskBrowse = computed(
|
||||||
() => route.query.from === 'desk' && typeof route.query.nav === 'string' && route.query.nav.length > 0,
|
() => route.query.from === 'desk' && typeof route.query.nav === 'string' && route.query.nav.length > 0,
|
||||||
);
|
);
|
||||||
|
const navColumnStageId = computed(() => {
|
||||||
|
const fromQuery =
|
||||||
|
typeof route.query.stage === 'string' && route.query.stage && route.query.stage !== 'all'
|
||||||
|
? route.query.stage
|
||||||
|
: '';
|
||||||
|
return fromQuery || activity.value?.stageId || '';
|
||||||
|
});
|
||||||
const navIndex = computed(() => navIds.value.indexOf(id.value));
|
const navIndex = computed(() => navIds.value.indexOf(id.value));
|
||||||
const prevNavId = computed(() => (navIndex.value > 0 ? navIds.value[navIndex.value - 1]! : ''));
|
const prevNavId = computed(() => (navIndex.value > 0 ? navIds.value[navIndex.value - 1]! : ''));
|
||||||
const nextNavId = computed(() =>
|
const nextNavId = computed(() =>
|
||||||
@@ -1012,13 +1047,13 @@ const nextNavId = computed(() =>
|
|||||||
);
|
);
|
||||||
const showNav = computed(() => deskBrowse.value && navIndex.value >= 0);
|
const showNav = computed(() => deskBrowse.value && navIndex.value >= 0);
|
||||||
|
|
||||||
function navStorageKey(token: string) {
|
function navStorageKey(token: string, stageId: string) {
|
||||||
return `activity-nav:${token}`;
|
return `activity-nav:${token}:${stageId || 'none'}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function readNavCache(token: string): string[] | null {
|
function readNavCache(token: string, stageId: string): string[] | null {
|
||||||
try {
|
try {
|
||||||
const raw = sessionStorage.getItem(navStorageKey(token));
|
const raw = sessionStorage.getItem(navStorageKey(token, stageId));
|
||||||
if (!raw) return null;
|
if (!raw) return null;
|
||||||
const parsed = JSON.parse(raw) as { ids?: unknown };
|
const parsed = JSON.parse(raw) as { ids?: unknown };
|
||||||
if (!Array.isArray(parsed.ids) || parsed.ids.some((item) => typeof item !== 'string')) return null;
|
if (!Array.isArray(parsed.ids) || parsed.ids.some((item) => typeof item !== 'string')) return null;
|
||||||
@@ -1028,42 +1063,70 @@ function readNavCache(token: string): string[] | null {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function writeNavCache(token: string, stageId: string, ids: string[]) {
|
||||||
|
try {
|
||||||
|
sessionStorage.setItem(navStorageKey(token, stageId), JSON.stringify({ ids }));
|
||||||
|
} catch {
|
||||||
|
/* حالت خصوصی مرورگر */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** بعد از ترک ستون: برو بعدیِ همان ستون، وگرنه قبلی؛ اگر خالی بود برو فهرست. */
|
||||||
|
async function advanceAfterLeavingColumn(leftId: string) {
|
||||||
|
commentOpen.value = false;
|
||||||
|
postponeOpen.value = false;
|
||||||
|
if (!deskBrowse.value) {
|
||||||
|
leaveToActivitiesList();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const list = navIds.value;
|
||||||
|
const idx = list.indexOf(leftId);
|
||||||
|
const target =
|
||||||
|
idx >= 0 && idx < list.length - 1
|
||||||
|
? list[idx + 1]!
|
||||||
|
: idx > 0
|
||||||
|
? list[idx - 1]!
|
||||||
|
: '';
|
||||||
|
const remaining = list.filter((item) => item !== leftId);
|
||||||
|
navIds.value = remaining;
|
||||||
|
const token = typeof route.query.nav === 'string' ? route.query.nav : '';
|
||||||
|
const stageId = navColumnStageId.value;
|
||||||
|
if (token) writeNavCache(token, stageId, remaining);
|
||||||
|
if (target) {
|
||||||
|
await router.push({ name: 'activity-detail', params: { id: target }, query: route.query });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
leaveToActivitiesList();
|
||||||
|
}
|
||||||
|
|
||||||
let navSeq = 0;
|
let navSeq = 0;
|
||||||
async function loadNav() {
|
async function loadNav() {
|
||||||
const seq = ++navSeq;
|
const seq = ++navSeq;
|
||||||
const token = typeof route.query.nav === 'string' ? route.query.nav : '';
|
const token = typeof route.query.nav === 'string' ? route.query.nav : '';
|
||||||
const columnMissing =
|
const stageId = navColumnStageId.value;
|
||||||
route.query.view === 'board' &&
|
if (!deskBrowse.value || !token || !stageId) {
|
||||||
(typeof route.query.stage !== 'string' || !route.query.stage || route.query.stage === 'all');
|
if (seq === navSeq) navIds.value = [];
|
||||||
if (!deskBrowse.value || !token || columnMissing) {
|
|
||||||
navIds.value = [];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const cached = readNavCache(token);
|
const cached = readNavCache(token, stageId);
|
||||||
if (cached) {
|
if (cached) {
|
||||||
if (seq === navSeq) navIds.value = cached;
|
if (seq === navSeq) navIds.value = cached;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const params: Record<string, string> = {
|
const params: Record<string, string> = {
|
||||||
filter: typeof route.query.filter === 'string' && route.query.filter ? route.query.filter : 'today',
|
filter: typeof route.query.filter === 'string' && route.query.filter ? route.query.filter : 'today',
|
||||||
|
stageId,
|
||||||
};
|
};
|
||||||
for (const key of NAV_API_QUERY) {
|
for (const key of NAV_API_QUERY) {
|
||||||
const value = route.query[key];
|
const value = route.query[key];
|
||||||
if (typeof value === 'string' && value) params[key] = value;
|
if (typeof value === 'string' && value) params[key] = value;
|
||||||
}
|
}
|
||||||
if (typeof route.query.board === 'string' && route.query.board) params.boardId = route.query.board;
|
if (typeof route.query.board === 'string' && route.query.board) params.boardId = route.query.board;
|
||||||
if (typeof route.query.stage === 'string' && route.query.stage && route.query.stage !== 'all') {
|
|
||||||
params.stageId = route.query.stage;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
const { data } = await api.get<{ ids: string[] }>('/activities/nav-ids', { params });
|
const { data } = await api.get<{ ids: string[] }>('/activities/nav-ids', { params });
|
||||||
if (seq !== navSeq) return;
|
if (seq !== navSeq) return;
|
||||||
const ids = Array.isArray(data.ids) ? data.ids : [];
|
const ids = Array.isArray(data.ids) ? data.ids : [];
|
||||||
try {
|
writeNavCache(token, stageId, ids);
|
||||||
sessionStorage.setItem(navStorageKey(token), JSON.stringify({ ids }));
|
|
||||||
} catch {
|
|
||||||
/* حالت خصوصی مرورگر */
|
|
||||||
}
|
|
||||||
navIds.value = ids;
|
navIds.value = ids;
|
||||||
} catch {
|
} catch {
|
||||||
if (seq === navSeq) navIds.value = [];
|
if (seq === navSeq) navIds.value = [];
|
||||||
@@ -1083,7 +1146,11 @@ watch(id, () => {
|
|||||||
postponeOpen.value = false;
|
postponeOpen.value = false;
|
||||||
void load();
|
void load();
|
||||||
});
|
});
|
||||||
watch(() => route.query.nav, () => void loadNav(), { immediate: true });
|
watch(
|
||||||
|
() => [route.query.nav, navColumnStageId.value] as const,
|
||||||
|
() => void loadNav(),
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
/** بدون next() — در Vue Router 4 گارد async+next باعث رد شدن بدون پرسش میشد */
|
/** بدون next() — در Vue Router 4 گارد async+next باعث رد شدن بدون پرسش میشد */
|
||||||
onBeforeRouteLeave(async () => resolveDirty());
|
onBeforeRouteLeave(async () => resolveDirty());
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user