From b30b854057d14af2353ff9707e67034128519d04 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 22 Jun 2018 16:41:59 -0400 Subject: [PATCH] LP#1775466 Catalog add to bucket action Signed-off-by: Bill Erickson --- .../eg2/src/app/staff/catalog/catalog.module.ts | 4 +- .../staff/catalog/record/actions.component.html | 6 ++ .../buckets/record-bucket-dialog.component.html | 56 +++++++++++ .../buckets/record-bucket-dialog.component.ts | 109 +++++++++++++++++++++ 4 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.ts 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 8c1a421150..26f0db3ac8 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 @@ -18,6 +18,7 @@ import {StaffCatalogService} from './catalog.service'; import {RecordPaginationComponent} from './record/pagination.component'; import {RecordActionsComponent} from './record/actions.component'; import {MarcViewComponent} from './record/marc-view.component'; +import {RecordBucketDialogComponent} from '@eg/staff/share/buckets/record-bucket-dialog.component'; @NgModule({ declarations: [ @@ -32,7 +33,8 @@ import {MarcViewComponent} from './record/marc-view.component'; ResultPaginationComponent, RecordPaginationComponent, RecordActionsComponent, - MarcViewComponent + MarcViewComponent, + RecordBucketDialogComponent ], imports: [ StaffCommonModule, diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html index fed3c1c8d6..53b7342fa6 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html @@ -10,6 +10,9 @@ + + +
@@ -50,6 +53,9 @@
+ View/Place Orders diff --git a/Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.html new file mode 100644 index 0000000000..3502ad81bc --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.html @@ -0,0 +1,56 @@ + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.ts new file mode 100644 index 0000000000..bca5b69921 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.ts @@ -0,0 +1,109 @@ +import {Component, OnInit, Input, Renderer2} from '@angular/core'; +import {NetService} from '@eg/core/net.service'; +import {IdlService} from '@eg/core/idl.service'; +import {EventService} from '@eg/core/event.service'; +import {ToastService} from '@eg/share/toast/toast.service'; +import {AuthService} from '@eg/core/auth.service'; +import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; + +/** + * Dialog for adding bib records to new and existing record buckets. + */ + +@Component({ + selector: 'eg-record-bucket-dialog', + templateUrl: 'record-bucket-dialog.component.html' +}) + +export class RecordBucketDialogComponent + extends DialogComponent implements OnInit { + + selectedBucket: number; + newBucketName: string; + newBucketDesc: string; + buckets: any[]; + + recId: number; + @Input() set recordId(id: number) { + this.recId = id; + } + + constructor( + private modal: NgbModal, // required for passing to parent + private renderer: Renderer2, + private toast: ToastService, + private idl: IdlService, + private net: NetService, + private evt: EventService, + private auth: AuthService) { + super(modal); // required for subclassing + } + + ngOnInit() { + + this.onOpen$.subscribe(ok => { + // Reset data on dialog open + + this.selectedBucket = null; + this.newBucketName = ''; + this.newBucketDesc = ''; + + this.net.request( + 'open-ils.actor', + 'open-ils.actor.container.retrieve_by_class.authoritative', + this.auth.token(), this.auth.user().id(), + 'biblio', 'staff_client' + ).subscribe(buckets => this.buckets = buckets); + }); + } + + addToSelected() { + this.addToBucket(this.selectedBucket); + } + + // Create a new bucket then add the record + addToNew() { + const bucket = this.idl.create('cbreb'); + + bucket.owner(this.auth.user().id()); + bucket.name(this.newBucketName); + bucket.description(this.newBucketDesc); + bucket.btype('staff_client'); + + this.net.request( + 'open-ils.actor', + 'open-ils.actor.container.create', + this.auth.token(), 'biblio', bucket + ).subscribe(bktId => { + const evt = this.evt.parse(bktId); + if (evt) { + this.toast.danger(evt.desc); + } else { + this.addToBucket(bktId); + } + }); + } + + // Add the record to the selected existing bucket + addToBucket(id: number) { + const item = this.idl.create('cbrebi'); + item.bucket(id); + item.target_biblio_record_entry(this.recId); + this.net.request( + 'open-ils.actor', + 'open-ils.actor.container.item.create', + this.auth.token(), 'biblio', item + ).subscribe(resp => { + const evt = this.evt.parse(resp); + if (evt) { + this.toast.danger(evt.toString()); + } else { + this.close(); + } + }); + } +} + + + -- 2.11.0