From af09f4229acfe521cf68ab9843695509810cd5f7 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 12 Jul 2022 13:08:50 -0400 Subject: [PATCH] LP1981739 Patrons Negative Balances Angular Port Port Admin => Local Admin => Patrons With Negative Balances to Angular. Adds paging support to the API. Adds support for display patrons whose home lib is a descendant of the selected org unit. Signed-off-by: Bill Erickson Signed-off-by: Garry Collum Signed-off-by: Jane Sandberg --- .../admin/local/admin-local-splash.component.html | 2 +- .../local/negative-balances/list.component.html | 40 ++++++++++++ .../local/negative-balances/list.component.ts | 75 ++++++++++++++++++++++ .../negative-balances/negative-balances.module.ts | 23 +++++++ .../local/negative-balances/routing.module.ts | 15 +++++ .../src/app/staff/admin/local/routing.module.ts | 4 ++ .../src/perlmods/lib/OpenILS/Application/Actor.pm | 13 +++- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 15 +++++ .../Pg/upgrade/XXXX.data.negative-balance-grid.sql | 23 +++++++ 9 files changed, 207 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/negative-balances/list.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/negative-balances/list.component.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/negative-balances/negative-balances.module.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/negative-balances/routing.module.ts create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.negative-balance-grid.sql diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html index 7ea6416b20..29e42ef375 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html @@ -55,7 +55,7 @@ + routerLink="/staff/admin/local/negative-balances"> + + +
+
+ Patron Home Library: + + +
+
+ + + + {{user.card().barcode()}} + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/negative-balances/list.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/negative-balances/list.component.ts new file mode 100644 index 0000000000..4d8967502b --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/negative-balances/list.component.ts @@ -0,0 +1,75 @@ +import {Component, Input, ViewChild, OnInit} from '@angular/core'; +import {empty} from 'rxjs'; +import {map, tap, concatMap} from 'rxjs/operators'; +import {IdlService, IdlObject} from '@eg/core/idl.service'; +import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap'; +import {OrgService} from '@eg/core/org.service'; +import {AuthService} from '@eg/core/auth.service'; +import {NetService} from '@eg/core/net.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {ToastService} from '@eg/share/toast/toast.service'; +import {StringComponent} from '@eg/share/string/string.component'; +import {StringService} from '@eg/share/string/string.service'; +import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; +import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component'; +import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; +import {GridDataSource, GridColumn, GridRowFlairEntry, GridCellTextGenerator} from '@eg/share/grid/grid'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {Pager} from '@eg/share/util/pager'; + +@Component({ + templateUrl: './list.component.html' +}) +export class NegativeBalancesComponent implements OnInit { + + dataSource: GridDataSource = new GridDataSource(); + contextOrg: IdlObject; + contextOrgLoaded = false; + + @ViewChild('grid') private grid: GridComponent; + + constructor( + private idl: IdlService, + private org: OrgService, + private auth: AuthService, + private net: NetService, + private pcrud: PcrudService, + private strings: StringService, + private toast: ToastService + ) {} + + ngOnInit() { + this.contextOrg = this.org.get(this.auth.user().ws_ou()); + + this.dataSource.getRows = (pager: Pager, sort: any[]) => { + + if (!this.contextOrgLoaded) { + // Still determining the default context org unit. + return empty(); + } + + return this.net.request( + 'open-ils.actor', + 'open-ils.actor.users.negative_balance', + this.auth.token(), this.contextOrg.id(), + {limit: pager.limit, offset: pager.offset, org_descendants: true} + ).pipe(map(data => { + + const user = data.usr; + user._extras = { + balance_owed: data.balance_owed, + last_billing_activity: data.last_billing_activity, + }; + + return user; + })); + }; + } + + orgChnaged(org: IdlObject) { + if (org) { + this.contextOrg = org; + this.grid.reload(); + } + } +} diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/negative-balances/negative-balances.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/negative-balances/negative-balances.module.ts new file mode 100644 index 0000000000..7a551392eb --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/negative-balances/negative-balances.module.ts @@ -0,0 +1,23 @@ +import {NgModule} from '@angular/core'; +import {AdminCommonModule} from '@eg/staff/admin/common.module'; +import {NegativeBalancesRoutingModule} from './routing.module'; +import {NegativeBalancesComponent} from './list.component'; + +@NgModule({ + declarations: [ + NegativeBalancesComponent + ], + imports: [ + AdminCommonModule, + NegativeBalancesRoutingModule + ], + exports: [ + ], + providers: [ + ] +}) + +export class NegativeBalancesModule { +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/negative-balances/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/negative-balances/routing.module.ts new file mode 100644 index 0000000000..097184a67f --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/negative-balances/routing.module.ts @@ -0,0 +1,15 @@ +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from '@angular/router'; +import {NegativeBalancesComponent} from './list.component'; + +const routes: Routes = [{ + path: '', + component: NegativeBalancesComponent +}]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) + +export class NegativeBalancesRoutingModule {} diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts index a2fef17104..2376260fec 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts @@ -86,6 +86,10 @@ const routes: Routes = [{ loadChildren: () => import('./field-documentation/field-documentation.module') .then(m => m.FieldDocumentationModule) }, { + path: 'negative-balances', + loadChildren: () => + import('./negative-balances/negative-balances.module').then(m => m.NegativeBalancesModule) +}, { path: ':schema/:table', component: BasicAdminPageComponent }]; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index c0d9851f02..3adc2a3ebf 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -4182,7 +4182,11 @@ __PACKAGE__->register_method ( ); sub negative_balance_users { - my($self, $conn, $auth, $org_id) = @_; + my($self, $conn, $auth, $org_id, $options) = @_; + + $options ||= {}; + $options->{limit} = 1000 unless $options->{limit}; + $options->{offset} = 0 unless $options->{offset}; my $e = new_editor(authtoken => $auth); return $e->die_event unless $e->checkauth; @@ -4211,9 +4215,14 @@ sub negative_balance_users { } } }, - where => {'+mous' => {balance_owed => {'<' => 0}}} + where => {'+mous' => {balance_owed => {'<' => 0}}}, + offset => $options->{offset}, + limit => $options->{limit}, + order_by => [{class => 'mous', field => 'usr'}] }; + $org_id = $U->get_org_descendants($org_id) if $options->{org_descendants}; + $query->{from}->{mous}->{au}->{filter}->{home_ou} = $org_id if $org_id; my $list = $e->json_query($query, {timeout => 600}); diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index ae6cdd3784..de0629bcbb 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -22193,4 +22193,19 @@ VALUES ( 'Library Selector Show Combined Names', 'cwst', 'label' ) +), ( + 'eg.grid.admin.local.negative_balances', 'gui', 'object', + oils_i18n_gettext( + 'eg.grid.admin.local.negative_balances', + 'Patrons With Negative Balances Grid Settings', + 'cwst', 'label' + ) +), ( + 'eg.orgselect.admin.local.negative_balances', 'gui', 'integer', + oils_i18n_gettext( + 'eg.orgselect.admin.local.negative_balances', + 'Default org unit for patron negative balances interface', + 'cwst', 'label' + ) ); + diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.negative-balance-grid.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.negative-balance-grid.sql new file mode 100644 index 0000000000..a0407f55db --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.negative-balance-grid.sql @@ -0,0 +1,23 @@ + +BEGIN; + +-- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version); + +INSERT INTO config.workstation_setting_type (name, grp, datatype, label) +VALUES ( + 'eg.grid.admin.local.negative_balances', 'gui', 'object', + oils_i18n_gettext( + 'eg.grid.admin.local.negative_balances', + 'Patrons With Negative Balances Grid Settings', + 'cwst', 'label' + ) +), ( + 'eg.orgselect.admin.local.negative_balances', 'gui', 'integer', + oils_i18n_gettext( + 'eg.orgselect.admin.local.negative_balances', + 'Default org unit for patron negative balances interface', + 'cwst', 'label' + ) +); + +COMMIT; -- 2.11.0