From 3ff34b0c4d93b3ca27b5f8380accfec48c72d3ed Mon Sep 17 00:00:00 2001 From: Mike Risher Date: Tue, 31 Dec 2019 19:51:37 +0000 Subject: [PATCH] lp1857911 Statistical Categories UI port This UI allows editing copy statistical categories (stat cats), patron statistical categories, and their entries. They are filtered by location. This port opens a new page when editing deleting or adding entries. Signed-off-by: Mike Risher Signed-off-by: Jason Etheridge --- Open-ILS/examples/fm_IDL.xml | 44 ++- .../admin/local/admin-local-splash.component.html | 2 +- .../src/app/staff/admin/local/routing.module.ts | 8 + .../admin/local/stat_cat/stat_cat.component.html | 86 ++++++ .../admin/local/stat_cat/stat_cat.component.ts | 326 +++++++++++++++++++++ .../staff/admin/local/stat_cat/stat_cat.module.ts | 20 ++ .../local/stat_cat/stat_cat_entries.component.html | 56 ++++ .../local/stat_cat/stat_cat_entries.component.ts | 235 +++++++++++++++ .../local/stat_cat/stat_cat_routing.module.ts | 22 ++ 9 files changed, 796 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.component.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.module.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_routing.module.ts diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index a4fb45b078..250fbcc010 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -7406,7 +7406,10 @@ SELECT usr, + + + @@ -7738,7 +7741,7 @@ SELECT usr, - + @@ -7751,8 +7754,22 @@ SELECT usr, + + + + + + + + + + + + + + - + @@ -7764,6 +7781,20 @@ SELECT usr, + + + + + + + + + + + + + + @@ -8872,7 +8903,16 @@ SELECT usr, + + + + + + + + + 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 92d22f03e4..37e337730e 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 @@ -71,7 +71,7 @@ + routerLink="/staff/admin/local/asset/stat_cat_editor"> + import('./stat_cat/stat_cat.module').then(m => m.StatCatModule) +}, { path: 'asset/copy_location_order', loadChildren: () => import('./copy-loc-order/copy-loc-order.module').then(m => m.CopyLocOrderModule) @@ -34,6 +38,10 @@ const routes: Routes = [{ loadChildren: () => import('./shelving_location_groups/shelving_location_groups.module').then(m => m.ShelvingLocationGroupsModule) }, { + path: 'asset/stat_cat_editor/:tab', + loadChildren: () => + import('./stat_cat/stat_cat.module').then(m => m.StatCatModule) +}, { path: 'container/carousel', component: AdminCarouselComponent }, { diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.component.html new file mode 100644 index 0000000000..1c870900ec --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.component.html @@ -0,0 +1,86 @@ + +
+
+ + + + +
+
Focus location
+ +
+ + + + + + + Edit Entries + + + + +
+
+ + + +
+
Focus location
+ +
+ + + + + + + Edit Entries + + + + +
+
+
+
+
+ + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.component.ts new file mode 100644 index 0000000000..ad62347501 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.component.ts @@ -0,0 +1,326 @@ +import {Pager} from '@eg/share/util/pager'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {GridDataSource} from '@eg/share/grid/grid'; +import {Router, ActivatedRoute, ParamMap} from '@angular/router'; +import {IdlObject, IdlService} 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'; +import {Component, OnInit, ViewChild} from '@angular/core'; +import {NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap'; +import {OrgService} from '@eg/core/org.service'; +import {PermService} from '@eg/core/perm.service'; +import {AuthService} from '@eg/core/auth.service'; + +@Component({ + templateUrl: './stat_cat.component.html' +}) + +export class StatCatComponent implements OnInit { + + currentTab: String; + ascDataSource: GridDataSource = new GridDataSource(); + actscDataSource: GridDataSource = new GridDataSource(); + selectedCopyOrg: IdlObject = this.org.get(this.auth.user().ws_ou()); + selectedPatronOrg: IdlObject = this.org.get(this.auth.user().ws_ou()); + selectedCopyOrgId: number = this.org.get(this.auth.user().ws_ou()).id(); + selectedPatronOrgId: number = this.org.get(this.auth.user().ws_ou()).id(); + + // list of orgs to retrieve stat cats for + copyOrgFamily: any; + patronOrgFamily: any; + + // object which has all permissions data for current user + userPerms: any = {}; + + // orgs that the user doesn't have permission to view. + hiddenCopyOrgs: any[]; + hiddenPatronOrgs: any[]; + + newActsc: IdlObject; + newAsc: IdlObject; + + @ViewChild('copyGrid') copyGrid: GridComponent; + @ViewChild('patronGrid') patronGrid: GridComponent; + @ViewChild('copyDialog') copyDialog: FmRecordEditorComponent; + @ViewChild('patronDialog') patronDialog: FmRecordEditorComponent; + @ViewChild('updateSuccessString') updateSuccessString: StringComponent; + @ViewChild('updateFailedString') updateFailedString: StringComponent; + @ViewChild('deleteFailedString') deleteFailedString: StringComponent; + @ViewChild('deleteSuccessString') deleteSuccessString: StringComponent; + @ViewChild('createSuccessString') createSuccessString: StringComponent; + @ViewChild('createErrString') createErrString: StringComponent; + + constructor( + private pcrud: PcrudService, + private router: Router, + private route: ActivatedRoute, + private org: OrgService, + private idl: IdlService, + private toast: ToastService, + private perm: PermService, + private auth: AuthService, + ) { + } + + ngOnInit() { + this.newActsc = this.idl.create('actsc'); + this.newAsc = this.idl.create('asc'); + this.perm.hasWorkPermAt(['CREATE_COPY_STAT_CAT', 'CREATE_PATRON_STAT_CAT', + 'UPDATE_PATRON_STAT_CAT', 'UPDATE_COPY_STAT_CAT', 'DELETE_COPY_STAT_CAT', + 'DELETE_PATRON_STAT_CAT'], true) + .then(userPerms => { + this.userPerms = userPerms; + const allOrgs = this.org.list(); + + // View permission is the same as permission to update, + // which is how it was handled in the old UI. + this.hiddenCopyOrgs = allOrgs.filter(x => { + return !this.userPerms.UPDATE_COPY_STAT_CAT.includes(x.id()); + }).map(x => { + return x.id(); + }); + this.hiddenPatronOrgs = allOrgs.filter(x => { + return !this.userPerms.UPDATE_PATRON_STAT_CAT.includes(x.id()); + }).map(x => { + return x.id(); + }); + + if (this.route.snapshot.paramMap.get('tab') === 'patron') { + this.onTabChange({nextId: '\'patron\''}); + } else { // if null or 'copy' + this.onTabChange({nextId: '\'copy\''}); + } + }); + } + + disableCopyOrgs = () => this.org.filterList( { inList: this.hiddenCopyOrgs }, true); + + disablePatronOrgs = () => this.org.filterList( { inList: this.hiddenCopyOrgs }, true); + + setCurrentPerms() { + this.userPerms.canEditCopy = + this.userPerms.UPDATE_COPY_STAT_CAT.indexOf(this.selectedCopyOrgId) !== -1; + this.userPerms.canEditPatron = + this.userPerms.UPDATE_PATRON_STAT_CAT.indexOf(this.selectedPatronOrgId) !== -1; + this.userPerms.canCreateCopy = + this.userPerms.CREATE_COPY_STAT_CAT.indexOf(this.selectedCopyOrgId) !== -1; + this.userPerms.canCreatePatron = + this.userPerms.CREATE_PATRON_STAT_CAT.indexOf(this.selectedPatronOrgId) !== -1; + this.userPerms.canDeleteCopy = + this.userPerms.DELETE_COPY_STAT_CAT.indexOf(this.selectedCopyOrgId) !== -1; + this.userPerms.canDeletePatron = + this.userPerms.DELETE_PATRON_STAT_CAT.indexOf(this.selectedPatronOrgId) !== -1; + } + + onTabChange(event: any) { + this.currentTab = event.nextId; + if (this.currentTab === '\'patron\'') { + this.routeToTab('patron'); + this.orgOnChange(this.selectedPatronOrg, 'patron'); + } else { + this.routeToTab('copy'); + this.orgOnChange(this.selectedCopyOrg, 'copy'); + } + } + + routeToTab(tab) { + const url = `/staff/admin/local/asset/stat_cat_editor/${tab}`; + this.router.navigate([url]); + } + + orgOnChange = (org: IdlObject, type): void => { + this.setCurrentPerms(); + if (type === 'copy') { + this.selectedCopyOrg = org; + this.selectedCopyOrgId = org.id(); + this.getOrgFamilyAndData('copy'); + if (this.copyGrid) { + this.copyGrid.reload(); + } + } else { + this.selectedPatronOrg = org; + this.selectedPatronOrgId = org.id(); + this.getOrgFamilyAndData('patron'); + if (this.patronGrid) { + this.patronGrid.reload(); + } + } + } + + getOrgFamilyAndData(type) { + if (type === 'copy') { + this.copyOrgFamily = this.org.fullPath(this.selectedCopyOrgId) + .map(record => { + return record.id(); + }); + this.getAscData(); + } else { + this.patronOrgFamily = this.org.fullPath(this.selectedPatronOrgId) + .map(record => { + return record.id(); + }); + this.getActscData(); + } + } + + getAscData() { + this.ascDataSource.getRows = (pager: Pager, sort: any[]) => { + const orderBy = {asc: 'id'}; + return this.pcrud.search('asc', {owner: this.copyOrgFamily}, orderBy); + }; + } + + getActscData() { + this.actscDataSource.getRows = (pager: Pager, sort: any[]) => { + const orderBy = {actsc: 'id'}; + return this.pcrud.search('actsc', {owner: this.patronOrgFamily}, orderBy); + }; + } + + editStatCat = (idlThing) => { + const idlString = idlThing[0].classname; + + // automatically fail if no permissions + if ((!this.userPerms.canEditCopy && idlString === 'asc') || + (!this.userPerms.canEditPatron && idlString === 'actsc')) { + this.updateFailedString.current() + .then(str => this.toast.danger(str)); + return; + } + + const lookupResponse = this.lookUpType(idlString); + const currentGrid = lookupResponse.currentGrid; + const currentDialog = lookupResponse.currentDialog; + currentDialog.mode = 'update'; + currentDialog.recordId = idlThing[0].id(); + currentDialog.open({size: 'lg'}).subscribe( + id => { + console.debug('Record editor performed action'); + currentGrid.reload(); + }, + err => { + console.debug(err); + }, + () => console.debug('Dialog closed') + ); + } + + deleteStatCat = (idlThings: IdlObject[]) => { + const idlString = idlThings[0].classname; + + // automatically fail if no permissions + if ((!this.userPerms.canDeleteCopy && idlString === 'asc') || + (!this.userPerms.canDeletePatron && idlString === 'actsc')) { + this.deleteFailedString.current() + .then(str => this.toast.danger(str)); + return; + } + + // check to see if copy stat cat is in use + if (idlString === 'asc') { + this.checkThenDelete(idlThings, idlString); + } else { + this.doDelete(idlThings, idlString); + } + } + + checkThenDelete = (idlThings, idlString) => { + const promises: any[] = []; + idlThings.forEach(idlThing => { // check one at a time to see if it's used + const id = idlThing.id(); + const promise: any = new Promise((resolve, reject) => { + this.pcrud.search('ascecm', {stat_cat: id}, {limit: 1}) + .toPromise().then( + rec => { + if (rec) { + this.deleteFailedString.current() + .then(str => this.toast.danger(str)); + resolve(false); + } else { + resolve(true); + } + }); + }); + promises.push(promise); + }); + const result = Promise.all(promises); + result.then(responses => { + if (!responses.includes(false)) { // only delete if none in use + this.doDelete(idlThings, idlString); + } + }); + } + + doDelete = (idlThings: IdlObject[], idlString) => { + idlThings.forEach(idlThing => { + idlThing.isdeleted(true); + }); + const currentGrid = this.lookUpType(idlString).currentGrid; + this.pcrud.autoApply(idlThings).subscribe( + val => { + console.debug('deleted: ' + val); + this.deleteSuccessString.current() + .then(str => this.toast.success(str)); + }, + err => { + this.deleteFailedString.current() + .then(str => this.toast.danger(str)); + }, + () => { + currentGrid.reload(); + } + ); + } + + lookUpType = (idlString) => { + let currentDialog; + let currentGrid; + if (idlString === 'asc') { + currentGrid = this.copyGrid; + currentDialog = this.copyDialog; + } else { + currentGrid = this.patronGrid; + currentDialog = this.patronDialog; + } + return { + currentDialog: currentDialog, + currentGrid: currentGrid + }; + } + + newStatCat = (type: any) => { + let currentDialog; + let currentGrid; + let newIdlObject; + if (this.currentTab === '\'patron\'') { + currentGrid = this.patronGrid; + currentDialog = this.patronDialog; + newIdlObject = this.idl.clone(this.newActsc); + newIdlObject.owner(this.selectedPatronOrg); + } else { + currentGrid = this.copyGrid; + currentDialog = this.copyDialog; + newIdlObject = this.idl.clone(this.newAsc); + newIdlObject.owner(this.selectedCopyOrg); + } + currentDialog.mode = 'create'; + currentDialog.recordId = null; + currentDialog.record = newIdlObject; + currentDialog.open({size: 'lg'}).subscribe( + ok => { + this.createSuccessString.current() + .then(str => this.toast.success(str)); + currentGrid.reload(); + }, + rejection => { + if (!rejection.dismissed) { + this.createErrString.current() + .then(str => this.toast.danger(str)); + } + } + ); + } + +} diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.module.ts new file mode 100644 index 0000000000..6be786b5a1 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.module.ts @@ -0,0 +1,20 @@ +import {NgModule} from '@angular/core'; +import {AdminCommonModule} from '@eg/staff/admin/common.module'; +import {StatCatComponent} from './stat_cat.component'; +import {StatCatEntriesComponent} from './stat_cat_entries.component'; +import {StatCatRoutingModule} from './stat_cat_routing.module'; + +@NgModule({ + declarations: [ + StatCatComponent, + StatCatEntriesComponent, + ], + imports: [ + AdminCommonModule, + StatCatRoutingModule, + ], + exports: [], + providers: [] +}) + +export class StatCatModule {} diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.html new file mode 100644 index 0000000000..431f8efa82 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.html @@ -0,0 +1,56 @@ + + + + + + + + + +
+ +
+ +
+ + + + + +
+
+ + + + + +
+ + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.ts new file mode 100644 index 0000000000..19a0f15d51 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.ts @@ -0,0 +1,235 @@ +import {Pager} from '@eg/share/util/pager'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {GridDataSource} from '@eg/share/grid/grid'; +import {IdlService, IdlObject} from '@eg/core/idl.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {OrgService} from '@eg/core/org.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'; +import {Component, OnInit, ViewChild} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; +import {Router} from '@angular/router'; +import {PermService} from '@eg/core/perm.service'; + +@Component({ + templateUrl: './stat_cat_entries.component.html' +}) + +export class StatCatEntriesComponent implements OnInit { + + statCatId: number; // parent stat cat id + statCatOrgId: number; // parent stat cat org id + statCatOrg: IdlObject; // parent stat cat org Idl + hiddenOrgs: any[]; // List of invalid orgs for a new entry + statCatType: 'Copy' | 'Patron'; // parent type + defaultNewRecord: IdlObject; + copyDataSource: GridDataSource = new GridDataSource(); + patronDataSource: GridDataSource = new GridDataSource(); + userPerms: any = {}; + + @ViewChild('copyGrid', {static: false}) copyGrid: GridComponent; + @ViewChild('patronGrid', {static: false}) patronGrid: GridComponent; + @ViewChild('copyDialog', {static: false}) copyDialog: FmRecordEditorComponent; + @ViewChild('patronDialog', {static: false}) patronDialog: FmRecordEditorComponent; + @ViewChild('updateSuccessString', {static: false}) updateSuccessString: StringComponent; + @ViewChild('updateFailedString', {static: false}) updateFailedString: StringComponent; + @ViewChild('deleteFailedString', {static: false}) deleteFailedString: StringComponent; + @ViewChild('deleteSuccessString', {static: false}) deleteSuccessString: StringComponent; + @ViewChild('createSuccessString', {static: false}) createSuccessString: StringComponent; + @ViewChild('createErrString', {static: false}) createErrString: StringComponent; + + constructor( + private router: Router, + private idl: IdlService, + private pcrud: PcrudService, + private route: ActivatedRoute, + private toast: ToastService, + private perm: PermService, + private org: OrgService + ) { + } + + ngOnInit() { + this.statCatId = parseInt(this.route.snapshot.paramMap.get('id'), 10); + if (this.router.url.includes('copy_entries')) { + this.statCatType = 'Copy'; + this.copyDataSource.getRows = (pager: Pager, sort: any[]) => { + const orderBy: any = {order_by: {asce: 'id'}}; + return this.pcrud.search('asce', {stat_cat: this.statCatId}, orderBy); + }; + this.getParentData('asc'); + } else if (this.router.url.includes('patron_entries')) { + this.statCatType = 'Patron'; + this.patronDataSource.getRows = (pager: Pager, sort: any[]) => { + const orderBy: any = {order_by: {actsce: 'id'}}; + return this.pcrud.search('actsce', {stat_cat: this.statCatId}, orderBy); + }; + this.getParentData('actsc'); + } else { + console.debug('Error - unable to determine type of stat cat'); + } + } + + back = () => { + let tab = 'copy'; + if (this.statCatType === 'Patron') { + tab = 'patron'; + } + this.router.navigate(['/staff/admin/local/asset/stat_cat_editor/' + tab]); + } + + checkPerms = () => { + this.perm.hasWorkPermAt(['CREATE_COPY_STAT_CAT_ENTRY', + 'CREATE_PATRON_STAT_CAT_ENTRY', 'DELETE_COPY_STAT_CAT_ENTRY', + 'DELETE_PATRON_STAT_CAT_ENTRY', 'UPDATE_COPY_STAT_CAT_ENTRY', + 'UPDATE_PATRON_STAT_CAT_ENTRY'], true) + .then(userPerms => { + this.userPerms = userPerms; + if (this.statCatType === 'Copy') { + this.userPerms.canEdit = + this.userPerms.UPDATE_COPY_STAT_CAT_ENTRY.indexOf(this.statCatOrg) !== -1; + this.userPerms.canCreate = + this.userPerms.CREATE_COPY_STAT_CAT_ENTRY.indexOf(this.statCatOrg) !== -1; + this.userPerms.canDelete = + this.userPerms.DELETE_COPY_STAT_CAT_ENTRY.indexOf(this.statCatOrg) !== -1; + } else { + this.userPerms.canEdit = + this.userPerms.UPDATE_PATRON_STAT_CAT_ENTRY.indexOf(this.statCatOrg) !== -1; + this.userPerms.canCreate = + this.userPerms.CREATE_PATRON_STAT_CAT_ENTRY.indexOf(this.statCatOrg) !== -1; + this.userPerms.canDelete = + this.userPerms.DELETE_PATRON_STAT_CAT_ENTRY.indexOf(this.statCatOrg) !== -1; + } + }); + } + + getParentData = (searchIdl) => { + return this.pcrud.search(searchIdl, {id: this.statCatId}, {} + ).subscribe(rec => { + this.statCatOrg = rec.owner(); + this.statCatOrgId = rec.owner(); + this.checkPerms(); + const allOrgIds = this.org.list().map(x => x.id()); + const statCatDescendantIds = this.org.descendants(rec.owner(), true); + this.hiddenOrgs = allOrgIds.filter(org => { + return !statCatDescendantIds.includes(org); + }); + return rec; + }); + } + + setOwner(e): void { + this.defaultNewRecord.owner(e); + } + + lookupType() { + let currentDialog; + let currentGrid; + let newIdl; + if (this.statCatType === 'Copy') { + currentGrid = this.copyGrid; + currentDialog = this.copyDialog; + newIdl = 'asce'; + } else { + currentGrid = this.patronGrid; + currentDialog = this.patronDialog; + newIdl = 'actsce'; + } + return { + currentGrid: currentGrid, + currentDialog: currentDialog, + newIdl: newIdl + }; + } + + createNewEntry = () => { + // automatically fail if no permissions + if (!this.userPerms.canCreate) { + this.createErrString.current() + .then(str => this.toast.danger(str)); + return; + } + + const lookupResponse = this.lookupType(); + const currentDialog = lookupResponse.currentDialog; + const currentGrid = lookupResponse.currentGrid; + this.defaultNewRecord = this.idl.create(lookupResponse.newIdl); + + // pre-populate new record with the current stat_cat and org + this.defaultNewRecord.owner(this.statCatOrg); + this.defaultNewRecord.stat_cat(this.statCatId); + currentDialog.mode = 'create'; + currentDialog.recordId = null; + currentDialog.record = this.defaultNewRecord; + currentDialog.open({size: 'lg'}).subscribe( + ok => { + this.createSuccessString.current() + .then(str => this.toast.success(str)); + currentGrid.reload(); + }, + rejection => { + if (!rejection.dismissed) { + this.createErrString.current() + .then(str => this.toast.danger(str)); + } + } + ); + } + + editEntry = (idlThing) => { + // automatically fail if no permissions + if (!this.userPerms.canEdit) { + this.updateFailedString.current() + .then(str => this.toast.danger(str)); + return; + } + + const lookupResponse = this.lookupType(); + const currentDialog = lookupResponse.currentDialog; + const currentGrid = lookupResponse.currentGrid; + currentDialog.mode = 'update'; + currentDialog.recordId = idlThing[0].id(); + currentDialog.open({size: 'lg'}).subscribe( + id => { + this.updateSuccessString.current() + .then(str => this.toast.success(str)); + console.debug('Record editor performed action'); + currentGrid.reload(); + }, + err => { + console.debug(err); + this.updateFailedString.current() + .then(str => this.toast.danger(str)); + }, + () => console.debug('Dialog closed') + ); + } + + deleteEntry = (idlThings: IdlObject[]) => { + // automatically fail if no permissions + if (!this.userPerms.canDelete) { + this.deleteFailedString.current() + .then(str => this.toast.danger(str)); + return; + } + + const currentGrid = this.lookupType().currentGrid; + idlThings.forEach(idlThing => idlThing.isdeleted(true)); + this.pcrud.autoApply(idlThings).subscribe( + val => { + console.debug('deleted: ' + val); + this.deleteSuccessString.current() + .then(str => this.toast.success(str)); + }, + err => { + this.deleteFailedString.current() + .then(str => this.toast.danger(str)); + }, + () => { + currentGrid.reload(); + } + ); + } + +} diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_routing.module.ts new file mode 100644 index 0000000000..f2d205da56 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_routing.module.ts @@ -0,0 +1,22 @@ +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from '@angular/router'; +import {StatCatComponent} from './stat_cat.component'; +import {StatCatEntriesComponent} from './stat_cat_entries.component'; + +const routes: Routes = [{ + path: '', + component: StatCatComponent +}, { + path: 'copy_entries/:id', + component: StatCatEntriesComponent +}, { + path: 'patron_entries/:id', + component: StatCatEntriesComponent +}]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) + +export class StatCatRoutingModule {} -- 2.11.0