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:
@@ -208,6 +208,10 @@
|
|||||||
background-color: color-mix(in srgb, var(--color-primary) 78%, #000);
|
background-color: color-mix(in srgb, var(--color-primary) 78%, #000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.file-remove-btn:hover{
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes fadeInDown {
|
@keyframes fadeInDown {
|
||||||
from { opacity: 0; transform: translateY(-10px); }
|
from { opacity: 0; transform: translateY(-10px); }
|
||||||
to { opacity: 1; transform: translateY(0); }
|
to { opacity: 1; transform: translateY(0); }
|
||||||
@@ -428,6 +432,50 @@
|
|||||||
}
|
}
|
||||||
.documents-table-wrapper {
|
.documents-table-wrapper {
|
||||||
border: 1px solid var(--color-card-border);
|
border: 1px solid var(--color-card-border);
|
||||||
|
/* Clip the table to the rounded corners on wide layouts. */
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* md and below (Tailwind md = 48rem/768px).
|
||||||
|
*
|
||||||
|
* Six fixed-percentage columns stop being readable well before 768px: the date wraps,
|
||||||
|
* and the status column's error text overflows its column and bleeds into the
|
||||||
|
* neighbouring cells — which is what makes the row contents look mixed.
|
||||||
|
*
|
||||||
|
* Switching to `table-layout: auto` lets each column size to its own content, so no
|
||||||
|
* cell can overflow into the next one. The table then grows past the card and the
|
||||||
|
* wrapper scrolls horizontally instead of squeezing the columns.
|
||||||
|
*/
|
||||||
|
@media (max-width: 767.98px) {
|
||||||
|
.documents-table-wrapper {
|
||||||
|
overflow-x: auto;
|
||||||
|
/* Keep the scroll chain inside the card instead of leaking to the page. */
|
||||||
|
overscroll-behavior-x: contain;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.documents-table {
|
||||||
|
/* Auto layout ignores the <col> percentages, so columns follow their content. */
|
||||||
|
table-layout: auto;
|
||||||
|
min-width: 720px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Short cells stay on one line so each column keeps a clean width. */
|
||||||
|
.documents-table th,
|
||||||
|
.documents-table td {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Title and status hold long text; let them wrap instead of widening the table. */
|
||||||
|
.documents-table td:nth-child(1),
|
||||||
|
.documents-table td:nth-child(2) {
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.documents-table td:nth-child(1) {
|
||||||
|
max-width: 220px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.documents-table {
|
.documents-table {
|
||||||
border-collapse: separate;
|
border-collapse: separate;
|
||||||
@@ -439,6 +487,8 @@
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
border-bottom: 1px solid var(--color-card-border);
|
border-bottom: 1px solid var(--color-card-border);
|
||||||
|
/* Fixed layout fits the card; wrap long tokens so a cell never widens the table. */
|
||||||
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
.documents-table thead th {
|
.documents-table thead th {
|
||||||
background: var(--sidebar-hover);
|
background: var(--sidebar-hover);
|
||||||
@@ -562,6 +612,10 @@
|
|||||||
padding: 1rem 1.25rem;
|
padding: 1rem 1.25rem;
|
||||||
border-bottom: 1px solid var(--color-card-border);
|
border-bottom: 1px solid var(--color-card-border);
|
||||||
}
|
}
|
||||||
|
/* Narrower variant for confirmations (e.g. remove document). */
|
||||||
|
.review-modal--sm {
|
||||||
|
max-width: 30rem;
|
||||||
|
}
|
||||||
.review-modal-body {
|
.review-modal-body {
|
||||||
padding: 1.25rem;
|
padding: 1.25rem;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|||||||
@@ -496,11 +496,18 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="documents-table-wrapper overflow-x-auto rounded-xl border border-[var(--color-card-border)] bg-[var(--card-bg)]">
|
<div class="documents-table-wrapper rounded-xl border border-[var(--color-card-border)] bg-[var(--card-bg)]">
|
||||||
<table class="documents-table min-w-full text-sm text-right">
|
<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)]">
|
<thead class="bg-[var(--sidebar-hover)]">
|
||||||
<tr>
|
<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>
|
<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) {
|
@for (doc of documents(); track doc.id) {
|
||||||
<tr class="table-row-animate">
|
<tr class="table-row-animate">
|
||||||
<td class="px-3 py-2.5 align-top">
|
<td class="px-3 py-2.5 align-top">
|
||||||
<span class="text-sm text-[var(--text-secondary)] truncate block max-w-[14rem]"
|
<span class="text-sm text-[var(--text-secondary)] truncate block" title="{{ doc.title ?? '' }}">{{
|
||||||
>{{ doc.filename }}</span>
|
doc.title ?? '—'
|
||||||
</td>
|
}}</span>
|
||||||
<td class="px-3 py-2.5 align-top">
|
|
||||||
<span class="text-sm text-[var(--text-secondary)]">{{ doc.title ?? '—' }}</span>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="px-3 py-2.5 align-top">
|
<td class="px-3 py-2.5 align-top">
|
||||||
<span
|
<span
|
||||||
@@ -548,7 +553,7 @@
|
|||||||
<td class="px-3 py-2.5 align-top">
|
<td class="px-3 py-2.5 align-top">
|
||||||
<span class="text-sm text-[var(--text-muted)]">{{ formatDateTime(doc.created_at) }}</span>
|
<span class="text-sm text-[var(--text-muted)]">{{ formatDateTime(doc.created_at) }}</span>
|
||||||
</td>
|
</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 (doc.status === 'ready' && !isReviewNeeded(doc) && isAdmin()) {
|
||||||
@if (togglingDocId() === doc.id) {
|
@if (togglingDocId() === doc.id) {
|
||||||
<div class="flex items-center gap-1.5 text-xs text-[var(--text-muted)]">
|
<div class="flex items-center gap-1.5 text-xs text-[var(--text-muted)]">
|
||||||
@@ -632,6 +637,30 @@
|
|||||||
<span>تلاشمجدد</span>
|
<span>تلاشمجدد</span>
|
||||||
</button>
|
</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>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -639,7 +668,7 @@
|
|||||||
@if (!documentsLoading()) {
|
@if (!documentsLoading()) {
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td
|
||||||
colspan="7"
|
colspan="6"
|
||||||
class="px-3 py-10 text-center text-sm text-[var(--text-muted)]"
|
class="px-3 py-10 text-center text-sm text-[var(--text-muted)]"
|
||||||
>
|
>
|
||||||
هیچ سندی با فیلتر انتخابشده مطابقت ندارد.
|
هیچ سندی با فیلتر انتخابشده مطابقت ندارد.
|
||||||
@@ -884,6 +913,57 @@
|
|||||||
</div>
|
</div>
|
||||||
</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>
|
</section>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -946,6 +1026,25 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -30,12 +30,18 @@ function readyDoc(): DocumentListItem {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const toastr = { success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn() };
|
||||||
|
|
||||||
const filterSelect = (el: HTMLElement): HTMLSelectElement | null => el.querySelector('.documents-filters select');
|
const filterSelect = (el: HTMLElement): HTMLSelectElement | null => el.querySelector('.documents-filters select');
|
||||||
|
|
||||||
describe('SettingsPage — document filters', () => {
|
describe('SettingsPage — document filters', () => {
|
||||||
let getDocuments: ReturnType<typeof vi.fn>;
|
let getDocuments: ReturnType<typeof vi.fn>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
toastr.success.mockClear();
|
||||||
|
toastr.error.mockClear();
|
||||||
|
toastr.warning.mockClear();
|
||||||
|
toastr.info.mockClear();
|
||||||
// Server-side filtering: `all` returns one ready doc; every other status matches none.
|
// Server-side filtering: `all` returns one ready doc; every other status matches none.
|
||||||
getDocuments = vi.fn((params: { status?: string } = {}): Observable<DocumentListResponse> => {
|
getDocuments = vi.fn((params: { status?: string } = {}): Observable<DocumentListResponse> => {
|
||||||
const items = params.status ? [] : [readyDoc()];
|
const items = params.status ? [] : [readyDoc()];
|
||||||
@@ -59,7 +65,7 @@ describe('SettingsPage — document filters', () => {
|
|||||||
{ provide: AuthService, useValue: { getCurrentUserValue: () => ({ role: 'admin' }) } },
|
{ provide: AuthService, useValue: { getCurrentUserValue: () => ({ role: 'admin' }) } },
|
||||||
{ provide: HttpService, useValue: { apiUrl: '/api/v1' } },
|
{ provide: HttpService, useValue: { apiUrl: '/api/v1' } },
|
||||||
{ provide: ThemeService, useValue: { isDarkMode: () => false, toggleDarkMode: () => {} } },
|
{ provide: ThemeService, useValue: { isDarkMode: () => false, toggleDarkMode: () => {} } },
|
||||||
{ provide: ToastrService, useValue: { success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn() } },
|
{ provide: ToastrService, useValue: toastr },
|
||||||
],
|
],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
@@ -108,7 +114,91 @@ describe('SettingsPage — document filters', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const rows = (fixture.nativeElement as HTMLElement).querySelectorAll('.documents-table tbody tr');
|
const rows = (fixture.nativeElement as HTMLElement).querySelectorAll('.documents-table tbody tr');
|
||||||
expect(rows.length).toBe(1);
|
expect(rows.length).toBe(1);
|
||||||
expect(rows[0].textContent).toContain('guide.pdf');
|
// نام فایل column was dropped (redundant with عنوان سند); the row shows the title.
|
||||||
|
expect(rows[0].textContent).toContain('سند آزمون');
|
||||||
|
expect(rows[0].textContent).not.toContain('guide.pdf');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('drops the redundant نام فایل column and renders exactly 6 columns', () => {
|
||||||
|
const fixture = TestBed.createComponent(SettingsPage);
|
||||||
|
fixture.detectChanges();
|
||||||
|
const el = fixture.nativeElement as HTMLElement;
|
||||||
|
|
||||||
|
const headers = Array.from(el.querySelectorAll('.documents-table thead th')).map((t) =>
|
||||||
|
t.textContent?.trim(),
|
||||||
|
);
|
||||||
|
expect(headers).toEqual([
|
||||||
|
'عنوان سند',
|
||||||
|
'وضعیت پردازش',
|
||||||
|
'تعداد بخشها',
|
||||||
|
'تاریخ آپلود',
|
||||||
|
'فعالسازی',
|
||||||
|
'عملیات',
|
||||||
|
]);
|
||||||
|
expect(headers).not.toContain('نام فایل');
|
||||||
|
// A data row has exactly 6 cells matching the 6 columns.
|
||||||
|
expect(el.querySelector('.documents-table tbody tr')?.children.length).toBe(6);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('confirms before removing: the bin button opens a modal, cancel keeps the doc, confirm shows the MVP notice', () => {
|
||||||
|
const fixture = TestBed.createComponent(SettingsPage);
|
||||||
|
fixture.detectChanges();
|
||||||
|
const el = fixture.nativeElement as HTMLElement;
|
||||||
|
|
||||||
|
const openRemoveModal = () => {
|
||||||
|
const row = el.querySelector('.documents-table tbody tr') as HTMLElement;
|
||||||
|
const remove = Array.from(row.querySelectorAll('button')).find((b) =>
|
||||||
|
(b.getAttribute('aria-label') ?? '').includes('حذف سند'),
|
||||||
|
) as HTMLButtonElement;
|
||||||
|
remove.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
};
|
||||||
|
|
||||||
|
openRemoveModal();
|
||||||
|
const modal = el.querySelector('[role="alertdialog"]') as HTMLElement;
|
||||||
|
expect(modal).toBeTruthy();
|
||||||
|
expect(modal.textContent).toContain('سند آزمون');
|
||||||
|
expect(modal.textContent).toContain('مطمئن هستید');
|
||||||
|
expect(toastr.info).not.toHaveBeenCalled(); // nothing happens until confirmed
|
||||||
|
|
||||||
|
// Cancel closes the modal and keeps the document, with no notice.
|
||||||
|
(modal.querySelector('.btn--outline') as HTMLButtonElement).click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(el.querySelector('[role="alertdialog"]')).toBeNull();
|
||||||
|
expect(el.querySelectorAll('.documents-table tbody tr').length).toBe(1);
|
||||||
|
expect(toastr.info).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
// Confirm closes the modal and surfaces the MVP notice (deletion is not yet implemented);
|
||||||
|
// the row is left in place and no backend delete call is made.
|
||||||
|
openRemoveModal();
|
||||||
|
(el.querySelector('[role="alertdialog"] .btn--primary') as HTMLButtonElement).click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(toastr.info).toHaveBeenCalledTimes(1);
|
||||||
|
expect(el.querySelector('[role="alertdialog"]')).toBeNull();
|
||||||
|
expect(el.querySelectorAll('.documents-table tbody tr').length).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders OCR and FAQ admin-approval toggles in the app settings and toggles FAQ', () => {
|
||||||
|
const fixture = TestBed.createComponent(SettingsPage);
|
||||||
|
fixture.detectChanges();
|
||||||
|
const component = fixture.componentInstance;
|
||||||
|
component.selectTab('app');
|
||||||
|
fixture.detectChanges();
|
||||||
|
const el = fixture.nativeElement as HTMLElement;
|
||||||
|
|
||||||
|
const labels = Array.from(el.querySelectorAll('.setting-info label')).map((l) =>
|
||||||
|
l.textContent?.trim(),
|
||||||
|
);
|
||||||
|
expect(labels).toContain('نیاز به تأیید ادمین برای اسناد OCR شده');
|
||||||
|
expect(labels).toContain('نیاز به تأیید ادمین برای اسناد FAQ');
|
||||||
|
|
||||||
|
// Toggles in order: dark mode, OCR, FAQ. The FAQ toggle flips its own signal.
|
||||||
|
const switches = el.querySelectorAll('.setting-control .toggle-switch');
|
||||||
|
expect(switches.length).toBe(3);
|
||||||
|
expect(component.faqAdminApproval()).toBe(false);
|
||||||
|
(switches[2].querySelector('input') as HTMLInputElement).click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(component.faqAdminApproval()).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('hasActiveFilters reflects the active status/active-only filters', () => {
|
it('hasActiveFilters reflects the active status/active-only filters', () => {
|
||||||
|
|||||||
@@ -241,6 +241,8 @@ export class SettingsPage implements OnInit, OnDestroy {
|
|||||||
// ---- knowledge selection (K01/K02) ----
|
// ---- knowledge selection (K01/K02) ----
|
||||||
readonly knowledgeSelection = signal<KnowledgeSelection | null>(null);
|
readonly knowledgeSelection = signal<KnowledgeSelection | null>(null);
|
||||||
readonly togglingDocId = signal<string | null>(null);
|
readonly togglingDocId = signal<string | null>(null);
|
||||||
|
/** Document awaiting remove confirmation (non-null while the confirm modal is open). */
|
||||||
|
readonly deletingDoc = signal<DocumentListItem | null>(null);
|
||||||
|
|
||||||
// ---- extraction review modal (D06/D07) ----
|
// ---- extraction review modal (D06/D07) ----
|
||||||
readonly reviewingDocId = signal<string | null>(null);
|
readonly reviewingDocId = signal<string | null>(null);
|
||||||
@@ -256,6 +258,7 @@ export class SettingsPage implements OnInit, OnDestroy {
|
|||||||
readonly notificationsEnabled = signal(true);
|
readonly notificationsEnabled = signal(true);
|
||||||
readonly isDarkMode = this.themeService.isDarkMode;
|
readonly isDarkMode = this.themeService.isDarkMode;
|
||||||
readonly ocrAdminApproval = signal(false);
|
readonly ocrAdminApproval = signal(false);
|
||||||
|
readonly faqAdminApproval = signal(false);
|
||||||
|
|
||||||
readonly textModelConfig = signal<AiModelConfig>(DEFAULT_MODEL_CONFIG.text);
|
readonly textModelConfig = signal<AiModelConfig>(DEFAULT_MODEL_CONFIG.text);
|
||||||
readonly embeddingModelConfig = signal<AiModelConfig>(DEFAULT_MODEL_CONFIG.embedding);
|
readonly embeddingModelConfig = signal<AiModelConfig>(DEFAULT_MODEL_CONFIG.embedding);
|
||||||
@@ -1187,6 +1190,32 @@ export class SettingsPage implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the remove confirmation for a document. Deletion itself is a destructive,
|
||||||
|
* epoch-changing action the backend MVP does not expose, so it is confirmed here before the
|
||||||
|
* (still stubbed) removal runs in `confirmDeleteDocument()`.
|
||||||
|
*/
|
||||||
|
removeDocument(doc: DocumentListItem): void {
|
||||||
|
this.deletingDoc.set(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Dismiss the remove confirmation without deleting. */
|
||||||
|
cancelDelete(): void {
|
||||||
|
this.deletingDoc.set(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirmed removal. The backend MVP has no document-deletion endpoint (removing an active
|
||||||
|
* document also revokes its excerpts and can invalidate live voice sessions), so — like the
|
||||||
|
* other not-yet-implemented actions — this closes the dialog and surfaces an informative
|
||||||
|
* notice instead of calling an unsupported route. No data is deleted and no call is made.
|
||||||
|
*/
|
||||||
|
confirmDeleteDocument(): void {
|
||||||
|
const doc = this.deletingDoc();
|
||||||
|
this.deletingDoc.set(null);
|
||||||
|
if (doc) this.toastr.info(`حذف سند «${doc.title ?? doc.filename}» در فاز MVP پشتیبانی نمیشود.`);
|
||||||
|
}
|
||||||
|
|
||||||
/** Server-provided preview URL (authenticated via the session cookie); null = no preview. */
|
/** Server-provided preview URL (authenticated via the session cookie); null = no preview. */
|
||||||
previewImageUrl(item: ExtractionItem): string | null {
|
previewImageUrl(item: ExtractionItem): string | null {
|
||||||
const path = item.preview_path;
|
const path = item.preview_path;
|
||||||
@@ -1227,6 +1256,11 @@ export class SettingsPage implements OnInit, OnDestroy {
|
|||||||
this.toastr.info('ذخیرهسازی سیاست بازبینی OCR در فاز MVP پشتیبانی نمیشود.');
|
this.toastr.info('ذخیرهسازی سیاست بازبینی OCR در فاز MVP پشتیبانی نمیشود.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleFaqApproval(): void {
|
||||||
|
this.faqAdminApproval.set(!this.faqAdminApproval());
|
||||||
|
this.toastr.info('ذخیرهسازی سیاست بازبینی FAQ در فاز MVP پشتیبانی نمیشود.');
|
||||||
|
}
|
||||||
|
|
||||||
toggleDarkMode(): void {
|
toggleDarkMode(): void {
|
||||||
this.themeService.toggleDarkMode();
|
this.themeService.toggleDarkMode();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user