<div class="common-form striped-even form-validated">
<div class="row">
<div class="col-lg-6">
- <div class="row"><label>Select a Record Source</label></div>
- <ngb-accordion [closeOthers]="true" activeIds="csv"
- (panelChange)="sourceChange($event)">
- <ngb-panel id="csv" title="CSV File">
- <ng-template ngbPanelContent>
- <div class="row">
- <div class="col-lg-6">
- <label for="csv-input" i18n>Use Field Number</label>
- </div>
- <div class="col-lg-6">
- <input id='csv-input' type="number" class="form-control"
- [(ngModel)]="fieldNumber"
- i18n-placeholder placeholder="Starts at 0..."/>
- </div>
- </div>
- <div class="row">
- <div class="col-lg-6">
- <label for="use-csv-file" i18n>From CSV file</label>
- </div>
- <div class="col-lg-6">
- <input #fileSelector (change)="fileSelected($event)"
- id="use-csv-file" class="form-control" type="file"/>
- </div>
- </div>
- </ng-template>
- </ngb-panel>
- <ngb-panel id="record-id" title="Record ID">
- <ng-template ngbPanelContent>
- <div class="row">
- <div class="col-lg-6">
- <label for="record-id-input" i18n>Record ID</label>
+ <ng-container *ngIf="exportingBasket">
+ <div class="alert alert-info" i18n>
+ Exporting {{basketRecords.length}} Records from Catalog Basket.
+ </div>
+ <div>
+ <a routerLink="/staff/catalog/search" queryParamsHandling="merge">
+ <button class="btn btn-info" i18n>Return to Catalog</button>
+ </a>
+ </div>
+ </ng-container>
+ <ng-container *ngIf="!exportingBasket">
+ <div class="row"><label>Select a Record Source</label></div>
+ <ngb-accordion [closeOthers]="true" activeIds="csv"
+ (panelChange)="sourceChange($event)">
+ <ngb-panel id="csv" title="CSV File">
+ <ng-template ngbPanelContent>
+ <div class="row">
+ <div class="col-lg-6">
+ <label for="csv-input" i18n>Use Field Number</label>
+ </div>
+ <div class="col-lg-6">
+ <input id='csv-input' type="number" class="form-control"
+ [(ngModel)]="fieldNumber"
+ i18n-placeholder placeholder="Starts at 0..."/>
+ </div>
</div>
- <div class="col-lg-6">
- <input id='record-id-input' type="number"
- class="form-control" [(ngModel)]="recordId"/>
+ <div class="row">
+ <div class="col-lg-6">
+ <label for="use-csv-file" i18n>From CSV file</label>
+ </div>
+ <div class="col-lg-6">
+ <input #fileSelector (change)="fileSelected($event)"
+ id="use-csv-file" class="form-control" type="file"/>
+ </div>
</div>
- </div>
- </ng-template>
- </ngb-panel>
- <ngb-panel id="bucket-id" title="Bucket">
- <ng-template ngbPanelContent>
- <div class="row">
- <div class="col-lg-6">
- <label for="bucket-id-input" i18n>Bucket ID</label>
+ </ng-template>
+ </ngb-panel>
+ <ngb-panel id="record-id" title="Record ID">
+ <ng-template ngbPanelContent>
+ <div class="row">
+ <div class="col-lg-6">
+ <label for="record-id-input" i18n>Record ID</label>
+ </div>
+ <div class="col-lg-6">
+ <input id='record-id-input' type="number"
+ class="form-control" [(ngModel)]="recordId"/>
+ </div>
</div>
- <div class="col-lg-6">
- <input id='bucket-id-input' type="number"
- class="form-control" [(ngModel)]="bucketId"/>
+ </ng-template>
+ </ngb-panel>
+ <ngb-panel id="bucket-id" title="Bucket">
+ <ng-template ngbPanelContent>
+ <div class="row">
+ <div class="col-lg-6">
+ <label for="bucket-id-input" i18n>Bucket ID</label>
+ </div>
+ <div class="col-lg-6">
+ <input id='bucket-id-input' type="number"
+ class="form-control" [(ngModel)]="bucketId"/>
+ </div>
</div>
- </div>
- </ng-template>
- </ngb-panel>
- </ngb-accordion>
+ </ng-template>
+ </ngb-panel>
+ </ngb-accordion>
+ </ng-container>
</div><!-- col -->
+
<div class="col-lg-6">
<div class="row">
<div class="col-lg-6">
</div>
<div class="col-lg-6">
<select class="form-control"
+ [disabled]="exportingBasket"
[(ngModel)]="recordType" id="record-type">
<option i18n value="biblio">Bibliographic Records</option>
<option i18n value="authority">Authority Records</option>
</div>
</div><!-- left col -->
</div><!-- row -->
-</div>
+</div><!-- form -->
+
-import {Component, AfterViewInit, ViewChild, Renderer2} from '@angular/core';
+import {Component, AfterViewInit, ViewChild, Renderer2, OnInit} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
import {NgbPanelChangeEvent} from '@ng-bootstrap/ng-bootstrap';
import {HttpClient, HttpRequest, HttpEventType} from '@angular/common/http';
import {HttpResponse, HttpErrorResponse} from '@angular/common/http';
import {AuthService} from '@eg/core/auth.service';
import {ToastService} from '@eg/share/toast/toast.service';
import {ProgressInlineComponent} from '@eg/share/dialog/progress-inline.component';
-import {VandelayService, VANDELAY_EXPORT_PATH} from './vandelay.service';
+import {VANDELAY_EXPORT_PATH} from './vandelay.service';
+import {BasketService} from '@eg/share/catalog/basket.service';
@Component({
templateUrl: 'export.component.html'
})
-export class ExportComponent implements AfterViewInit {
+export class ExportComponent implements AfterViewInit, OnInit {
recordSource: string;
fieldNumber: number;
recordEncoding: string;
includeHoldings: boolean;
isExporting: boolean;
+ exportingBasket: boolean;
+ basketRecords: number[];
@ViewChild('fileSelector') private fileSelector;
@ViewChild('exportProgress')
constructor(
private renderer: Renderer2,
+ private route: ActivatedRoute,
private http: HttpClient,
private toast: ToastService,
- private auth: AuthService
+ private auth: AuthService,
+ private basket: BasketService
) {
this.recordType = 'biblio';
this.recordFormat = 'USMARC';
this.recordEncoding = 'UTF-8';
this.includeHoldings = false;
+ this.basketRecords = [];
+ }
+
+ ngOnInit() {
+ const segments = this.route.snapshot.url.length;
+ if (segments > 0 &&
+ this.route.snapshot.url[segments - 1].path === 'basket') {
+ this.exportingBasket = true;
+ this.basket.getRecordIds().then(
+ ids => this.basketRecords = ids
+ );
+ }
}
ngAfterViewInit() {
+ if (this.exportingBasket) {
+ return; // no source to focus
+ }
this.renderer.selectRootElement('#csv-input').focus();
}
sourceChange($event: NgbPanelChangeEvent) {
this.recordSource = $event.panelId;
+ if (this.exportingBasket) {
+ return; // no source to focus
+ }
+
if ($event.nextState) { // panel opened
// give the panel a chance to render before focusing input
hasNeededData(): boolean {
return Boolean(
- this.selectedFile || this.recordId || this.bucketId
+ this.selectedFile ||
+ this.recordId ||
+ this.bucketId ||
+ (this.exportingBasket && this.basketRecords.length > 0)
);
}
formData.append('holdings', '1');
}
- switch (this.recordSource) {
+ if (this.exportingBasket) {
+ this.basketRecords.forEach(id => formData.append('id', '' + id));
+
+ } else {
- case 'csv':
- formData.append('idcolumn', '' + this.fieldNumber);
- formData.append('idfile',
- this.selectedFile, this.selectedFile.name);
- break;
+ switch (this.recordSource) {
- case 'record-id':
- formData.append('id', '' + this.recordId);
- break;
+ case 'csv':
+ formData.append('idcolumn', '' + this.fieldNumber);
+ formData.append('idfile',
+ this.selectedFile, this.selectedFile.name);
+ break;
- case 'bucket-id':
- formData.append('containerid', '' + this.bucketId);
- break;
+ case 'record-id':
+ formData.append('id', '' + this.recordId);
+ break;
+
+ case 'bucket-id':
+ formData.append('containerid', '' + this.bucketId);
+ break;
+ }
}
this.sendExportRequest(formData);