From b7836d7cfd7903b5ccd6fbb5d4ebb4d6dd257ed9 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 8 Jul 2026 12:58:40 -0700 Subject: [PATCH] More direct signals conversion --- .../components/admin/logs/logs.component.html | 8 ++--- .../admin/logs/logs.component.spec.ts | 8 ++--- .../components/admin/logs/logs.component.ts | 12 +++---- .../users-groups/users-groups.component.html | 12 +++---- .../users-groups/users-groups.component.ts | 34 +++++-------------- .../dashboard/dashboard.component.html | 2 +- .../dashboard/dashboard.component.ts | 22 ++++-------- .../custom-fields.component.html | 4 +-- .../custom-fields/custom-fields.component.ts | 12 ++----- .../manage/workflows/workflows.component.html | 6 ++-- .../manage/workflows/workflows.component.ts | 12 ++----- 11 files changed, 45 insertions(+), 87 deletions(-) diff --git a/src-ui/src/app/components/admin/logs/logs.component.html b/src-ui/src/app/components/admin/logs/logs.component.html index 12b6b1d5a..108ca41c3 100644 --- a/src-ui/src/app/components/admin/logs/logs.component.html +++ b/src-ui/src/app/components/admin/logs/logs.component.html @@ -11,19 +11,19 @@ type="number" min="100" step="100" - [(ngModel)]="limit" - (ngModelChange)="onLimitChange($event)" + [ngModel]="limit()" + (ngModelChange)="limit.set($event); onLimitChange($event)" style="width: 100px;"> lines
- +
- } -@if ((canViewUsers && !users) || (canViewGroups && !groups)) { +@if ((canViewUsers && !users()) || (canViewGroups && !groups())) {
Loading...
diff --git a/src-ui/src/app/components/admin/users-groups/users-groups.component.ts b/src-ui/src/app/components/admin/users-groups/users-groups.component.ts index a36629648..209749ffd 100644 --- a/src-ui/src/app/components/admin/users-groups/users-groups.component.ts +++ b/src-ui/src/app/components/admin/users-groups/users-groups.component.ts @@ -43,24 +43,8 @@ export class UsersAndGroupsComponent permissionsService = inject(PermissionsService) private settings = inject(SettingsService) - private usersSignal = signal(null) - private groupsSignal = signal(null) - - get users(): User[] { - return this.usersSignal() - } - - set users(value: User[]) { - this.usersSignal.set(value) - } - - get groups(): Group[] { - return this.groupsSignal() - } - - set groups(value: Group[]) { - this.groupsSignal.set(value) - } + readonly users = signal(null) + readonly groups = signal(null) unsubscribeNotifier: Subject = new Subject() @@ -85,7 +69,7 @@ export class UsersAndGroupsComponent .pipe(first(), takeUntil(this.unsubscribeNotifier)) .subscribe({ next: (r) => { - this.users = r.results + this.users.set(r.results) }, error: (e) => { this.toastService.showError($localize`Error retrieving users`, e) @@ -99,7 +83,7 @@ export class UsersAndGroupsComponent .pipe(first(), takeUntil(this.unsubscribeNotifier)) .subscribe({ next: (r) => { - this.groups = r.results + this.groups.set(r.results) }, error: (e) => { this.toastService.showError($localize`Error retrieving groups`, e) @@ -141,7 +125,7 @@ export class UsersAndGroupsComponent $localize`Saved user "${newUser.username}".` ) this.usersService.listAll().subscribe((r) => { - this.users = r.results + this.users.set(r.results) }) } }) @@ -168,7 +152,7 @@ export class UsersAndGroupsComponent modal.close() this.toastService.showInfo($localize`Deleted user "${user.username}"`) this.usersService.listAll().subscribe((r) => { - this.users = r.results + this.users.set(r.results) }) }, error: (e) => { @@ -195,7 +179,7 @@ export class UsersAndGroupsComponent .subscribe((newGroup) => { this.toastService.showInfo($localize`Saved group "${newGroup.name}".`) this.groupsService.listAll().subscribe((r) => { - this.groups = r.results + this.groups.set(r.results) }) }) modal.componentInstance.failed @@ -221,7 +205,7 @@ export class UsersAndGroupsComponent modal.close() this.toastService.showInfo($localize`Deleted group "${group.name}"`) this.groupsService.listAll().subscribe((r) => { - this.groups = r.results + this.groups.set(r.results) }) }, error: (e) => { @@ -235,6 +219,6 @@ export class UsersAndGroupsComponent } getGroupName(id: number): string { - return this.groups?.find((g) => g.id === id)?.name ?? '' + return this.groups()?.find((g) => g.id === id)?.name ?? '' } } diff --git a/src-ui/src/app/components/dashboard/dashboard.component.html b/src-ui/src/app/components/dashboard/dashboard.component.html index 41b124544..dda955361 100644 --- a/src-ui/src/app/components/dashboard/dashboard.component.html +++ b/src-ui/src/app/components/dashboard/dashboard.component.html @@ -45,7 +45,7 @@
} - @for (v of dashboardViews; track v.id) { + @for (v of dashboardViews(); track v.id) {
([]) - - get dashboardViews(): SavedView[] { - return this.dashboardViewsSignal() - } - - set dashboardViews(value: SavedView[]) { - this.dashboardViewsSignal.set(value) - } + readonly dashboardViews = signal([]) constructor() { super() this.savedViewService.listAll().subscribe(() => { - this.dashboardViews = this.savedViewService.dashboardViews + this.dashboardViews.set(this.savedViewService.dashboardViews) }) } @@ -89,14 +81,12 @@ export class DashboardComponent extends ComponentWithPermissions { } onDrop(event: CdkDragDrop) { - moveItemInArray( - this.dashboardViews, - event.previousIndex, - event.currentIndex - ) + const dashboardViews = [...this.dashboardViews()] + moveItemInArray(dashboardViews, event.previousIndex, event.currentIndex) + this.dashboardViews.set(dashboardViews) this.settingsService - .updateDashboardViewsSort(this.dashboardViews) + .updateDashboardViewsSort(this.dashboardViews()) .subscribe({ next: () => { this.toastService.showInfo($localize`Dashboard updated`) diff --git a/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.html b/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.html index b90f8d3d1..3f45dfe51 100644 --- a/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.html +++ b/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.html @@ -15,7 +15,7 @@ } - @for (field of fields; track field) { + @for (field of fields(); track field) {
  • @@ -64,7 +64,7 @@
  • } - @if (!loading && fields.length === 0) { + @if (!loading && fields().length === 0) {
  • No fields defined.
  • } diff --git a/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.ts b/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.ts index e264cbb8f..4b3253202 100644 --- a/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.ts +++ b/src-ui/src/app/components/manage/document-attributes/custom-fields/custom-fields.component.ts @@ -51,15 +51,7 @@ export class CustomFieldsComponent private readonly documentService = inject(DocumentService) private readonly savedViewService = inject(SavedViewService) - private fieldsSignal = signal([]) - - public get fields(): CustomField[] { - return this.fieldsSignal() - } - - public set fields(fields: CustomField[]) { - this.fieldsSignal.set(fields) - } + readonly fields = signal([]) ngOnInit() { this.reload() @@ -72,7 +64,7 @@ export class CustomFieldsComponent .pipe( takeUntil(this.unsubscribeNotifier), tap((r) => { - this.fields = r.results + this.fields.set(r.results) }) ) .subscribe(() => { diff --git a/src-ui/src/app/components/manage/workflows/workflows.component.html b/src-ui/src/app/components/manage/workflows/workflows.component.html index 1c03d871b..fdbcf4249 100644 --- a/src-ui/src/app/components/manage/workflows/workflows.component.html +++ b/src-ui/src/app/components/manage/workflows/workflows.component.html @@ -22,14 +22,14 @@
    - @if (loading && workflows.length === 0) { + @if (loading && workflows().length === 0) {
  • Loading...
  • } - @for (workflow of workflows; track workflow.id) { + @for (workflow of workflows(); track workflow.id) {
  • @@ -76,7 +76,7 @@
  • } - @if (!loading && workflows.length === 0) { + @if (!loading && workflows().length === 0) {
  • No workflows defined.
  • } diff --git a/src-ui/src/app/components/manage/workflows/workflows.component.ts b/src-ui/src/app/components/manage/workflows/workflows.component.ts index 5ede19c59..b1c7e7519 100644 --- a/src-ui/src/app/components/manage/workflows/workflows.component.ts +++ b/src-ui/src/app/components/manage/workflows/workflows.component.ts @@ -39,15 +39,7 @@ export class WorkflowsComponent private modalService = inject(NgbModal) private toastService = inject(ToastService) - private workflowsSignal = signal([]) - - public get workflows(): Workflow[] { - return this.workflowsSignal() - } - - public set workflows(workflows: Workflow[]) { - this.workflowsSignal.set(workflows) - } + readonly workflows = signal([]) ngOnInit() { this.reload() @@ -59,7 +51,7 @@ export class WorkflowsComponent .listAll() .pipe( takeUntil(this.unsubscribeNotifier), - tap((r) => (this.workflows = r.results)) + tap((r) => this.workflows.set(r.results)) ) .subscribe(() => { this.show = true