feat(ui): modals close only via Esc/X/cancel; standard 3:1 form cover processing
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -106,7 +106,7 @@ export class LeadFormsController {
|
|||||||
const form = await this.leadFormsService.get(user.organizationId, id);
|
const form = await this.leadFormsService.get(user.organizationId, id);
|
||||||
const row = await this.leadFormsService.getByToken(form.publicToken);
|
const row = await this.leadFormsService.getByToken(form.publicToken);
|
||||||
if (!row?.coverStorageKey) return { ok: false };
|
if (!row?.coverStorageKey) return { ok: false };
|
||||||
res.set({ 'Content-Type': 'image/jpeg' });
|
res.set({ 'Content-Type': this.leadFormsService.coverContentType(row.coverStorageKey) });
|
||||||
return new StreamableFile(this.files.openReadStream(row.coverStorageKey));
|
return new StreamableFile(this.files.openReadStream(row.coverStorageKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ import {
|
|||||||
} from '../contacts/normalize';
|
} from '../contacts/normalize';
|
||||||
import { LeadStagesService } from '../leads/lead-stages.service';
|
import { LeadStagesService } from '../leads/lead-stages.service';
|
||||||
|
|
||||||
|
const COVER_CONTENT_TYPES: Record<string, string> = {
|
||||||
|
jpg: 'image/jpeg',
|
||||||
|
jpeg: 'image/jpeg',
|
||||||
|
png: 'image/png',
|
||||||
|
webp: 'image/webp',
|
||||||
|
};
|
||||||
|
|
||||||
const DEFAULT_FIELDS: LeadFormFieldInput[] = [
|
const DEFAULT_FIELDS: LeadFormFieldInput[] = [
|
||||||
{
|
{
|
||||||
key: 'fullName',
|
key: 'fullName',
|
||||||
@@ -222,7 +229,7 @@ export class LeadFormsService {
|
|||||||
submitColor: row.submitColor || '#14b8a6',
|
submitColor: row.submitColor || '#14b8a6',
|
||||||
hasCover: Boolean(row.coverStorageKey),
|
hasCover: Boolean(row.coverStorageKey),
|
||||||
coverPath: row.coverStorageKey
|
coverPath: row.coverStorageKey
|
||||||
? `/api/public/forms/${row.publicToken}/cover`
|
? `/api/public/forms/${row.publicToken}/cover?v=${row.updatedAt.getTime()}`
|
||||||
: null,
|
: null,
|
||||||
fields: row.fields.map((f) => ({
|
fields: row.fields.map((f) => ({
|
||||||
key: f.key,
|
key: f.key,
|
||||||
@@ -806,7 +813,10 @@ export class LeadFormsService {
|
|||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.replace(/[^a-z0-9]/g, '')
|
.replace(/[^a-z0-9]/g, '')
|
||||||
.slice(0, 6);
|
.slice(0, 6);
|
||||||
const key = `lead-forms/${id}/cover.${ext || 'jpg'}`;
|
if (!COVER_CONTENT_TYPES[ext]) {
|
||||||
|
throw new BadRequestException('فرمت تصویر کاور باید PNG، JPG یا WEBP باشد');
|
||||||
|
}
|
||||||
|
const key = `lead-forms/${id}/cover.${ext}`;
|
||||||
await this.files.save(key, file.buffer);
|
await this.files.save(key, file.buffer);
|
||||||
if (row.coverStorageKey && row.coverStorageKey !== key) {
|
if (row.coverStorageKey && row.coverStorageKey !== key) {
|
||||||
await this.files.remove(row.coverStorageKey);
|
await this.files.remove(row.coverStorageKey);
|
||||||
@@ -832,6 +842,11 @@ export class LeadFormsService {
|
|||||||
return row.coverStorageKey;
|
return row.coverStorageKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
coverContentType(key: string) {
|
||||||
|
const ext = key.split('.').pop()?.toLowerCase() ?? '';
|
||||||
|
return COVER_CONTENT_TYPES[ext] ?? 'image/jpeg';
|
||||||
|
}
|
||||||
|
|
||||||
async getByToken(token: string, onlyActive = false) {
|
async getByToken(token: string, onlyActive = false) {
|
||||||
return this.prisma.leadForm.findFirst({
|
return this.prisma.leadForm.findFirst({
|
||||||
where: { publicToken: token, ...(onlyActive ? { isActive: true } : {}) },
|
where: { publicToken: token, ...(onlyActive ? { isActive: true } : {}) },
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ export class PublicLeadFormsController {
|
|||||||
) {
|
) {
|
||||||
const row = await this.leadFormsService.getByToken(token);
|
const row = await this.leadFormsService.getByToken(token);
|
||||||
if (!row?.coverStorageKey) throw new NotFoundException('کاور پیدا نشد');
|
if (!row?.coverStorageKey) throw new NotFoundException('کاور پیدا نشد');
|
||||||
res.set({ 'Content-Type': 'image/jpeg', 'Cache-Control': 'public, max-age=3600' });
|
res.set({
|
||||||
|
'Content-Type': this.leadFormsService.coverContentType(row.coverStorageKey),
|
||||||
|
'Cache-Control': 'public, max-age=3600',
|
||||||
|
});
|
||||||
return new StreamableFile(this.files.openReadStream(row.coverStorageKey));
|
return new StreamableFile(this.files.openReadStream(row.coverStorageKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
import { computed, onUnmounted, ref, watch } from 'vue';
|
||||||
|
import { useEscClose } from '@/lib/modal-stack';
|
||||||
import type { MessageAutomationDelayUnit } from '@mento/shared';
|
import type { MessageAutomationDelayUnit } from '@mento/shared';
|
||||||
import { toFaDigits } from '@/lib/jalali';
|
import { toFaDigits } from '@/lib/jalali';
|
||||||
import UiIcon from '@/components/UiIcon.vue';
|
import UiIcon from '@/components/UiIcon.vue';
|
||||||
@@ -92,17 +93,13 @@ function pickImmediate() {
|
|||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKey(event: KeyboardEvent) {
|
useEscClose(() => open.value, () => { open.value = false; });
|
||||||
if (event.key === 'Escape') open.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(open, (isOpen) => {
|
watch(open, (isOpen) => {
|
||||||
document.body.style.overflow = isOpen ? 'hidden' : '';
|
document.body.style.overflow = isOpen ? 'hidden' : '';
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => window.addEventListener('keydown', onKey));
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.removeEventListener('keydown', onKey);
|
|
||||||
document.body.style.overflow = '';
|
document.body.style.overflow = '';
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -116,7 +113,7 @@ onUnmounted(() => {
|
|||||||
|
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<div v-if="open" class="layer">
|
<div v-if="open" class="layer">
|
||||||
<button class="dim" type="button" aria-label="بستن" @click="open = false" />
|
<div class="dim" aria-hidden="true" />
|
||||||
<section class="sheet" role="dialog" aria-modal="true" aria-label="انتخاب فاصله زمانی">
|
<section class="sheet" role="dialog" aria-modal="true" aria-label="انتخاب فاصله زمانی">
|
||||||
<header>
|
<header>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { computed, onMounted, ref, watch } from 'vue';
|
import { computed, onMounted, ref, watch } from 'vue';
|
||||||
import { api } from '@/lib/api';
|
import { api } from '@/lib/api';
|
||||||
import UiIcon from '@/components/UiIcon.vue';
|
import UiIcon from '@/components/UiIcon.vue';
|
||||||
|
import { useEscClose } from '@/lib/modal-stack';
|
||||||
import type { SavedViewDto, SavedViewScope } from '@mento/shared';
|
import type { SavedViewDto, SavedViewScope } from '@mento/shared';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -22,6 +23,7 @@ const error = ref('');
|
|||||||
const saveOpen = ref(false);
|
const saveOpen = ref(false);
|
||||||
const saveName = ref('');
|
const saveName = ref('');
|
||||||
const saveShared = ref(false);
|
const saveShared = ref(false);
|
||||||
|
useEscClose(() => saveOpen.value, () => { saveOpen.value = false; });
|
||||||
|
|
||||||
const activeView = computed(
|
const activeView = computed(
|
||||||
() => views.value.find((v) => v.id === activeId.value) ?? null,
|
() => views.value.find((v) => v.id === activeId.value) ?? null,
|
||||||
@@ -151,9 +153,14 @@ onMounted(() => {
|
|||||||
<p v-if="error" class="err">{{ error }}</p>
|
<p v-if="error" class="err">{{ error }}</p>
|
||||||
|
|
||||||
<div v-if="saveOpen" class="sheet">
|
<div v-if="saveOpen" class="sheet">
|
||||||
<div class="sheet-backdrop" @click="saveOpen = false" />
|
<div class="sheet-backdrop" aria-hidden="true" />
|
||||||
<div class="sheet-panel">
|
<div class="sheet-panel" role="dialog" aria-modal="true">
|
||||||
<h3>{{ activeId ? 'بهروزرسانی فیلتر' : 'ذخیره فیلتر' }}</h3>
|
<header class="sheet-head">
|
||||||
|
<h3>{{ activeId ? 'بهروزرسانی فیلتر' : 'ذخیره فیلتر' }}</h3>
|
||||||
|
<button type="button" class="x-btn" aria-label="بستن (Esc)" title="بستن (Esc)" @click="saveOpen = false">
|
||||||
|
<UiIcon name="x" :size="16" />
|
||||||
|
</button>
|
||||||
|
</header>
|
||||||
<label>
|
<label>
|
||||||
نام
|
نام
|
||||||
<input v-model="saveName" type="text" maxlength="120" placeholder="مثلاً سرنخهای این هفته" />
|
<input v-model="saveName" type="text" maxlength="120" placeholder="مثلاً سرنخهای این هفته" />
|
||||||
@@ -253,6 +260,9 @@ input[type='text'] {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
|
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
|
||||||
|
.x-btn { width: 32px; height: 32px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; color: #64748b; display: grid; place-items: center; cursor: pointer; }
|
||||||
|
.x-btn:hover { background: #f8fafc; color: #0f172a; }
|
||||||
.sheet-panel label {
|
.sheet-panel label {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 0.3rem;
|
gap: 0.3rem;
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ onBeforeUnmount(() => {
|
|||||||
<template>
|
<template>
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<div class="layer" role="presentation">
|
<div class="layer" role="presentation">
|
||||||
<button class="backdrop" type="button" aria-label="بستن" @click="close" />
|
<div class="backdrop" aria-hidden="true" />
|
||||||
<section
|
<section
|
||||||
class="sheet"
|
class="sheet"
|
||||||
role="dialog"
|
role="dialog"
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ onBeforeUnmount(() => {
|
|||||||
<template>
|
<template>
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<div class="layer" role="presentation">
|
<div class="layer" role="presentation">
|
||||||
<button class="backdrop" type="button" aria-label="بستن" @click="close" />
|
<div class="backdrop" aria-hidden="true" />
|
||||||
<section class="sheet" role="dialog" aria-modal="true" aria-labelledby="postpone-title">
|
<section class="sheet" role="dialog" aria-modal="true" aria-labelledby="postpone-title">
|
||||||
<div class="handle" aria-hidden="true" />
|
<div class="handle" aria-hidden="true" />
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onUnmounted, watch } from 'vue';
|
|
||||||
import UiIcon from '@/components/UiIcon.vue';
|
import UiIcon from '@/components/UiIcon.vue';
|
||||||
|
import { useEscClose } from '@/lib/modal-stack';
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -13,33 +13,20 @@ const props = withDefaults(
|
|||||||
|
|
||||||
const emit = defineEmits<{ close: [] }>();
|
const emit = defineEmits<{ close: [] }>();
|
||||||
|
|
||||||
function onKey(e: KeyboardEvent) {
|
useEscClose(() => props.open, () => emit('close'));
|
||||||
if (e.key === 'Escape') emit('close');
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.open,
|
|
||||||
(open) => {
|
|
||||||
if (open) window.addEventListener('keydown', onKey);
|
|
||||||
else window.removeEventListener('keydown', onKey);
|
|
||||||
},
|
|
||||||
{ immediate: true },
|
|
||||||
);
|
|
||||||
|
|
||||||
onUnmounted(() => window.removeEventListener('keydown', onKey));
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<Transition name="ui-drawer">
|
<Transition name="ui-drawer">
|
||||||
<div v-if="open" class="ui-drawer-layer">
|
<div v-if="open" class="ui-drawer-layer">
|
||||||
<button class="ui-drawer-dim" type="button" aria-label="بستن" @click="emit('close')" />
|
<div class="ui-drawer-dim" aria-hidden="true" />
|
||||||
<aside class="ui-drawer" role="dialog" aria-modal="true" :aria-label="title" :style="{ '--drawer-w': width }">
|
<aside class="ui-drawer" role="dialog" aria-modal="true" :aria-label="title" :style="{ '--drawer-w': width }">
|
||||||
<header class="ui-drawer-head">
|
<header class="ui-drawer-head">
|
||||||
<slot name="header">
|
<slot name="header">
|
||||||
<h2>{{ title }}</h2>
|
<h2>{{ title }}</h2>
|
||||||
</slot>
|
</slot>
|
||||||
<button type="button" class="ui-drawer-close" aria-label="بستن" @click="emit('close')">
|
<button type="button" class="ui-drawer-close" aria-label="بستن (Esc)" title="بستن (Esc)" @click="emit('close')">
|
||||||
<UiIcon name="x" :size="18" />
|
<UiIcon name="x" :size="18" />
|
||||||
</button>
|
</button>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ let openModalCount = 0;
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onUnmounted, watch } from 'vue';
|
import { onUnmounted, watch } from 'vue';
|
||||||
import UiIcon from '@/components/UiIcon.vue';
|
import UiIcon from '@/components/UiIcon.vue';
|
||||||
|
import { useEscClose } from '@/lib/modal-stack';
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -12,15 +13,9 @@ const props = withDefaults(
|
|||||||
title: string;
|
title: string;
|
||||||
/** برای مودال روی مودال (مثل انتخاب مخاطب داخل فرم) */
|
/** برای مودال روی مودال (مثل انتخاب مخاطب داخل فرم) */
|
||||||
nest?: boolean;
|
nest?: boolean;
|
||||||
/**
|
|
||||||
* بستن با کلیک روی پسزمینه.
|
|
||||||
* پیشفرض: فقط موبایل (تمامصفحه). در دسکتاپ عمداً بسته نمیشود.
|
|
||||||
*/
|
|
||||||
closeOnBackdrop?: boolean | 'mobile';
|
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
nest: false,
|
nest: false,
|
||||||
closeOnBackdrop: 'mobile',
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -28,6 +23,8 @@ const emit = defineEmits<{
|
|||||||
close: [];
|
close: [];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
useEscClose(() => props.open, () => emit('close'));
|
||||||
|
|
||||||
let locked = false;
|
let locked = false;
|
||||||
|
|
||||||
function setLock(next: boolean) {
|
function setLock(next: boolean) {
|
||||||
@@ -44,34 +41,20 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
onUnmounted(() => setLock(false));
|
onUnmounted(() => setLock(false));
|
||||||
|
|
||||||
function isMobileViewport() {
|
|
||||||
return typeof window !== 'undefined' && window.matchMedia('(max-width: 900px)').matches;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onBackdrop(event: MouseEvent) {
|
|
||||||
if (event.target !== event.currentTarget) return;
|
|
||||||
const mode = props.closeOnBackdrop;
|
|
||||||
if (mode === false) return;
|
|
||||||
if (mode === true || (mode === 'mobile' && isMobileViewport())) {
|
|
||||||
emit('close');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<div v-if="open" class="backdrop" :class="{ nest }" @click="onBackdrop">
|
<div v-if="open" class="backdrop" :class="{ nest }">
|
||||||
<section
|
<section
|
||||||
class="dialog"
|
class="dialog"
|
||||||
role="dialog"
|
role="dialog"
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
:aria-label="title"
|
:aria-label="title"
|
||||||
@click.stop
|
|
||||||
>
|
>
|
||||||
<header class="head">
|
<header class="head">
|
||||||
<h2>{{ title }}</h2>
|
<h2>{{ title }}</h2>
|
||||||
<button type="button" class="close" aria-label="بستن" @click="emit('close')">
|
<button type="button" class="close" aria-label="بستن (Esc)" title="بستن (Esc)" @click="emit('close')">
|
||||||
<UiIcon name="x" :size="18" />
|
<UiIcon name="x" :size="18" />
|
||||||
</button>
|
</button>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/** اندازهٔ استاندارد کاور فرم (نسبت ۳:۱) */
|
||||||
|
export const COVER_WIDTH = 1200;
|
||||||
|
export const COVER_HEIGHT = 400;
|
||||||
|
const MAX_INPUT_BYTES = 15_000_000;
|
||||||
|
/** تصاویر عریضتر از این نسبت بنر حساب میشوند و برش میخورند؛ بقیه لوگو هستند و کامل جا میگیرند */
|
||||||
|
const BANNER_MIN_RATIO = 2;
|
||||||
|
|
||||||
|
function loadImage(file: File): Promise<HTMLImageElement> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const url = URL.createObjectURL(file);
|
||||||
|
const img = new Image();
|
||||||
|
img.onload = () => {
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
resolve(img);
|
||||||
|
};
|
||||||
|
img.onerror = () => {
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
reject(new Error('تصویر قابل خواندن نیست.'));
|
||||||
|
};
|
||||||
|
img.src = url;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function toBlob(canvas: HTMLCanvasElement, type: string, quality?: number): Promise<Blob> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
canvas.toBlob((b) => (b ? resolve(b) : reject(new Error('پردازش تصویر ناموفق بود.'))), type, quality);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* تصویر را به کاور ۱۲۰۰×۴۰۰ تبدیل میکند:
|
||||||
|
* بنرهای عریض از وسط برش میخورند (JPEG)،
|
||||||
|
* لوگوها و تصاویر مربعی/عمودی بدون برش وسط کادر با پسزمینهٔ شفاف قرار میگیرند (PNG) تا رنگ فرم پشتشان دیده شود.
|
||||||
|
*/
|
||||||
|
export async function prepareFormCover(file: File): Promise<File> {
|
||||||
|
if (!file.type.startsWith('image/')) throw new Error('فقط فایل تصویری (PNG، JPG، WEBP، SVG) مجاز است.');
|
||||||
|
if (file.size > MAX_INPUT_BYTES) throw new Error('حجم تصویر بیش از ۱۵ مگابایت است.');
|
||||||
|
|
||||||
|
const img = await loadImage(file);
|
||||||
|
const w = img.naturalWidth || img.width;
|
||||||
|
const h = img.naturalHeight || img.height;
|
||||||
|
if (!w || !h) throw new Error('ابعاد تصویر نامعتبر است.');
|
||||||
|
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
canvas.width = COVER_WIDTH;
|
||||||
|
canvas.height = COVER_HEIGHT;
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
if (!ctx) throw new Error('مرورگر از پردازش تصویر پشتیبانی نمیکند.');
|
||||||
|
ctx.imageSmoothingEnabled = true;
|
||||||
|
ctx.imageSmoothingQuality = 'high';
|
||||||
|
|
||||||
|
const ratio = w / h;
|
||||||
|
if (ratio >= BANNER_MIN_RATIO) {
|
||||||
|
const target = COVER_WIDTH / COVER_HEIGHT;
|
||||||
|
let sw = w;
|
||||||
|
let sh = h;
|
||||||
|
if (ratio > target) sw = h * target;
|
||||||
|
else sh = w / target;
|
||||||
|
ctx.drawImage(img, (w - sw) / 2, (h - sh) / 2, sw, sh, 0, 0, COVER_WIDTH, COVER_HEIGHT);
|
||||||
|
const blob = await toBlob(canvas, 'image/jpeg', 0.88);
|
||||||
|
return new File([blob], 'cover.jpg', { type: 'image/jpeg' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const boxW = COVER_WIDTH * 0.6;
|
||||||
|
const boxH = COVER_HEIGHT * 0.7;
|
||||||
|
const scale = Math.min(boxW / w, boxH / h, 3);
|
||||||
|
const dw = w * scale;
|
||||||
|
const dh = h * scale;
|
||||||
|
ctx.drawImage(img, (COVER_WIDTH - dw) / 2, (COVER_HEIGHT - dh) / 2, dw, dh);
|
||||||
|
const blob = await toBlob(canvas, 'image/png');
|
||||||
|
return new File([blob], 'cover.png', { type: 'image/png' });
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import { onUnmounted, watch, type WatchSource } from 'vue';
|
||||||
|
|
||||||
|
type Entry = { id: number; close: () => void };
|
||||||
|
|
||||||
|
const stack: Entry[] = [];
|
||||||
|
let seq = 0;
|
||||||
|
let listening = false;
|
||||||
|
|
||||||
|
function onKeydown(e: KeyboardEvent) {
|
||||||
|
if (e.key !== 'Escape' || !stack.length || e.isComposing) return;
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
stack[stack.length - 1]!.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function sync() {
|
||||||
|
if (stack.length && !listening) {
|
||||||
|
window.addEventListener('keydown', onKeydown, true);
|
||||||
|
listening = true;
|
||||||
|
} else if (!stack.length && listening) {
|
||||||
|
window.removeEventListener('keydown', onKeydown, true);
|
||||||
|
listening = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* مودال/شیت را در پشتهٔ Esc ثبت میکند؛ Esc فقط بالاترین مودال باز را میبندد.
|
||||||
|
* بستن با کلیک بیرون عمداً پشتیبانی نمیشود تا دادههای فرم از دست نرود.
|
||||||
|
*/
|
||||||
|
export function useEscClose(open: WatchSource<unknown>, close: () => void) {
|
||||||
|
const id = ++seq;
|
||||||
|
const remove = () => {
|
||||||
|
const i = stack.findIndex((e) => e.id === id);
|
||||||
|
if (i >= 0) stack.splice(i, 1);
|
||||||
|
sync();
|
||||||
|
};
|
||||||
|
watch(
|
||||||
|
open,
|
||||||
|
(isOpen) => {
|
||||||
|
remove();
|
||||||
|
if (isOpen) {
|
||||||
|
stack.push({ id, close });
|
||||||
|
sync();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
onUnmounted(remove);
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||||
|
import { useEscClose } from '@/lib/modal-stack';
|
||||||
import { matchesSearch } from '@/lib/search';
|
import { matchesSearch } from '@/lib/search';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
@@ -1638,12 +1639,15 @@ function toggleChannelMember(id: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** در دسکتاپ با کلیک بیرون مودال بسته نشود (انتخاب اعضا قطع نشود) */
|
useEscClose(() => showNewDm.value, () => { showNewDm.value = false; });
|
||||||
function closeModalOnBackdrop(close: () => void) {
|
useEscClose(() => showNewGroup.value, () => { showNewGroup.value = false; });
|
||||||
if (typeof window !== 'undefined' && window.matchMedia('(max-width: 900px)').matches) {
|
useEscClose(() => showNewChannel.value, () => { showNewChannel.value = false; });
|
||||||
close();
|
useEscClose(() => activityFromMsg.value, () => closeActivityFromMsg());
|
||||||
}
|
useEscClose(() => showCrmLink.value, () => { showCrmLink.value = false; });
|
||||||
}
|
useEscClose(() => showAiAssist.value, () => { showAiAssist.value = false; });
|
||||||
|
useEscClose(() => showMembers.value, () => { showMembers.value = false; });
|
||||||
|
useEscClose(() => showForward.value, () => { showForward.value = false; });
|
||||||
|
useEscClose(() => lightboxUrl.value, () => { lightboxUrl.value = ''; });
|
||||||
|
|
||||||
function openNewDm() {
|
function openNewDm() {
|
||||||
peerPickerQuery.value = '';
|
peerPickerQuery.value = '';
|
||||||
@@ -2507,9 +2511,11 @@ onUnmounted(() => {
|
|||||||
v-if="showNewDm"
|
v-if="showNewDm"
|
||||||
class="modal"
|
class="modal"
|
||||||
open
|
open
|
||||||
@click.self="closeModalOnBackdrop(() => (showNewDm = false))"
|
|
||||||
>
|
>
|
||||||
<div class="modal-card wide">
|
<div class="modal-card wide">
|
||||||
|
<button type="button" class="modal-x" aria-label="???? (Esc)" title="???? (Esc)" @click="(() => (showNewDm = false))()">
|
||||||
|
<UiIcon name="x" :size="18" />
|
||||||
|
</button>
|
||||||
<h3>گفتگوی جدید</h3>
|
<h3>گفتگوی جدید</h3>
|
||||||
<p class="hint">همکار موردنظر را انتخاب کنید</p>
|
<p class="hint">همکار موردنظر را انتخاب کنید</p>
|
||||||
<label class="peer-search">
|
<label class="peer-search">
|
||||||
@@ -2552,9 +2558,11 @@ onUnmounted(() => {
|
|||||||
v-if="showNewGroup"
|
v-if="showNewGroup"
|
||||||
class="modal"
|
class="modal"
|
||||||
open
|
open
|
||||||
@click.self="closeModalOnBackdrop(() => (showNewGroup = false))"
|
|
||||||
>
|
>
|
||||||
<div class="modal-card wide member-picker-modal">
|
<div class="modal-card wide member-picker-modal">
|
||||||
|
<button type="button" class="modal-x" aria-label="???? (Esc)" title="???? (Esc)" @click="(() => (showNewGroup = false))()">
|
||||||
|
<UiIcon name="x" :size="18" />
|
||||||
|
</button>
|
||||||
<h3>گروه جدید</h3>
|
<h3>گروه جدید</h3>
|
||||||
<input v-model="groupName" type="text" placeholder="نام گروه" />
|
<input v-model="groupName" type="text" placeholder="نام گروه" />
|
||||||
<div class="picker-head">
|
<div class="picker-head">
|
||||||
@@ -2624,9 +2632,11 @@ onUnmounted(() => {
|
|||||||
v-if="showNewChannel"
|
v-if="showNewChannel"
|
||||||
class="modal"
|
class="modal"
|
||||||
open
|
open
|
||||||
@click.self="closeModalOnBackdrop(() => (showNewChannel = false))"
|
|
||||||
>
|
>
|
||||||
<div class="modal-card wide member-picker-modal">
|
<div class="modal-card wide member-picker-modal">
|
||||||
|
<button type="button" class="modal-x" aria-label="???? (Esc)" title="???? (Esc)" @click="(() => (showNewChannel = false))()">
|
||||||
|
<UiIcon name="x" :size="18" />
|
||||||
|
</button>
|
||||||
<h3>کانال جدید</h3>
|
<h3>کانال جدید</h3>
|
||||||
<p class="hint channel-hint">
|
<p class="hint channel-hint">
|
||||||
کانال یکطرفه است؛ فقط شما و مدیران سازمان میتوانند پیام بفرستند.
|
کانال یکطرفه است؛ فقط شما و مدیران سازمان میتوانند پیام بفرستند.
|
||||||
@@ -2699,9 +2709,11 @@ onUnmounted(() => {
|
|||||||
v-if="showActivityFromMsg"
|
v-if="showActivityFromMsg"
|
||||||
class="modal"
|
class="modal"
|
||||||
open
|
open
|
||||||
@click.self="closeModalOnBackdrop(closeActivityFromMsg)"
|
|
||||||
>
|
>
|
||||||
<div class="modal-card activity-sheet">
|
<div class="modal-card activity-sheet">
|
||||||
|
<button type="button" class="modal-x" aria-label="???? (Esc)" title="???? (Esc)" @click="(closeActivityFromMsg)()">
|
||||||
|
<UiIcon name="x" :size="18" />
|
||||||
|
</button>
|
||||||
<template v-if="!activityCreatedId">
|
<template v-if="!activityCreatedId">
|
||||||
<h3>تبدیل به فعالیت</h3>
|
<h3>تبدیل به فعالیت</h3>
|
||||||
<p class="hint">از این پیام یک فعالیت در CRM ساخته میشود.</p>
|
<p class="hint">از این پیام یک فعالیت در CRM ساخته میشود.</p>
|
||||||
@@ -2750,9 +2762,11 @@ onUnmounted(() => {
|
|||||||
v-if="showCrmLink"
|
v-if="showCrmLink"
|
||||||
class="modal"
|
class="modal"
|
||||||
open
|
open
|
||||||
@click.self="closeModalOnBackdrop(() => (showCrmLink = false))"
|
|
||||||
>
|
>
|
||||||
<div class="modal-card wide">
|
<div class="modal-card wide">
|
||||||
|
<button type="button" class="modal-x" aria-label="???? (Esc)" title="???? (Esc)" @click="(() => (showCrmLink = false))()">
|
||||||
|
<UiIcon name="x" :size="18" />
|
||||||
|
</button>
|
||||||
<h3>لینک CRM</h3>
|
<h3>لینک CRM</h3>
|
||||||
<p class="hint">شخص، معامله یا تیکت را انتخاب کنید تا در پیام درج شود.</p>
|
<p class="hint">شخص، معامله یا تیکت را انتخاب کنید تا در پیام درج شود.</p>
|
||||||
<div class="crm-kind-tabs" role="tablist">
|
<div class="crm-kind-tabs" role="tablist">
|
||||||
@@ -2814,9 +2828,11 @@ onUnmounted(() => {
|
|||||||
v-if="showAiAssist"
|
v-if="showAiAssist"
|
||||||
class="modal"
|
class="modal"
|
||||||
open
|
open
|
||||||
@click.self="closeModalOnBackdrop(() => (showAiAssist = false))"
|
|
||||||
>
|
>
|
||||||
<div class="modal-card wide ai-assist-sheet">
|
<div class="modal-card wide ai-assist-sheet">
|
||||||
|
<button type="button" class="modal-x" aria-label="???? (Esc)" title="???? (Esc)" @click="(() => (showAiAssist = false))()">
|
||||||
|
<UiIcon name="x" :size="18" />
|
||||||
|
</button>
|
||||||
<h3>{{ brand.askLabelFa }}</h3>
|
<h3>{{ brand.askLabelFa }}</h3>
|
||||||
<p class="hint">با توجه به CRM و چند پیام اخیر این گفتگو پاسخ میدهد؛ میتوانید پاسخ را در پیشنویس درج کنید.</p>
|
<p class="hint">با توجه به CRM و چند پیام اخیر این گفتگو پاسخ میدهد؛ میتوانید پاسخ را در پیشنویس درج کنید.</p>
|
||||||
<AskMentoPanel
|
<AskMentoPanel
|
||||||
@@ -2835,9 +2851,11 @@ onUnmounted(() => {
|
|||||||
v-if="showMembers"
|
v-if="showMembers"
|
||||||
class="modal"
|
class="modal"
|
||||||
open
|
open
|
||||||
@click.self="closeModalOnBackdrop(() => (showMembers = false))"
|
|
||||||
>
|
>
|
||||||
<div class="modal-card wide members-sheet member-picker-modal">
|
<div class="modal-card wide members-sheet member-picker-modal">
|
||||||
|
<button type="button" class="modal-x" aria-label="???? (Esc)" title="???? (Esc)" @click="(() => (showMembers = false))()">
|
||||||
|
<UiIcon name="x" :size="18" />
|
||||||
|
</button>
|
||||||
<h3>اعضای {{ activeRoom ? roomTitle(activeRoom) : 'گفتگو' }}</h3>
|
<h3>اعضای {{ activeRoom ? roomTitle(activeRoom) : 'گفتگو' }}</h3>
|
||||||
<p v-if="activeRoom?.kind === 'channel'" class="hint channel-hint">
|
<p v-if="activeRoom?.kind === 'channel'" class="hint channel-hint">
|
||||||
ادمینها میتوانند در کانال پیام بفرستند؛ بقیه فقط مشاهده میکنند.
|
ادمینها میتوانند در کانال پیام بفرستند؛ بقیه فقط مشاهده میکنند.
|
||||||
@@ -2898,9 +2916,11 @@ onUnmounted(() => {
|
|||||||
v-if="showForward"
|
v-if="showForward"
|
||||||
class="modal"
|
class="modal"
|
||||||
open
|
open
|
||||||
@click.self="closeModalOnBackdrop(() => (showForward = false))"
|
|
||||||
>
|
>
|
||||||
<div class="modal-card">
|
<div class="modal-card">
|
||||||
|
<button type="button" class="modal-x" aria-label="???? (Esc)" title="???? (Esc)" @click="(() => (showForward = false))()">
|
||||||
|
<UiIcon name="x" :size="18" />
|
||||||
|
</button>
|
||||||
<h3>ارسال برای دیگری</h3>
|
<h3>ارسال برای دیگری</h3>
|
||||||
<p class="hint">{{ toFaDigits(selectedCount) }} پیام انتخاب شده</p>
|
<p class="hint">{{ toFaDigits(selectedCount) }} پیام انتخاب شده</p>
|
||||||
<div v-if="!forwardTargets.length" class="muted">گفتگوی دیگری برای ارسال نیست.</div>
|
<div v-if="!forwardTargets.length" class="muted">گفتگوی دیگری برای ارسال نیست.</div>
|
||||||
@@ -2923,7 +2943,7 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
||||||
<dialog v-if="lightboxUrl" class="lightbox" open @click.self="lightboxUrl = ''">
|
<dialog v-if="lightboxUrl" class="lightbox" open>
|
||||||
<button type="button" class="lightbox-close" aria-label="بستن" @click="lightboxUrl = ''">
|
<button type="button" class="lightbox-close" aria-label="بستن" @click="lightboxUrl = ''">
|
||||||
<UiIcon name="x" :size="18" />
|
<UiIcon name="x" :size="18" />
|
||||||
</button>
|
</button>
|
||||||
@@ -4262,7 +4282,25 @@ onUnmounted(() => {
|
|||||||
place-items: center;
|
place-items: center;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
}
|
}
|
||||||
|
.modal-x {
|
||||||
|
position: absolute;
|
||||||
|
top: 0.9rem;
|
||||||
|
left: 0.9rem;
|
||||||
|
z-index: 2;
|
||||||
|
width: 34px;
|
||||||
|
height: 34px;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 10px;
|
||||||
|
background: var(--surface);
|
||||||
|
color: var(--muted);
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.modal-x:hover { background: var(--surface-subtle); color: var(--ink); }
|
||||||
|
.modal-card > h3 { padding-inline-end: 2.6rem; }
|
||||||
.modal-card {
|
.modal-card {
|
||||||
|
position: relative;
|
||||||
background: var(--surface);
|
background: var(--surface);
|
||||||
border-radius: 18px;
|
border-radius: 18px;
|
||||||
padding: 1.25rem;
|
padding: 1.25rem;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref, watch } from 'vue';
|
import { computed, onMounted, ref, watch } from 'vue';
|
||||||
|
import { useEscClose } from '@/lib/modal-stack';
|
||||||
import { matchesSearch } from '@/lib/search';
|
import { matchesSearch } from '@/lib/search';
|
||||||
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
||||||
import { PAGE_SIZE_OPTIONS, usePageSize } from '@/lib/pageSize';
|
import { PAGE_SIZE_OPTIONS, usePageSize } from '@/lib/pageSize';
|
||||||
@@ -81,6 +82,7 @@ const pageSize = usePageSize('invoices', 10);
|
|||||||
const selected = ref<Set<string>>(new Set());
|
const selected = ref<Set<string>>(new Set());
|
||||||
const menuId = ref<string | null>(null);
|
const menuId = ref<string | null>(null);
|
||||||
const filterSheet = ref(false);
|
const filterSheet = ref(false);
|
||||||
|
useEscClose(() => filterSheet.value, () => { filterSheet.value = false; });
|
||||||
const addOpen = ref(false);
|
const addOpen = ref(false);
|
||||||
const invoiceModal = ref<{ kind: 'invoice' | 'credit' | 'quote' } | null>(null);
|
const invoiceModal = ref<{ kind: 'invoice' | 'credit' | 'quote' } | null>(null);
|
||||||
|
|
||||||
@@ -617,10 +619,10 @@ onMounted(load);
|
|||||||
/>
|
/>
|
||||||
</UiModal>
|
</UiModal>
|
||||||
|
|
||||||
<div v-if="filterSheet" class="sheet-backdrop" @click="filterSheet = false">
|
<div v-if="filterSheet" class="sheet-backdrop">
|
||||||
<div class="sheet" @click.stop>
|
<div class="sheet" role="dialog" aria-modal="true" aria-label="فیلترها">
|
||||||
<header>
|
<header>
|
||||||
<button type="button" class="icon-btn" @click="filterSheet = false">
|
<button type="button" class="icon-btn" aria-label="بستن (Esc)" title="بستن (Esc)" @click="filterSheet = false">
|
||||||
<UiIcon name="x" :size="18" />
|
<UiIcon name="x" :size="18" />
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="link" @click="clearFilters">حذف همه</button>
|
<button type="button" class="link" @click="clearFilters">حذف همه</button>
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import type {
|
|||||||
PipelineDto,
|
PipelineDto,
|
||||||
} from '@mento/shared';
|
} from '@mento/shared';
|
||||||
import { toFaDigits } from '@/lib/jalali';
|
import { toFaDigits } from '@/lib/jalali';
|
||||||
|
import { prepareFormCover } from '@/lib/form-cover';
|
||||||
|
import { useEscClose } from '@/lib/modal-stack';
|
||||||
|
|
||||||
type Tab = 'edit' | 'settings' | 'share' | 'responses';
|
type Tab = 'edit' | 'settings' | 'share' | 'responses';
|
||||||
type IconName =
|
type IconName =
|
||||||
@@ -133,9 +135,13 @@ const iframeSnippet = computed(
|
|||||||
const qrUrl = computed(() =>
|
const qrUrl = computed(() =>
|
||||||
`https://api.qrserver.com/v1/create-qr-code/?size=160x160&data=${encodeURIComponent(publicUrl.value)}`,
|
`https://api.qrserver.com/v1/create-qr-code/?size=160x160&data=${encodeURIComponent(publicUrl.value)}`,
|
||||||
);
|
);
|
||||||
const coverSrc = computed(() =>
|
const coverUploading = ref(false);
|
||||||
form.value?.hasCover ? `/api/public/forms/${form.value.publicToken}/cover` : '',
|
const coverVersion = ref(0);
|
||||||
);
|
const coverSrc = computed(() => {
|
||||||
|
if (!form.value?.hasCover) return '';
|
||||||
|
const v = coverVersion.value || Date.parse(form.value.updatedAt) || 0;
|
||||||
|
return `/api/public/forms/${form.value.publicToken}/cover?v=${v}`;
|
||||||
|
});
|
||||||
const editingField = computed(() => fields.value.find((f) => f.key === editFieldKey.value) ?? null);
|
const editingField = computed(() => fields.value.find((f) => f.key === editFieldKey.value) ?? null);
|
||||||
/** متن خام گزینهها — جدا از options تا خط خالی هنگام تایپ حذف نشود */
|
/** متن خام گزینهها — جدا از options تا خط خالی هنگام تایپ حذف نشود */
|
||||||
const optionsDraft = ref('');
|
const optionsDraft = ref('');
|
||||||
@@ -149,11 +155,33 @@ function syncOptions() {
|
|||||||
if (editingField.value) editingField.value.options = parseOptions(optionsDraft.value);
|
if (editingField.value) editingField.value.options = parseOptions(optionsDraft.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fieldSnapshot = ref<LeadFormFieldDto | null>(null);
|
||||||
|
const fieldIsNew = ref(false);
|
||||||
|
|
||||||
watch(editFieldKey, () => {
|
watch(editFieldKey, () => {
|
||||||
optionsDraft.value = editingField.value?.options.join('\n') ?? '';
|
const f = editingField.value;
|
||||||
|
optionsDraft.value = f?.options.join('\n') ?? '';
|
||||||
|
fieldSnapshot.value = f ? { ...f, options: [...f.options] } : null;
|
||||||
sheetError.value = '';
|
sheetError.value = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function cancelFieldSheet() {
|
||||||
|
const snap = fieldSnapshot.value;
|
||||||
|
const key = editFieldKey.value;
|
||||||
|
if (key && fieldIsNew.value) {
|
||||||
|
fields.value = fields.value.filter((f) => f.key !== key);
|
||||||
|
} else if (key && snap) {
|
||||||
|
const i = fields.value.findIndex((f) => f.key === key);
|
||||||
|
if (i >= 0) fields.value[i] = { ...snap, options: [...snap.options] };
|
||||||
|
}
|
||||||
|
fieldIsNew.value = false;
|
||||||
|
editFieldKey.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
useEscClose(() => editFieldKey.value, cancelFieldSheet);
|
||||||
|
useEscClose(() => desktopPreviewOpen.value, () => { desktopPreviewOpen.value = false; });
|
||||||
|
useEscClose(() => publishOpen.value, () => { publishOpen.value = false; });
|
||||||
|
|
||||||
function needsOptions(type: string) {
|
function needsOptions(type: string) {
|
||||||
return type === 'select' || type === 'radio' || type === 'checkbox';
|
return type === 'select' || type === 'radio' || type === 'checkbox';
|
||||||
}
|
}
|
||||||
@@ -172,6 +200,7 @@ function closeFieldSheet() {
|
|||||||
f.label = f.label.trim();
|
f.label = f.label.trim();
|
||||||
optionsDraft.value = f.options.join('\n');
|
optionsDraft.value = f.options.join('\n');
|
||||||
}
|
}
|
||||||
|
fieldIsNew.value = false;
|
||||||
editFieldKey.value = null;
|
editFieldKey.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,6 +212,7 @@ const COLOR_PRESETS = [
|
|||||||
];
|
];
|
||||||
const colorOpen = ref(false);
|
const colorOpen = ref(false);
|
||||||
const hexDraft = ref('');
|
const hexDraft = ref('');
|
||||||
|
useEscClose(() => colorOpen.value, () => { colorOpen.value = false; });
|
||||||
|
|
||||||
function toggleColor() {
|
function toggleColor() {
|
||||||
colorOpen.value = !colorOpen.value;
|
colorOpen.value = !colorOpen.value;
|
||||||
@@ -272,7 +302,9 @@ function addField(type: LeadFormFieldType, preset?: Partial<LeadFormFieldInput>)
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addAndEdit(type: LeadFormFieldType) {
|
function addAndEdit(type: LeadFormFieldType) {
|
||||||
editFieldKey.value = addField(type);
|
const key = addField(type);
|
||||||
|
fieldIsNew.value = true;
|
||||||
|
editFieldKey.value = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function duplicateField(field: LeadFormFieldDto) {
|
function duplicateField(field: LeadFormFieldDto) {
|
||||||
@@ -410,21 +442,33 @@ async function save() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function uploadCover(ev: Event) {
|
async function uploadCover(ev: Event) {
|
||||||
const file = (ev.target as HTMLInputElement).files?.[0];
|
const input = ev.target as HTMLInputElement;
|
||||||
|
const file = input.files?.[0];
|
||||||
|
input.value = '';
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
const body = new FormData();
|
error.value = '';
|
||||||
body.append('file', file);
|
coverUploading.value = true;
|
||||||
try {
|
try {
|
||||||
|
const prepared = await prepareFormCover(file);
|
||||||
|
const body = new FormData();
|
||||||
|
body.append('file', prepared);
|
||||||
const { data } = await api.post<LeadFormDto>(`/lead-forms/${id.value}/cover`, body);
|
const { data } = await api.post<LeadFormDto>(`/lead-forms/${id.value}/cover`, body);
|
||||||
applyForm(data);
|
form.value = data;
|
||||||
} catch {
|
coverVersion.value = Date.now();
|
||||||
error.value = 'آپلود کاور ناموفق بود.';
|
} catch (e) {
|
||||||
|
error.value = e instanceof Error && !axios.isAxiosError(e) ? e.message : 'آپلود کاور ناموفق بود.';
|
||||||
|
} finally {
|
||||||
|
coverUploading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clearCover() {
|
async function clearCover() {
|
||||||
const { data } = await api.delete<LeadFormDto>(`/lead-forms/${id.value}/cover`);
|
try {
|
||||||
applyForm(data);
|
const { data } = await api.delete<LeadFormDto>(`/lead-forms/${id.value}/cover`);
|
||||||
|
form.value = data;
|
||||||
|
} catch {
|
||||||
|
error.value = 'حذف کاور ناموفق بود.';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadResponses() {
|
async function loadResponses() {
|
||||||
@@ -576,11 +620,23 @@ onMounted(load);
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<section class="canvas">
|
<section class="canvas">
|
||||||
<button class="cover-box" type="button" @click="coverInput?.click()">
|
<button
|
||||||
|
class="cover-box"
|
||||||
|
:class="{ has: coverSrc }"
|
||||||
|
type="button"
|
||||||
|
:disabled="coverUploading"
|
||||||
|
:style="coverSrc ? { background: submitColor } : undefined"
|
||||||
|
@click="coverInput?.click()"
|
||||||
|
>
|
||||||
<img v-if="coverSrc" :src="coverSrc" alt="" />
|
<img v-if="coverSrc" :src="coverSrc" alt="" />
|
||||||
<span v-else>+ افزودن لوگو یا تصویر کاور</span>
|
<span v-else-if="coverUploading">در حال پردازش تصویر…</span>
|
||||||
|
<span v-else class="cover-empty">
|
||||||
|
+ افزودن لوگو یا تصویر کاور
|
||||||
|
<small>اندازهٔ استاندارد ۱۲۰۰×۴۰۰ پیکسل (۳:۱) — تصاویر دیگر خودکار تنظیم میشوند</small>
|
||||||
|
</span>
|
||||||
|
<span v-if="coverSrc" class="cover-change">{{ coverUploading ? 'در حال آپلود…' : 'تغییر تصویر' }}</span>
|
||||||
</button>
|
</button>
|
||||||
<input ref="coverInput" type="file" accept="image/*" hidden @change="uploadCover" />
|
<input ref="coverInput" type="file" accept="image/png,image/jpeg,image/webp,image/svg+xml" hidden @change="uploadCover" />
|
||||||
<button v-if="coverSrc" class="link" type="button" @click="clearCover">حذف کاور</button>
|
<button v-if="coverSrc" class="link" type="button" @click="clearCover">حذف کاور</button>
|
||||||
|
|
||||||
<div class="title-card">
|
<div class="title-card">
|
||||||
@@ -866,11 +922,13 @@ onMounted(load);
|
|||||||
</article>
|
</article>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div v-if="desktopPreviewOpen" class="overlay desk-overlay" @click.self="desktopPreviewOpen = false">
|
<div v-if="desktopPreviewOpen" class="overlay desk-overlay">
|
||||||
<div class="desk-sheet" role="dialog" aria-label="پیشنمایش دسکتاپ">
|
<div class="desk-sheet" role="dialog" aria-modal="true" aria-label="پیشنمایش دسکتاپ">
|
||||||
<header>
|
<header>
|
||||||
<strong>پیشنمایش دسکتاپ</strong>
|
<strong>پیشنمایش دسکتاپ</strong>
|
||||||
<button class="btn ghost" type="button" @click="desktopPreviewOpen = false">بستن</button>
|
<button class="x-btn" type="button" aria-label="بستن (Esc)" title="بستن (Esc)" @click="desktopPreviewOpen = false">
|
||||||
|
<UiIcon name="x" :size="18" />
|
||||||
|
</button>
|
||||||
</header>
|
</header>
|
||||||
<div class="desk-form">
|
<div class="desk-form">
|
||||||
<div class="cover" :style="{ background: submitColor }">
|
<div class="cover" :style="{ background: submitColor }">
|
||||||
@@ -907,9 +965,14 @@ onMounted(load);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="editingField" class="overlay" @click.self="closeFieldSheet">
|
<div v-if="editingField" class="overlay">
|
||||||
<div class="sheet">
|
<div class="sheet" role="dialog" aria-modal="true" aria-label="ویرایش فیلد">
|
||||||
<h3>ویرایش فیلد</h3>
|
<header class="sheet-head">
|
||||||
|
<h3>{{ fieldIsNew ? 'فیلد جدید' : 'ویرایش فیلد' }}</h3>
|
||||||
|
<button class="x-btn" type="button" aria-label="بستن (Esc)" title="بستن (Esc)" @click="cancelFieldSheet">
|
||||||
|
<UiIcon name="x" :size="18" />
|
||||||
|
</button>
|
||||||
|
</header>
|
||||||
<label>عنوان <input v-model="editingField.label" maxlength="120" /></label>
|
<label>عنوان <input v-model="editingField.label" maxlength="120" /></label>
|
||||||
<label>متن راهنما <input v-model="editingField.placeholder" /></label>
|
<label>متن راهنما <input v-model="editingField.placeholder" /></label>
|
||||||
<label class="chk"><input v-model="editingField.required" type="checkbox" /> الزامی</label>
|
<label class="chk"><input v-model="editingField.required" type="checkbox" /> الزامی</label>
|
||||||
@@ -959,15 +1022,20 @@ onMounted(load);
|
|||||||
</small>
|
</small>
|
||||||
</label>
|
</label>
|
||||||
<p v-if="sheetError" class="sheet-error">{{ sheetError }}</p>
|
<p v-if="sheetError" class="sheet-error">{{ sheetError }}</p>
|
||||||
<button class="btn primary" type="button" @click="closeFieldSheet">تمام</button>
|
<div class="sheet-actions">
|
||||||
|
<button class="btn primary" type="button" @click="closeFieldSheet">تأیید</button>
|
||||||
|
<button class="btn ghost" type="button" @click="cancelFieldSheet">انصراف</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="publishOpen" class="overlay" @click.self="publishOpen = false">
|
<div v-if="publishOpen" class="overlay">
|
||||||
<div class="sheet publish-sheet" role="dialog" aria-label="انتشار فرم">
|
<div class="sheet publish-sheet" role="dialog" aria-modal="true" aria-label="انتشار فرم">
|
||||||
<header class="publish-head">
|
<header class="publish-head">
|
||||||
<strong>انتشار فرم</strong>
|
<strong>انتشار فرم</strong>
|
||||||
<button class="btn ghost" type="button" @click="publishOpen = false">بستن</button>
|
<button class="x-btn" type="button" aria-label="بستن (Esc)" title="بستن (Esc)" @click="publishOpen = false">
|
||||||
|
<UiIcon name="x" :size="18" />
|
||||||
|
</button>
|
||||||
</header>
|
</header>
|
||||||
<div class="publish-preview">
|
<div class="publish-preview">
|
||||||
<div class="mini-cover" :style="{ background: submitColor }">
|
<div class="mini-cover" :style="{ background: submitColor }">
|
||||||
@@ -1031,14 +1099,13 @@ onMounted(load);
|
|||||||
}
|
}
|
||||||
.desk-sheet header { display: flex; justify-content: space-between; align-items: center; }
|
.desk-sheet header { display: flex; justify-content: space-between; align-items: center; }
|
||||||
.desk-form { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: 0 16px 40px rgba(15,23,42,.08); }
|
.desk-form { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: 0 16px 40px rgba(15,23,42,.08); }
|
||||||
.desk-form .cover { height: 140px; }
|
.desk-form .cover { height: auto; aspect-ratio: 3 / 1; max-height: 260px; }
|
||||||
.desk-form .cover img { width: 100%; height: 140px; object-fit: cover; }
|
|
||||||
.desk-body { padding: 1.2rem 1.4rem 1.4rem; }
|
.desk-body { padding: 1.2rem 1.4rem 1.4rem; }
|
||||||
.desk-body h3 { font-size: 1.35rem; }
|
.desk-body h3 { font-size: 1.35rem; }
|
||||||
.desk-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
|
.desk-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
|
||||||
.desk-fields .wide { grid-column: 1 / -1; }
|
.desk-fields .wide { grid-column: 1 / -1; }
|
||||||
.desk-form .send { justify-self: start; min-width: 200px; }
|
.desk-form .send { justify-self: start; min-width: 200px; }
|
||||||
.cover { height: 86px; display: grid; place-items: center; color: #fff; overflow: hidden; }
|
.cover { aspect-ratio: 3 / 1; display: grid; place-items: center; color: #fff; overflow: hidden; }
|
||||||
.cover img { width: 100%; height: 100%; object-fit: cover; }
|
.cover img { width: 100%; height: 100%; object-fit: cover; }
|
||||||
.preview-body { padding: 0.8rem; display: grid; gap: 0.5rem; }
|
.preview-body { padding: 0.8rem; display: grid; gap: 0.5rem; }
|
||||||
.preview-body h3 { margin: 0; font-size: 1rem; }
|
.preview-body h3 { margin: 0; font-size: 1rem; }
|
||||||
@@ -1047,8 +1114,14 @@ onMounted(load);
|
|||||||
.preview-body input, .preview-body textarea, .preview-body select { border: 1px solid #e2e8f0; border-radius: var(--radius); padding: 0.45rem 0.6rem; font: inherit; background: #f8fafc; }
|
.preview-body input, .preview-body textarea, .preview-body select { border: 1px solid #e2e8f0; border-radius: var(--radius); padding: 0.45rem 0.6rem; font: inherit; background: #f8fafc; }
|
||||||
.send { border: 0; color: #fff; border-radius: var(--radius); min-height: var(--control-h); height: var(--control-h); font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem; box-sizing: border-box; }
|
.send { border: 0; color: #fff; border-radius: var(--radius); min-height: var(--control-h); height: var(--control-h); font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem; box-sizing: border-box; }
|
||||||
.opts, .stars { color: #64748b; font-size: 0.75rem; display: grid; gap: 0.2rem; }
|
.opts, .stars { color: #64748b; font-size: 0.75rem; display: grid; gap: 0.2rem; }
|
||||||
.cover-box { width: 100%; min-height: 88px; border: 1.5px dashed #99f6e4; border-radius: var(--radius); background: #f0fdfa; color: #0f766e; font: inherit; font-weight: 700; cursor: pointer; overflow: hidden; }
|
.cover-box { position: relative; width: 100%; aspect-ratio: 3 / 1; max-height: 200px; border: 1.5px dashed #99f6e4; border-radius: var(--radius); background: #f0fdfa; color: #0f766e; font: inherit; font-weight: 700; cursor: pointer; overflow: hidden; display: grid; place-items: center; padding: 0; }
|
||||||
.cover-box img { width: 100%; height: 88px; object-fit: cover; display: block; }
|
.cover-box.has { border-style: solid; border-color: transparent; }
|
||||||
|
.cover-box:disabled { cursor: progress; opacity: 0.75; }
|
||||||
|
.cover-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
||||||
|
.cover-empty { display: grid; gap: 0.25rem; justify-items: center; padding: 0.5rem; }
|
||||||
|
.cover-empty small { font-weight: 500; font-size: 0.74rem; color: #64748b; }
|
||||||
|
.cover-change { position: absolute; inset-inline-start: 0.5rem; bottom: 0.5rem; background: rgba(15,23,42,.65); color: #fff; font-size: 0.74rem; padding: 0.2rem 0.55rem; border-radius: 999px; opacity: 0; transition: opacity .15s; }
|
||||||
|
.cover-box:hover .cover-change, .cover-box:disabled .cover-change { opacity: 1; }
|
||||||
.title-card, .field-card, .submit-card, .adv-box { border: 1px solid #eef2f7; border-radius: var(--radius); padding: 0.8rem; display: grid; gap: 0.45rem; }
|
.title-card, .field-card, .submit-card, .adv-box { border: 1px solid #eef2f7; border-radius: var(--radius); padding: 0.8rem; display: grid; gap: 0.45rem; }
|
||||||
.title { font: inherit; font-size: 1.1rem; font-weight: 700; color: #0f172a; border: 1px solid #e2e8f0; border-radius: var(--radius); padding: 0.55rem 0.7rem; background: #fff; width: 100%; box-sizing: border-box; }
|
.title { font: inherit; font-size: 1.1rem; font-weight: 700; color: #0f172a; border: 1px solid #e2e8f0; border-radius: var(--radius); padding: 0.55rem 0.7rem; background: #fff; width: 100%; box-sizing: border-box; }
|
||||||
.title:hover { border-color: #99f6e4; }
|
.title:hover { border-color: #99f6e4; }
|
||||||
@@ -1130,7 +1203,13 @@ onMounted(load);
|
|||||||
.row input { flex: 1; min-width: 0; }
|
.row input { flex: 1; min-width: 0; }
|
||||||
.sub { border-bottom: 1px solid #f1f5f9; padding: 0.5rem 0; }
|
.sub { border-bottom: 1px solid #f1f5f9; padding: 0.5rem 0; }
|
||||||
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.35); display: grid; place-items: center; z-index: 40; padding: 1rem; }
|
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.35); display: grid; place-items: center; z-index: 40; padding: 1rem; }
|
||||||
.sheet { width: min(420px,100%); background: #fff; border-radius: var(--radius); padding: 1rem; display: grid; gap: 0.65rem; }
|
.sheet { width: min(420px,100%); max-height: calc(100dvh - 2rem); overflow-y: auto; background: #fff; border-radius: var(--radius); padding: 1rem; display: grid; gap: 0.65rem; box-sizing: border-box; }
|
||||||
|
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
|
||||||
|
.sheet-head h3 { margin: 0; }
|
||||||
|
.sheet-actions { display: flex; gap: 0.5rem; }
|
||||||
|
.sheet-actions .btn { flex: 1; }
|
||||||
|
.x-btn { width: 36px; height: 36px; flex-shrink: 0; border: 1px solid #e2e8f0; border-radius: var(--radius); background: #fff; color: #64748b; display: grid; place-items: center; cursor: pointer; }
|
||||||
|
.x-btn:hover { background: #f8fafc; color: #0f172a; border-color: #cbd5e1; }
|
||||||
.link { background: none; border: 0; color: #0f766e; font: inherit; font-weight: 700; cursor: pointer; text-align: right; padding: 0; }
|
.link { background: none; border: 0; color: #0f766e; font: inherit; font-weight: 700; cursor: pointer; text-align: right; padding: 0; }
|
||||||
.panel-title {
|
.panel-title {
|
||||||
margin: 0.2rem 0 0;
|
margin: 0.2rem 0 0;
|
||||||
@@ -1296,8 +1375,8 @@ onMounted(load);
|
|||||||
.publish-preview p { margin: 0 0 0.35rem; color: #64748b; font-size: 0.82rem; }
|
.publish-preview p { margin: 0 0 0.35rem; color: #64748b; font-size: 0.82rem; }
|
||||||
.publish-preview a { color: #0f766e; font-weight: 700; font-size: 0.85rem; }
|
.publish-preview a { color: #0f766e; font-weight: 700; font-size: 0.85rem; }
|
||||||
.mini-cover {
|
.mini-cover {
|
||||||
width: 72px;
|
width: 108px;
|
||||||
height: 72px;
|
aspect-ratio: 3 / 1;
|
||||||
border-radius: var(--radius);
|
border-radius: var(--radius);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
@@ -1321,7 +1400,7 @@ onMounted(load);
|
|||||||
.tabs { display: grid; grid-template-columns: 1fr 1fr; }
|
.tabs { display: grid; grid-template-columns: 1fr 1fr; }
|
||||||
.stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
.stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||||
.publish-preview { grid-template-columns: 56px 1fr; }
|
.publish-preview { grid-template-columns: 56px 1fr; }
|
||||||
.mini-cover { width: 56px; height: 56px; }
|
.mini-cover { width: 84px; }
|
||||||
.settings-grid { grid-template-columns: 1fr; }
|
.settings-grid { grid-template-columns: 1fr; }
|
||||||
.settings-grid .span-2 { grid-column: auto; }
|
.settings-grid .span-2 { grid-column: auto; }
|
||||||
.settings-card { padding: 0.85rem; }
|
.settings-card { padding: 0.85rem; }
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ onBeforeUnmount(() => window.removeEventListener('storage', onStorage));
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: 0 0 0 1px #e2e8f0, 0 18px 44px rgba(15, 23, 42, 0.1);
|
box-shadow: 0 0 0 1px #e2e8f0, 0 18px 44px rgba(15, 23, 42, 0.1);
|
||||||
}
|
}
|
||||||
.cover { height: 120px; display: grid; place-items: center; color: #fff; overflow: hidden; }
|
.cover { aspect-ratio: 3 / 1; display: grid; place-items: center; color: #fff; overflow: hidden; }
|
||||||
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
||||||
.body { padding: 1.1rem 1.15rem 1.25rem; display: grid; gap: 0.75rem; }
|
.body { padding: 1.1rem 1.15rem 1.25rem; display: grid; gap: 0.75rem; }
|
||||||
header { display: grid; gap: 0.3rem; }
|
header { display: grid; gap: 0.3rem; }
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||||
|
import { useEscClose } from '@/lib/modal-stack';
|
||||||
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
||||||
import { RouterLink } from 'vue-router';
|
import { RouterLink } from 'vue-router';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
@@ -240,6 +241,8 @@ function closeModal() {
|
|||||||
modal.value = null;
|
modal.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEscClose(() => modal.value, closeModal);
|
||||||
|
|
||||||
function openSettings() {
|
function openSettings() {
|
||||||
modal.value = 'settings';
|
modal.value = 'settings';
|
||||||
}
|
}
|
||||||
@@ -879,7 +882,7 @@ onBeforeUnmount(() => {
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<div v-if="modal" class="overlay" @click.self="closeModal">
|
<div v-if="modal" class="overlay">
|
||||||
<div class="sheet" role="dialog" aria-modal="true">
|
<div class="sheet" role="dialog" aria-modal="true">
|
||||||
<header>
|
<header>
|
||||||
<h3>
|
<h3>
|
||||||
@@ -892,7 +895,7 @@ onBeforeUnmount(() => {
|
|||||||
<template v-else-if="modal === 'reward'">{{ editingRewardId ? 'ویرایش پاداش' : 'پاداش جدید' }}</template>
|
<template v-else-if="modal === 'reward'">{{ editingRewardId ? 'ویرایش پاداش' : 'پاداش جدید' }}</template>
|
||||||
<template v-else>ثبت پاداش</template>
|
<template v-else>ثبت پاداش</template>
|
||||||
</h3>
|
</h3>
|
||||||
<button class="icon-btn" type="button" @click="closeModal"><UiIcon name="x" :size="16" /></button>
|
<button class="icon-btn" type="button" aria-label="بستن (Esc)" title="بستن (Esc)" @click="closeModal"><UiIcon name="x" :size="16" /></button>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<form v-if="modal === 'settings'" class="form" @submit.prevent="saveSettings">
|
<form v-if="modal === 'settings'" class="form" @submit.prevent="saveSettings">
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||||
|
import { useEscClose } from '@/lib/modal-stack';
|
||||||
import { matchesSearch } from '@/lib/search';
|
import { matchesSearch } from '@/lib/search';
|
||||||
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
@@ -290,6 +291,9 @@ function askRemove(row: MessageAutomationRuleDto) {
|
|||||||
pendingDelete.value = row;
|
pendingDelete.value = row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEscClose(() => fieldsSheet.value, () => { fieldsSheet.value = false; });
|
||||||
|
useEscClose(() => pendingDelete.value, () => cancelRemove());
|
||||||
|
|
||||||
function cancelRemove() {
|
function cancelRemove() {
|
||||||
pendingDelete.value = null;
|
pendingDelete.value = null;
|
||||||
}
|
}
|
||||||
@@ -1050,7 +1054,7 @@ onUnmounted(() => {
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div v-if="fieldsSheet" class="sheet-layer">
|
<div v-if="fieldsSheet" class="sheet-layer">
|
||||||
<button class="dim" type="button" aria-label="بستن" @click="fieldsSheet = false" />
|
<div class="dim" aria-hidden="true" />
|
||||||
<section class="sheet" role="dialog" aria-modal="true" aria-label="فهرست فیلدها">
|
<section class="sheet" role="dialog" aria-modal="true" aria-label="فهرست فیلدها">
|
||||||
<header>
|
<header>
|
||||||
<h3>فهرست فیلدهای پویا</h3>
|
<h3>فهرست فیلدهای پویا</h3>
|
||||||
@@ -1158,7 +1162,7 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="pendingDelete" class="sheet-layer">
|
<div v-if="pendingDelete" class="sheet-layer">
|
||||||
<button class="dim" type="button" aria-label="انصراف" @click="cancelRemove" />
|
<div class="dim" aria-hidden="true" />
|
||||||
<section class="confirm-box" role="dialog" aria-modal="true" aria-labelledby="delete-confirm-title">
|
<section class="confirm-box" role="dialog" aria-modal="true" aria-labelledby="delete-confirm-title">
|
||||||
<h3 id="delete-confirm-title">حذف قانون</h3>
|
<h3 id="delete-confirm-title">حذف قانون</h3>
|
||||||
<p>آیا از حذف مطمئن هستید؟</p>
|
<p>آیا از حذف مطمئن هستید؟</p>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||||
|
import { useEscClose } from '@/lib/modal-stack';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { api } from '@/lib/api';
|
import { api } from '@/lib/api';
|
||||||
@@ -579,6 +580,10 @@ async function openHistory(note: NoteDto) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEscClose(() => editorOpen.value, () => closeEditor());
|
||||||
|
useEscClose(() => moreSheetOpen.value, () => { moreSheetOpen.value = false; });
|
||||||
|
useEscClose(() => historyOpen.value, () => closeHistory());
|
||||||
|
|
||||||
function closeHistory() {
|
function closeHistory() {
|
||||||
historyOpen.value = false;
|
historyOpen.value = false;
|
||||||
historyNoteId.value = null;
|
historyNoteId.value = null;
|
||||||
@@ -1023,7 +1028,7 @@ onBeforeUnmount(() => {
|
|||||||
<!-- Unified create/edit modal -->
|
<!-- Unified create/edit modal -->
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<div v-if="editorOpen" class="panel-root">
|
<div v-if="editorOpen" class="panel-root">
|
||||||
<div class="panel-backdrop" @click="closeEditor" />
|
<div class="panel-backdrop" aria-hidden="true" />
|
||||||
<aside
|
<aside
|
||||||
class="editor-panel"
|
class="editor-panel"
|
||||||
:style="{
|
:style="{
|
||||||
@@ -1309,7 +1314,7 @@ onBeforeUnmount(() => {
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div v-if="moreSheetOpen" class="sheet-root">
|
<div v-if="moreSheetOpen" class="sheet-root">
|
||||||
<div class="sheet-backdrop" @click="moreSheetOpen = false" />
|
<div class="sheet-backdrop" aria-hidden="true" />
|
||||||
<div class="sheet">
|
<div class="sheet">
|
||||||
<header>
|
<header>
|
||||||
<h3>جزئیات بیشتر</h3>
|
<h3>جزئیات بیشتر</h3>
|
||||||
@@ -1385,7 +1390,7 @@ onBeforeUnmount(() => {
|
|||||||
|
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<div v-if="historyOpen" class="history-root">
|
<div v-if="historyOpen" class="history-root">
|
||||||
<div class="history-backdrop" @click="closeHistory" />
|
<div class="history-backdrop" aria-hidden="true" />
|
||||||
<aside class="history-panel" role="dialog" aria-label="تاریخچه ویرایش">
|
<aside class="history-panel" role="dialog" aria-label="تاریخچه ویرایش">
|
||||||
<header class="history-head">
|
<header class="history-head">
|
||||||
<h2>تاریخچه ویرایش</h2>
|
<h2>تاریخچه ویرایش</h2>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||||
|
import { useEscClose } from '@/lib/modal-stack';
|
||||||
import { matchesSearch } from '@/lib/search';
|
import { matchesSearch } from '@/lib/search';
|
||||||
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
@@ -66,6 +67,7 @@ const selectedRoleId = ref<string | null>(null);
|
|||||||
const showAllMembers = ref(false);
|
const showAllMembers = ref(false);
|
||||||
const menuUserId = ref<string | null>(null);
|
const menuUserId = ref<string | null>(null);
|
||||||
const isNarrow = ref(false);
|
const isNarrow = ref(false);
|
||||||
|
useEscClose(() => isNarrow.value && selectedRoleId.value, () => { selectedRoleId.value = null; });
|
||||||
|
|
||||||
const inviteOpen = ref(false);
|
const inviteOpen = ref(false);
|
||||||
const inviteSaving = ref(false);
|
const inviteSaving = ref(false);
|
||||||
@@ -851,7 +853,7 @@ onUnmounted(() => {
|
|||||||
</button>
|
</button>
|
||||||
</footer>
|
</footer>
|
||||||
</aside>
|
</aside>
|
||||||
<div v-if="isNarrow && selectedRoleId" class="sheet-backdrop" @click="selectedRoleId = null" />
|
<div v-if="isNarrow && selectedRoleId" class="sheet-backdrop" aria-hidden="true" />
|
||||||
|
|
||||||
<div class="main-col">
|
<div class="main-col">
|
||||||
<div class="toolbar">
|
<div class="toolbar">
|
||||||
|
|||||||
Reference in New Issue
Block a user