diff --git a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html
index 51b8a2a5d..9dce30891 100644
--- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html
+++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html
@@ -140,7 +140,7 @@
@if (formGroup.get('schedule_date_field').value === 'custom_field') {
diff --git a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.spec.ts
index 936b3708e..2c7b56149 100644
--- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.spec.ts
+++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.spec.ts
@@ -771,25 +771,21 @@ describe('WorkflowEditDialogComponent', () => {
false
)
- component.correspondents = [{ id: 1, name: 'C1' } as any]
- component.documentTypes = [{ id: 2, name: 'DT' } as any]
- component.storagePaths = [{ id: 3, name: 'SP' } as any]
-
expect(
component.getFilterSelectItems(TriggerFilterType.CorrespondentIs)
- ).toEqual(component.correspondents)
+ ).toEqual(component.correspondents())
expect(
component.getFilterSelectItems(TriggerFilterType.DocumentTypeIs)
- ).toEqual(component.documentTypes)
+ ).toEqual(component.documentTypes())
expect(
component.getFilterSelectItems(TriggerFilterType.DocumentTypeAny)
- ).toEqual(component.documentTypes)
+ ).toEqual(component.documentTypes())
expect(
component.getFilterSelectItems(TriggerFilterType.StoragePathIs)
- ).toEqual(component.storagePaths)
+ ).toEqual(component.storagePaths())
expect(
component.getFilterSelectItems(TriggerFilterType.StoragePathAny)
- ).toEqual(component.storagePaths)
+ ).toEqual(component.storagePaths())
expect(component.getFilterSelectItems(TriggerFilterType.TagsAll)).toEqual(
[]
)
diff --git a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts
index f379ed3ae..57603e412 100644
--- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts
+++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts
@@ -4,7 +4,8 @@ import {
moveItemInArray,
} from '@angular/cdk/drag-drop'
import { NgTemplateOutlet } from '@angular/common'
-import { Component, OnInit, inject, signal } from '@angular/core'
+import { Component, OnInit, computed, inject, signal } from '@angular/core'
+import { toSignal } from '@angular/core/rxjs-interop'
import {
AbstractControl,
FormArray,
@@ -15,7 +16,7 @@ import {
} from '@angular/forms'
import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
-import { Subscription, first, takeUntil } from 'rxjs'
+import { Subscription, map, takeUntil } from 'rxjs'
import { Correspondent } from 'src/app/data/correspondent'
import { CustomField, CustomFieldDataType } from 'src/app/data/custom-field'
import { DocumentType } from 'src/app/data/document-type'
@@ -470,79 +471,40 @@ export class WorkflowEditDialogComponent
public TriggerFilterType = TriggerFilterType
public filterDefinitions = TRIGGER_FILTER_DEFINITIONS
- private correspondentService: CorrespondentService
- private documentTypeService: DocumentTypeService
- private storagePathService: StoragePathService
- private mailRuleService: MailRuleService
- private customFieldsService: CustomFieldsService
+ private correspondentService = inject(CorrespondentService)
+ private documentTypeService = inject(DocumentTypeService)
+ private storagePathService = inject(StoragePathService)
+ private mailRuleService = inject(MailRuleService)
+ private customFieldsService = inject(CustomFieldsService)
- private templatesSignal = signal
(undefined)
- private correspondentsSignal = signal(undefined)
- private documentTypesSignal = signal(undefined)
- private storagePathsSignal = signal(undefined)
- private mailRulesSignal = signal(undefined)
- private customFieldsSignal = signal(undefined)
- private dateCustomFieldsSignal = signal(undefined)
-
- get templates(): Workflow[] {
- return this.templatesSignal()
- }
-
- set templates(templates: Workflow[]) {
- this.templatesSignal.set(templates)
- }
-
- get correspondents(): Correspondent[] {
- return this.correspondentsSignal()
- }
-
- set correspondents(correspondents: Correspondent[]) {
- this.correspondentsSignal.set(correspondents)
- }
-
- get documentTypes(): DocumentType[] {
- return this.documentTypesSignal()
- }
-
- set documentTypes(documentTypes: DocumentType[]) {
- this.documentTypesSignal.set(documentTypes)
- }
-
- get storagePaths(): StoragePath[] {
- return this.storagePathsSignal()
- }
-
- set storagePaths(storagePaths: StoragePath[]) {
- this.storagePathsSignal.set(storagePaths)
- }
-
- get mailRules(): MailRule[] {
- return this.mailRulesSignal()
- }
-
- set mailRules(mailRules: MailRule[]) {
- this.mailRulesSignal.set(mailRules)
- }
-
- get customFields(): CustomField[] {
- return this.customFieldsSignal()
- }
-
- set customFields(customFields: CustomField[]) {
- this.customFieldsSignal.set(customFields)
- }
-
- get dateCustomFields(): CustomField[] {
- return this.dateCustomFieldsSignal()
- }
-
- set dateCustomFields(dateCustomFields: CustomField[]) {
- this.dateCustomFieldsSignal.set(dateCustomFields)
- }
+ readonly templates = signal(undefined)
+ readonly correspondents = toSignal(
+ this.correspondentService.listAll().pipe(map((result) => result.results)),
+ { initialValue: undefined as Correspondent[] }
+ )
+ readonly documentTypes = toSignal(
+ this.documentTypeService.listAll().pipe(map((result) => result.results)),
+ { initialValue: undefined as DocumentType[] }
+ )
+ readonly storagePaths = toSignal(
+ this.storagePathService.listAll().pipe(map((result) => result.results)),
+ { initialValue: undefined as StoragePath[] }
+ )
+ readonly mailRules = toSignal(
+ this.mailRuleService.listAll().pipe(map((result) => result.results)),
+ { initialValue: undefined as MailRule[] }
+ )
+ readonly customFields = toSignal(
+ this.customFieldsService.listAll().pipe(map((result) => result.results)),
+ { initialValue: undefined as CustomField[] }
+ )
+ readonly dateCustomFields = computed(() =>
+ this.customFields()?.filter((f) => f.data_type === CustomFieldDataType.Date)
+ )
expandedItem: number = null
- private allowedActionTypesSignal = signal([])
+ readonly allowedActionTypes = signal([])
private readonly triggerFilterOptionsMap = new WeakMap<
FormArray,
@@ -552,43 +514,8 @@ export class WorkflowEditDialogComponent
constructor() {
super()
this.service = inject(WorkflowService)
- this.correspondentService = inject(CorrespondentService)
- this.documentTypeService = inject(DocumentTypeService)
- this.storagePathService = inject(StoragePathService)
- this.mailRuleService = inject(MailRuleService)
this.userService = inject(UserService)
this.settingsService = inject(SettingsService)
- this.customFieldsService = inject(CustomFieldsService)
-
- this.correspondentService
- .listAll()
- .pipe(first())
- .subscribe((result) => (this.correspondents = result.results))
-
- this.documentTypeService
- .listAll()
- .pipe(first())
- .subscribe((result) => (this.documentTypes = result.results))
-
- this.storagePathService
- .listAll()
- .pipe(first())
- .subscribe((result) => (this.storagePaths = result.results))
-
- this.mailRuleService
- .listAll()
- .pipe(first())
- .subscribe((result) => (this.mailRules = result.results))
-
- this.customFieldsService
- .listAll()
- .pipe(first())
- .subscribe((result) => {
- this.customFields = result.results
- this.dateCustomFields = this.customFields?.filter(
- (f) => f.data_type === CustomFieldDataType.Date
- )
- })
}
getCreateTitle() {
@@ -621,11 +548,13 @@ export class WorkflowEditDialogComponent
this.checkRemovalActionFields.bind(this)
)
this.checkRemovalActionFields(this.objectForm.value)
- this.allowedActionTypes = this.settingsService.get(
- SETTINGS_KEYS.EMAIL_ENABLED
+ this.allowedActionTypes.set(
+ this.settingsService.get(SETTINGS_KEYS.EMAIL_ENABLED)
+ ? WORKFLOW_ACTION_OPTIONS
+ : WORKFLOW_ACTION_OPTIONS.filter(
+ (a) => a.id !== WorkflowActionType.Email
+ )
)
- ? WORKFLOW_ACTION_OPTIONS
- : WORKFLOW_ACTION_OPTIONS.filter((a) => a.id !== WorkflowActionType.Email)
}
private checkRemovalActionFields(formWorkflow: Workflow) {
@@ -1010,11 +939,11 @@ export class WorkflowEditDialogComponent
switch (definition.selectItems) {
case 'correspondents':
- return this.correspondents
+ return this.correspondents()
case 'documentTypes':
- return this.documentTypes
+ return this.documentTypes()
case 'storagePaths':
- return this.storagePaths
+ return this.storagePaths()
default:
return []
}
@@ -1351,15 +1280,7 @@ export class WorkflowEditDialogComponent
get actionTypeOptions() {
this.settingsService.trackChanges()
- return this.allowedActionTypes
- }
-
- get allowedActionTypes() {
- return this.allowedActionTypesSignal()
- }
-
- set allowedActionTypes(allowedActionTypes) {
- this.allowedActionTypesSignal.set(allowedActionTypes)
+ return this.allowedActionTypes()
}
getActionTypeOptionName(type: WorkflowActionType): string {
diff --git a/src-ui/src/app/components/common/permissions-dialog/permissions-dialog.component.html b/src-ui/src/app/components/common/permissions-dialog/permissions-dialog.component.html
index f11fc9760..7ac84c6cc 100644
--- a/src-ui/src/app/components/common/permissions-dialog/permissions-dialog.component.html
+++ b/src-ui/src/app/components/common/permissions-dialog/permissions-dialog.component.html
@@ -1,5 +1,5 @@
@@ -7,7 +7,7 @@
-
- @if (displayCollectionSize > 0) {
+ @if (displayCollectionSize() > 0) {
- {displayCollectionSize, plural, =1 {One {{typeName}}} other {{{displayCollectionSize || 0}} total {{typeNamePlural}}}}
+ {displayCollectionSize(), plural, =1 {One {{typeName}}} other {{{displayCollectionSize() || 0}} total {{typeNamePlural}}}}
@if (hasSelection) {
({{selectedCount}} selected)
}
}
- @if (collectionSize > 20) {
-
+ @if (collectionSize() > 20) {
+
}
}
diff --git a/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.spec.ts b/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.spec.ts
index cfc087ba4..1e8fb3f7c 100644
--- a/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.spec.ts
+++ b/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.spec.ts
@@ -147,7 +147,7 @@ describe('ManagementListComponent', () => {
component.nameFilter = 'foo' // subject normally triggered by ngModel
tick(400) // debounce
fixture.detectChanges()
- expect(component.data).toEqual([tags[0]])
+ expect(component.data()).toEqual([tags[0]])
nameFilterInput.nativeElement.dispatchEvent(
new KeyboardEvent('keyup', { code: 'Escape' })
@@ -155,7 +155,7 @@ describe('ManagementListComponent', () => {
tick(400) // debounce
fixture.detectChanges()
expect(component.nameFilter).toBeNull()
- expect(component.data).toEqual(tags)
+ expect(component.data()).toEqual(tags)
tick(100) // load
}))
@@ -242,8 +242,8 @@ describe('ManagementListComponent', () => {
component.reloadData()
tick(100)
- expect(component.collectionSize).toBe(1)
- expect(component.displayCollectionSize).toBe(3)
+ expect(component.collectionSize()).toBe(1)
+ expect(component.displayCollectionSize()).toBe(3)
}))
it('should support quick filter for objects', () => {
@@ -275,9 +275,9 @@ describe('ManagementListComponent', () => {
})
)
)
- component.page = 2
+ component.page.set(2)
component.reloadData()
- expect(component.page).toEqual(1)
+ expect(component.page()).toEqual(1)
})
it('should support toggle select page in vew', () => {
@@ -295,28 +295,28 @@ describe('ManagementListComponent', () => {
it('selectNone should clear selection and reset toggle flag', () => {
component.selectedObjects = new Set([tags[0].id, tags[1].id])
- component.togggleAll = true
+ component.togggleAll.set(true)
component.selectNone()
expect(component.selectedObjects.size).toBe(0)
- expect(component.togggleAll).toBe(false)
+ expect(component.togggleAll()).toBe(false)
})
it('selectPage should select current page items or clear selection', () => {
component.selectPage()
expect(component.selectedObjects).toEqual(new Set(tags.map((t) => t.id)))
- expect(component.togggleAll).toBe(true)
+ expect(component.togggleAll()).toBe(true)
- component.togggleAll = true
+ component.togggleAll.set(true)
component.clearSelection()
expect(component.selectedObjects.size).toBe(0)
- expect(component.togggleAll).toBe(false)
+ expect(component.togggleAll()).toBe(false)
})
it('selectAll should activate all-selection mode', () => {
;(tagService.listFiltered as jest.Mock).mockClear()
- component.collectionSize = tags.length
+ component.collectionSize.set(tags.length)
component.selectAll()
@@ -325,41 +325,41 @@ describe('ManagementListComponent', () => {
expect((component as any).allSelectionActive).toBe(true)
expect(component.hasSelection).toBe(true)
expect(component.selectedCount).toBe(tags.length)
- expect(component.togggleAll).toBe(true)
+ expect(component.togggleAll()).toBe(true)
})
it('selectAll should clear selection when collection size is zero', () => {
component.selectedObjects = new Set([1])
- component.collectionSize = 0
- component.togggleAll = true
+ component.collectionSize.set(0)
+ component.togggleAll.set(true)
component.selectAll()
expect(component.selectedObjects.size).toBe(0)
- expect(component.togggleAll).toBe(false)
+ expect(component.togggleAll()).toBe(false)
})
it('toggleSelected should toggle object selection and update toggle state', () => {
component.toggleSelected(tags[0])
expect(component.selectedObjects.has(tags[0].id)).toBe(true)
- expect(component.togggleAll).toBe(false)
+ expect(component.togggleAll()).toBe(false)
component.toggleSelected(tags[1])
component.toggleSelected(tags[2])
- expect(component.togggleAll).toBe(true)
+ expect(component.togggleAll()).toBe(true)
component.toggleSelected(tags[1])
expect(component.selectedObjects.has(tags[1].id)).toBe(false)
- expect(component.togggleAll).toBe(false)
+ expect(component.togggleAll()).toBe(false)
})
it('areAllPageItemsSelected should return false when page has no selectable items', () => {
- component.data = []
+ component.data.set([])
component.selectedObjects.clear()
expect((component as any).areAllPageItemsSelected()).toBe(false)
- component.data = tags
+ component.data.set(tags)
})
it('should support bulk edit permissions', () => {
@@ -498,7 +498,7 @@ describe('ManagementListComponent', () => {
document_count: 10,
parent: 1,
}
- component['unfilteredData'].push(childTag)
+ component['unfilteredData'].update((data) => [...data, childTag])
const original = component.getOriginalObject({ id: 4 } as Tag)
expect(original).toEqual(childTag)
})
@@ -536,7 +536,7 @@ describe('ManagementListComponent', () => {
.mockReturnValue(of({ success: true }))
component.typeNamePlural = 'tags'
- component.page = 2
+ component.page.set(2)
component.pageSize = 100
tick()
@@ -545,7 +545,7 @@ describe('ManagementListComponent', () => {
SETTINGS_KEYS.OBJECT_LIST_SIZES,
{ tags: 100 }
)
- expect(component.page).toBe(1)
+ expect(component.page()).toBe(1)
expect(reloadSpy).toHaveBeenCalled()
expect(toastErrorSpy).not.toHaveBeenCalled()
}))
diff --git a/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.ts b/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.ts
index a49e5a84e..b385df69f 100644
--- a/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.ts
+++ b/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.ts
@@ -88,89 +88,25 @@ export abstract class ManagementListComponent