-<eg-progress-dialog #progressDialog></eg-progress-dialog>
-
<div class="import-form form-validated">
<h2 i18n>MARC File Upload</h2>
<div class="row">
Importing {{importSelection().recordIds.length}} Record(s)</span>
<span *ngIf="importSelection().importQueue" i18n>
Importing Queue {{importSelection().queue.name()}}</span>
+ </div>
+ <div class="col-lg-3">
<button class="btn btn-outline-info ml-2" (click)="clearSelection()" i18n>
Clear Selection
</button>
},
(err: HttpErrorResponse) => {
- //this.progressDialog.close();
console.error(err);
this.toast.danger(err.error.error);
}
importRecordQueue(recIds?: number[]): Promise<any> {
const rtype = this.recordType === 'bib' ? 'bib' : 'auth';
+
let method = `open-ils.vandelay.${rtype}_queue.import`;
const options: ImportOptions = this.compileImportOptions();
-<ng-container *ngIf="queueSummary">
+
+<eg-progress-dialog #progressDlg></eg-progress-dialog>
+
+<ng-container *ngIf="queueSummary && queueSummary.queue">
+
+ <eg-confirm-dialog
+ #confirmDelDlg
+ i18n-dialogTitle i18n-dialogBody
+ dialogTitle="Confirm Delete"
+ dialogBody="Delete Queue {{queueSummary.queue.name()}}?">
+ </eg-confirm-dialog>
+
<h2 i18n>Queue {{queueSummary.queue.name()}}</h2>
<div class="row pb-2">
<div class="col-lg-6">
i18n>Import Selected Records</a>
</div>
<div class="flex-1">
- <a i18n>Import All Records</a>
+ <a [routerLink]="" (click)="importAll()" i18n>Import All Records</a>
</div>
</div>
</li>
</li>
<li class="list-group-item">
<div class="d-flex">
+ <eg-record-bucket-dialog #bucketDialog [queueId]="queueId">
+ </eg-record-bucket-dialog>
<div class="flex-1">
- <a i18n>Copy Queue To Bucket</a>
+ <a [routerLink]="" (click)="bucketDialog.open({size:'lg'})" i18n>
+ Copy Queue To Bucket
+ </a>
</div>
<div class="flex-1">
- <a i18n>Delete Queue</a>
+ <a [routerLink]="" (click)="deleteQueue()" i18n>Delete Queue</a>
</div>
</div>
</li>
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import {map} from 'rxjs/operators/map';
+import {filter} from 'rxjs/operators/filter';
import {Router, ActivatedRoute, ParamMap} from '@angular/router';
import {Pager} from '@eg/share/util/pager';
import {IdlObject} from '@eg/core/idl.service';
+import {EventService} from '@eg/core/event.service';
import {NetService} from '@eg/core/net.service';
import {AuthService} from '@eg/core/auth.service';
+import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
+import {ProgressDialogComponent} from '@eg/share/dialog/progress.component';
import {GridComponent} from '@eg/share/grid/grid.component';
import {GridDataSource, GridColumn} from '@eg/share/grid/grid';
import {VandelayService, VandelayImportSelection} from './vandelay.service';
attrDefs: IdlObject[];
@ViewChild('queueGrid') queueGrid: GridComponent;
+ @ViewChild('confirmDelDlg') confirmDelDlg: ConfirmDialogComponent;
+ @ViewChild('progressDlg') progressDlg: ProgressDialogComponent;
constructor(
private router: Router,
private route: ActivatedRoute,
+ private evt: EventService,
private net: NetService,
private auth: AuthService,
private vandelay: VandelayService) {
);
}
+ qtypeShort(): string {
+ return this.queueType === 'bib' ? 'bib' : 'auth';
+ }
+
loadQueueSummary(): Promise<any> {
- const qtype = this.queueType === 'bib' ? 'bib' : 'auth';
const method =
- `open-ils.vandelay.${qtype}_queue.summary.retrieve`;
+ `open-ils.vandelay.${this.qtypeShort()}_queue.summary.retrieve`;
return this.net.request(
'open-ils.vandelay', method, this.auth.token(), this.queueId)
}
return this.vandelay.getQueuedRecords(
- this.queueId, this.queueType, options, this.filters.matches)
- .pipe(map(rec => {
-
+ this.queueId, this.queueType, options, this.filters.matches).pipe(
+ filter(rec => {
+ // avoid sending mishapen data to the grid
+ // this happens (among other reasons) when the grid
+ // no longer exists
+ const e = this.evt.parse(rec);
+ if (e) { console.error(e); return false; }
+ return true;
+ }),
+ map(rec => {
const recHash: any = {
id: rec.id(),
import_error: rec.import_error(),
this.vandelay.importSelection = selection;
this.router.navigate(['/staff/cat/vandelay/import']);
}
+
+ importAll() {
+ const selection = new VandelayImportSelection();
+ selection.queue = this.queueSummary.queue;
+ selection.importQueue = true;
+ this.vandelay.importSelection = selection;
+ this.router.navigate(['/staff/cat/vandelay/import']);
+ }
+
+ deleteQueue() {
+ this.confirmDelDlg.open().then(
+ yes => {
+ this.progressDlg.open();
+ return this.net.request(
+ 'open-ils.vandelay',
+ `open-ils.vandelay.${this.qtypeShort()}_queue.delete`,
+ this.auth.token(), this.queueId
+ ).toPromise();
+ },
+ no => {
+ this.progressDlg.close();
+ return Promise.reject('delete failed');
+ }
+ ).then(
+ resp => {
+ this.progressDlg.close();
+ const e = this.evt.parse(resp);
+ if (e) {
+ console.error(e);
+ alert(e);
+ } else {
+ // Jump back to the main queue page.
+ this.router.navigate(['/staff/cat/vandelay/queue']);
+ }
+ },
+ err => {
+ this.progressDlg.close();
+ }
+ );
+ }
}
import {QueueListComponent} from './queue-list.component';
import {GridModule} from '@eg/share/grid/grid.module';
import {HttpClientModule} from '@angular/common/http';
+import {RecordBucketDialogComponent} from '@eg/staff/share/buckets/record-bucket-dialog.component';
@NgModule({
declarations: [
ImportComponent,
ExportComponent,
QueueComponent,
- QueueListComponent
+ QueueListComponent,
+ RecordBucketDialogComponent
],
imports: [
StaffCommonModule,
<ng-template #dialogContent>
<div class="modal-header bg-info">
- <h4 class="modal-title" i18n>Add To Record #{{recId}} to Bucket</h4>
+ <h4 class="modal-title" *ngIf="recId" i18n>Add To Record #{{recId}} to Bucket</h4>
+ <h4 class="modal-title" *ngIf="qId" i18n>Add Records from queue #{{qId}} to Bucket</h4>
<button type="button" class="close"
i18n-aria-label aria-label="Close"
(click)="dismiss('cross_click')">
newBucketDesc: string;
buckets: any[];
+ @Input() bucketType: string;
+
recId: number;
@Input() set recordId(id: number) {
this.recId = id;
}
+ // Add items from a (vandelay) bib queue to a bucket
+ qId: number;
+ @Input() set queueId(id: number) {
+ this.qId = id;
+ }
+
constructor(
private modal: NgbModal, // required for passing to parent
private renderer: Renderer2,
}
ngOnInit() {
+
+ if (this.qId) {
+ this.bucketType = 'vandelay_queue';
+ } else {
+ this.bucketType = 'staff_client';
+ }
this.onOpen$.subscribe(ok => {
// Reset data on dialog open
'open-ils.actor',
'open-ils.actor.container.retrieve_by_class.authoritative',
this.auth.token(), this.auth.user().id(),
- 'biblio', 'staff_client'
+ 'biblio', this.bucketType
).subscribe(buckets => this.buckets = buckets);
});
}
bucket.owner(this.auth.user().id());
bucket.name(this.newBucketName);
bucket.description(this.newBucketDesc);
- bucket.btype('staff_client');
+ bucket.btype(this.bucketType);
this.net.request(
'open-ils.actor',
if (evt) {
this.toast.danger(evt.desc);
} else {
+ // make it find-able to the queue-add method which
+ // requires the bucket name.
+ bucket.id(bktId);
+ this.buckets.push(bucket);
+
this.addToBucket(bktId);
}
});
// Add the record to the selected existing bucket
addToBucket(id: number) {
+ if (this.recId) {
+ this.addRecordToBucket(id);
+ } else if (this.qId) {
+ this.addQueueToBucket(id);
+ }
+ }
+
+ addRecordToBucket(bucketId: number) {
const item = this.idl.create('cbrebi');
- item.bucket(id);
+ item.bucket(bucketId);
item.target_biblio_record_entry(this.recId);
this.net.request(
'open-ils.actor',
}
});
}
+
+ addQueueToBucket(bucketId: number) {
+ const bucket = this.buckets.filter(b => b.id() === bucketId)[0];
+ if (!bucket) { return; }
+
+ this.net.request(
+ 'open-ils.vandelay',
+ 'open-ils.vandelay.bib_queue.to_bucket',
+ this.auth.token(), this.qId, bucket.name()
+ ).toPromise().then(resp => {
+ const evt = this.evt.parse(resp);
+ if (evt) {
+ this.toast.danger(evt.toString());
+ } else {
+ this.close();
+ }
+ });
+ }
}