From: Bill Erickson Date: Fri, 22 Jun 2018 16:47:03 +0000 (-0400) Subject: LP#1775466 Catalog copies now use grid X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c6c76abc3d77e3a61f9a715285dc35fbbdb268ba;p=working%2FEvergreen.git LP#1775466 Catalog copies now use grid For added display flexibility, grid printing, possible future multi-select actions. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts index 34548a9e4c..dd8adb2faf 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts @@ -47,6 +47,7 @@ export class GridColumnComponent implements OnInit { col.cellContext = this.cellContext; col.isSortable = this.sortable; col.isMultiSortable = this.multiSortable; + col.datatype = this.datatype; this.grid.context.columnSet.add(col); } } diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.ts b/Open-ILS/src/eg2/src/app/share/grid/grid.ts index 3a967a7112..4b4fc841d9 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.ts @@ -80,7 +80,7 @@ export class GridColumnSet { } idlInfoFromDotpath(dotpath: string): any { - if (!dotpath) { return null; } + if (!dotpath || !this.idlClass) { return null; } let idlParent; let idlField; 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 e9870e9e78..b8de7cb29e 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 @@ -1,5 +1,6 @@ import {NgModule} from '@angular/core'; import {StaffCommonModule} from '@eg/staff/common.module'; +import {GridModule} from '@eg/share/grid/grid.module'; import {UnapiService} from '@eg/share/catalog/unapi.service'; import {CatalogRoutingModule} from './routing.module'; import {CatalogService} from '@eg/share/catalog/catalog.service'; @@ -33,6 +34,7 @@ import {MarcViewComponent} from './record/marc-view.component'; ], imports: [ StaffCommonModule, + GridModule, CatalogRoutingModule ], providers: [ diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.html index 8c7a4f3204..e7d82491b5 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.html @@ -1,71 +1,53 @@ -
- -
-
-
Location
-
Call Number / Copy Notes
-
Barcode
-
Shelving Location
-
Circulation Modifier
-
Age Hold Protection
-
Active/Create Date
-
Holdable?
-
Status
-
Due Date
-
-
-
    -
  • -
    -
    {{orgName(copy.circ_lib)}}
    -
    - {{copy.call_number_prefix_label}} - {{copy.call_number_label}} - {{copy.call_number_suffix_label}} -
    -
    - {{copy.barcode}} - View - | - Edit -
    -
    {{copy.copy_location}}
    -
    {{copy.circ_modifier || ''}}
    -
    {{copy.age_protect}}
    -
    - {{copy.active_date || copy.create_date | date:'shortDate'}} -
    -
    - Yes - No -
    -
    {{copy.copy_status}}
    -
    {{copy.due_date | date:'shortDate'}}
    -
    -
  • -
-
+ + {{copy.call_number_prefix_label}} + {{copy.call_number_label}} + {{copy.call_number_suffix_label}} + + + +
{{copy.barcode}}
+
+ View + | + Edit
+
+ + + Yes + No + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.ts index 86ac3e3bee..b868c8f056 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.ts @@ -1,8 +1,12 @@ -import {Component, OnInit, Input} from '@angular/core'; +import {Component, OnInit, Input, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {map} from 'rxjs/operators/map'; import {NetService} from '@eg/core/net.service'; import {StaffCatalogService} from '../catalog.service'; import {Pager} from '@eg/share/util/pager'; import {OrgService} from '@eg/core/org.service'; +import {GridDataSource} from '@eg/share/grid/grid'; +import {GridComponent} from '@eg/share/grid/grid.component'; @Component({ selector: 'eg-catalog-copies', @@ -10,17 +14,18 @@ import {OrgService} from '@eg/core/org.service'; }) export class CopiesComponent implements OnInit { - pager: Pager; - copies: any[]; recId: number; initDone = false; + gridDataSource: GridDataSource; + copyContext: any; // grid context + @ViewChild('copyGrid') copyGrid: GridComponent; @Input() set recordId(id: number) { this.recId = id; // Only force new data collection when recordId() // is invoked after ngInit() has already run. if (this.initDone) { - this.collectData(); + this.copyGrid.reload(); } } @@ -28,26 +33,37 @@ export class CopiesComponent implements OnInit { private net: NetService, private org: OrgService, private staffCat: StaffCatalogService, - ) {} + ) { + this.gridDataSource = new GridDataSource(); + } ngOnInit() { this.initDone = true; - this.collectData(); + + this.gridDataSource.getRows = (pager: Pager, sort: any[]) => { + // sorting not currently supported + return this.fetchCopies(pager); + } + + this.copyContext = { + holdable: (copy: any) => { + return copy.holdable === 't' + && copy.location_holdable === 't' + && copy.status_holdable === 't'; + } + } } collectData() { if (!this.recId) { return; } - this.pager = new Pager(); - this.pager.limit = 10; // TODO UI - this.fetchCopies(); } orgName(orgId: number): string { return this.org.get(orgId).shortname(); } - fetchCopies(): void { - this.copies = []; + fetchCopies(pager: Pager): Observable { + if (!this.recId) { return Observable.of([]); } // "Show Result from All Libraries" i.e. global search displays // copies from all branches, sorted by search/pref libs. @@ -55,39 +71,20 @@ export class CopiesComponent implements OnInit { this.org.root().ou_type().depth() : this.staffCat.searchContext.searchOrg.ou_type().depth(); - this.net.request( + return this.net.request( 'open-ils.search', 'open-ils.search.bib.copies.staff', this.recId, this.staffCat.searchContext.searchOrg.id(), copy_depth, - this.pager.limit, - this.pager.offset, + pager.limit, + pager.offset, this.staffCat.prefOrg ? this.staffCat.prefOrg.id() : null - ).subscribe(copy => { - this.copies.push(copy); - }); - } - - holdable(copy: any): boolean { - return copy.holdable === 't' - && copy.location_holdable === 't' - && copy.status_holdable === 't'; - } - - firstPage(): void { - this.pager.offset = 0; - this.fetchCopies(); + ).pipe(map(copy => { + copy.active_date = copy.active_date || copy.create_date + return copy; + })); } - prevPage(): void { - this.pager.decrement(); - this.fetchCopies(); - } - nextPage(): void { - this.pager.increment(); - this.fetchCopies(); - } - }