Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Enhancement: consolidate management lists into document attributes section (#12045)

shamoonb050fab77ff0
diff --git a/src-ui/e2e/dashboard/dashboard.spec.ts b/src-ui/e2e/dashboard/dashboard.spec.ts
index 2ee8c1f35..801f431f3 100644
--- a/src-ui/e2e/dashboard/dashboard.spec.ts
+++ b/src-ui/e2e/dashboard/dashboard.spec.ts
@@ -52,11 +52,11 @@ test('dashboard saved view document links', async ({ page }) => {
test('test slim sidebar', async ({ page }) => {
await page.routeFromHAR(REQUESTS_HAR1, { notFound: 'fallback' })
await page.goto('/dashboard')
- await page.locator('#sidebarMenu').getByRole('button').click()
+ await page.locator('.sidebar-slim-toggler').click()
await expect(
page.getByRole('link', { name: 'Dashboard' }).getByText('Dashboard')
).toBeHidden()
- await page.locator('#sidebarMenu').getByRole('button').click()
+ await page.locator('.sidebar-slim-toggler').click()
await expect(
page.getByRole('link', { name: 'Dashboard' }).getByText('Dashboard')
).toBeVisible()
diff --git a/src-ui/e2e/permissions/global-permissions.spec.ts b/src-ui/e2e/permissions/global-permissions.spec.ts
index e5bc98edf..7021b6d9b 100644
--- a/src-ui/e2e/permissions/global-permissions.spec.ts
+++ b/src-ui/e2e/permissions/global-permissions.spec.ts
@@ -33,9 +33,9 @@ test('should not allow user to view correspondents', async ({ page }) => {
await page.routeFromHAR(REQUESTS_HAR, { notFound: 'fallback' })
await page.goto('/dashboard')
await expect(
- page.getByRole('link', { name: 'Correspondents' })
+ page.getByRole('link', { name: 'Attributes' })
).not.toBeAttached()
- await page.goto('/correspondents')
+ await page.goto('/attributes/correspondents')
await expect(page.locator('body')).toHaveText(
/You don't have permissions to do that/i
)
@@ -44,8 +44,10 @@ test('should not allow user to view correspondents', async ({ page }) => {
test('should not allow user to view tags', async ({ page }) => {
await page.routeFromHAR(REQUESTS_HAR, { notFound: 'fallback' })
await page.goto('/dashboard')
- await expect(page.getByRole('link', { name: 'Tags' })).not.toBeAttached()
- await page.goto('/tags')
+ await expect(
+ page.getByRole('link', { name: 'Attributes' })
+ ).not.toBeAttached()
+ await page.goto('/attributes/tags')
await expect(page.locator('body')).toHaveText(
/You don't have permissions to do that/i
)
@@ -55,9 +57,9 @@ test('should not allow user to view document types', async ({ page }) => {
await page.routeFromHAR(REQUESTS_HAR, { notFound: 'fallback' })
await page.goto('/dashboard')
await expect(
- page.getByRole('link', { name: 'Document Types' })
+ page.getByRole('link', { name: 'Attributes' })
).not.toBeAttached()
- await page.goto('/documenttypes')
+ await page.goto('/attributes/documenttypes')
await expect(page.locator('body')).toHaveText(
/You don't have permissions to do that/i
)
@@ -67,9 +69,9 @@ test('should not allow user to view storage paths', async ({ page }) => {
await page.routeFromHAR(REQUESTS_HAR, { notFound: 'fallback' })
await page.goto('/dashboard')
await expect(
- page.getByRole('link', { name: 'Storage Paths' })
+ page.getByRole('link', { name: 'Attributes' })
).not.toBeAttached()
- await page.goto('/storagepaths')
+ await page.goto('/attributes/storagepaths')
await expect(page.locator('body')).toHaveText(
/You don't have permissions to do that/i
)
diff --git a/src-ui/src/app/app-routing.module.ts b/src-ui/src/app/app-routing.module.ts
index f65514f74..66864a0d5 100644
--- a/src-ui/src/app/app-routing.module.ts
+++ b/src-ui/src/app/app-routing.module.ts
@@ -11,13 +11,9 @@ import { DashboardComponent } from './components/dashboard/dashboard.component'
import { DocumentAsnComponent } from './components/document-asn/document-asn.component'
import { DocumentDetailComponent } from './components/document-detail/document-detail.component'
import { DocumentListComponent } from './components/document-list/document-list.component'
-import { CorrespondentListComponent } from './components/manage/correspondent-list/correspondent-list.component'
-import { CustomFieldsComponent } from './components/manage/custom-fields/custom-fields.component'
-import { DocumentTypeListComponent } from './components/manage/document-type-list/document-type-list.component'
+import { DocumentAttributesComponent } from './components/manage/document-attributes/document-attributes.component'
import { MailComponent } from './components/manage/mail/mail.component'
import { SavedViewsComponent } from './components/manage/saved-views/saved-views.component'
-import { StoragePathListComponent } from './components/manage/storage-path-list/storage-path-list.component'
-import { TagListComponent } from './components/manage/tag-list/tag-list.component'
import { WorkflowsComponent } from './components/manage/workflows/workflows.component'
import { NotFoundComponent } from './components/not-found/not-found.component'
import { DirtyDocGuard } from './guards/dirty-doc.guard'
@@ -106,52 +102,76 @@ export const routes: Routes = [
},
},
{
- path: 'tags',
- component: TagListComponent,
+ path: 'attributes',
+ component: DocumentAttributesComponent,
canActivate: [PermissionsGuard],
data: {
- requiredPermission: {
- action: PermissionAction.View,
- type: PermissionType.Tag,
- },
- componentName: 'TagListComponent',
+ requiredPermissionAny: [
+ { action: PermissionAction.View, type: PermissionType.Tag },
+ {
+ action: PermissionAction.View,
+ type: PermissionType.Correspondent,
+ },
+ {
+ action: PermissionAction.View,
+ type: PermissionType.DocumentType,
+ },
+ { action: PermissionAction.View, type: PermissionType.StoragePath },
+ { action: PermissionAction.View, type: PermissionType.CustomField },
+ ],
+ componentName: 'DocumentAttributesComponent',
},
},
{
- path: 'documenttypes',
- component: DocumentTypeListComponent,
+ path: 'attributes/:section',
+ component: DocumentAttributesComponent,
canActivate: [PermissionsGuard],
data: {
- requiredPermission: {
- action: PermissionAction.View,
- type: PermissionType.DocumentType,
- },
- componentName: 'DocumentTypeListComponent',
+ requiredPermissionAny: [
+ { action: PermissionAction.View, type: PermissionType.Tag },
+ {
+ action: PermissionAction.View,
+ type: PermissionType.Correspondent,
+ },
+ {
+ action: PermissionAction.View,
+ type: PermissionType.DocumentType,
+ },
+ { action: PermissionAction.View, type: PermissionType.StoragePath },
+ { action: PermissionAction.View, type: PermissionType.CustomField },
+ ],
+ componentName: 'DocumentAttributesComponent',
},
},
+ {
+ path: 'documentproperties',
+ redirectTo: '/attributes',
+ pathMatch: 'full',
+ },
+ {
+ path: 'documentproperties/:section',
+ redirectTo: '/attributes/:section',
+ pathMatch: 'full',
+ },
+ {
+ path: 'tags',
+ redirectTo: '/attributes/tags',
+ pathMatch: 'full',
+ },
{
path: 'correspondents',
- component: CorrespondentListComponent,
- canActivate: [PermissionsGuard],
- data: {
- requiredPermission: {
- action: PermissionAction.View,
- type: PermissionType.Correspondent,
- },
- componentName: 'CorrespondentListComponent',
- },
+ redirectTo: '/attributes/correspondents',
+ pathMatch: 'full',
+ },
+ {
+ path: 'documenttypes',
+ redirectTo: '/attributes/documenttypes',
+ pathMatch: 'full',
},
{
path: 'storagepaths',
- component: StoragePathListComponent,
- canActivate: [PermissionsGuard],
- data: {
- requiredPermission: {
- action: PermissionAction.View,
- type: PermissionType.StoragePath,
- },
- componentName: 'StoragePathListComponent',
- },
+ redirectTo: '/attributes/storagepaths',
+ pathMatch: 'full',
},
{
path: 'logs',
@@ -239,15 +259,8 @@ export const routes: Routes = [
},
{
path: 'customfields',
- component: CustomFieldsComponent,
- canActivate: [PermissionsGuard],
- data: {
- requiredPermission: {
- action: PermissionAction.View,
- type: PermissionType.CustomField,
- },
- componentName: 'CustomFieldsComponent',
- },
+ redirectTo: '/attributes/customfields',
+ pathMatch: 'full',
},
{
path: 'workflows',
diff --git a/src-ui/src/app/app.component.ts b/src-ui/src/app/app.component.ts
index 818f8eab0..543d2ecaa 100644
--- a/src-ui/src/app/app.component.ts
+++ b/src-ui/src/app/app.component.ts
@@ -195,8 +195,8 @@ export class AppComponent implements OnInit, OnDestroy {
},
{
anchorId: 'tour.tags',
- content: $localize`Tags, correspondents, document types and storage paths can all be managed using these pages. They can also be created from the document edit view.`,
- route: '/tags',
+ content: $localize`Attributes like tags, correspondents, document types, storage paths and custom fields can all be managed here. They can also be created from the document edit view.`,
+ route: '/attributes/tags',
backdropConfig: {
offset: 0,
},
diff --git a/src-ui/src/app/components/app-frame/app-frame.component.html b/src-ui/src/app/components/app-frame/app-frame.component.html
index 62a2e16cc..13bf9069c 100644
--- a/src-ui/src/app/components/app-frame/app-frame.component.html
+++ b/src-ui/src/app/components/app-frame/app-frame.component.html
@@ -175,44 +175,60 @@
<span i18n>Manage</span>
</h6>
<ul class="nav flex-column mb-2">
- <li class="nav-item app-link"
- *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.Correspondent }">
- <a class="nav-link" routerLink="correspondents" routerLinkActive="active" (click)="closeMenu()"
- ngbPopover="Correspondents" i18n-ngbPopover [disablePopover]="!slimSidebarEnabled" placement="end"
- container="body" triggers="mouseenter:mouseleave" popoverClass="popover-slim">
- <i-bs class="me-1" name="person"></i-bs><span>&nbsp;<ng-container i18n>Correspondents</ng-container></span>
- </a>
- </li>
- <li class="nav-item app-link" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.Tag }"
- tourAnchor="tour.tags">
- <a class="nav-link" routerLink="tags" routerLinkActive="active" (click)="closeMenu()" ngbPopover="Tags"
- i18n-ngbPopover [disablePopover]="!slimSidebarEnabled" placement="end" container="body"
- triggers="mouseenter:mouseleave" popoverClass="popover-slim">
- <i-bs class="me-1" name="tags"></i-bs><span>&nbsp;<ng-container i18n>Tags</ng-container></span>
- </a>
- </li>
- <li class="nav-item app-link"
- *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.DocumentType }">
- <a class="nav-link" routerLink="documenttypes" routerLinkActive="active" (click)="closeMenu()"
- ngbPopover="Document Types" i18n-ngbPopover [disablePopover]="!slimSidebarEnabled" placement="end"
- container="body" triggers="mouseenter:mouseleave" popoverClass="popover-slim">
- <i-bs class="me-1" name="hash"></i-bs><span>&nbsp;<ng-container i18n>Document Types</ng-container></span>
- </a>
- </li>
- <li class="nav-item app-link" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.StoragePath }">
- <a class="nav-link" routerLink="storagepaths" routerLinkActive="active" (click)="closeMenu()"
- ngbPopover="Storage Paths" i18n-ngbPopover [disablePopover]="!slimSidebarEnabled" placement="end"
- container="body" triggers="mouseenter:mouseleave" popoverClass="popover-slim">
- <i-bs class="me-1" name="folder"></i-bs><span>&nbsp;<ng-container i18n>Storage Paths</ng-container></span>
- </a>
- </li>
- <li class="nav-item app-link" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.CustomField }">
- <a class="nav-link" routerLink="customfields" routerLinkActive="active" (click)="closeMenu()"
- ngbPopover="Custom Fields" i18n-ngbPopover [disablePopover]="!slimSidebarEnabled" placement="end"
- container="body" triggers="mouseenter:mouseleave" popoverClass="popover-slim">
- <i-bs class="me-1" name="ui-radios"></i-bs><span>&nbsp;<ng-container i18n>Custom Fields</ng-container></span>
- </a>
- </li>
+ @if (canManageAttributes) {
+ <li class="nav-item app-link" tourAnchor="tour.tags">
+ <div class="d-flex align-items-center attributes-row">
+ <a class="nav-link flex-fill" routerLink="attributes" routerLinkActive="active" (click)="closeMenu()"
+ ngbPopover="Attributes" i18n-ngbPopover [disablePopover]="!slimSidebarEnabled" placement="end"
+ container="body" triggers="mouseenter:mouseleave" popoverClass="popover-slim">
+ <i-bs class="me-1" name="stack"></i-bs><span>&nbsp;<ng-container i18n>Attributes</ng-container></span>
+ </a>
+ @if (!slimSidebarEnabled) {
+ <button
+ type="button"
+ class="btn btn-link btn-sm text-muted p-0 me-3 attributes-expand-btn"
+ (click)="toggleAttributesSections($event)"
+ [attr.aria-label]="attributesSectionsCollapsed ? 'Expand attributes sections' : 'Collapse attributes sections'"
+ i18n-aria-label
+ >
+ <i-bs [name]="attributesSectionsCollapsed ? 'plus-circle' : 'dash-circle'"></i-bs>
+ </button>
+ }
+ </div>
+ <div
+ class="attributes-submenu ms-2"
+ [ngbCollapse]="slimSidebarEnabled || attributesSectionsCollapsed"
+ >
+ <ul class="nav flex-column">
+ <li class="nav-item app-link" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.Tag }">
+ <a class="nav-link py-1" routerLink="attributes/tags" routerLinkActive="active" (click)="closeMenu()">
+ <i-bs class="me-1" name="tags"></i-bs><span>&nbsp;<ng-container i18n>Tags</ng-container></span>
+ </a>
+ </li>
+ <li class="nav-item app-link" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.Correspondent }">
+ <a class="nav-link py-1" routerLink="attributes/correspondents" routerLinkActive="active" (click)="closeMenu()">
+ <i-bs class="me-1" name="person"></i-bs><span>&nbsp;<ng-container i18n>Correspondents</ng-container></span>
+ </a>
+ </li>
+ <li class="nav-item app-link" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.DocumentType }">
+ <a class="nav-link py-1" routerLink="attributes/documenttypes" routerLinkActive="active" (click)="closeMenu()">
+ <i-bs class="me-1" name="hash"></i-bs><span>&nbsp;<ng-container i18n>Document types</ng-container></span>
+ </a>
+ </li>
+ <li class="nav-item app-link" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.StoragePath }">
+ <a class="nav-link py-1" routerLink="attributes/storagepaths" routerLinkActive="active" (click)="closeMenu()">
+ <i-bs class="me-1" name="folder"></i-bs><span>&nbsp;<ng-container i18n>Storage paths</ng-container></span>
+ </a>
+ </li>
+ <li class="nav-item app-link" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.CustomField }">
+ <a class="nav-link py-1" routerLink="attributes/customfields" routerLinkActive="active" (click)="closeMenu()">
+ <i-bs class="me-1" name="ui-radios"></i-bs><span>&nbsp;<ng-container i18n>Custom fields</ng-container></span>
+ </a>
+ </li>
+ </ul>
+ </div>
+ </li>
+ }
<li class="nav-item app-link" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.SavedView }">
<a class="nav-link" routerLink="savedviews" routerLinkActive="active" (click)="closeMenu()"
ngbPopover="Saved Views" i18n-ngbPopover [disablePopover]="!slimSidebarEnabled" placement="end"
diff --git a/src-ui/src/app/components/app-frame/app-frame.component.scss b/src-ui/src/app/components/app-frame/app-frame.component.scss
index ad645c683..31fda990a 100644
--- a/src-ui/src/app/components/app-frame/app-frame.component.scss
+++ b/src-ui/src/app/components/app-frame/app-frame.component.scss
@@ -177,6 +177,15 @@ main {
}
}
+.attributes-row .attributes-expand-btn {
+ opacity: 0.2;
+ transition: opacity 0.15s ease-in-out;
+}
+
+.attributes-row:hover .attributes-expand-btn {
+ opacity: 1;
+}
+
.sidebar-heading {
font-size: 0.75rem;
text-transform: uppercase;
diff --git a/src-ui/src/app/components/app-frame/app-frame.component.spec.ts b/src-ui/src/app/components/app-frame/app-frame.component.spec.ts
index 79d55eb1d..15151782d 100644
--- a/src-ui/src/app/components/app-frame/app-frame.component.spec.ts
+++ b/src-ui/src/app/components/app-frame/app-frame.component.spec.ts
@@ -28,7 +28,10 @@ import {
DjangoMessagesService,
} from 'src/app/services/django-messages.service'
import { OpenDocumentsService } from 'src/app/services/open-documents.service'
-import { PermissionsService } from 'src/app/services/permissions.service'
+import {
+ PermissionType,
+ PermissionsService,
+} from 'src/app/services/permissions.service'
import { RemoteVersionService } from 'src/app/services/rest/remote-version.service'
import { SavedViewService } from 'src/app/services/rest/saved-view.service'
import { SearchService } from 'src/app/services/rest/search.service'
@@ -258,7 +261,7 @@ describe('AppFrameComponent', () => {
const toastSpy = jest.spyOn(toastService, 'showError')
component.toggleSlimSidebar()
httpTestingController
- .expectOne(`${environment.apiBaseUrl}ui_settings/`)
+ .match(`${environment.apiBaseUrl}ui_settings/`)[0]
.flush('error', {
status: 500,
statusText: 'error',
@@ -373,4 +376,103 @@ describe('AppFrameComponent', () => {
it('should call maybeRefreshDocumentCounts after saved views reload', () => {
expect(maybeRefreshSpy).toHaveBeenCalled()
})
+
+ it('should indicate attributes management availability when any permission is granted', () => {
+ jest
+ .spyOn(permissionsService, 'currentUserCan')
+ .mockImplementation((action, type) => {
+ return type === PermissionType.Tag
+ })
+
+ expect(component.canManageAttributes).toBe(true)
+ })
+
+ it('should indicate attributes management availability for other permission types', () => {
+ const canSpy = jest
+ .spyOn(permissionsService, 'currentUserCan')
+ .mockImplementation((action, type) => {
+ return type === PermissionType.Correspondent
+ })
+ expect(component.canManageAttributes).toBe(true)
+
+ canSpy.mockImplementation((action, type) => {
+ return type === PermissionType.DocumentType
+ })
+ expect(component.canManageAttributes).toBe(true)
+
+ canSpy.mockImplementation((action, type) => {
+ return type === PermissionType.StoragePath
+ })
+ expect(component.canManageAttributes).toBe(true)
+
+ canSpy.mockImplementation((action, type) => {
+ return type === PermissionType.CustomField
+ })
+ expect(component.canManageAttributes).toBe(true)
+ })
+
+ it('should toggle attributes sections and stop event bubbling', () => {
+ const preventDefault = jest.fn()
+ const stopPropagation = jest.fn()
+ const setSpy = jest.spyOn(settingsService, 'set')
+ jest.spyOn(settingsService, 'storeSettings').mockReturnValue(of(true))
+
+ component.toggleAttributesSections({
+ preventDefault,
+ stopPropagation,
+ } as any)
+
+ expect(preventDefault).toHaveBeenCalled()
+ expect(stopPropagation).toHaveBeenCalled()
+ expect(setSpy).toHaveBeenCalledWith(
+ SETTINGS_KEYS.ATTRIBUTES_SECTIONS_COLLAPSED,
+ ['attributes']
+ )
+ })
+
+ it('should show error when saving slim sidebar setting fails', () => {
+ const toastSpy = jest.spyOn(toastService, 'showError')
+ jest.spyOn(console, 'warn').mockImplementation(() => {})
+ jest
+ .spyOn(settingsService, 'storeSettings')
+ .mockReturnValue(throwError(() => new Error('boom')))
+
+ component.slimSidebarEnabled = true
+
+ expect(toastSpy).toHaveBeenCalled()
+ })
+
+ it('should show error when saving attributes collapsed setting fails', () => {
+ const toastSpy = jest.spyOn(toastService, 'showError')
+ jest.spyOn(console, 'warn').mockImplementation(() => {})
+ jest
+ .spyOn(settingsService, 'storeSettings')
+ .mockReturnValue(throwError(() => new Error('boom')))
+
+ component.attributesSectionsCollapsed = true
+
+ expect(toastSpy).toHaveBeenCalled()
+ })
+
+ it('should persist attributes section collapse state', () => {
+ const setSpy = jest.spyOn(settingsService, 'set')
+ jest.spyOn(settingsService, 'storeSettings').mockReturnValue(of(true))
+
+ component.attributesSectionsCollapsed = true
+
+ expect(setSpy).toHaveBeenCalledWith(
+ SETTINGS_KEYS.ATTRIBUTES_SECTIONS_COLLAPSED,
+ ['attributes']
+ )
+ })
+
+ it('should collapse attributes sections when enabling slim sidebar', () => {
+ jest.spyOn(settingsService, 'storeSettings').mockReturnValue(of(true))
+ settingsService.set(SETTINGS_KEYS.ATTRIBUTES_SECTIONS_COLLAPSED, [])
+ settingsService.set(SETTINGS_KEYS.SLIM_SIDEBAR, false)
+
+ component.toggleSlimSidebar()
+
+ expect(component.attributesSectionsCollapsed).toBe(true)
+ })
})
diff --git a/src-ui/src/app/components/app-frame/app-frame.component.ts b/src-ui/src/app/components/app-frame/app-frame.component.ts
index 0aff40b01..a063c5095 100644
--- a/src-ui/src/app/components/app-frame/app-frame.component.ts
+++ b/src-ui/src/app/components/app-frame/app-frame.component.ts
@@ -21,7 +21,7 @@ import { Observable } from 'rxjs'
import { first } from 'rxjs/operators'
import { Document } from 'src/app/data/document'
import { SavedView } from 'src/app/data/saved-view'
-import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
+import { CollapsibleSection, SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { ComponentCanDeactivate } from 'src/app/guards/dirty-doc.guard'
import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe'
@@ -141,11 +141,20 @@ export class AppFrameComponent
toggleSlimSidebar(): void {
this.slimSidebarAnimating = true
this.slimSidebarEnabled = !this.slimSidebarEnabled
+ if (this.slimSidebarEnabled) {
+ this.attributesSectionsCollapsed = true
+ }
setTimeout(() => {
this.slimSidebarAnimating = false
}, 200) // slightly longer than css animation for slim sidebar
}
+ toggleAttributesSections(event?: Event): void {
+ event?.preventDefault()
+ event?.stopPropagation()
+ this.attributesSectionsCollapsed = !this.attributesSectionsCollapsed
+ }
+
get versionString(): string {
return `${environment.appTitle} v${this.settingsService.get(SETTINGS_KEYS.VERSION)}${environment.tag === 'prod' ? '' : ` #${environment.tag}`}`
}
@@ -167,6 +176,31 @@ export class AppFrameComponent
)
}
+ get canManageAttributes(): boolean {
+ return (
+ this.permissionsService.currentUserCan(
+ PermissionAction.View,
+ PermissionType.Tag
+ ) ||
+ this.permissionsService.currentUserCan(
+ PermissionAction.View,
+ PermissionType.Correspondent
+ ) ||
+ this.permissionsService.currentUserCan(
+ PermissionAction.View,
+ PermissionType.DocumentType
+ ) ||
+ this.permissionsService.currentUserCan(
+ PermissionAction.View,
+ PermissionType.StoragePath
+ ) ||
+ this.permissionsService.currentUserCan(
+ PermissionAction.View,
+ PermissionType.CustomField
+ )
+ )
+ }
+
get slimSidebarEnabled(): boolean {
return this.settingsService.get(SETTINGS_KEYS.SLIM_SIDEBAR)
}
@@ -186,6 +220,31 @@ export class AppFrameComponent
})
}
+ get attributesSectionsCollapsed(): boolean {
+ return this.settingsService
+ .get(SETTINGS_KEYS.ATTRIBUTES_SECTIONS_COLLAPSED)
+ ?.includes(CollapsibleSection.ATTRIBUTES)
+ }
+
+ set attributesSectionsCollapsed(collapsed: boolean) {
+ // TODO: refactor to be able to toggle individual sections, if implemented
+ this.settingsService.set(
+ SETTINGS_KEYS.ATTRIBUTES_SECTIONS_COLLAPSED,
+ collapsed ? [CollapsibleSection.ATTRIBUTES] : []
+ )
+ this.settingsService
+ .storeSettings()
+ .pipe(first())
+ .subscribe({
+ error: (error) => {
+ this.toastService.showError(
+ $localize`An error occurred while saving settings.`
+ )
+ console.warn(error)
+ },
+ })
+ }
+
get aiEnabled(): boolean {
return this.settingsService.get(SETTINGS_KEYS.AI_ENABLED)
}
diff --git a/src-ui/src/app/components/manage/custom-fields/custom-fields.component.html b/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.html
similarity index 88%
rename from src-ui/src/app/components/manage/custom-fields/custom-fields.component.html
rename to src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.html
index 0a6d80658..635201f76 100644
--- a/src-ui/src/app/components/manage/custom-fields/custom-fields.component.html
+++ b/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.html
@@ -1,15 +1,3 @@
-<pngx-page-header
- title="Custom Fields"
- i18n-title
- info="Customize the data fields that can be attached to documents."
- i18n-info
- infoLink="usage/#custom-fields"
- >
- <button type="button" class="btn btn-sm btn-outline-primary" (click)="editField()" *pngxIfPermissions="{ action: PermissionAction.Add, type: PermissionType.CustomField }">
- <i-bs name="plus-circle"></i-bs>&nbsp;<ng-container i18n>Add Field</ng-container>
- </button>
-</pngx-page-header>
-
<ul class="list-group">
<li class="list-group-item">
diff --git a/src-ui/src/app/components/manage/custom-fields/custom-fields.component.scss b/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.scss
similarity index 100%
rename from src-ui/src/app/components/manage/custom-fields/custom-fields.component.scss
rename to src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.scss
diff --git a/src-ui/src/app/components/manage/custom-fields/custom-fields.component.spec.ts b/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.spec.ts
similarity index 92%
rename from src-ui/src/app/components/manage/custom-fields/custom-fields.component.spec.ts
rename to src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.spec.ts
index b86d476f3..96eaab503 100644
--- a/src-ui/src/app/components/manage/custom-fields/custom-fields.component.spec.ts
+++ b/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.spec.ts
@@ -26,9 +26,9 @@ import { PermissionsService } from 'src/app/services/permissions.service'
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
import { SettingsService } from 'src/app/services/settings.service'
import { ToastService } from 'src/app/services/toast.service'
-import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dialog.component'
-import { CustomFieldEditDialogComponent } from '../../common/edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component'
-import { PageHeaderComponent } from '../../common/page-header/page-header.component'
+import { ConfirmDialogComponent } from '../../../common/confirm-dialog/confirm-dialog.component'
+import { CustomFieldEditDialogComponent } from '../../../common/edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component'
+import { PageHeaderComponent } from '../../../common/page-header/page-header.component'
import { CustomFieldsComponent } from './custom-fields.component'
const fields: CustomField[] = [
@@ -110,10 +110,7 @@ describe('CustomFieldsComponent', () => {
const toastInfoSpy = jest.spyOn(toastService, 'showInfo')
const reloadSpy = jest.spyOn(component, 'reload')
- const createButton = fixture.debugElement
- .queryAll(By.css('button'))
- .find((btn) => btn.nativeElement.textContent.trim().includes('Add Field'))
- createButton.triggerEventHandler('click')
+ component.editField()
expect(modal).not.toBeUndefined()
const editDialog = modal.componentInstance as CustomFieldEditDialogComponent
diff --git a/src-ui/src/app/components/manage/custom-fields/custom-fields.component.ts b/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.ts
similarity index 82%
rename from src-ui/src/app/components/manage/custom-fields/custom-fields.component.ts
rename to src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.ts
index 8ecd713ef..9b9eb98bf 100644
--- a/src-ui/src/app/components/manage/custom-fields/custom-fields.component.ts
+++ b/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.ts
@@ -7,6 +7,10 @@ import {
} from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
import { delay, takeUntil, tap } from 'rxjs'
+import { ConfirmDialogComponent } from 'src/app/components/common/confirm-dialog/confirm-dialog.component'
+import { CustomFieldEditDialogComponent } from 'src/app/components/common/edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component'
+import { EditDialogMode } from 'src/app/components/common/edit-dialog/edit-dialog.component'
+import { LoadingComponentWithPermissions } from 'src/app/components/loading-component/loading.component'
import { CustomField, DATA_TYPE_LABELS } from 'src/app/data/custom-field'
import {
CustomFieldQueryLogicalOperator,
@@ -21,18 +25,12 @@ import { DocumentService } from 'src/app/services/rest/document.service'
import { SavedViewService } from 'src/app/services/rest/saved-view.service'
import { SettingsService } from 'src/app/services/settings.service'
import { ToastService } from 'src/app/services/toast.service'
-import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dialog.component'
-import { CustomFieldEditDialogComponent } from '../../common/edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component'
-import { EditDialogMode } from '../../common/edit-dialog/edit-dialog.component'
-import { PageHeaderComponent } from '../../common/page-header/page-header.component'
-import { LoadingComponentWithPermissions } from '../../loading-component/loading.component'
@Component({
selector: 'pngx-custom-fields',
templateUrl: './custom-fields.component.html',
styleUrls: ['./custom-fields.component.scss'],
imports: [
- PageHeaderComponent,
IfPermissionsDirective,
NgbDropdownModule,
NgbPaginationModule,
@@ -44,14 +42,14 @@ export class CustomFieldsComponent
extends LoadingComponentWithPermissions
implements OnInit
{
- private customFieldsService = inject(CustomFieldsService)
- permissionsService = inject(PermissionsService)
- private modalService = inject(NgbModal)
- private toastService = inject(ToastService)
- private documentListViewService = inject(DocumentListViewService)
- private settingsService = inject(SettingsService)
- private documentService = inject(DocumentService)
- private savedViewService = inject(SavedViewService)
+ private readonly customFieldsService = inject(CustomFieldsService)
+ public readonly permissionsService = inject(PermissionsService)
+ private readonly modalService = inject(NgbModal)
+ private readonly toastService = inject(ToastService)
+ private readonly documentListViewService = inject(DocumentListViewService)
+ private readonly settingsService = inject(SettingsService)
+ private readonly documentService = inject(DocumentService)
+ private readonly savedViewService = inject(SavedViewService)
public fields: CustomField[] = []
diff --git a/src-ui/src/app/components/manage/document-attributes/document-attributes.component.html b/src-ui/src/app/components/manage/document-attributes/document-attributes.component.html
new file mode 100644
index 000000000..1aa105b9d
--- /dev/null
+++ b/src-ui/src/app/components/manage/document-attributes/document-attributes.component.html
@@ -0,0 +1,78 @@
+<pngx-page-header
+ [title]="activeTabLabel"
+ info="Manage tags, correspondents, document types, storage paths, and custom fields."
+ i18n-info
+ [infoLink]="activeInfoLink"
+ [loading]="activeHeaderLoading"
+ >
+ @if (activeManagementList) {
+ <div ngbDropdown class="btn-group flex-fill d-sm-none">
+ <button class="btn btn-sm btn-outline-primary" id="dropdownSelectMobile" ngbDropdownToggle>
+ <i-bs name="text-indent-left"></i-bs>
+ <div class="d-none d-sm-inline">&nbsp;<ng-container i18n>Select</ng-container></div>
+ @if (activeManagementList.selectedObjects.size > 0) {
+ <pngx-clearable-badge [selected]="activeManagementList.selectedObjects.size > 0" [number]="activeManagementList.selectedObjects.size" (cleared)="activeManagementList.selectNone()"></pngx-clearable-badge><span class="visually-hidden">selected</span>
+ }
+ </button>
+ <div ngbDropdownMenu aria-labelledby="dropdownSelectMobile" class="shadow">
+ <button ngbDropdownItem (click)="activeManagementList.selectNone()" i18n>Select none</button>
+ <button ngbDropdownItem (click)="activeManagementList.selectPage(true)" i18n>Select page</button>
+ <button ngbDropdownItem (click)="activeManagementList.selectAll()" i18n>Select all</button>
+ </div>
+ </div>
+
+ <div class="d-none d-sm-flex flex-fill me-3">
+ <div class="input-group input-group-sm">
+ <span class="input-group-text border-0" i18n>Select:</span>
+ </div>
+ <div class="btn-group btn-group-sm flex-nowrap">
+ @if (activeManagementList.selectedObjects.size > 0) {
+ <button class="btn btn-sm btn-outline-secondary" (click)="activeManagementList.selectNone()">
+ <i-bs name="slash-circle"></i-bs>&nbsp;<ng-container i18n>None</ng-container>
+ </button>
+ }
+ <button class="btn btn-sm btn-outline-primary" (click)="activeManagementList.selectPage(true)">
+ <i-bs name="file-earmark-check"></i-bs>&nbsp;<ng-container i18n>Page</ng-container>
+ </button>
+ <button class="btn btn-sm btn-outline-primary" (click)="activeManagementList.selectAll()">
+ <i-bs name="check-all"></i-bs>&nbsp;<ng-container i18n>All</ng-container>
+ </button>
+ </div>
+ </div>
+
+ <button type="button" class="btn btn-sm btn-outline-primary" (click)="activeManagementList.setPermissions()"
+ [disabled]="!activeManagementList.userCanBulkEdit(PermissionAction.Change) || activeManagementList.selectedObjects.size === 0">
+ <i-bs name="person-fill-lock"></i-bs>&nbsp;<ng-container i18n>Permissions</ng-container>
+ </button>
+ <button type="button" class="btn btn-sm btn-outline-danger" (click)="activeManagementList.delete()"
+ [disabled]="!activeManagementList.userCanBulkEdit(PermissionAction.Delete) || activeManagementList.selectedObjects.size === 0">
+ <i-bs name="trash"></i-bs>&nbsp;<ng-container i18n>Delete</ng-container>
+ </button>
+ <button type="button" class="btn btn-sm btn-outline-primary ms-md-5" (click)="activeManagementList.openCreateDialog()"
+ *pngxIfPermissions="{ action: PermissionAction.Add, type: activeManagementList.permissionType }">
+ <i-bs name="plus-circle"></i-bs>&nbsp;<ng-container i18n>Create</ng-container>
+ </button>
+ } @else if (activeCustomFields) {
+ <button type="button" class="btn btn-sm btn-outline-primary" (click)="activeCustomFields.editField()"
+ *pngxIfPermissions="{ action: PermissionAction.Add, type: PermissionType.CustomField }">
+ <i-bs name="plus-circle"></i-bs>&nbsp;<ng-container i18n>Add Field</ng-container>
+ </button>
+ }
+</pngx-page-header>
+
+<ul ngbNav #nav="ngbNav" (navChange)="onNavChange($event)" [(activeId)]="activeNavID" class="nav-underline">
+ @for (section of visibleSections; track section.id) {
+ <li [ngbNavItem]="section.id">
+ <a ngbNavLink >
+ <i-bs class="me-2" [name]="section.icon"></i-bs>{{ section.label }}
+ </a>
+ </li>
+ }
+</ul>
+
+<div class="my-3 shadow-sm">
+ <ng-container
+ [ngComponentOutlet]="activeSection?.component"
+ #activeOutlet="ngComponentOutlet"
+ ></ng-container>
+</div>
diff --git a/src-ui/src/app/components/manage/document-attributes/document-attributes.component.scss b/src-ui/src/app/components/manage/document-attributes/document-attributes.component.scss
new file mode 100644
index 000000000..e69de29bb
diff --git a/src-ui/src/app/components/manage/document-attributes/document-attributes.component.spec.ts b/src-ui/src/app/components/manage/document-attributes/document-attributes.component.spec.ts
new file mode 100644
index 000000000..54017a7e0
--- /dev/null
+++ b/src-ui/src/app/components/manage/document-attributes/document-attributes.component.spec.ts
@@ -0,0 +1,189 @@
+import { Component } from '@angular/core'
+import { ComponentFixture, TestBed } from '@angular/core/testing'
+import {
+ ActivatedRoute,
+ convertToParamMap,
+ ParamMap,
+ Router,
+} from '@angular/router'
+import { RouterTestingModule } from '@angular/router/testing'
+import { allIcons, NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
+import { Subject } from 'rxjs'
+import {
+ PermissionAction,
+ PermissionsService,
+ PermissionType,
+} from 'src/app/services/permissions.service'
+import {
+ DocumentAttributesComponent,
+ DocumentAttributesSectionKind,
+} from './document-attributes.component'
+
+@Component({
+ selector: 'pngx-dummy-section',
+ template: '',
+ standalone: true,
+})
+class DummySectionComponent {}
+
+describe('DocumentAttributesComponent', () => {
+ let component: DocumentAttributesComponent
+ let fixture: ComponentFixture<DocumentAttributesComponent>
+ let router: Router
+ let paramMapSubject: Subject<ParamMap>
+ let permissionsService: PermissionsService
+
+ beforeEach(async () => {
+ paramMapSubject = new Subject<ParamMap>()
+
+ TestBed.configureTestingModule({
+ imports: [
+ RouterTestingModule,
+ NgxBootstrapIconsModule.pick(allIcons),
+ DocumentAttributesComponent,
+ DummySectionComponent,
+ ],
+ providers: [
+ {
+ provide: ActivatedRoute,
+ useValue: {
+ paramMap: paramMapSubject.asObservable(),
+ },
+ },
+ {
+ provide: PermissionsService,
+ useValue: {
+ currentUserCan: jest.fn(),
+ },
+ },
+ ],
+ }).compileComponents()
+
+ fixture = TestBed.createComponent(DocumentAttributesComponent)
+ component = fixture.componentInstance
+ router = TestBed.inject(Router)
+ permissionsService = TestBed.inject(PermissionsService)
+
+ jest.spyOn(router, 'navigate').mockResolvedValue(true)
+ ;(component as any).sections = [
+ {
+ id: 1,
+ path: 'tags',
+ label: 'Tags',
+ icon: 'tags',
+ permissionType: PermissionType.Tag,
+ kind: DocumentAttributesSectionKind.ManagementList,
+ component: DummySectionComponent,
+ },
+ {
+ id: 2,
+ path: 'customfields',
+ label: 'Custom fields',
+ icon: 'ui-radios',
+ permissionType: PermissionType.CustomField,
+ kind: DocumentAttributesSectionKind.CustomFields,
+ component: DummySectionComponent,
+ },
+ ]
+ })
+
+ it('should navigate to default section when no section is provided', () => {
+ jest
+ .spyOn(permissionsService, 'currentUserCan')
+ .mockImplementation((action, type) => {
+ return action === PermissionAction.View && type === PermissionType.Tag
+ })
+
+ fixture.detectChanges()
+ paramMapSubject.next(convertToParamMap({}))
+
+ expect(router.navigate).toHaveBeenCalledWith(['attributes', 'tags'], {
+ replaceUrl: true,
+ })
+ expect(component.activeNavID).toBe(1)
+ })
+
+ it('should set active section from route param when valid', () => {
+ jest
+ .spyOn(permissionsService, 'currentUserCan')
+ .mockImplementation((action, type) => {
+ return (
+ action === PermissionAction.View &&
+ type === PermissionType.CustomField
+ )
+ })
+
+ fixture.detectChanges()
+ paramMapSubject.next(convertToParamMap({ section: 'customfields' }))
+
+ expect(component.activeNavID).toBe(2)
+ expect(router.navigate).not.toHaveBeenCalled()
+ })
+
+ it('should update active nav id when route section changes', () => {
+ jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true)
+
+ fixture.detectChanges()
+ component.activeNavID = 1
+ paramMapSubject.next(convertToParamMap({ section: 'customfields' }))
+
+ expect(component.activeNavID).toBe(2)
+ })
+
+ it('should redirect to dashboard when no sections are visible', () => {
+ jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(false)
+
+ fixture.detectChanges()
+ paramMapSubject.next(convertToParamMap({}))
+
+ expect(router.navigate).toHaveBeenCalledWith(['/dashboard'], {
+ replaceUrl: true,
+ })
+ })
+
+ it('should navigate when a nav change occurs', () => {
+ jest
+ .spyOn(permissionsService, 'currentUserCan')
+ .mockImplementation(() => true)
+
+ fixture.detectChanges()
+ paramMapSubject.next(convertToParamMap({ section: 'tags' }))
+
+ component.onNavChange({ nextId: 2 } as any)
+
+ expect(router.navigate).toHaveBeenCalledWith(['attributes', 'customfields'])
+ })
+
+ it('should ignore nav changes for unknown sections', () => {
+ jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true)
+
+ fixture.detectChanges()
+ paramMapSubject.next(convertToParamMap({ section: 'tags' }))
+
+ component.onNavChange({ nextId: 999 } as any)
+
+ expect(router.navigate).not.toHaveBeenCalled()
+ })
+
+ it('should return activeManagementList correctly', () => {
+ jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true)
+ expect(component.activeManagementList).toBeNull()
+
+ component.activeNavID = 1
+ expect(component.activeSection.kind).toBe(
+ DocumentAttributesSectionKind.ManagementList
+ )
+ expect(component.activeManagementList).toBeDefined()
+ })
+
+ it('should return activeCustomFields correctly', () => {
+ jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true)
+ expect(component.activeCustomFields).toBeNull()
+
+ component.activeNavID = 2
+ expect(component.activeSection.kind).toBe(
+ DocumentAttributesSectionKind.CustomFields
+ )
+ expect(component.activeCustomFields).toBeDefined()
+ })
+})
diff --git a/src-ui/src/app/components/manage/document-attributes/document-attributes.component.ts b/src-ui/src/app/components/manage/document-attributes/document-attributes.component.ts
new file mode 100644
index 000000000..8396ca6b2
--- /dev/null
+++ b/src-ui/src/app/components/manage/document-attributes/document-attributes.component.ts
@@ -0,0 +1,256 @@
+import { NgComponentOutlet } from '@angular/common'
+import {
+ AfterViewChecked,
+ ChangeDetectorRef,
+ Component,
+ inject,
+ OnDestroy,
+ OnInit,
+ Type,
+ ViewChild,
+} from '@angular/core'
+import { ActivatedRoute, Router } from '@angular/router'
+import {
+ NgbDropdownModule,
+ NgbNavChangeEvent,
+ NgbNavModule,
+} from '@ng-bootstrap/ng-bootstrap'
+import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
+import { Subject, takeUntil } from 'rxjs'
+import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
+import {
+ PermissionAction,
+ PermissionsService,
+ PermissionType,
+} from 'src/app/services/permissions.service'
+import { ClearableBadgeComponent } from '../../common/clearable-badge/clearable-badge.component'
+import { PageHeaderComponent } from '../../common/page-header/page-header.component'
+import { CustomFieldsComponent } from './custom-fields/custom-fields.component'
+import { CorrespondentListComponent } from './management-list/correspondent-list/correspondent-list.component'
+import { DocumentTypeListComponent } from './management-list/document-type-list/document-type-list.component'
+import { ManagementListComponent } from './management-list/management-list.component'
+import { StoragePathListComponent } from './management-list/storage-path-list/storage-path-list.component'
+import { TagListComponent } from './management-list/tag-list/tag-list.component'
+
+enum DocumentAttributesNavIDs {
+ Tags = 1,
+ Correspondents = 2,
+ DocumentTypes = 3,
+ StoragePaths = 4,
+ CustomFields = 5,
+}
+
+export enum DocumentAttributesSectionKind {
+ ManagementList = 'managementList',
+ CustomFields = 'customFields',
+}
+
+interface DocumentAttributesSection {
+ id: DocumentAttributesNavIDs
+ path: string
+ label: string
+ icon: string
+ infoLink?: string
+ permissionType: PermissionType
+ kind: DocumentAttributesSectionKind
+ component: Type<any>
+}
+
+@Component({
+ selector: 'pngx-document-attributes',
+ templateUrl: './document-attributes.component.html',
+ styleUrls: ['./document-attributes.component.scss'],
+ imports: [
+ PageHeaderComponent,
+ NgbNavModule,
+ NgbDropdownModule,
+ NgComponentOutlet,
+ NgxBootstrapIconsModule,
+ IfPermissionsDirective,
+ ClearableBadgeComponent,
+ ],
+})
+export class DocumentAttributesComponent
+ implements OnInit, OnDestroy, AfterViewChecked
+{
+ private readonly permissionsService = inject(PermissionsService)
+ private readonly activatedRoute = inject(ActivatedRoute)
+ private readonly router = inject(Router)
+ private readonly cdr = inject(ChangeDetectorRef)
+ private readonly unsubscribeNotifier = new Subject<void>()
+
+ protected readonly PermissionAction = PermissionAction
+ protected readonly PermissionType = PermissionType
+
+ readonly sections: DocumentAttributesSection[] = [
+ {
+ id: DocumentAttributesNavIDs.Tags,
+ path: 'tags',
+ label: $localize`Tags`,
+ icon: 'tags',
+ infoLink: 'usage/#terms-and-definitions',
+ permissionType: PermissionType.Tag,
+ kind: DocumentAttributesSectionKind.ManagementList,
+ component: TagListComponent,
+ },
+ {
+ id: DocumentAttributesNavIDs.Correspondents,
+ path: 'correspondents',
+ label: $localize`Correspondents`,
+ icon: 'person',
+ infoLink: 'usage/#terms-and-definitions',
+ permissionType: PermissionType.Correspondent,
+ kind: DocumentAttributesSectionKind.ManagementList,
+ component: CorrespondentListComponent,
+ },
+ {
+ id: DocumentAttributesNavIDs.DocumentTypes,
+ path: 'documenttypes',
+ label: $localize`Document types`,
+ icon: 'hash',
+ infoLink: 'usage/#terms-and-definitions',
+ permissionType: PermissionType.DocumentType,
+ kind: DocumentAttributesSectionKind.ManagementList,
+ component: DocumentTypeListComponent,
+ },
+ {
+ id: DocumentAttributesNavIDs.StoragePaths,
+ path: 'storagepaths',
+ label: $localize`Storage paths`,
+ icon: 'folder',
+ infoLink: 'usage/#terms-and-definitions',
+ permissionType: PermissionType.StoragePath,
+ kind: DocumentAttributesSectionKind.ManagementList,
+ component: StoragePathListComponent,
+ },
+ {
+ id: DocumentAttributesNavIDs.CustomFields,
+ path: 'customfields',
+ label: $localize`Custom fields`,
+ icon: 'ui-radios',
+ infoLink: 'usage/#custom-fields',
+ permissionType: PermissionType.CustomField,
+ kind: DocumentAttributesSectionKind.CustomFields,
+ component: CustomFieldsComponent,
+ },
+ ]
+
+ @ViewChild('activeOutlet', { read: NgComponentOutlet })
+ private readonly activeOutlet?: NgComponentOutlet
+
+ private lastHeaderLoading: boolean
+
+ activeNavID: number = null
+
+ get visibleSections(): DocumentAttributesSection[] {
+ return this.sections.filter((section) =>
+ this.permissionsService.currentUserCan(
+ PermissionAction.View,
+ section.permissionType
+ )
+ )
+ }
+
+ get activeSection(): DocumentAttributesSection | null {
+ return (
+ this.visibleSections.find((section) => section.id === this.activeNavID) ??
+ null
+ )
+ }
+
+ get activeManagementList(): ManagementListComponent<any> | null {
+ if (
+ this.activeSection?.kind !== DocumentAttributesSectionKind.ManagementList
+ )
+ return null
+ const instance = this.activeOutlet?.componentInstance
+ return instance instanceof ManagementListComponent ? instance : null
+ }
+
+ get activeCustomFields(): CustomFieldsComponent | null {
+ if (this.activeSection?.kind !== DocumentAttributesSectionKind.CustomFields)
+ return null
+ const instance = this.activeOutlet?.componentInstance
+ return instance instanceof CustomFieldsComponent ? instance : null
+ }
+
+ get activeTabLabel(): string {
+ return this.activeSection?.label ?? ''
+ }
+
+ get activeInfoLink(): string {
+ return this.activeSection?.infoLink ?? null
+ }
+
+ get activeHeaderLoading(): boolean {
+ return (
+ this.activeManagementList?.loading ??
+ this.activeCustomFields?.loading ??
+ false
+ )
+ }
+
+ ngOnInit(): void {
+ this.activatedRoute.paramMap
+ .pipe(takeUntil(this.unsubscribeNotifier))
+ .subscribe((paramMap) => {
+ const section = paramMap.get('section')
+ const navIDFromSection =
+ this.getNavIDForSection(section) ?? this.getDefaultNavID()
+
+ if (navIDFromSection == null) {
+ this.router.navigate(['/dashboard'], { replaceUrl: true })
+ return
+ }
+
+ if (this.activeNavID !== navIDFromSection) {
+ this.activeNavID = navIDFromSection
+ }
+
+ if (!section || this.getNavIDForSection(section) == null) {
+ this.router.navigate(
+ ['attributes', this.getSectionForNavID(this.activeNavID)],
+ { replaceUrl: true }
+ )
+ }
+ })
+ }
+
+ ngOnDestroy(): void {
+ this.unsubscribeNotifier.next()
+ this.unsubscribeNotifier.complete()
+ }
+
+ ngAfterViewChecked(): void {
+ const current = this.activeHeaderLoading
+ if (this.lastHeaderLoading !== current) {
+ this.lastHeaderLoading = current
+ this.cdr.detectChanges()
+ }
+ }
+
+ onNavChange(navChangeEvent: NgbNavChangeEvent): void {
+ const nextSection = this.getSectionForNavID(navChangeEvent.nextId)
+ if (!nextSection) {
+ return
+ }
+ this.router.navigate(['attributes', nextSection])
+ }
+
+ private getDefaultNavID(): DocumentAttributesNavIDs | null {
+ return this.visibleSections[0]?.id ?? null
+ }
+
+ private getNavIDForSection(section: string): DocumentAttributesNavIDs | null {
+ const path = section?.toLowerCase()
+ if (!path) return null
+
+ const found = this.visibleSections.find((s) => s.path === path)
+ return found?.id ?? null
+ }
+
+ private getSectionForNavID(navID: number): string | null {
+ const section = this.visibleSections.find((s) => s.id === navID)
+ return section?.path ?? null
+ }
+}
diff --git a/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.spec.ts b/src-ui/src/app/components/manage/document-attributes/management-list/correspondent-list/correspondent-list.component.spec.ts
similarity index 97%
rename from src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.spec.ts
rename to src-ui/src/app/components/manage/document-attributes/management-list/correspondent-list/correspondent-list.component.spec.ts
index 98071cb90..35f04fd8a 100644
--- a/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.spec.ts
+++ b/src-ui/src/app/components/manage/document-attributes/management-list/correspondent-list/correspondent-list.component.spec.ts
@@ -9,7 +9,7 @@ import { of } from 'rxjs'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { SortableDirective } from 'src/app/directives/sortable.directive'
import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
-import { PageHeaderComponent } from '../../common/page-header/page-header.component'
+import { PageHeaderComponent } from '../../../../common/page-header/page-header.component'
import { CorrespondentListComponent } from './correspondent-list.component'
describe('CorrespondentListComponent', () => {
diff --git a/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.ts b/src-ui/src/app/components/manage/document-attributes/management-list/correspondent-list/correspondent-list.component.ts
similarity index 77%
rename from src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.ts
rename to src-ui/src/app/components/manage/document-attributes/management-list/correspondent-list/correspondent-list.component.ts
index 4a3a82b9c..8f12aaf7a 100644
--- a/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.ts
+++ b/src-ui/src/app/components/manage/document-attributes/management-list/correspondent-list/correspondent-list.component.ts
@@ -1,4 +1,4 @@
-import { NgClass, NgTemplateOutlet, TitleCasePipe } from '@angular/common'
+import { NgClass, NgTemplateOutlet } from '@angular/common'
import { Component, inject } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { RouterModule } from '@angular/router'
@@ -7,6 +7,7 @@ import {
NgbPaginationModule,
} from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
+import { CorrespondentEditDialogComponent } from 'src/app/components/common/edit-dialog/correspondent-edit-dialog/correspondent-edit-dialog.component'
import { Correspondent } from 'src/app/data/correspondent'
import { FILTER_HAS_CORRESPONDENT_ANY } from 'src/app/data/filter-rule-type'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
@@ -14,21 +15,16 @@ import { SortableDirective } from 'src/app/directives/sortable.directive'
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
import { PermissionType } from 'src/app/services/permissions.service'
import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
-import { ClearableBadgeComponent } from '../../common/clearable-badge/clearable-badge.component'
-import { CorrespondentEditDialogComponent } from '../../common/edit-dialog/correspondent-edit-dialog/correspondent-edit-dialog.component'
-import { PageHeaderComponent } from '../../common/page-header/page-header.component'
-import { ManagementListComponent } from '../management-list/management-list.component'
+import { ManagementListComponent } from '../management-list.component'
@Component({
selector: 'pngx-correspondent-list',
- templateUrl: './../management-list/management-list.component.html',
- styleUrls: ['./../management-list/management-list.component.scss'],
+ templateUrl: './../management-list.component.html',
+ styleUrls: ['./../management-list.component.scss'],
providers: [{ provide: CustomDatePipe }],
imports: [
SortableDirective,
IfPermissionsDirective,
- PageHeaderComponent,
- TitleCasePipe,
FormsModule,
ReactiveFormsModule,
RouterModule,
@@ -37,11 +33,10 @@ import { ManagementListComponent } from '../management-list/management-list.comp
NgbDropdownModule,
NgbPaginationModule,
NgxBootstrapIconsModule,
- ClearableBadgeComponent,
],
})
export class CorrespondentListComponent extends ManagementListComponent<Correspondent> {
- private datePipe = inject(CustomDatePipe)
+ private readonly datePipe = inject(CustomDatePipe)
constructor() {
super()
diff --git a/src-ui/src/app/components/manage/document-type-list/document-type-list.component.spec.ts b/src-ui/src/app/components/manage/document-attributes/management-list/document-type-list/document-type-list.component.spec.ts
similarity index 96%
rename from src-ui/src/app/components/manage/document-type-list/document-type-list.component.spec.ts
rename to src-ui/src/app/components/manage/document-attributes/management-list/document-type-list/document-type-list.component.spec.ts
index 640d6aab8..c8931cdc2 100644
--- a/src-ui/src/app/components/manage/document-type-list/document-type-list.component.spec.ts
+++ b/src-ui/src/app/components/manage/document-attributes/management-list/document-type-list/document-type-list.component.spec.ts
@@ -9,7 +9,7 @@ import { of } from 'rxjs'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { SortableDirective } from 'src/app/directives/sortable.directive'
import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
-import { PageHeaderComponent } from '../../common/page-header/page-header.component'
+import { PageHeaderComponent } from '../../../../common/page-header/page-header.component'
import { DocumentTypeListComponent } from './document-type-list.component'
describe('DocumentTypeListComponent', () => {
diff --git a/src-ui/src/app/components/manage/document-type-list/document-type-list.component.ts b/src-ui/src/app/components/manage/document-attributes/management-list/document-type-list/document-type-list.component.ts
similarity index 70%
rename from src-ui/src/app/components/manage/document-type-list/document-type-list.component.ts
rename to src-ui/src/app/components/manage/document-attributes/management-list/document-type-list/document-type-list.component.ts
index dc3a020be..cafe038d2 100644
--- a/src-ui/src/app/components/manage/document-type-list/document-type-list.component.ts
+++ b/src-ui/src/app/components/manage/document-attributes/management-list/document-type-list/document-type-list.component.ts
@@ -1,4 +1,4 @@
-import { NgClass, NgTemplateOutlet, TitleCasePipe } from '@angular/common'
+import { NgClass, NgTemplateOutlet } from '@angular/common'
import { Component, inject } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { RouterModule } from '@angular/router'
@@ -7,25 +7,21 @@ import {
NgbPaginationModule,
} from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
+import { DocumentTypeEditDialogComponent } from 'src/app/components/common/edit-dialog/document-type-edit-dialog/document-type-edit-dialog.component'
import { DocumentType } from 'src/app/data/document-type'
import { FILTER_HAS_DOCUMENT_TYPE_ANY } from 'src/app/data/filter-rule-type'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { SortableDirective } from 'src/app/directives/sortable.directive'
import { PermissionType } from 'src/app/services/permissions.service'
import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
-import { ClearableBadgeComponent } from '../../common/clearable-badge/clearable-badge.component'
-import { DocumentTypeEditDialogComponent } from '../../common/edit-dialog/document-type-edit-dialog/document-type-edit-dialog.component'
-import { PageHeaderComponent } from '../../common/page-header/page-header.component'
-import { ManagementListComponent } from '../management-list/management-list.component'
+import { ManagementListComponent } from '../management-list.component'
@Component({
selector: 'pngx-document-type-list',
- templateUrl: './../management-list/management-list.component.html',
- styleUrls: ['./../management-list/management-list.component.scss'],
+ templateUrl: './../management-list.component.html',
+ styleUrls: ['./../management-list.component.scss'],
imports: [
SortableDirective,
- PageHeaderComponent,
- TitleCasePipe,
IfPermissionsDirective,
FormsModule,
ReactiveFormsModule,
@@ -35,7 +31,6 @@ import { ManagementListComponent } from '../management-list/management-list.comp
NgbDropdownModule,
NgbPaginationModule,
NgxBootstrapIconsModule,
- ClearableBadgeComponent,
],
})
export class DocumentTypeListComponent extends ManagementListComponent<DocumentType> {
diff --git a/src-ui/src/app/components/manage/management-list/management-list.component.html b/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.html
similarity index 64%
rename from src-ui/src/app/components/manage/management-list/management-list.component.html
rename to src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.html
index cb2f1010f..fcec43bb8 100644
--- a/src-ui/src/app/components/manage/management-list/management-list.component.html
+++ b/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.html
@@ -1,50 +1,3 @@
-<pngx-page-header title="{{ typeNamePlural | titlecase }}" info="View, add, edit and delete {{ typeNamePlural }}." infoLink="usage/#terms-and-definitions" [loading]="loading">
-
- <div ngbDropdown class="btn-group flex-fill d-sm-none">
- <button class="btn btn-sm btn-outline-primary" id="dropdownSelectMobile" ngbDropdownToggle>
- <i-bs name="text-indent-left"></i-bs>
- <div class="d-none d-sm-inline">&nbsp;<ng-container i18n>Select</ng-container></div>
- @if (selectedObjects.size > 0) {
- <pngx-clearable-badge [selected]="selectedObjects.size > 0" [number]="selectedObjects.size" (cleared)="selectNone()"></pngx-clearable-badge><span class="visually-hidden">selected</span>
- }
- </button>
- <div ngbDropdownMenu aria-labelledby="dropdownSelectMobile" class="shadow">
- <button ngbDropdownItem (click)="selectNone()" i18n>Select none</button>
- <button ngbDropdownItem (click)="selectPage(true)" i18n>Select page</button>
- <button ngbDropdownItem (click)="selectAll()" i18n>Select all</button>
- </div>
- </div>
-
- <div class="d-none d-sm-flex flex-fill me-3">
- <div class="input-group input-group-sm">
- <span class="input-group-text border-0" i18n>Select:</span>
- </div>
- <div class="btn-group btn-group-sm flex-nowrap">
- @if (selectedObjects.size > 0) {
- <button class="btn btn-sm btn-outline-secondary" (click)="selectNone()">
- <i-bs name="slash-circle"></i-bs>&nbsp;<ng-container i18n>None</ng-container>
- </button>
- }
- <button class="btn btn-sm btn-outline-primary" (click)="selectPage(true)">
- <i-bs name="file-earmark-check"></i-bs>&nbsp;<ng-container i18n>Page</ng-container>
- </button>
- <button class="btn btn-sm btn-outline-primary" (click)="selectAll()">
- <i-bs name="check-all"></i-bs>&nbsp;<ng-container i18n>All</ng-container>
- </button>
- </div>
- </div>
-
- <button type="button" class="btn btn-sm btn-outline-primary" (click)="setPermissions()" [disabled]="!userCanBulkEdit(PermissionAction.Change) || selectedObjects.size === 0">
- <i-bs name="person-fill-lock"></i-bs>&nbsp;<ng-container i18n>Permissions</ng-container>
- </button>
- <button type="button" class="btn btn-sm btn-outline-danger" (click)="delete()" [disabled]="!userCanBulkEdit(PermissionAction.Delete) || selectedObjects.size === 0">
- <i-bs name="trash"></i-bs>&nbsp;<ng-container i18n>Delete</ng-container>
- </button>
- <button type="button" class="btn btn-sm btn-outline-primary ms-md-5" (click)="openCreateDialog()" *pngxIfPermissions="{ action: PermissionAction.Add, type: permissionType }">
- <i-bs name="plus-circle"></i-bs>&nbsp;<ng-container i18n>Create</ng-container>
- </button>
-</pngx-page-header>
-
<div class="row mb-3">
<div class="col mb-2 mb-xl-0">
<div class="form-inline d-flex align-items-center">
@@ -76,19 +29,19 @@
<table class="table table-striped align-middle shadow-sm mb-0">
<thead>
<tr>
- <th scope="col">
+ <th>
<div class="form-check m-0 ms-2 me-n2">
- <input type="checkbox" class="form-check-input" id="all-objects" [(ngModel)]="togggleAll" [disabled]="data.length === 0" (change)="selectPage($event.target.checked); $event.stopPropagation();">
+ <input type="checkbox" class="form-check-input" id="all-objects" [(ngModel)]="togggleAll" [disabled]="data.length === 0" (change)="$event.target.checked ? selectPage() : clearSelection(); $event.stopPropagation();">
<label class="form-check-label" for="all-objects"></label>
</div>
</th>
- <th scope="col" class="fw-normal" pngxSortable="name" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Name</th>
- <th scope="col" class="fw-normal d-none d-sm-table-cell" pngxSortable="matching_algorithm" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Matching</th>
- <th scope="col" class="fw-normal" pngxSortable="document_count" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Document count</th>
+ <th class="fw-normal" pngxSortable="name" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Name</th>
+ <th class="fw-normal d-none d-sm-table-cell" pngxSortable="matching_algorithm" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Matching</th>
+ <th class="fw-normal" pngxSortable="document_count" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Document count</th>
@for (column of extraColumns; track column) {
- <th scope="col" class="fw-normal" [ngClass]="{ 'd-none d-sm-table-cell' : column.hideOnMobile }" pngxSortable="{{column.key}}" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)">{{column.name}}</th>
+ <th class="fw-normal" [ngClass]="{ 'd-none d-sm-table-cell' : column.hideOnMobile }" pngxSortable="{{column.key}}" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)">{{column.name}}</th>
}
- <th scope="col" class="fw-normal" i18n>Actions</th>
+ <th class="fw-normal" i18n>Actions</th>
</tr>
</thead>
<tbody>
@@ -131,16 +84,16 @@
<label class="form-check-label" for="{{typeName}}{{object.id}}"></label>
</div>
</td>
- <td scope="row" class="name-cell" style="--depth: {{depth}}">
+ <td class="name-cell" style="--depth: {{depth}}">
@if (depth > 0) {
<div class="indicator"></div>
}
<button class="btn btn-link ms-0 ps-0 text-start" (click)="userCanEdit(object) ? openEditDialog(object) : null; $event.stopPropagation()">{{ object.name }}</button>
</td>
- <td scope="row" class="d-none d-sm-table-cell">{{ getMatching(object) }}</td>
- <td scope="row">{{ getDocumentCount(object) }}</td>
+ <td class="d-none d-sm-table-cell">{{ getMatching(object) }}</td>
+ <td>{{ getDocumentCount(object) }}</td>
@for (column of extraColumns; track column) {
- <td scope="row" [ngClass]="{ 'd-none d-sm-table-cell' : column.hideOnMobile }">
+ <td [ngClass]="{ 'd-none d-sm-table-cell' : column.hideOnMobile }">
@if (column.badgeFn) {
<span
class="badge"
@@ -156,7 +109,7 @@
}
</td>
}
- <td scope="row">
+ <td>
<div class="btn-toolbar gap-2">
<div class="btn-group d-block d-sm-none">
<div ngbDropdown container="body" class="d-inline-block">
diff --git a/src-ui/src/app/components/manage/management-list/management-list.component.scss b/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.scss
similarity index 100%
rename from src-ui/src/app/components/manage/management-list/management-list.component.scss
rename to src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.scss
diff --git a/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts b/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.spec.ts
similarity index 97%
rename from src-ui/src/app/components/manage/management-list/management-list.component.spec.ts
rename to src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.spec.ts
index b2a494425..48b567752 100644
--- a/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts
+++ b/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.spec.ts
@@ -44,12 +44,12 @@ import { BulkEditObjectOperation } from 'src/app/services/rest/abstract-name-fil
import { TagService } from 'src/app/services/rest/tag.service'
import { SettingsService } from 'src/app/services/settings.service'
import { ToastService } from 'src/app/services/toast.service'
-import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dialog.component'
-import { EditDialogComponent } from '../../common/edit-dialog/edit-dialog.component'
-import { PageHeaderComponent } from '../../common/page-header/page-header.component'
-import { PermissionsDialogComponent } from '../../common/permissions-dialog/permissions-dialog.component'
-import { TagListComponent } from '../tag-list/tag-list.component'
+import { ConfirmDialogComponent } from '../../../common/confirm-dialog/confirm-dialog.component'
+import { EditDialogComponent } from '../../../common/edit-dialog/edit-dialog.component'
+import { PageHeaderComponent } from '../../../common/page-header/page-header.component'
+import { PermissionsDialogComponent } from '../../../common/permissions-dialog/permissions-dialog.component'
import { ManagementListComponent } from './management-list.component'
+import { TagListComponent } from './tag-list/tag-list.component'
const tags: Tag[] = [
{
@@ -304,12 +304,12 @@ describe('ManagementListComponent', () => {
})
it('selectPage should select current page items or clear selection', () => {
- component.selectPage(true)
+ component.selectPage()
expect(component.selectedObjects).toEqual(new Set(tags.map((t) => t.id)))
expect(component.togggleAll).toBe(true)
component.togggleAll = true
- component.selectPage(false)
+ component.clearSelection()
expect(component.selectedObjects.size).toBe(0)
expect(component.togggleAll).toBe(false)
})
diff --git a/src-ui/src/app/components/manage/management-list/management-list.component.ts b/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.ts
similarity index 91%
rename from src-ui/src/app/components/manage/management-list/management-list.component.ts
rename to src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.ts
index 6f5e9c0dd..e53664520 100644
--- a/src-ui/src/app/components/manage/management-list/management-list.component.ts
+++ b/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.ts
@@ -16,6 +16,10 @@ import {
takeUntil,
tap,
} from 'rxjs/operators'
+import { ConfirmDialogComponent } from 'src/app/components/common/confirm-dialog/confirm-dialog.component'
+import { EditDialogMode } from 'src/app/components/common/edit-dialog/edit-dialog.component'
+import { PermissionsDialogComponent } from 'src/app/components/common/permissions-dialog/permissions-dialog.component'
+import { LoadingComponentWithPermissions } from 'src/app/components/loading-component/loading.component'
import {
MATCH_AUTO,
MATCH_NONE,
@@ -40,10 +44,6 @@ import {
} from 'src/app/services/rest/abstract-name-filter-service'
import { SettingsService } from 'src/app/services/settings.service'
import { ToastService } from 'src/app/services/toast.service'
-import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dialog.component'
-import { EditDialogMode } from '../../common/edit-dialog/edit-dialog.component'
-import { PermissionsDialogComponent } from '../../common/permissions-dialog/permissions-dialog.component'
-import { LoadingComponentWithPermissions } from '../../loading-component/loading.component'
export interface ManagementListColumn {
key: string
@@ -69,13 +69,14 @@ export abstract class ManagementListComponent<T extends MatchingModel>
implements OnInit, OnDestroy
{
protected service: AbstractNameFilterService<T>
- private modalService: NgbModal = inject(NgbModal)
+ private readonly modalService: NgbModal = inject(NgbModal)
protected editDialogComponent: any
- private toastService: ToastService = inject(ToastService)
- private documentListViewService: DocumentListViewService = inject(
+ private readonly toastService: ToastService = inject(ToastService)
+ private readonly documentListViewService: DocumentListViewService = inject(
DocumentListViewService
)
- private permissionsService: PermissionsService = inject(PermissionsService)
+ private readonly permissionsService: PermissionsService =
+ inject(PermissionsService)
protected filterRuleType: number
public typeName: string
public typeNamePlural: string
@@ -196,7 +197,7 @@ export abstract class ManagementListComponent<T extends MatchingModel>
}
openCreateDialog() {
- var activeModal = this.modalService.open(this.editDialogComponent, {
+ const activeModal = this.modalService.open(this.editDialogComponent, {
backdrop: 'static',
})
activeModal.componentInstance.dialogMode = EditDialogMode.CREATE
@@ -215,7 +216,7 @@ export abstract class ManagementListComponent<T extends MatchingModel>
}
openEditDialog(object: T) {
- var activeModal = this.modalService.open(this.editDialogComponent, {
+ const activeModal = this.modalService.open(this.editDialogComponent, {
backdrop: 'static',
})
activeModal.componentInstance.object = object
@@ -243,7 +244,7 @@ export abstract class ManagementListComponent<T extends MatchingModel>
}
openDeleteDialog(object: T) {
- var activeModal = this.modalService.open(ConfirmDialogComponent, {
+ const activeModal = this.modalService.open(ConfirmDialogComponent, {
backdrop: 'static',
})
activeModal.componentInstance.title = $localize`Confirm delete`
@@ -343,13 +344,9 @@ export abstract class ManagementListComponent<T extends MatchingModel>
this.clearSelection()
}
- selectPage(select: boolean) {
- if (select) {
- this.selectedObjects = new Set(this.getSelectableIDs(this.data))
- this.togggleAll = this.areAllPageItemsSelected()
- } else {
- this.clearSelection()
- }
+ selectPage() {
+ this.selectedObjects = new Set(this.getSelectableIDs(this.data))
+ this.togggleAll = this.areAllPageItemsSelected()
}
selectAll() {
diff --git a/src-ui/src/app/components/manage/storage-path-list/storage-path-list.component.spec.ts b/src-ui/src/app/components/manage/document-attributes/management-list/storage-path-list/storage-path-list.component.spec.ts
similarity index 96%
rename from src-ui/src/app/components/manage/storage-path-list/storage-path-list.component.spec.ts
rename to src-ui/src/app/components/manage/document-attributes/management-list/storage-path-list/storage-path-list.component.spec.ts
index e59c52789..d2b75ca56 100644
--- a/src-ui/src/app/components/manage/storage-path-list/storage-path-list.component.spec.ts
+++ b/src-ui/src/app/components/manage/document-attributes/management-list/storage-path-list/storage-path-list.component.spec.ts
@@ -10,7 +10,7 @@ import { StoragePath } from 'src/app/data/storage-path'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { SortableDirective } from 'src/app/directives/sortable.directive'
import { StoragePathService } from 'src/app/services/rest/storage-path.service'
-import { PageHeaderComponent } from '../../common/page-header/page-header.component'
+import { PageHeaderComponent } from '../../../../common/page-header/page-header.component'
import { StoragePathListComponent } from './storage-path-list.component'
describe('StoragePathListComponent', () => {
diff --git a/src-ui/src/app/components/manage/storage-path-list/storage-path-list.component.ts b/src-ui/src/app/components/manage/document-attributes/management-list/storage-path-list/storage-path-list.component.ts
similarity index 73%
rename from src-ui/src/app/components/manage/storage-path-list/storage-path-list.component.ts
rename to src-ui/src/app/components/manage/document-attributes/management-list/storage-path-list/storage-path-list.component.ts
index 3ab940521..14129544e 100644
--- a/src-ui/src/app/components/manage/storage-path-list/storage-path-list.component.ts
+++ b/src-ui/src/app/components/manage/document-attributes/management-list/storage-path-list/storage-path-list.component.ts
@@ -1,4 +1,4 @@
-import { NgClass, NgTemplateOutlet, TitleCasePipe } from '@angular/common'
+import { NgClass, NgTemplateOutlet } from '@angular/common'
import { Component, inject } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { RouterModule } from '@angular/router'
@@ -7,25 +7,21 @@ import {
NgbPaginationModule,
} from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
+import { StoragePathEditDialogComponent } from 'src/app/components/common/edit-dialog/storage-path-edit-dialog/storage-path-edit-dialog.component'
import { FILTER_HAS_STORAGE_PATH_ANY } from 'src/app/data/filter-rule-type'
import { StoragePath } from 'src/app/data/storage-path'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { SortableDirective } from 'src/app/directives/sortable.directive'
import { PermissionType } from 'src/app/services/permissions.service'
import { StoragePathService } from 'src/app/services/rest/storage-path.service'
-import { ClearableBadgeComponent } from '../../common/clearable-badge/clearable-badge.component'
-import { StoragePathEditDialogComponent } from '../../common/edit-dialog/storage-path-edit-dialog/storage-path-edit-dialog.component'
-import { PageHeaderComponent } from '../../common/page-header/page-header.component'
-import { ManagementListComponent } from '../management-list/management-list.component'
+import { ManagementListComponent } from '../management-list.component'
@Component({
selector: 'pngx-storage-path-list',
- templateUrl: './../management-list/management-list.component.html',
- styleUrls: ['./../management-list/management-list.component.scss'],
+ templateUrl: './../management-list.component.html',
+ styleUrls: ['./../management-list.component.scss'],
imports: [
SortableDirective,
- PageHeaderComponent,
- TitleCasePipe,
IfPermissionsDirective,
FormsModule,
ReactiveFormsModule,
@@ -35,7 +31,6 @@ import { ManagementListComponent } from '../management-list/management-list.comp
NgbDropdownModule,
NgbPaginationModule,
NgxBootstrapIconsModule,
- ClearableBadgeComponent,
],
})
export class StoragePathListComponent extends ManagementListComponent<StoragePath> {
diff --git a/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts b/src-ui/src/app/components/manage/document-attributes/management-list/tag-list/tag-list.component.spec.ts
similarity index 96%
rename from src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts
rename to src-ui/src/app/components/manage/document-attributes/management-list/tag-list/tag-list.component.spec.ts
index a69eacba0..526da6c9e 100644
--- a/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts
+++ b/src-ui/src/app/components/manage/document-attributes/management-list/tag-list/tag-list.component.spec.ts
@@ -9,7 +9,7 @@ import { of } from 'rxjs'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { SortableDirective } from 'src/app/directives/sortable.directive'
import { TagService } from 'src/app/services/rest/tag.service'
-import { PageHeaderComponent } from '../../common/page-header/page-header.component'
+import { PageHeaderComponent } from '../../../../common/page-header/page-header.component'
import { TagListComponent } from './tag-list.component'
describe('TagListComponent', () => {
@@ -138,12 +138,12 @@ describe('TagListComponent', () => {
}
component.data = [parent as any]
- component.selectPage(true)
+ component.selectPage()
expect(component.selectedObjects.has(10)).toBe(true)
expect(component.selectedObjects.has(11)).toBe(true)
- component.selectPage(false)
+ component.clearSelection()
expect(component.selectedObjects.size).toBe(0)
})
})
diff --git a/src-ui/src/app/components/manage/tag-list/tag-list.component.ts b/src-ui/src/app/components/manage/document-attributes/management-list/tag-list/tag-list.component.ts
similarity index 79%
rename from src-ui/src/app/components/manage/tag-list/tag-list.component.ts
rename to src-ui/src/app/components/manage/document-attributes/management-list/tag-list/tag-list.component.ts
index 87045a50a..f221fd572 100644
--- a/src-ui/src/app/components/manage/tag-list/tag-list.component.ts
+++ b/src-ui/src/app/components/manage/document-attributes/management-list/tag-list/tag-list.component.ts
@@ -1,4 +1,4 @@
-import { NgClass, NgTemplateOutlet, TitleCasePipe } from '@angular/common'
+import { NgClass, NgTemplateOutlet } from '@angular/common'
import { Component, inject } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { RouterModule } from '@angular/router'
@@ -7,25 +7,21 @@ import {
NgbPaginationModule,
} from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
+import { TagEditDialogComponent } from 'src/app/components/common/edit-dialog/tag-edit-dialog/tag-edit-dialog.component'
import { FILTER_HAS_TAGS_ALL } from 'src/app/data/filter-rule-type'
import { Tag } from 'src/app/data/tag'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { SortableDirective } from 'src/app/directives/sortable.directive'
import { PermissionType } from 'src/app/services/permissions.service'
import { TagService } from 'src/app/services/rest/tag.service'
-import { ClearableBadgeComponent } from '../../common/clearable-badge/clearable-badge.component'
-import { TagEditDialogComponent } from '../../common/edit-dialog/tag-edit-dialog/tag-edit-dialog.component'
-import { PageHeaderComponent } from '../../common/page-header/page-header.component'
-import { ManagementListComponent } from '../management-list/management-list.component'
+import { ManagementListComponent } from '../management-list.component'
@Component({
selector: 'pngx-tag-list',
- templateUrl: './../management-list/management-list.component.html',
- styleUrls: ['./../management-list/management-list.component.scss'],
+ templateUrl: './../management-list.component.html',
+ styleUrls: ['./../management-list.component.scss'],
imports: [
SortableDirective,
- PageHeaderComponent,
- TitleCasePipe,
IfPermissionsDirective,
FormsModule,
ReactiveFormsModule,
@@ -35,7 +31,6 @@ import { ManagementListComponent } from '../management-list/management-list.comp
NgbDropdownModule,
NgbPaginationModule,
NgxBootstrapIconsModule,
- ClearableBadgeComponent,
],
})
export class TagListComponent extends ManagementListComponent<Tag> {
diff --git a/src-ui/src/app/data/ui-settings.ts b/src-ui/src/app/data/ui-settings.ts
index 9b72cb1d6..c47c409d5 100644
--- a/src-ui/src/app/data/ui-settings.ts
+++ b/src-ui/src/app/data/ui-settings.ts
@@ -19,6 +19,10 @@ export enum GlobalSearchType {
TITLE_CONTENT = 'title-content',
}
+export enum CollapsibleSection {
+ ATTRIBUTES = 'attributes',
+}
+
export const PAPERLESS_GREEN_HEX = '#17541f'
export const SETTINGS_KEYS = {
@@ -51,6 +55,8 @@ export const SETTINGS_KEYS = {
NOTES_ENABLED: 'general-settings:notes-enabled',
AUDITLOG_ENABLED: 'general-settings:auditlog-enabled',
SLIM_SIDEBAR: 'general-settings:slim-sidebar',
+ ATTRIBUTES_SECTIONS_COLLAPSED:
+ 'general-settings:attributes-sections-collapsed',
UPDATE_CHECKING_ENABLED: 'general-settings:update-checking:enabled',
UPDATE_CHECKING_BACKEND_SETTING:
'general-settings:update-checking:backend-setting',
@@ -112,6 +118,11 @@ export const SETTINGS: UiSetting[] = [
type: 'boolean',
default: false,
},
+ {
+ key: SETTINGS_KEYS.ATTRIBUTES_SECTIONS_COLLAPSED,
+ type: 'array',
+ default: [],
+ },
{
key: SETTINGS_KEYS.DOCUMENT_LIST_SIZE,
type: 'number',
diff --git a/src-ui/src/app/guards/permissions.guard.spec.ts b/src-ui/src/app/guards/permissions.guard.spec.ts
index c10232f2b..69191e1ad 100644
--- a/src-ui/src/app/guards/permissions.guard.spec.ts
+++ b/src-ui/src/app/guards/permissions.guard.spec.ts
@@ -96,4 +96,52 @@ describe('PermissionsGuard', () => {
expect(canActivate).toHaveProperty('root') // returns UrlTree
expect(toastSpy).toHaveBeenCalled()
})
+
+ it('should activate when any required permission is granted', () => {
+ jest
+ .spyOn(permissionsService, 'currentUserCan')
+ .mockImplementation((action, type) => {
+ return type === PermissionType.Tag
+ })
+
+ const canActivate = guard.canActivate(
+ {
+ data: {
+ requiredPermissionAny: [
+ { action: PermissionAction.View, type: PermissionType.Tag },
+ {
+ action: PermissionAction.View,
+ type: PermissionType.DocumentType,
+ },
+ ],
+ },
+ } as any,
+ routerState.snapshot
+ )
+
+ expect(canActivate).toBeTruthy()
+ })
+
+ it('should not activate when no required permission is granted', () => {
+ jest
+ .spyOn(permissionsService, 'currentUserCan')
+ .mockImplementation(() => false)
+
+ const canActivate = guard.canActivate(
+ {
+ data: {
+ requiredPermissionAny: [
+ { action: PermissionAction.View, type: PermissionType.Tag },
+ {
+ action: PermissionAction.View,
+ type: PermissionType.DocumentType,
+ },
+ ],
+ },
+ } as any,
+ routerState.snapshot
+ )
+
+ expect(canActivate).toHaveProperty('root')
+ })
})
diff --git a/src-ui/src/app/guards/permissions.guard.ts b/src-ui/src/app/guards/permissions.guard.ts
index ddac8e035..01d5e63cb 100644
--- a/src-ui/src/app/guards/permissions.guard.ts
+++ b/src-ui/src/app/guards/permissions.guard.ts
@@ -20,12 +20,20 @@ export class PermissionsGuard {
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): boolean | UrlTree {
+ const requiredPermissionAny: { action: any; type: any }[] =
+ route.data.requiredPermissionAny
+
if (
(route.data.requireAdmin && !this.permissionsService.isAdmin()) ||
(route.data.requiredPermission &&
!this.permissionsService.currentUserCan(
route.data.requiredPermission.action,
route.data.requiredPermission.type
+ )) ||
+ (Array.isArray(requiredPermissionAny) &&
+ requiredPermissionAny.length > 0 &&
+ !requiredPermissionAny.some((p) =>
+ this.permissionsService.currentUserCan(p.action, p.type)
))
) {
// Check if tour is running 1 = TourState.ON
diff --git a/src-ui/src/main.ts b/src-ui/src/main.ts
index cccfc96db..675e9961c 100644
--- a/src-ui/src/main.ts
+++ b/src-ui/src/main.ts
@@ -125,6 +125,7 @@ import {
sliders2Vertical,
sortAlphaDown,
sortAlphaUpAlt,
+ stack,
stars,
tag,
tagFill,
@@ -343,6 +344,7 @@ const icons = {
sliders2Vertical,
sortAlphaDown,
sortAlphaUpAlt,
+ stack,
stars,
tagFill,
tag,