From: Bill Erickson Date: Sun, 10 Dec 2017 19:19:42 +0000 (-0500) Subject: LP#626157 Ang2 experiments X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0a16b99292bd60a8e6dbdae0e9807a4c88dd777a;p=working%2FEvergreen.git LP#626157 Ang2 experiments Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/webby-src/src/app/share/catalog/catalog.service.ts b/Open-ILS/webby-src/src/app/share/catalog/catalog.service.ts index a86fbe839a..7e3d8d644f 100644 --- a/Open-ILS/webby-src/src/app/share/catalog/catalog.service.ts +++ b/Open-ILS/webby-src/src/app/share/catalog/catalog.service.ts @@ -68,6 +68,11 @@ export class EgCatalogService { let method = 'open-ils.search.biblio.multiclass.query'; if (ctx.isStaff) method += '.staff'; + // Grab a few pages worth of IDs + let limit = Math.max(ctx.pager.limit, 100); + + // TODO: reset context result IDs for all searches except for paging + return new Promise((resolve, reject) => { this.net.request( 'open-ils.search', method, { @@ -75,25 +80,36 @@ export class EgCatalogService { offset : ctx.pager.offset }, fullQuery, true ).subscribe(result => { - ctx.result = result; - ctx.result.records = []; - ctx.pager.resultCount = result.count; + this.applyResultData(ctx, result); ctx.searchState = CatalogSearchState.COMPLETE; resolve(); }); }) } + applyResultData(ctx: CatalogSearchContext, result: any): void { + ctx.result = result; + ctx.pager.resultCount = result.count; + + // records[] tracks the current page of bib summaries. + result.records = []; + + // If this is a new search, reset the result IDs collection. + if (this.lastFacetKey != result.facet_key) ctx.resultIds = []; + + result.ids.forEach((blob, idx) => {ctx.addResultId(blob[0], idx)}); + } + fetchBibSummaries(ctx: CatalogSearchContext): Promise { let promises = []; - ctx.result.ids.forEach((blob, idx) => { + let depth = ctx.global ? + ctx.org.root().ou_type().depth() : + ctx.searchOrg.ou_type().depth(); + + ctx.currentResultIds().forEach((recId, idx) => { promises.push( - this.getBibSummary(blob[0], - ctx.searchOrg.id(), - ctx.global ? - ctx.org.root().ou_type().depth() : - ctx.searchOrg.ou_type().depth() - ).then( + this.getBibSummary(recId, ctx.searchOrg.id(), depth) + .then( // idx maintains result sort order summary => ctx.result.records[idx] = summary ) diff --git a/Open-ILS/webby-src/src/app/share/catalog/search-context.ts b/Open-ILS/webby-src/src/app/share/catalog/search-context.ts index af22ed1a8b..5503580e81 100644 --- a/Open-ILS/webby-src/src/app/share/catalog/search-context.ts +++ b/Open-ILS/webby-src/src/app/share/catalog/search-context.ts @@ -53,6 +53,9 @@ export class CatalogSearchContext { result: any = {}; searchState: CatalogSearchState = CatalogSearchState.PENDING; + // List of IDs in page/offset context. + resultIds: number[] = []; + // Utility stuff pager: Pager; org: EgOrgService; @@ -62,6 +65,35 @@ export class CatalogSearchContext { this.reset(); } + // List of result IDs for the current page of data. + currentResultIds(): number[] { + let ids = []; + for ( + let idx = this.pager.offset; + idx < this.pager.offset + this.pager.limit; + idx++ + ) {ids.push(this.resultIds[idx])} + return ids; + } + + addResultId(id: number, resultIdx: number ): void { + this.resultIds[resultIdx + this.pager.offset] = id; + } + + // Return the record at the requested index. + resultIdAt(index: number): number { + return this.resultIds[index] || null; + } + + // Return the index of the requested record + indexForResult(id: number): number { + for (let i = 0; i < this.resultIds.length; i++) { + if (this.resultIds[i] == id) + return i; + } + return null; + } + /** * Reset search parameters. This does not reset global filters * like limit-to-available and search-global. diff --git a/Open-ILS/webby-src/src/app/staff/catalog/record/copies.component.css b/Open-ILS/webby-src/src/app/staff/catalog/record/copies.component.css index 422af1a07a..6c08652de5 100644 --- a/Open-ILS/webby-src/src/app/staff/catalog/record/copies.component.css +++ b/Open-ILS/webby-src/src/app/staff/catalog/record/copies.component.css @@ -5,3 +5,6 @@ border-left: 1px solid rgba(0,0,0,0.2); */ } +/* +.eg-copies .pagination {margin: 0px 0px 0px 0px} +*/ diff --git a/Open-ILS/webby-src/src/app/staff/catalog/record/copies.component.html b/Open-ILS/webby-src/src/app/staff/catalog/record/copies.component.html index de8f32242b..79984ff636 100644 --- a/Open-ILS/webby-src/src/app/staff/catalog/record/copies.component.html +++ b/Open-ILS/webby-src/src/app/staff/catalog/record/copies.component.html @@ -7,49 +7,74 @@ padding: .25rem; } -
-
-
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 +
    + +
    +
    +
    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.copy_status}}
      -
      {{copy.due_date | date:'shortDate'}}
      -
    -
  • -
+ + +
diff --git a/Open-ILS/webby-src/src/app/staff/catalog/record/copies.component.ts b/Open-ILS/webby-src/src/app/staff/catalog/record/copies.component.ts index 33107eccf7..94ad3c7fdf 100644 --- a/Open-ILS/webby-src/src/app/staff/catalog/record/copies.component.ts +++ b/Open-ILS/webby-src/src/app/staff/catalog/record/copies.component.ts @@ -12,7 +12,7 @@ import {EgOrgService} from '@eg/core/org'; export class CopiesComponent implements OnInit { pager: Pager; - copies: any[]; + copies: any[] recId: number; initDone: boolean = false; @@ -67,6 +67,19 @@ export class CopiesComponent implements OnInit { && copy.status_holdable == 't'; } + firstPage(): void { + this.pager.offset = 0; + this.fetchCopies(); + } + prevPage(): void { + this.pager.decrement(); + this.fetchCopies(); + } + nextPage(): void { + this.pager.increment(); + this.fetchCopies(); + } + } diff --git a/Open-ILS/webby-src/src/app/staff/catalog/record/pagination.component.css b/Open-ILS/webby-src/src/app/staff/catalog/record/pagination.component.css index 262903d6cf..8b6be46d70 100644 --- a/Open-ILS/webby-src/src/app/staff/catalog/record/pagination.component.css +++ b/Open-ILS/webby-src/src/app/staff/catalog/record/pagination.component.css @@ -1,5 +1,7 @@ /* Bootstrap default is 20px */ +/* .pagination {margin: 0px 0px 0px 0px} +*/ diff --git a/Open-ILS/webby-src/src/app/staff/catalog/record/pagination.component.html b/Open-ILS/webby-src/src/app/staff/catalog/record/pagination.component.html index 65c413ea66..0edcded4cc 100644 --- a/Open-ILS/webby-src/src/app/staff/catalog/record/pagination.component.html +++ b/Open-ILS/webby-src/src/app/staff/catalog/record/pagination.component.html @@ -1,38 +1,33 @@ -