From: Mike Risher Date: Fri, 9 Oct 2020 20:30:01 +0000 (+0000) Subject: Merge branch 'master' into user/mrisher/lp1857911-stat-cat-v3 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bfb7f58a44dbfc631a052700dbd97b83721e4dd8;p=working%2FEvergreen.git Merge branch 'master' into user/mrisher/lp1857911-stat-cat-v3 --- bfb7f58a44dbfc631a052700dbd97b83721e4dd8 diff --cc Open-ILS/examples/fm_IDL.xml index fd7d259d5a,a312c105ef..cb5df569db --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@@ -1476,62 -1476,62 +1476,6 @@@ Foundation, Inc., 51 Franklin Street, F -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- @@@ -2811,7 -2811,7 +2755,7 @@@ -- ++ @@@ -2821,11 -2821,11 +2765,6 @@@ -- -- -- -- -- @@@ -2833,7 -2833,7 +2772,6 @@@ -- @@@ -3111,162 -3111,162 +3049,6 @@@ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- @@@ -3910,7 -3910,7 +3692,6 @@@ -- @@@ -4603,7 -4603,7 +4384,6 @@@ -- @@@ -4853,26 -4853,26 +4633,6 @@@ SELECT usr -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- @@@ -5431,10 -5431,10 +5191,10 @@@ -- -- -- -- ++ ++ ++ ++ @@@ -5451,18 -5451,18 +5211,10 @@@ -- -- -- -- -- -- -- -- -- -- -- -- ++ ++ ++ ++ @@@ -6603,7 -6603,7 +6355,6 @@@ -- @@@ -6769,7 -6769,7 +6520,6 @@@ -- @@@ -6841,7 -6841,7 +6591,6 @@@ -- @@@ -7506,22 -7503,8 +7252,22 @@@ + - ++ + + + + + + + + + + + + - + @@@ -7533,20 -7516,6 +7279,20 @@@ + - ++ + + + + + + + + + + + + @@@ -8587,16 -8556,7 +8333,10 @@@ - - - ++ - - - - - - ++ ++ @@@ -9076,10 -9036,10 +8816,10 @@@ -- -- -- -- ++ ++ ++ ++ @@@ -9092,25 -9052,25 +8832,15 @@@ -- -- -- -- -- -- -- -- -- ++ ++ -- -- -- @@@ -9275,14 -9235,14 +9005,14 @@@ -- -- ++ ++ -- -- -- ++ ++ ++ @@@ -9311,15 -9271,15 +9041,13 @@@ -- -- ++ ++ -- -- @@@ -9342,15 -9302,15 +9070,15 @@@ -- -- ++ ++ -- -- -- ++ ++ ++ -- ++ @@@ -9930,7 -9890,7 +9658,7 @@@ -- ++ @@@ -9947,7 -9907,7 +9675,6 @@@ -- @@@ -9982,7 -9942,7 +9709,7 @@@ -- ++ @@@ -10088,7 -10048,7 +9815,7 @@@ -- ++ @@@ -10104,7 -10064,7 +9831,6 @@@ -- @@@ -10150,7 -10110,7 +9876,7 @@@ -- ++ @@@ -10329,10 -10289,10 +10055,10 @@@ -- -- -- -- ++ ++ ++ ++ @@@ -10361,9 -10321,9 +10087,9 @@@ -- -- -- ++ ++ ++ @@@ -10399,20 -10359,20 +10125,20 @@@ -- -- ++ ++ -- ++ -- ++ -- ++ @@@ -12179,33 -12139,33 +11905,6 @@@ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + import('./stat_cat/stat_cat.module').then(m => m.StatCatModule) +}, { ++ path: 'asset/stat_cat_editor/:tab', ++ loadChildren: () => ++ import('./stat_cat/stat_cat.module').then(m => m.StatCatModule) + }, { path: 'container/carousel', component: AdminCarouselComponent }, { diff --cc Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.component.ts index 2cf15f8e7d,0000000000..037497df07 mode 100644,000000..100644 --- 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 @@@ -1,320 -1,0 +1,330 @@@ +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'; - import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; + +@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('confirmDialog') private confirmDialog: ConfirmDialogComponent; - + @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 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(); + }); - + this.setCurrentPerms(); - this.getOrgFamilyAndData('copy'); - this.copyGrid.reload(); ++ ++ 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: NgbTabChangeEvent) { ++ onTabChange(event: any) { + this.currentTab = event.nextId; - if (this.currentTab === "patron") { ++ if (this.currentTab === "'patron'") { ++ this.routeToTab('patron'); + this.orgOnChange(this.selectedPatronOrg, 'patron'); + } else { ++ this.routeToTab('copy'); + this.orgOnChange(this.selectedCopyOrg, 'copy'); + } + } + ++ routeToTab(tab: any) { ++ 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) => { + let promises: any[] = []; + idlThings.forEach(idlThing => { // check one at a time to see if it's used + const id = idlThing.id(); + let 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); + }); + let 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 --cc Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.html index 9cb59993aa,0000000000..5564751b00 mode 100644,000000..100644 --- 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 @@@ -1,50 -1,0 +1,57 @@@ + + + + + + + + + ++
++ ++
++ ++ +
+ + + + + +
+
+ + + + + +
+ + + + + + + + + diff --cc Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_entries.component.ts index d08b7c1998,0000000000..19a0f15d51 mode 100644,000000..100644 --- 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 @@@ -1,227 -1,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 --cc Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat_routing.module.ts index f2d205da56,0000000000..5c7dd25f21 mode 100644,000000..100644 --- 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 @@@ -1,22 -1,0 +1,25 @@@ +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: ':tab', ++ component: StatCatComponent ++}, { + path: 'copy_entries/:id', + component: StatCatEntriesComponent +}, { + path: 'patron_entries/:id', + component: StatCatEntriesComponent +}]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) + +export class StatCatRoutingModule {}