feat(settings): implement document removal and responsive table layout

Add a confirmation workflow for removing documents and refactor the
documents table to support responsive layouts. The table now uses
a fixed layout with defined column widths and handles overflow on
mobile devices. The redundant filename column has been removed.
This commit is contained in:
PeymanHonarjoo
2026-10-11 17:25:28 +03:30
parent 2ac7a099b5
commit a6c466e1ba
4 changed files with 289 additions and 12 deletions
+109 -10
View File
@@ -496,11 +496,18 @@
</button>
</div>
<div class="documents-table-wrapper overflow-x-auto rounded-xl border border-[var(--color-card-border)] bg-[var(--card-bg)]">
<table class="documents-table min-w-full text-sm text-right">
<div class="documents-table-wrapper rounded-xl border border-[var(--color-card-border)] bg-[var(--card-bg)]">
<table class="documents-table w-full table-fixed text-sm text-right">
<colgroup>
<col class="w-[26%]" />
<col class="w-[18%]" />
<col class="w-[10%]" />
<col class="w-[16%]" />
<col class="w-[15%]" />
<col class="w-[15%]" />
</colgroup>
<thead class="bg-[var(--sidebar-hover)]">
<tr>
<th class="px-3 py-2 text-xs font-medium text-[var(--text-muted)]">نام فایل</th>
<th class="px-3 py-2 text-xs font-medium text-[var(--text-muted)]">عنوان سند</th>
<th class="px-3 py-2 text-xs font-medium text-[var(--text-muted)]">وضعیت پردازش</th>
<th class="px-3 py-2 text-xs font-medium text-[var(--text-muted)]">تعداد بخش‌ها</th>
@@ -513,11 +520,9 @@
@for (doc of documents(); track doc.id) {
<tr class="table-row-animate">
<td class="px-3 py-2.5 align-top">
<span class="text-sm text-[var(--text-secondary)] truncate block max-w-[14rem]"
>{{ doc.filename }}</span>
</td>
<td class="px-3 py-2.5 align-top">
<span class="text-sm text-[var(--text-secondary)]">{{ doc.title ?? '—' }}</span>
<span class="text-sm text-[var(--text-secondary)] truncate block" title="{{ doc.title ?? '' }}">{{
doc.title ?? '—'
}}</span>
</td>
<td class="px-3 py-2.5 align-top">
<span
@@ -548,7 +553,7 @@
<td class="px-3 py-2.5 align-top">
<span class="text-sm text-[var(--text-muted)]">{{ formatDateTime(doc.created_at) }}</span>
</td>
<td class="px-3 py-2.5 align-top min-w-[11rem]">
<td class="px-3 py-2.5 align-top">
@if (doc.status === 'ready' && !isReviewNeeded(doc) && isAdmin()) {
@if (togglingDocId() === doc.id) {
<div class="flex items-center gap-1.5 text-xs text-[var(--text-muted)]">
@@ -632,6 +637,30 @@
<span>تلاش‌مجدد</span>
</button>
}
<button
type="button"
class="file-remove-btn p-2 text-[var(--text-muted)] rounded-lg transition-all duration-200 hover:text-red-400 hover:bg-red-400/10 hover:scale-110 shrink-0"
[attr.aria-label]="'حذف سند ' + (doc.title ?? doc.filename)"
title="حذف سند"
(click)="removeDocument(doc)"
>
<svg
class="w-4 h-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M3 6h18" />
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" />
<path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
<line x1="10" y1="11" x2="10" y2="17" />
<line x1="14" y1="11" x2="14" y2="17" />
</svg>
</button>
</div>
</td>
</tr>
@@ -639,7 +668,7 @@
@if (!documentsLoading()) {
<tr>
<td
colspan="7"
colspan="6"
class="px-3 py-10 text-center text-sm text-[var(--text-muted)]"
>
هیچ سندی با فیلتر انتخاب‌شده مطابقت ندارد.
@@ -884,6 +913,57 @@
</div>
</div>
}
<!-- Remove-document confirmation -->
@if (deletingDoc(); as doc) {
<div class="review-backdrop" (click)="cancelDelete()">
<div
class="review-modal review-modal--sm"
(click)="onReviewModalClick($event)"
role="alertdialog"
aria-modal="true"
aria-label="حذف سند"
>
<header class="review-modal-header">
<h3 class="text-lg font-semibold text-[var(--text-primary)]">حذف سند</h3>
<button
type="button"
class="file-remove-btn p-1 text-[var(--text-muted)]"
(click)="cancelDelete()"
aria-label="بستن"
>
<svg
class="w-4 h-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<line x1="18" y1="6" x2="6" y2="18" />
<line x1="6" y1="6" x2="18" y2="18" />
</svg>
</button>
</header>
<div class="review-modal-body">
<p class="text-sm text-[var(--text-secondary)]">
آیا از حذف سند «{{ doc.title ?? doc.filename }}» مطمئن هستید؟ این عملیات قابل بازگشت نیست.
</p>
</div>
<footer
class="review-modal-footer border-t border-[var(--color-card-border)] p-3 flex justify-end gap-2"
>
<button type="button" class="btn btn--outline" (click)="cancelDelete()">
<span>انصراف</span>
</button>
<button type="button" class="btn btn--primary" (click)="confirmDeleteDocument()">
<span>حذف سند</span>
</button>
</footer>
</div>
</div>
}
</section>
}
@@ -946,6 +1026,25 @@
</label>
</div>
</div>
<div
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
>
<div class="setting-info flex flex-col gap-1 min-w-0">
<label class="text-sm font-medium text-[var(--text-secondary)] cursor-pointer">
نیاز به تأیید ادمین برای اسناد FAQ
</label>
<span class="text-xs text-[var(--text-muted)] block mt-0.5">
در صورت فعال بودن، محتوای استخراج‌شده از اسناد FAQ باید توسط ادمین بازبینی و تأیید شود.
</span>
</div>
<div class="setting-control shrink-0">
<label class="toggle-switch" [class.toggle-active]="faqAdminApproval()">
<input type="checkbox" [checked]="faqAdminApproval()" (change)="toggleFaqApproval()" />
<span class="toggle-slider"></span>
</label>
</div>
</div>
</div>
</section>