merge: bring latest origin/main into dev (keep local UI)

Resolved UI conflicts in favor of local Ant Design screens; kept non-UI changes from main.
This commit is contained in:
2026-11-03 16:55:42 +03:30
201 changed files with 19202 additions and 1607 deletions
@@ -42,7 +42,7 @@ const emit = defineEmits<{
stagesChanged: [];
add: [stageId: string];
error: [message: string];
menuDeal: [activity: ActivityDto];
menuDeal: [activity: ActivityDto, stageId?: string];
toggleSelect: [activityId: string];
bulkDelete: [];
}>();
@@ -218,7 +218,7 @@ function findActivity(id: string) {
function onMenuActivity(id: string) {
const item = findActivity(id);
if (item) emit('menuDeal', item);
if (item) emit('menuDeal', item, findStageOf(id));
}
function onDragStart(deal: PipelineDeal, event: DragEvent) {
@@ -391,7 +391,26 @@ async function onAddStage(name: string) {
}
function openActivity(id: string) {
void router.push({ name: 'activity-detail', params: { id } });
const query: Record<string, string> = {
from: 'desk',
nav: crypto.randomUUID(),
view: 'board',
};
const source = props.params;
if (source.filter) query.filter = source.filter;
if (source.boardId) query.board = source.boardId;
if (source.desk) query.desk = source.desk;
if (source.q) query.q = source.q;
if (source.typeDefId) query.typeDefId = source.typeDefId;
else if (source.type) query.type = source.type;
if (source.status) query.status = source.status;
if (source.assigneeId) query.assigneeId = source.assigneeId;
if (source.title) query.title = source.title;
if (source.customer) query.customer = source.customer;
if (source.due) query.due = source.due;
const columnId = findStageOf(id);
if (columnId) query.stage = columnId;
void router.push({ name: 'activity-detail', params: { id }, query });
}
</script>
@@ -6,6 +6,8 @@ import {
formatClockFa,
formatJalaliDay,
} from '@/lib/jalali';
import { prepareActivityAttachment } from '@/lib/activity-attachment';
import { startVoiceRecorder, type VoiceRecorder } from '@/lib/voice-note';
import { appendSpokenText } from '@/lib/spoken-text';
import UiIcon from '@/components/UiIcon.vue';
import VoiceToTextButton from '@/components/VoiceToTextButton.vue';
@@ -14,11 +16,11 @@ import type { ActivityDto, ActivityType, OrganizationDto, OrgUserDto } from '@me
const props = defineProps<{
activity: ActivityDto;
saving?: boolean;
save: (payload: { text: string; photoOnly: boolean }) => Promise<void>;
}>();
const emit = defineEmits<{
close: [];
submit: [text: string];
}>();
const typeIcon: Record<ActivityType, 'phone' | 'users' | 'check' | 'chat'> = {
@@ -28,8 +30,26 @@ const typeIcon: Record<ActivityType, 'phone' | 'users' | 'check' | 'chat'> = {
note: 'chat',
};
const PHOTO_LIMIT = 8;
const VOICE_LIMIT = 5;
const FILE_LIMIT = 8;
type PendingPhoto = { localId: string; name: string; dataUrl: string; file: File };
type PendingVoice = { localId: string; name: string; url: string; file: File };
type PendingFile = { localId: string; name: string; file: File };
const comment = ref('');
const textareaRef = ref<HTMLTextAreaElement | null>(null);
const pendingPhotos = ref<PendingPhoto[]>([]);
const pendingVoices = ref<PendingVoice[]>([]);
const pendingFiles = ref<PendingFile[]>([]);
const uploadedCount = ref(0);
const photoBusy = ref(false);
const uploading = ref(false);
const photoError = ref('');
const fileInput = ref<HTMLInputElement | null>(null);
const voiceNoteOn = ref(false);
const voiceNoteSeconds = ref(0);
let voiceNote: VoiceRecorder | null = null;
const orgName = ref('سازمان');
const users = ref<OrgUserDto[]>([]);
const mentionOpen = ref(false);
@@ -61,8 +81,29 @@ const nowLabel = computed(
() => `${formatJalaliDay(now.value)} ساعت ${formatClockFa(now.value)}`,
);
function imageCount(kind: 'image' | 'audio' | 'file') {
return (
props.activity.images?.filter((image) => {
const mime = image.mimeType.toLowerCase();
if (kind === 'audio') return mime.startsWith('audio/');
if (kind === 'image') return mime.startsWith('image/');
return !mime.startsWith('audio/') && !mime.startsWith('image/');
}).length ?? 0
);
}
const canSubmit = computed(
() => comment.value.trim().length > 0 && !props.saving && !voiceBusy.value,
() =>
(comment.value.trim().length > 0 ||
pendingPhotos.value.length > 0 ||
pendingVoices.value.length > 0 ||
pendingFiles.value.length > 0 ||
uploadedCount.value > 0) &&
!props.saving &&
!voiceBusy.value &&
!photoBusy.value &&
!uploading.value &&
!voiceNoteOn.value,
);
function onVoiceTranscript(text: string) {
@@ -77,10 +118,164 @@ function onVoiceBusy(active: boolean) {
}
}
function submit() {
function apiMessage(error: unknown, fallback: string) {
const raw = (error as { response?: { data?: { message?: string | string[] } } }).response?.data
?.message;
if (Array.isArray(raw)) return raw.join('، ');
if (typeof raw === 'string' && raw.trim()) return raw;
return fallback;
}
async function onFilesPicked(event: Event) {
const input = event.target as HTMLInputElement;
const files = Array.from(input.files ?? []);
input.value = '';
if (!files.length) return;
photoError.value = '';
for (const file of files) {
photoBusy.value = true;
try {
const prepared = await prepareActivityAttachment(file);
if (prepared.kind === 'image') {
if (imageCount('image') + pendingPhotos.value.length >= PHOTO_LIMIT) {
photoError.value = `حداکثر ${PHOTO_LIMIT} عکس برای هر فعالیت.`;
continue;
}
pendingPhotos.value = [
...pendingPhotos.value,
{ localId: crypto.randomUUID(), name: prepared.name, dataUrl: prepared.previewUrl, file: prepared.file },
];
} else if (prepared.kind === 'audio') {
if (imageCount('audio') + pendingVoices.value.length >= VOICE_LIMIT) {
URL.revokeObjectURL(prepared.previewUrl);
photoError.value = `حداکثر ${VOICE_LIMIT} صوت برای هر فعالیت.`;
continue;
}
pendingVoices.value = [
...pendingVoices.value,
{ localId: crypto.randomUUID(), name: prepared.name, url: prepared.previewUrl, file: prepared.file },
];
} else if (imageCount('file') + pendingFiles.value.length >= FILE_LIMIT) {
photoError.value = `حداکثر ${FILE_LIMIT} فایل برای هر فعالیت.`;
} else {
pendingFiles.value = [
...pendingFiles.value,
{ localId: crypto.randomUUID(), name: prepared.name, file: prepared.file },
];
}
} catch (error) {
photoError.value = error instanceof Error ? error.message : 'افزودن فایل ناموفق بود.';
} finally {
photoBusy.value = false;
}
}
}
function removePendingPhoto(localId: string) {
pendingPhotos.value = pendingPhotos.value.filter((photo) => photo.localId !== localId);
}
function removePendingVoice(localId: string) {
const voice = pendingVoices.value.find((item) => item.localId === localId);
if (voice) URL.revokeObjectURL(voice.url);
pendingVoices.value = pendingVoices.value.filter((item) => item.localId !== localId);
}
function removePendingFile(localId: string) {
pendingFiles.value = pendingFiles.value.filter((item) => item.localId !== localId);
}
function voiceClock(total: number) {
return `${Math.floor(total / 60)}:${String(total % 60).padStart(2, '0')}`;
}
function addVoiceNote(file: File) {
if (imageCount('audio') + pendingVoices.value.length >= VOICE_LIMIT) {
photoError.value = `حداکثر ${VOICE_LIMIT} صوت برای هر فعالیت.`;
return;
}
pendingVoices.value = [
...pendingVoices.value,
{ localId: crypto.randomUUID(), name: file.name, url: URL.createObjectURL(file), file },
];
}
async function toggleVoiceNote() {
photoError.value = '';
if (voiceNote) {
const handle = voiceNote;
voiceNote = null;
voiceNoteOn.value = false;
try {
addVoiceNote(await handle.stop());
} catch (error) {
photoError.value = error instanceof Error ? error.message : 'ضبط صوت ناموفق بود.';
}
return;
}
try {
voiceNoteSeconds.value = 0;
voiceNote = await startVoiceRecorder({
onTick: (seconds) => {
voiceNoteSeconds.value = seconds;
},
onAutoStop: (file) => {
voiceNote = null;
voiceNoteOn.value = false;
addVoiceNote(file);
},
});
voiceNoteOn.value = true;
} catch (error) {
photoError.value = error instanceof Error ? error.message : 'ضبط صوت ناموفق بود.';
}
}
async function uploadQueue(items: Array<{ localId: string; name: string; file: File }>, drop: (localId: string) => void) {
for (const item of items) {
const form = new FormData();
form.append('file', item.file, item.name);
await api.post(`/activities/${props.activity.id}/images`, form);
drop(item.localId);
uploadedCount.value += 1;
}
}
async function uploadPendingPhotos() {
await uploadQueue([...pendingPhotos.value], (localId) => {
pendingPhotos.value = pendingPhotos.value.filter((item) => item.localId !== localId);
});
await uploadQueue([...pendingVoices.value], (localId) => {
const voice = pendingVoices.value.find((item) => item.localId === localId);
if (voice) URL.revokeObjectURL(voice.url);
pendingVoices.value = pendingVoices.value.filter((item) => item.localId !== localId);
});
await uploadQueue([...pendingFiles.value], (localId) => {
pendingFiles.value = pendingFiles.value.filter((item) => item.localId !== localId);
});
}
async function submit() {
const text = comment.value.trim();
if (!text || props.saving || voiceBusy.value) return;
emit('submit', text);
if (!canSubmit.value) return;
photoError.value = '';
uploading.value = true;
const hadPhoto =
pendingPhotos.value.length > 0 ||
pendingVoices.value.length > 0 ||
pendingFiles.value.length > 0 ||
uploadedCount.value > 0;
try {
await uploadPendingPhotos();
await props.save({ text, photoOnly: hadPhoto && !text });
} catch (error) {
photoError.value =
pendingPhotos.value.length > 0
? apiMessage(error, 'افزودن فایل ناموفق بود.')
: apiMessage(error, 'ثبت نظر ناموفق بود.');
} finally {
uploading.value = false;
}
}
function close() {
@@ -150,6 +345,8 @@ onMounted(async () => {
});
onBeforeUnmount(() => {
voiceNote?.cancel();
for (const voice of pendingVoices.value) URL.revokeObjectURL(voice.url);
document.body.style.overflow = '';
window.removeEventListener('keydown', onKeydown);
clearInterval(clockTimer);
@@ -215,13 +412,40 @@ onBeforeUnmount(() => {
rows="6"
placeholder="متن خود را بنویسید..."
/>
<p v-if="photoError" class="photo-err">{{ photoError }}</p>
<div v-if="pendingPhotos.length" class="photo-grid">
<figure v-for="photo in pendingPhotos" :key="photo.localId">
<img :src="photo.dataUrl" :alt="photo.name" />
<button type="button" aria-label="حذف عکس" :disabled="uploading" @click="removePendingPhoto(photo.localId)">
×
</button>
</figure>
</div>
<div v-if="pendingVoices.length" class="voice-list">
<div v-for="voice in pendingVoices" :key="voice.localId" class="voice-item">
<audio :src="voice.url" controls preload="metadata" />
<button type="button" aria-label="حذف صوت" :disabled="uploading" @click="removePendingVoice(voice.localId)">
×
</button>
</div>
</div>
<ul v-if="pendingFiles.length" class="file-list">
<li v-for="file in pendingFiles" :key="file.localId">
<UiIcon name="document" :size="15" />
<span>{{ file.name }}</span>
<button type="button" aria-label="حذف فایل" :disabled="uploading" @click="removePendingFile(file.localId)">
×
</button>
</li>
</ul>
<div class="tools">
<div class="tool-cluster">
<div class="tool-wrap">
<button
class="tool"
type="button"
aria-label="منشن"
:disabled="recording"
:disabled="recording || voiceNoteOn"
@click="mentionOpen = !mentionOpen"
>
@
@@ -235,12 +459,36 @@ onBeforeUnmount(() => {
</li>
</ul>
</div>
<button
class="tool"
type="button"
aria-label="پیوست"
title="پیوست"
:disabled="photoBusy || uploading || recording || voiceNoteOn"
@click="fileInput?.click()"
>
<UiIcon name="clip" :size="16" />
</button>
<input ref="fileInput" class="photo-file" type="file" multiple @change="onFilesPicked" />
<button
class="tool"
type="button"
:class="{ 'voice-on': voiceNoteOn }"
:aria-label="voiceNoteOn ? 'توقف ضبط پیام صوتی' : 'ضبط پیام صوتی'"
:title="voiceNoteOn ? 'توقف ضبط پیام صوتی' : 'ضبط پیام صوتی'"
:disabled="photoBusy || uploading || recording"
@click="toggleVoiceNote"
>
<UiIcon name="mic" :size="16" />
</button>
<span v-if="voiceNoteOn" class="rec-time">{{ voiceClock(voiceNoteSeconds) }}</span>
</div>
<div class="tool-wrap">
<p v-if="voiceTip && !recording" class="tip">تایپ صوتی را امتحان کنید! 🎙️✨</p>
<VoiceToTextButton
variant="toolbar"
hide-error
:disabled="saving"
:disabled="saving || voiceNoteOn"
@transcript="onVoiceTranscript"
@recording="recording = $event"
@busy="onVoiceBusy"
@@ -259,9 +507,9 @@ onBeforeUnmount(() => {
<div class="actions">
<button class="act primary" type="button" :disabled="!canSubmit" @click="submit">
{{ recording ? 'در حال ضبط…' : 'ثبت نظر' }}
{{ recording ? 'در حال ضبط…' : uploading || saving ? 'در حال ثبت…' : 'ثبت نظر' }}
</button>
<button class="act ghost" type="button" :disabled="saving || voiceBusy" @click="close">انصراف</button>
<button class="act ghost" type="button" :disabled="saving || voiceBusy || uploading" @click="close">انصراف</button>
</div>
</div>
</section>
@@ -457,6 +705,85 @@ onBeforeUnmount(() => {
color: #94a3b8;
}
.photo-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.45rem;
padding: 0 0.7rem;
}
.photo-row small {
color: #64748b;
font-size: 0.75rem;
}
.photo-add {
display: inline-flex;
align-items: center;
gap: 0.35rem;
border: 1px dashed #99f6e4;
background: #f0fdfa;
color: #0f766e;
border-radius: var(--radius);
padding: 0.35rem 0.7rem;
font: inherit;
font-weight: 700;
cursor: pointer;
}
.photo-add:disabled {
opacity: 0.55;
cursor: not-allowed;
}
.photo-file {
display: none;
}
.photo-err {
margin: 0;
padding: 0 0.7rem;
color: #b91c1c;
font-size: 0.8rem;
}
.photo-grid {
display: flex;
flex-wrap: wrap;
gap: 0.45rem;
padding: 0 0.7rem;
}
.photo-grid figure {
position: relative;
margin: 0;
width: 4.5rem;
height: 4.5rem;
}
.photo-grid img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 0.6rem;
border: 1px solid #e2e8f0;
}
.photo-grid figure button {
position: absolute;
top: 0.15rem;
inset-inline-end: 0.15rem;
width: 1.2rem;
height: 1.2rem;
border: 0;
border-radius: 999px;
background: rgba(15, 23, 42, 0.72);
color: #fff;
cursor: pointer;
line-height: 1;
}
.tools {
display: flex;
justify-content: space-between;
@@ -464,6 +791,73 @@ onBeforeUnmount(() => {
padding: 0.35rem 0.5rem 0.5rem;
}
.tool-cluster {
display: flex;
align-items: center;
gap: 0.35rem;
}
.tool.voice-on {
border-color: #fecaca;
background: #fef2f2;
color: #b91c1c;
}
.rec-time {
color: #b91c1c;
font-size: 0.78rem;
font-weight: 700;
}
.voice-list {
display: grid;
gap: 0.35rem;
padding: 0 0.5rem;
}
.voice-item {
display: flex;
align-items: center;
gap: 0.35rem;
}
.voice-item audio {
flex: 1;
min-width: 0;
height: 2.1rem;
}
.voice-item button,
.file-list button {
width: 1.4rem;
height: 1.4rem;
border: 0;
border-radius: 999px;
background: #e2e8f0;
cursor: pointer;
}
.file-list {
list-style: none;
margin: 0;
padding: 0 0.5rem;
display: grid;
gap: 0.3rem;
}
.file-list li {
display: flex;
align-items: center;
gap: 0.35rem;
min-width: 0;
}
.file-list span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.tool-wrap {
position: relative;
}
@@ -0,0 +1,492 @@
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
export type DeskFilterField = 'title' | 'who' | 'customer' | 'type' | 'when' | 'status';
const props = defineProps<{
/** یک ستون، یا پنل کامل بالای صفحه */
field: DeskFilterField | 'all';
title: string;
customer: string;
due: '' | 'set' | 'unset';
typeKey: string;
statusKey: string;
assigneeId: string;
showAssignee: boolean;
users: Array<{ id: string; fullName: string }>;
types: Array<{ key: string; label: string }>;
statuses: Array<{ key: string; label: string }>;
}>();
const emit = defineEmits<{
title: [value: string];
customer: [value: string];
due: [value: '' | 'set' | 'unset'];
type: [value: string];
status: [value: string];
assignee: [value: string];
clear: [];
done: [];
}>();
const LIST_CAP = 40;
const titleDraft = ref(props.title);
const customerDraft = ref(props.customer);
const whoQuery = ref('');
const typeQuery = ref('');
const openSection = ref<DeskFilterField | null>(null);
watch(
() => props.title,
(value) => {
titleDraft.value = value;
},
);
watch(
() => props.customer,
(value) => {
customerDraft.value = value;
},
);
function norm(value: string) {
return value.trim().replace(/ي/g, 'ی').replace(/ك/g, 'ک').toLowerCase();
}
const filteredUsers = computed(() => {
const q = norm(whoQuery.value);
const matches = props.users.filter((user) => !q || norm(user.fullName).includes(q));
const selected = props.assigneeId
? props.users.find((user) => user.id === props.assigneeId)
: undefined;
const head = selected && !matches.slice(0, LIST_CAP).some((user) => user.id === selected.id)
? [selected]
: [];
return [...head, ...matches.filter((user) => user.id !== selected?.id)].slice(0, LIST_CAP);
});
const hiddenUsers = computed(() => {
const q = norm(whoQuery.value);
const count = props.users.filter((user) => !q || norm(user.fullName).includes(q)).length;
return Math.max(0, count - filteredUsers.value.length);
});
const showTypeSearch = computed(() => props.types.length > 8);
const visibleTypes = computed(() => {
const q = norm(typeQuery.value);
const all = props.types.filter((item) => item.key === 'all');
const rest = props.types.filter(
(item) => item.key !== 'all' && (!q || norm(item.label).includes(q)),
);
return [...all, ...rest];
});
const hasAny = computed(
() =>
Boolean(props.title.trim() || props.customer.trim() || props.due || props.assigneeId) ||
props.typeKey !== 'all' ||
props.statusKey !== 'all',
);
const dueOptions: Array<{ key: '' | 'set' | 'unset'; label: string }> = [
{ key: '', label: 'همه' },
{ key: 'set', label: 'دارد' },
{ key: 'unset', label: 'ندارد' },
];
const whoLabel = computed(
() => props.users.find((user) => user.id === props.assigneeId)?.fullName || 'همه',
);
const typeLabel = computed(
() => props.types.find((item) => item.key === props.typeKey)?.label || 'همه',
);
const statusLabel = computed(
() => props.statuses.find((item) => item.key === props.statusKey)?.label || 'همه',
);
const dueLabel = computed(() => dueOptions.find((item) => item.key === props.due)?.label ?? 'همه');
function opened(name: DeskFilterField) {
return props.field !== 'all' || openSection.value === name;
}
function toggleSection(name: DeskFilterField) {
openSection.value = openSection.value === name ? null : name;
}
function finish() {
if (props.field === 'all') openSection.value = null;
else emit('done');
}
function shows(name: DeskFilterField) {
if (name === 'who' && !props.showAssignee) return false;
return props.field === 'all' || props.field === name;
}
function applyTitle() {
emit('title', titleDraft.value.trim());
finish();
}
function applyCustomer() {
emit('customer', customerDraft.value.trim());
finish();
}
function pickDue(next: '' | 'set' | 'unset') {
emit('due', props.due === next ? '' : next);
finish();
}
function pickType(next: string) {
emit('type', props.typeKey === next && next !== 'all' ? 'all' : next);
finish();
}
function pickStatus(next: string) {
emit('status', props.statusKey === next && next !== 'all' ? 'all' : next);
finish();
}
function pickAssignee(next: string) {
emit('assignee', props.assigneeId === next ? '' : next);
finish();
}
</script>
<template>
<div class="filters" @click.stop>
<section v-if="shows('title')">
<button
v-if="field === 'all'"
type="button"
class="acc"
:class="{ on: Boolean(title.trim()) }"
@click="toggleSection('title')"
>
<span>عنوان فعالیت</span>
<em>{{ title.trim() || 'همه' }}</em>
</button>
<form v-if="opened('title')" class="draft" @submit.prevent="applyTitle">
<input
v-model="titleDraft"
type="search"
placeholder="بخشی از عنوان"
autocomplete="off"
/>
<button type="submit">اعمال</button>
<button v-if="title" type="button" class="quiet" @click="titleDraft = ''; applyTitle()">
پاک
</button>
</form>
</section>
<section v-if="shows('who')">
<button
v-if="field === 'all'"
type="button"
class="acc"
:class="{ on: Boolean(assigneeId) }"
@click="toggleSection('who')"
>
<span>کارشناس</span>
<em>{{ whoLabel }}</em>
</button>
<input
v-if="opened('who')"
v-model="whoQuery"
class="find"
type="search"
placeholder="جستجوی نام کارشناس"
autocomplete="off"
/>
<div v-if="opened('who')" class="pick" role="listbox" aria-label="کارشناس">
<button type="button" :class="{ on: !assigneeId }" @click="pickAssignee('')">
همه کارشناسان
</button>
<button
v-for="user in filteredUsers"
:key="user.id"
type="button"
:class="{ on: assigneeId === user.id }"
@click="pickAssignee(user.id)"
>
{{ user.fullName }}
</button>
<p v-if="whoQuery.trim() && !filteredUsers.length" class="empty">کارشناسی با این نام نیست</p>
</div>
<p v-if="opened('who') && hiddenUsers" class="hint">برای دیدن بقیه، نام را دقیق‌تر بنویسید</p>
</section>
<section v-if="shows('customer')">
<button
v-if="field === 'all'"
type="button"
class="acc"
:class="{ on: Boolean(customer.trim()) }"
@click="toggleSection('customer')"
>
<span>مشتری</span>
<em>{{ customer.trim() || 'همه' }}</em>
</button>
<form v-if="opened('customer')" class="draft" @submit.prevent="applyCustomer">
<input
v-model="customerDraft"
type="search"
placeholder="نام شخص یا شرکت"
autocomplete="off"
/>
<button type="submit">اعمال</button>
<button
v-if="customer"
type="button"
class="quiet"
@click="customerDraft = ''; applyCustomer()"
>
پاک
</button>
</form>
</section>
<section v-if="shows('type')">
<button
v-if="field === 'all'"
type="button"
class="acc"
:class="{ on: typeKey !== 'all' }"
@click="toggleSection('type')"
>
<span>نوع فعالیت</span>
<em>{{ typeLabel }}</em>
</button>
<input
v-if="opened('type') && showTypeSearch"
v-model="typeQuery"
class="find"
type="search"
placeholder="جستجوی نوع"
autocomplete="off"
/>
<div v-if="opened('type')" class="pick" role="listbox" aria-label="نوع فعالیت">
<button
v-for="opt in visibleTypes"
:key="opt.key"
type="button"
:class="{ on: typeKey === opt.key }"
@click="pickType(opt.key)"
>
{{ opt.label }}
</button>
<p v-if="visibleTypes.length <= 1 && typeQuery.trim()" class="empty">این نوع پیدا نشد</p>
</div>
</section>
<section v-if="shows('when')">
<button
v-if="field === 'all'"
type="button"
class="acc"
:class="{ on: Boolean(due) }"
@click="toggleSection('when')"
>
<span>زمان شروع</span>
<em>{{ dueLabel }}</em>
</button>
<p v-else class="hint tight">فقط بودن یا نبودن زمان شروع</p>
<div v-if="opened('when')" class="seg" role="radiogroup" aria-label="زمان شروع">
<button
v-for="opt in dueOptions"
:key="opt.key || 'any'"
type="button"
role="radio"
:aria-checked="due === opt.key"
:class="{ on: due === opt.key }"
@click="pickDue(opt.key)"
>
{{ opt.label }}
</button>
</div>
</section>
<section v-if="shows('status')">
<button
v-if="field === 'all'"
type="button"
class="acc"
:class="{ on: statusKey !== 'all' }"
@click="toggleSection('status')"
>
<span>وضعیت</span>
<em>{{ statusLabel }}</em>
</button>
<div v-if="opened('status')" class="pick" role="listbox" aria-label="وضعیت">
<button
v-for="opt in statuses"
:key="opt.key"
type="button"
:class="{ on: statusKey === opt.key }"
@click="pickStatus(opt.key)"
>
{{ opt.label }}
</button>
</div>
</section>
<button
v-if="field === 'all' && hasAny"
type="button"
class="clear"
@click="openSection = null; emit('clear')"
>
پاک کردن فیلترها
</button>
</div>
</template>
<style scoped>
.filters {
display: grid;
gap: 0.65rem;
}
.acc {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.6rem;
width: 100%;
margin: 0;
padding: 0.28rem 0.15rem;
border: 0;
background: transparent;
font: inherit;
text-align: start;
cursor: pointer;
color: #0f172a;
}
.acc em {
font-style: normal;
color: #94a3b8;
font-size: 0.78rem;
max-width: 9.5rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.acc.on em {
color: #0f766e;
font-weight: 700;
}
.draft {
display: flex;
gap: 0.3rem;
}
.draft input,
.find {
width: 100%;
min-width: 0;
border: 1px solid #e2e8f0;
border-radius: 8px;
background: #fff;
padding: 0.4rem 0.55rem;
font: inherit;
color: #0f172a;
}
.draft input {
flex: 1;
}
.draft button,
.pick button,
.seg button,
.clear {
border: 0;
background: transparent;
font: inherit;
cursor: pointer;
}
.draft button {
flex: none;
border-radius: 8px;
background: #0f766e;
color: #fff;
padding: 0.4rem 0.65rem;
}
.draft button.quiet {
background: #f1f5f9;
color: #475569;
}
.pick {
max-height: 11.5rem;
overflow: auto;
display: grid;
align-content: start;
margin-top: 0.35rem;
}
.pick button {
text-align: start;
border-radius: 8px;
padding: 0.42rem 0.5rem;
color: #0f172a;
}
.pick button:hover,
.pick button.on {
background: #f0fdfa;
color: #0f766e;
}
.pick button.on {
font-weight: 700;
}
.seg {
display: flex;
gap: 0.25rem;
padding: 0.2rem;
border-radius: 10px;
background: #f8fafc;
}
.seg button {
flex: 1;
border-radius: 8px;
padding: 0.4rem 0.2rem;
color: #475569;
}
.seg button.on {
background: #fff;
color: #0f766e;
font-weight: 700;
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
.empty,
.hint {
margin: 0.25rem 0.2rem 0;
color: #94a3b8;
font-size: 0.75rem;
}
.hint.tight {
margin: 0 0 0.35rem;
}
.clear {
border-top: 1px solid #e2e8f0;
padding: 0.55rem 0.2rem 0.15rem;
text-align: start;
color: #b91c1c;
}
</style>
@@ -8,7 +8,7 @@ import {
import UiIcon from '@/components/UiIcon.vue';
import JalaliDateInput from '@/components/JalaliDateInput.vue';
type PostponeKey = 'm15' | 'm30' | 'h1' | 'tomorrow-am' | 'tomorrow-pm' | 'custom';
type PostponeKey = 'h1' | 'tomorrow-am' | 'next-saturday' | 'next-week' | 'custom';
const props = defineProps<{
dueAt?: string | null;
@@ -21,7 +21,7 @@ const emit = defineEmits<{
}>();
const nowTick = ref(Date.now());
const selected = ref<PostponeKey | null>(null);
const customOpen = ref(false);
const customLocal = ref('');
let tickTimer: number | null = null;
@@ -43,47 +43,50 @@ function tomorrowAt(hour: number, minute = 0) {
return d;
}
/** شنبهٔ بعد، ساعت ۱۰. اگر امروز شنبه باشد، شنبهٔ هفتهٔ بعد. */
function nextSaturdayMorning() {
const d = startOfLocalDay(new Date(nowTick.value));
const untilSaturday = (6 - d.getDay() + 7) % 7;
d.setDate(d.getDate() + (untilSaturday === 0 ? 7 : untilSaturday));
d.setHours(10, 0, 0, 0);
return d;
}
function nextWeekSameTime() {
const d = new Date(base.value.getTime());
d.setDate(d.getDate() + 7);
return d;
}
const options = computed(() => {
const m15 = addMinutes(15);
const m30 = addMinutes(30);
const h1 = addMinutes(60);
const am = tomorrowAt(10);
const pm = tomorrowAt(13);
const saturday = nextSaturdayMorning();
const week = nextWeekSameTime();
return [
{
key: 'm15' as const,
icon: 'refresh' as const,
label: 'یک ربع دیرتر',
time: formatClockFa(m15),
at: m15,
},
{
key: 'm30' as const,
icon: 'refresh' as const,
label: 'نیم ساعت دیرتر',
time: formatClockFa(m30),
at: m30,
},
{
key: 'h1' as const,
icon: 'refresh' as const,
label: 'یک ساعت دیرتر',
time: formatClockFa(h1),
at: h1,
},
{
key: 'tomorrow-am' as const,
icon: 'calendar-sun' as const,
label: 'فردا صبح',
time: `فردا ${formatClockFa(am)}`,
time: formatClockFa(am),
at: am,
},
{
key: 'tomorrow-pm' as const,
icon: 'calendar-sun' as const,
label: 'فردا بعد از ظهر',
time: `فردا ${formatClockFa(pm)}`,
at: pm,
key: 'next-saturday' as const,
label: 'شنبه آینده',
time: formatJalaliDayClock(saturday),
at: saturday,
},
{
key: 'next-week' as const,
label: 'هفته آینده',
time: formatJalaliDayClock(week),
at: week,
},
];
});
@@ -100,31 +103,27 @@ const customDate = computed(() => {
});
const customPreview = computed(() =>
customDate.value ? formatJalaliDayClock(customDate.value) : 'تاریخ و ساعت را انتخاب کنید',
customDate.value ? formatJalaliDayClock(customDate.value) : '',
);
const canSubmit = computed(() => {
if (props.saving || !selected.value) return false;
if (selected.value === 'custom') return Boolean(customDate.value);
return true;
});
function chosenDate(): Date | null {
if (selected.value === 'custom') return customDate.value;
return options.value.find((item) => item.key === selected.value)?.at ?? null;
function apply(at: Date) {
if (props.saving) return;
emit('submit', at.toISOString());
}
function pick(key: PostponeKey) {
selected.value = key;
if (key === 'custom' && !customLocal.value) {
customLocal.value = toLocalInput(addMinutes(60));
if (key === 'custom') {
customOpen.value = true;
if (!customLocal.value) customLocal.value = toLocalInput(addMinutes(60));
return;
}
const at = options.value.find((item) => item.key === key)?.at;
if (at) apply(at);
}
function submit() {
const at = chosenDate();
if (!at || props.saving) return;
emit('submit', at.toISOString());
function submitCustom() {
if (!customDate.value || props.saving) return;
apply(customDate.value);
}
function close() {
@@ -156,73 +155,57 @@ onBeforeUnmount(() => {
<template>
<Teleport to="body">
<div class="layer" role="presentation">
<div class="backdrop" aria-hidden="true" />
<button class="backdrop" type="button" aria-label="بستن" @click="close" />
<section class="sheet" role="dialog" aria-modal="true" aria-labelledby="postpone-title">
<div class="handle" aria-hidden="true" />
<header class="head">
<button class="icon" type="button" aria-label="تأیید تعویق" :disabled="!canSubmit" @click="submit">
<UiIcon name="check-plain" :size="22" />
</button>
<div class="titles">
<h2 id="postpone-title">به تعویق انداختن فعالیت</h2>
</div>
<h2 id="postpone-title">به تعویق انداختن</h2>
<button class="icon" type="button" aria-label="بستن" @click="close">
<UiIcon name="x" :size="20" />
</button>
</header>
<p class="lead">زمان جدید برای این فعالیت را انتخاب کنید.</p>
<div class="body">
<button
v-for="item in options"
:key="item.key"
class="card"
type="button"
:class="{ on: selected === item.key }"
:disabled="saving"
@click="pick(item.key)"
>
<span class="label">{{ item.label }}</span>
<span class="aside">
<span class="ico-box">
<UiIcon :name="item.icon" :size="20" />
</span>
<div class="presets">
<button
v-for="item in options"
:key="item.key"
class="card"
type="button"
:disabled="saving"
@click="pick(item.key)"
>
<span class="label">{{ item.label }}</span>
<span class="when">{{ item.time }}</span>
</span>
</button>
</button>
</div>
<button
class="card custom"
type="button"
:class="{ on: selected === 'custom' }"
:class="{ on: customOpen }"
:disabled="saving"
@click="pick('custom')"
>
<span class="copy">
<strong>تنظیم زمان دلخواه</strong>
<small>انتخاب تاریخ و ساعت</small>
</span>
<span class="aside">
<span class="ico-box">
<UiIcon name="calendar-edit" :size="20" />
</span>
</span>
<span class="label">زمان دلخواه</span>
<span class="when">{{ customOpen && customPreview ? customPreview : 'تاریخ و ساعت' }}</span>
</button>
<div v-if="selected === 'custom'" class="custom-box">
<div v-if="customOpen" class="custom-box">
<label class="picker">
<span>تاریخ و ساعت جدید</span>
<JalaliDateInput v-model="customLocal" mode="datetime" />
</label>
<p class="preview">{{ customPreview }}</p>
<button
class="confirm"
type="button"
:disabled="saving || !customDate"
@click="submitCustom"
>
{{ saving ? 'در حال ثبت…' : 'ثبت تعویق' }}
</button>
</div>
<p class="notice">
<UiIcon name="lightbulb" :size="18" />
با تعویق انداختن، این فعالیت در زمان جدید به لیست فعالیت‌های شما منتقل می‌شود.
</p>
</div>
</section>
</div>
@@ -236,20 +219,27 @@ onBeforeUnmount(() => {
z-index: 90;
display: flex;
justify-content: center;
align-items: stretch;
align-items: flex-end;
}
.backdrop {
display: none;
position: absolute;
inset: 0;
border: 0;
background: rgba(15, 23, 42, 0.28);
cursor: pointer;
}
.sheet {
position: relative;
width: 100%;
height: 100dvh;
max-height: 92dvh;
background: #fff;
display: flex;
flex-direction: column;
font-family: IRANSans, Tahoma, sans-serif;
border-radius: 16px 16px 0 0;
box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.12);
}
.handle {
@@ -261,75 +251,65 @@ onBeforeUnmount(() => {
}
.head {
display: grid;
grid-template-columns: 40px 1fr 40px;
display: flex;
align-items: center;
padding: 0.1rem 0.7rem 0.15rem;
justify-content: space-between;
gap: 0.5rem;
padding: 0.15rem 0.85rem 0.35rem;
}
.titles h2,
.lead {
.head h2 {
margin: 0;
text-align: center;
}
.titles h2 {
font-size: 16px;
font-weight: 500;
font-weight: 600;
color: #0f172a;
}
.lead {
color: #94a3b8;
font-size: 0.82rem;
padding: 0 1.2rem 0.55rem;
}
.icon {
width: 40px;
height: 40px;
width: 36px;
height: 36px;
border: 0;
background: none;
color: #0f766e;
color: #64748b;
display: grid;
place-items: center;
cursor: pointer;
}
.icon:disabled {
opacity: 0.35;
cursor: not-allowed;
.body {
overflow: auto;
padding: 0.35rem 1rem calc(1rem + env(safe-area-inset-bottom));
display: grid;
gap: 0.55rem;
}
.body {
flex: 1;
overflow: auto;
padding: 0.15rem 1rem calc(1rem + env(safe-area-inset-bottom));
.presets {
display: grid;
align-content: start;
grid-template-columns: 1fr 1fr;
gap: 0.55rem;
}
.card {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.8rem;
min-height: 72px;
padding: 0.7rem 0.9rem;
flex-direction: column;
align-items: flex-start;
justify-content: center;
gap: 0.2rem;
min-height: 64px;
padding: 0.7rem 0.85rem;
border: 1px solid #e8eef3;
border-radius: var(--radius);
border-radius: var(--radius, 10px);
background: #fff;
font: inherit;
text-align: start;
cursor: pointer;
}
.card.on {
.card.on,
.card:hover:not(:disabled) {
border-color: #99f6e4;
background: #f0fdfa;
box-shadow: 0 0 0 1px #99f6e4;
}
.card:disabled {
@@ -337,54 +317,27 @@ onBeforeUnmount(() => {
cursor: not-allowed;
}
.label,
.copy strong {
font-size: 0.95rem;
font-weight: 600;
.label {
font-size: 0.92rem;
font-weight: 700;
color: #0f172a;
}
.copy {
display: grid;
gap: 0.15rem;
}
.copy small {
color: #94a3b8;
font-size: 0.78rem;
}
.aside {
display: grid;
justify-items: center;
gap: 0.28rem;
min-width: 3.6rem;
flex-shrink: 0;
}
.ico-box {
width: 40px;
height: 40px;
border-radius: var(--radius);
background: #e6f7f4;
color: #0d9488;
display: grid;
place-items: center;
}
.when {
color: #0d9488;
font-size: 0.74rem;
color: #0f766e;
font-size: 0.84rem;
font-weight: 600;
white-space: nowrap;
}
.custom {
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.custom-box {
border: 1px solid #e8eef3;
border-radius: var(--radius);
padding: 0.85rem 0.9rem;
display: grid;
gap: 0.55rem;
gap: 0.65rem;
}
.picker {
@@ -394,65 +347,31 @@ onBeforeUnmount(() => {
font-size: 0.8rem;
}
.picker input {
width: 100%;
min-height: var(--control-h);
height: var(--control-h);
border: 1px solid #e2e8f0;
border-radius: var(--radius);
padding: 0.45rem 0.7rem;
.confirm {
border: 0;
background: #0f766e;
color: #fff;
border-radius: var(--radius, 10px);
min-height: 42px;
font: inherit;
color: #0f172a;
background: #fff;
}
.preview {
margin: 0;
color: #0f766e;
font-size: 0.82rem;
font-weight: 700;
cursor: pointer;
}
.notice {
margin: 0.35rem 0 0;
display: flex;
align-items: flex-start;
gap: 0.55rem;
padding: 0.85rem 0.9rem;
border-radius: var(--radius);
background: #f8fafc;
color: #475569;
font-size: 0.8rem;
line-height: 1.75;
}
.notice :deep(.ico) {
margin-top: 0.15rem;
color: #0d9488;
flex-shrink: 0;
.confirm:disabled {
opacity: 0.55;
cursor: not-allowed;
}
@media (min-width: 900px) {
.layer {
background: rgba(15, 23, 42, 0.28);
align-items: center;
padding: 1.2rem;
}
.backdrop {
display: block;
position: absolute;
inset: 0;
border: 0;
background: transparent;
cursor: pointer;
}
.sheet {
position: relative;
max-width: 480px;
height: min(92dvh, 860px);
border-radius: var(--radius, 10px);
max-width: 420px;
border-radius: 16px;
box-shadow: 0 28px 70px rgba(15, 23, 42, 0.22);
}
}