From 4641ab15b819556f901db02c561d2cba75550068 Mon Sep 17 00:00:00 2001 From: Rogan Hamby Date: Thu, 5 Aug 2021 18:01:48 +0000 Subject: [PATCH] LP#1929242: add interface for editing bib record notes This adds an Angular interface for editing bibliographic record notes, i.e., notes stored in the biblio.record_note table. Signed-off-by: Rogan Hamby Signed-off-by: Ruth Frasur Signed-off-by: Galen Charlton --- Open-ILS/examples/fm_IDL.xml | 27 +++-- .../eg2/src/app/staff/catalog/catalog.module.ts | 2 + .../app/staff/catalog/record/notes.component.html | 18 ++++ .../app/staff/catalog/record/notes.component.ts | 110 +++++++++++++++++++++ .../app/staff/catalog/record/record.component.html | 6 ++ Open-ILS/src/sql/Pg/010.schema.biblio.sql | 1 + Open-ILS/src/sql/Pg/950.data.seed-values.sql | 11 ++- .../src/sql/Pg/upgrade/xxxx.data.record_notes.sql | 16 +++ 8 files changed, 181 insertions(+), 10 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/catalog/record/notes.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/catalog/record/notes.component.ts create mode 100644 Open-ILS/src/sql/Pg/upgrade/xxxx.data.record_notes.sql diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index c3571d9982..4cfdd3f9f2 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -7454,22 +7454,31 @@ SELECT usr, - + - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts index 89eb2b06ae..2108000a22 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts @@ -20,6 +20,7 @@ import {RecordActionsComponent} from './record/actions.component'; import {BasketActionsComponent} from './basket-actions.component'; import {HoldComponent} from './hold/hold.component'; import {PartsComponent} from './record/parts.component'; +import {NotesComponent} from './record/notes.component'; import {AddToCarouselDialogComponent} from './record/add-to-carousel-dialog.component'; import {PartMergeDialogComponent} from './record/part-merge-dialog.component'; import {BrowseComponent} from './browse.component'; @@ -48,6 +49,7 @@ import {BrowsePagerComponent} from './result/browse-pager.component'; BasketActionsComponent, HoldComponent, PartsComponent, + NotesComponent, AddToCarouselDialogComponent, PartMergeDialogComponent, BrowseComponent, diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/notes.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/notes.component.html new file mode 100644 index 0000000000..9c7e2e91b6 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/notes.component.html @@ -0,0 +1,18 @@ +
+ + + + + + + + + + + +
diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/notes.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/notes.component.ts new file mode 100644 index 0000000000..b489190892 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/notes.component.ts @@ -0,0 +1,110 @@ +import {Component, OnInit, Input, ViewChild} from '@angular/core'; +import {IdlService, IdlObject} from '@eg/core/idl.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {Pager} from '@eg/share/util/pager'; +import {OrgService} from '@eg/core/org.service'; +import {PermService} from '@eg/core/perm.service'; +import {GridDataSource} from '@eg/share/grid/grid'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component'; + +@Component({ + selector: 'eg-catalog-record-notes', + templateUrl: 'notes.component.html' +}) +export class NotesComponent implements OnInit { + + recId: number; + gridDataSource: GridDataSource; + initDone: boolean; + @ViewChild('notesGrid', { static: true }) notesGrid: GridComponent; + @ViewChild('editDialog', { static: true }) editDialog: FmRecordEditorComponent; + + canCreate: boolean; + canDelete: boolean; + createNew: () => void; + deleteSelected: (rows: IdlObject[]) => void; + permissions: {[name: string]: boolean}; + + @Input() set recordId(id: number) { + this.recId = id; + // Only force new data collection when recordId() + // is invoked after ngInit() has already run. + if (this.initDone) { + this.notesGrid.reload(); + } + } + + get recordId(): number { + return this.recId; + } + + constructor( + private idl: IdlService, + private org: OrgService, + private pcrud: PcrudService, + private perm: PermService + ) { + this.permissions = {}; + this.gridDataSource = new GridDataSource(); + } + + ngOnInit() { + this.initDone = true; + + // Load edit perms + this.perm.hasWorkPermHere([ + 'CREATE_RECORD_NOTE', + 'UPDATE_RECORD_NOTE', + 'DELETE_RECORD_NOTE' + ]).then(perms => this.permissions = perms); + + this.gridDataSource.getRows = (pager: Pager, sort: any[]) => { + const orderBy: any = {}; + + if (sort.length) { // Sort provided by grid. + orderBy.bren = sort[0].name + ' ' + sort[0].dir; + } else { + orderBy.bren = 'edit_date'; + } + + const searchOps = { + offset: pager.offset, + limit: pager.limit, + order_by: orderBy + }; + + return this.pcrud.search('bren', + {record: this.recId, deleted: 'f'}, searchOps); + }; + + this.notesGrid.onRowActivate.subscribe( + (note: IdlObject) => { + this.editDialog.mode = 'update'; + this.editDialog.recordId = note.id(); + this.editDialog.open() + .subscribe(ok => this.notesGrid.reload()); + } + ); + + this.createNew = () => { + + const note = this.idl.create('bren'); + note.record(this.recordId); + this.editDialog.record = note; + + this.editDialog.mode = 'create'; + this.editDialog.open().subscribe(ok => this.notesGrid.reload()); + }; + + this.deleteSelected = (notes: IdlObject[]) => { + notes.forEach(note => note.isdeleted(true)); + this.pcrud.autoApply(notes).subscribe( + val => console.debug('deleted: ' + val), + err => {}, + () => this.notesGrid.reload() + ); + }; + } +} + diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html index c245e88061..3d7ee748c3 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html @@ -57,6 +57,12 @@ + + + + + +