From 7934689cca51946ce0ea88f5cd48055d5e0f6ba0 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 29 Nov 2018 17:54:20 -0500 Subject: [PATCH] initial mono parts UI for catalog Signed-off-by: Bill Erickson --- .../src/app/share/fm-editor/fm-editor.component.ts | 7 +- .../eg2/src/app/staff/catalog/catalog.module.ts | 4 +- .../src/app/staff/catalog/hold/hold.component.html | 10 ++ .../src/app/staff/catalog/hold/hold.component.ts | 6 ++ .../app/staff/catalog/record/parts.component.html | 20 ++++ .../app/staff/catalog/record/parts.component.ts | 118 +++++++++++++++++++++ .../app/staff/catalog/record/record.component.html | 6 ++ .../src/eg2/src/app/staff/share/hold.service.ts | 4 +- 8 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/catalog/record/parts.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/catalog/record/parts.component.ts diff --git a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts index 5f7a65a4a4..d079f6a389 100644 --- a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts +++ b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts @@ -177,9 +177,12 @@ export class FmRecordEditorComponent }); } - // create a new record from scratch + // create a new record from scratch or from a stub record + // provided by the caller. this.pkeyIsEditable = !('pkey_sequence' in this.idlDef); - this.record = this.idl.create(this.idlClass); + if (!this.record) { + this.record = this.idl.create(this.idlClass); + } return this.getFieldList(); } 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 87cda490c2..3289e607b8 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 @@ -17,6 +17,7 @@ import {HoldingsService} from '@eg/staff/share/holdings.service'; import {BasketActionsComponent} from './basket-actions.component'; import {HoldComponent} from './hold/hold.component'; import {HoldService} from '@eg/staff/share/hold.service'; +import {PartsComponent} from './record/parts.component'; @NgModule({ declarations: [ @@ -31,7 +32,8 @@ import {HoldService} from '@eg/staff/share/hold.service'; RecordPaginationComponent, RecordActionsComponent, BasketActionsComponent, - HoldComponent + HoldComponent, + PartsComponent ], imports: [ StaffCommonModule, diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html index 7b6cae8880..c4afcf5eed 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html @@ -171,6 +171,16 @@ ANY + +
diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts index 5c59508c38..a8c9fcbdce 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts @@ -287,6 +287,12 @@ export class HoldComponent implements OnInit { iconFormatLabel(code: string): string { return this.cat.iconFormatLabel(code); } + + hasMetaFilters(ctx: HoldContext): boolean { + return ctx.holdMeta.metarecord_filters && ( + ctx.holdMeta.metarecord_filters.langs.length > 1 || + ctx.holdMeta.metarecord_filters.formats.length > 1); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/parts.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/parts.component.html new file mode 100644 index 0000000000..caa28b9b4e --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/parts.component.html @@ -0,0 +1,20 @@ + +
+ + + + + + + + + + + + + +
diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/parts.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/parts.component.ts new file mode 100644 index 0000000000..4df2c37cc3 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/parts.component.ts @@ -0,0 +1,118 @@ +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-parts', + templateUrl: 'parts.component.html' +}) +export class PartsComponent implements OnInit { + + recId: number; + gridDataSource: GridDataSource; + initDone: boolean; + @ViewChild('partsGrid') partsGrid: GridComponent; + @ViewChild('editDialog') editDialog: FmRecordEditorComponent; + + canCreate: boolean; + canDelete: boolean; + createNew: () => void; + deleteSelected: (rows: IdlObject[]) => void; + mergeSelected: (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.partsGrid.reload(); + } + } + + 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_MONOGRAPH_PART', + 'UPDATE_MONOGRAPH_PART', + 'DELETE_MONOGRAPH_PART' + ]).then(perms => this.permissions = perms); + + this.gridDataSource.getRows = (pager: Pager, sort: any[]) => { + const orderBy: any = {}; + + if (sort.length) { // Sort provided by grid. + orderBy.bmp = sort[0].name + ' ' + sort[0].dir; + } else { + orderBy.bmp = 'label'; + } + + const searchOps = { + offset: pager.offset, + limit: pager.limit, + order_by: orderBy + }; + + return this.pcrud.search('bmp', + {record: this.recId, deleted: 'f'}, searchOps); + }; + + this.partsGrid.onRowActivate.subscribe( + (part: IdlObject) => { + this.editDialog.mode = 'update'; + this.editDialog.recId = part.id(); + this.editDialog.open().then( + ok => this.partsGrid.reload(), + err => {} + ); + } + ); + + this.createNew = () => { + + const part = this.idl.create('bmp'); + part.record(this.recId); + this.editDialog.record = part; + + this.editDialog.mode = 'create'; + this.editDialog.open().then( + ok => this.partsGrid.reload(), + err => {} + ); + }; + + this.deleteSelected = (parts: IdlObject[]) => { + parts.forEach(part => part.isdeleted(true)); + this.pcrud.autoApply(parts).subscribe( + val => console.debug('deleted: ' + val), + err => {}, + () => this.partsGrid.reload() + ); + }; + + this.mergeSelected = (parts: IdlObject[]) => this.mergeParts(parts); + } + + mergeParts(parts: IdlObject[]) { + console.log('merging parts for rec', parts, this.recId); + } +} + 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 cefd1ffcf0..96c733ecde 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 @@ -35,6 +35,12 @@ + + + + + +
diff --git a/Open-ILS/src/eg2/src/app/staff/share/hold.service.ts b/Open-ILS/src/eg2/src/app/staff/share/hold.service.ts index 7f4b216136..0bbfd63cb4 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/hold.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/hold.service.ts @@ -42,7 +42,8 @@ export interface HoldRequest { // available for each hold type / target. E.g. a TITLE hold will // not have a value for 'volume', but a COPY hold will, since all // copies have volumes. Every HoldRequestTarget will have a bibId and -// bibSummary. +// bibSummary. Some values come directly from the API call, others +// applied locally. export interface HoldRequestTarget { target: number; metarecord?: IdlObject; @@ -130,6 +131,7 @@ export class HoldService { ).pipe(mergeMap(meta => { const target: HoldRequestTarget = meta; target.bibId = target.bibrecord.id(); + return this.bib.getBibSummary(target.bibId) .pipe(map(sum => { target.bibSummary = sum; -- 2.11.0