--- /dev/null
+
+<div class="row form-validated mt-5">
+ <div class="col-lg-6 form-inline">
+ <div class="input-group">
+ <div class="input-group-prepend">
+ <span class="input-group-text" id="bib-ident-label">
+ <ng-container *ngIf="identType === 'id'" i18n>Record ID:</ng-container>
+ <ng-container *ngIf="identType === 'tcn'" i18n>Record TCN:</ng-container>
+ </span>
+ </div>
+ <input id="bib-ident-value" type="text" required
+ (keyup.enter)="search()" [(ngModel)]="identValue"
+ class="form-control" aria-describedby="bib-ident-label"/>
+ </div>
+ <button class="btn btn-outline-dark" (click)="search()" i18n>Submit</button>
+ </div>
+</div>
+
+<div class="row mt-3">
+ <div class="col-lg-6">
+ <div class="alert alert-warning" *ngIf="notFound && !multiRecordsFound" i18n>
+ Record not found: {{identValue}}
+ </div>
+ <div class="alert alert-warning" *ngIf="multiRecordsFound" i18n>
+ More than one Bib Record found with TCN: {{identValue}}
+ </div>
+ </div>
+</div>
--- /dev/null
+import {Component, OnInit, ViewChild, Input, AfterViewInit} from '@angular/core';
+import {Router, ActivatedRoute, ParamMap} from '@angular/router';
+import {IdlObject} from '@eg/core/idl.service';
+import {NetService} from '@eg/core/net.service';
+import {PcrudService} from '@eg/core/pcrud.service';
+
+/* Component for retrieving bib records by ID, TCN */
+
+@Component({
+ templateUrl: 'bib-by-ident.component.html'
+})
+export class BibByIdentComponent implements OnInit, AfterViewInit {
+
+ identType: 'id' | 'tcn' = 'id';
+ identValue: string;
+ notFound = false;
+ multiRecordsFound = false;
+
+ constructor(
+ private router: Router,
+ private route: ActivatedRoute,
+ private net: NetService,
+ private pcrud: PcrudService
+ ) {}
+
+ ngOnInit() {
+ this.route.paramMap.subscribe((params: ParamMap) => {
+ this.identType = params.get('identType') as 'id' | 'tcn';
+ });
+ }
+
+ ngAfterViewInit() {
+ const node = document.getElementById('bib-ident-value');
+ setTimeout(() => node.focus());
+ }
+
+ search() {
+ if (!this.identValue) { return; }
+
+ this.notFound = false;
+ this.multiRecordsFound = false;
+
+ let promise;
+ if (this.identType === 'id') {
+ promise = this.getById();
+
+ } else if (this.identType === 'tcn') {
+ promise = this.getByTcn();
+ }
+
+ promise.then(id => {
+ if (id === null) {
+ this.notFound = true;
+ } else {
+ this.goToRecord(id);
+ }
+ });
+ }
+
+ getById(): Promise<number> {
+ // Confirm the record exists before redirecting.
+ return this.pcrud.retrieve('bre', this.identValue).toPromise()
+ .then(rec => rec ? rec.id() : null);
+ }
+
+ getByTcn(): Promise<number> {
+ // Start by searching non-deleted records
+
+ return this.net.request(
+ 'open-ils.search',
+ 'open-ils.search.biblio.tcn', this.identValue).toPromise()
+ .then(resp => {
+
+ if (resp.count > 0) {
+ return Promise.resolve(resp);
+ }
+
+ // No active records, see if we have any deleted records.
+ return this.net.request(
+ 'open-ils.search',
+ 'open-ils.search.biblio.tcn', this.identValue, true
+ ).toPromise();
+
+ }).then(resp => {
+
+ if (resp.count) {
+ if (resp.count > 1) {
+ this.multiRecordsFound = true;
+ return null;
+ } else {
+ return resp.ids[0];
+ }
+ }
+
+ return null;
+ });
+ }
+
+ goToRecord(id: number) {
+ this.router.navigate([`/staff/catalog/record/${id}`]);
+ }
+}
+
+
<span i18n>Item Buckets</span>
</a>
<div class="dropdown-divider"></div>
- <a href="/eg/staff/cat/catalog/retrieve_by_id" class="dropdown-item">
+ <a routerLink="/staff/cat/bib-from/id" class="dropdown-item">
<span class="material-icons" aria-hidden="true">collections</span>
<span i18n>Retrieve Bib Record by ID</span>
</a>
- <a href="/eg/staff/cat/catalog/retrieve_by_tcn"
- class="dropdown-item"
+ <a routerLink="/staff/cat/bib-from/tcn" class="dropdown-item"
egAccessKey keyCtx="navbar" i18n-keySpec i18n-keyDesc
keySpec="shift+f3" keyDesc="Retrieve Bib Record by TCN">
<span class="material-icons" aria-hidden="true">collections_bookmark</span>
</li>
<li class="divider"></li>
<li>
- <a href="./cat/catalog/retrieve_by_id" target="_self">
+ <a href="/eg2/staff/cat/bib-from/id">
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
[% l('Retrieve Bib Record by ID') %]
</a>
</li>
<li>
- <a href="./cat/catalog/retrieve_by_tcn" target="_self"
+
+ <a href="/eg2/staff/cat/bib-from/tcn"
eg-accesskey="[% l('shift+f3') %]"
eg-accesskey-desc="[% l('Retrieve Last Bib Record') %]">
<span class="glyphicon glyphicon-tag" aria-hidden="true"></span>