From: Jason Stephenson Date: Tue, 19 Jul 2022 18:18:29 +0000 (-0400) Subject: Revert "LP#1945385: use eg-admin-page for circ limit sets admin UI" X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=484e6a5d65274bb572b28974d436e3c5e3620ebc;p=Evergreen.git Revert "LP#1945385: use eg-admin-page for circ limit sets admin UI" This reverts commit 5380bfb11a3a38bac521ce8ef92216c13d46f3b9. The reverted code raises the following error in 3.7: ERROR in src/app/staff/admin/local/circ_limit_set/circ_limit_set.component.html:4:32 - error NG8002: Can't bind to 'templateFields' since it isn't a known property of 'eg-admin-page'. Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.component.html index 44fc39beca..58340e758b 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.component.html @@ -1,14 +1,26 @@ - + + + + + + - -
- - Manage - -
-
+ + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.component.ts index ce28023b6e..f38a9dfbc2 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.component.ts @@ -1,7 +1,123 @@ -import {Component} from '@angular/core'; +import {Pager} from '@eg/share/util/pager'; +import {Component, OnInit, Input, ViewChild} from '@angular/core'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {GridDataSource} from '@eg/share/grid/grid'; +import {Router} from '@angular/router'; +import {IdlObject} from '@eg/core/idl.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component'; +import {StringComponent} from '@eg/share/string/string.component'; +import {ToastService} from '@eg/share/toast/toast.service'; @Component({ templateUrl: './circ_limit_set.component.html' }) -export class CircLimitSetComponent { } +export class CircLimitSetComponent implements OnInit { + + recId: number; + gridDataSource: GridDataSource; + initDone = false; + cspSource: GridDataSource = new GridDataSource(); + + @ViewChild('editDialog', {static: true}) editDialog: FmRecordEditorComponent; + @ViewChild('grid', {static: true}) grid: GridComponent; + @ViewChild('updateSuccessString', {static: true}) updateSuccessString: StringComponent; + @ViewChild('updateFailedString', {static: true}) updateFailedString: StringComponent; + @ViewChild('deleteFailedString', {static: true}) deleteFailedString: StringComponent; + @ViewChild('deleteSuccessString', {static: true}) deleteSuccessString: StringComponent; + @ViewChild('createSuccessString', {static: true}) createSuccessString: StringComponent; + @ViewChild('createErrString', {static: true}) createErrString: StringComponent; + + @Input() dialogSize: 'sm' | 'lg' = 'lg'; + + constructor( + private pcrud: PcrudService, + private toast: ToastService, + private router: Router + ) { + this.gridDataSource = new GridDataSource(); + } + + ngOnInit() { + this.gridDataSource.getRows = (pager: Pager, sort: any[]) => { + const orderBy: any = {}; + const searchOps = { + offset: pager.offset, + limit: pager.limit, + order_by: orderBy + }; + return this.pcrud.retrieveAll('ccls', searchOps, {fleshSelectors: true}); + }; + + this.grid.onRowActivate.subscribe( + (set: IdlObject) => { + const idToEdit = set.id(); + this.navigateToEditPage(idToEdit); + } + ); + } + + deleteSelected = (idlThings: IdlObject[]) => { + idlThings.forEach(idlThing => idlThing.isdeleted(true)); + this.pcrud.autoApply(idlThings).subscribe( + val => { + this.deleteSuccessString.current() + .then(str => this.toast.success(str)); + }, + err => { + this.deleteFailedString.current() + .then(str => this.toast.danger(str)); + }, + () => this.grid.reload() + ); + } + + editSelected(sets: IdlObject[]) { + const idToEdit = sets[0].id(); + this.navigateToEditPage(idToEdit); + } + + navigateToEditPage(id: any) { + this.router.navigate(['/staff/admin/local/config/circ_limit_set/' + id]); + } + + createNew() { + this.editDialog.mode = 'create'; + this.editDialog.recordId = null; + this.editDialog.record = null; + this.editDialog.open({size: this.dialogSize}).subscribe( + ok => { + this.createSuccessString.current() + .then(str => this.toast.success(str)); + this.grid.reload(); + }, + rejection => { + if (!rejection.dismissed) { + this.createErrString.current() + .then(str => this.toast.danger(str)); + } + } + ); + } + + showEditDialog(standingPenalty: IdlObject): Promise { + this.editDialog.mode = 'update'; + this.editDialog.recordId = standingPenalty['id'](); + return new Promise((resolve, reject) => { + this.editDialog.open({size: this.dialogSize}).subscribe( + result => { + this.updateSuccessString.current() + .then(str => this.toast.success(str)); + this.grid.reload(); + resolve(result); + }, + error => { + this.updateFailedString.current() + .then(str => this.toast.danger(str)); + reject(error); + } + ); + }); + } +} diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.module.ts index 814969165d..e7cf75a9f1 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.module.ts @@ -4,7 +4,6 @@ import {CircLimitSetComponent} from './circ_limit_set.component'; import {CircLimitSetEditComponent} from './circ_limit_set_edit.component'; import {CircLimitSetRoutingModule} from './circ_limit_set_routing.module'; import {ItemLocationSelectModule} from '@eg/share/item-location-select/item-location-select.module'; -import {AdminPageModule} from '@eg/staff/share/admin-page/admin-page.module'; @NgModule({ declarations: [ @@ -13,7 +12,6 @@ import {AdminPageModule} from '@eg/staff/share/admin-page/admin-page.module'; ], imports: [ AdminCommonModule, - AdminPageModule, CircLimitSetRoutingModule, ItemLocationSelectModule, ], diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set_edit.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set_edit.component.ts index be81a1c3ee..a8dd48e2ae 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set_edit.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set_edit.component.ts @@ -25,7 +25,7 @@ export class CircLimitSetEditComponent implements OnInit { selectedLimitGroup: any; locId = 0; - circTab: 'limitSet' | 'linked' = 'linked'; + circTab: 'limitSet' | 'linked' = 'limitSet'; @ViewChild('addingSuccess', {static: true}) addingSuccess: StringComponent; @ViewChild('removingSuccess', {static: true}) removingSuccess: StringComponent;