<div class="flex-1"></div>
+ <button *ngIf="tab == 'list'"
+ class="btn btn-outline-dark mr-2" (click)="showDetails()">
+ Detail View
+ </button>
+
+ <button *ngIf="tab != 'list'"
+ class="btn btn-outline-dark mr-2" (click)="showList()">
+ List View
+ </button>
+
+
<!-- ACTIONS MENU -->
<eg-grouped-menu i18n-label label="Actions" *ngIf="item && tab != 'list'">
</div>
</div>
+<ng-template #callNumberTemplate let-r="row">
+ {{r.call_number().prefix().label()}}
+ {{r.call_number().label()}}
+ {{r.call_number().suffix().label()}}
+</ng-template>
+
+<eg-grid *ngIf="tab == 'list'" #grid [dataSource]="dataSource"
+ [useLocalSort]="true" [sortable]="true" [showDeclaredFieldsOnly]="true">
+
+ <eg-grid-column i18n-label label="Item ID" path="id" [index]="true">
+ </eg-grid-column>
+
+ <eg-grid-column i18n-label label="Alert Message" path="alert_message">
+ </eg-grid-column>
+
+ <eg-grid-column i18n-label label="Barcode" path="barcode">
+ </eg-grid-column>
+
+ <eg-grid-column i18n-label label="Location" path="location.name">
+ </eg-grid-column>
+
+ <eg-grid-column i18n-label label="Due Date" path="_circ.due_date"
+ timezoneContextOrg="_circ.circ_lib" dateOnlyIntervalField="_circ.duration"
+ datatype="timestamp">
+ </eg-grid-column>
+
+ <eg-grid-column i18n-label label="Call Number" name="call_number_label"
+ [cellTemplate]="callNumberTemplate"></eg-grid-column>
+
+ <eg-grid-column i18n-label label="Title"
+ path="call_number.record.simple_record.title"></eg-grid-column>
+
+ <eg-grid-column i18n-label label="Author"
+ path="call_number.record.simple_record.author"></eg-grid-column>
+
+ <eg-grid-column path="call_number.*" [hidden]="true"></eg-grid-column>
+ <eg-grid-column path="call_number.record.simple_record.*" [hidden]="true">
+ </eg-grid-column>
+</eg-grid>
<div *ngIf="tab != 'list' && item">
import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
import {MarkItemsDialogComponent
} from '@eg/staff/share/holdings/mark-items-dialog.component';
+import {GridDataSource, GridColumn, GridCellTextGenerator} from '@eg/share/grid/grid';
+import {GridComponent} from '@eg/share/grid/grid.component';
+import {Pager} from '@eg/share/util/pager';
+import {ItemStatusService} from './item.service';
@Component({
templateUrl: 'status.component.html'
noSuchItem = false;
item: IdlObject;
tab: string;
- discardCount = 0;
+ preloadCopyIds: number[];
+
+ dataSource: GridDataSource = new GridDataSource();
+ @ViewChild('grid') private grid: GridComponent;
@ViewChild('barcodeSelect') private barcodeSelect: BarcodeSelectComponent;
private holdings: HoldingsService,
private toast: ToastService,
private strings: StringService,
- private anonCache: AnonCacheService
+ private anonCache: AnonCacheService,
+ private itemService: ItemStatusService
) {}
ngOnInit() {
this.itemId = +this.route.snapshot.paramMap.get('id');
this.tab = this.route.snapshot.paramMap.get('tab');
+ const copyIdList = this.route.snapshot.paramMap.get('copyIdList');
+ if (copyIdList) {
+ this.preloadCopyIds = copyIdList.split(',').map(id => Number(id));
+ }
+
if (!this.tab) {
if (this.itemId) {
this.tab = 'summary';
}
}
- this.worklog.loadSettings().then(_ => this.load());
+ this.worklog.loadSettings().then(_ => this.load(true));
+
+ this.dataSource.getRows = (pager: Pager, sort: any[]) => {
+ return from(this.itemService.scannedItems);
+ };
}
- load() {
+ load(first?: boolean) {
this.cat.fetchCcvms()
.then(_ => this.cat.fetchCmfs())
.then(_ => {
if (this.itemId) {
return this.getItemById(this.itemId);
+ } else if (this.preloadCopyIds) {
+ return from(this.preloadCopyIds).pipe(concatMap(id => {
+ return of(this.getItemById(id));
+ })).toPromise().then(_ => this.preloadCopyIds = null);
}
})
.then(_ => {
+
+ // Avoid multiple subscriptions
+ if (!first) { return; }
+
// Avoid watching for changes until after ngOnInit is complete
// so we don't grab the same copy twice.
-
this.route.paramMap.subscribe((params: ParamMap) => {
- this.tab = params.get('tab');
+ this.tab = params.get('tab') || 'list';
const id = +params.get('id');
- if (id !== this.itemId) {
+ if (id && id !== this.itemId) {
this.itemId = id;
- if (id) {
- this.getItemById(id);
- }
+ this.getItemById(id);
}
});
});
getItemById(id: number): Promise<any> {
+ // TODO fetch open circ and store it on the copy
+
const flesh = {
flesh : 4,
flesh_fields : {
return this.pcrud.retrieve('acp', id, flesh)
.toPromise().then(item => {
this.item = item;
- this.itemId = item.id();
this.mungeIsbns();
this.selectInput();
+ this.itemService.scannedItems.unshift(item);
+ this.grid.reload();
});
}
const item = this.item;
const isbn = item.call_number().record().simple_record().isbn();
if (isbn) {
- item._isbns = isbn.match(/"(.*?)"/g).map(i => i.replace(/"/g, ''));
+ const matches = isbn.match(/"(.*?)"/g);
+ item._isbns = matches ? matches.map(i => i.replace(/"/g, '')) : [];
} else {
item._isbns = [item.dummy_isbn()];
}
this.transferItems.transferItems(copies.map(c => c.id()), cnId)
.then(success => success ? this.load() : null);
}
+
+ showDetails() {
+ }
+
+ showList() {
+ this.router.navigate(['/staff/cat/item/list']);
+ }
}