add line item search results grid
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 1 Nov 2019 01:35:18 +0000 (21:35 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 16 Jan 2020 21:38:28 +0000 (16:38 -0500)
TODO:

- make invoice link on the results table link to an invoice
  search once we're further along
- move the search to a separate service

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.html
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.module.ts
Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts [new file with mode: 0644]

index a56d0d3..43439ae 100644 (file)
@@ -8,6 +8,7 @@
   <div class="col-lg-12">
     <ngb-tabset #acqSearchTabs [activeId]="searchType" (tabChange)="onTabChange($event)" type="pills">
       <ngb-tab title="Line Items Search" i18n-title id="lineitems">
+        <ng-template ngbTabContent><eg-lineitem-results></eg-lineitem-results></ng-template>
       </ngb-tab>
       <ngb-tab title="Purchase Orders Search" i18n-title id="purchaseorders">
       </ngb-tab>
index 985cb0e..f294a10 100644 (file)
@@ -2,6 +2,7 @@ import {Component, OnInit, AfterViewInit, ViewChild} from '@angular/core';
 import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap';
 import {Router, ActivatedRoute} from '@angular/router';
 import {StaffCommonModule} from '@eg/staff/common.module';
+import {LineitemResultsComponent} from './lineitem-results.component';
 
 @Component({
   templateUrl: './acq-search.component.html'
index 0a08454..b0d73e8 100644 (file)
@@ -2,10 +2,12 @@ import {NgModule} from '@angular/core';
 import {StaffCommonModule} from '@eg/staff/common.module';
 import {AcqSearchRoutingModule} from './routing.module';
 import {AcqSearchComponent} from './acq-search.component';
+import {LineitemResultsComponent} from './lineitem-results.component';
 
 @NgModule({
   declarations: [
-    AcqSearchComponent
+    AcqSearchComponent,
+    LineitemResultsComponent
   ],
   imports: [
     StaffCommonModule,
diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html
new file mode 100644 (file)
index 0000000..ba1e7d7
--- /dev/null
@@ -0,0 +1,57 @@
+<ng-template #idTmpl let-lineitem="row">
+  <a href="/eg/staff/acq/legacy/po/view/{{lineitem.purchase_order()}}?focus_li={{lineitem.id()}}"
+     target="_blank">
+    {{lineitem.id()}}
+  </a>
+</ng-template>
+
+<ng-template #liAttrTmpl let-lineitem="row" let-col="col">
+  <ng-container *ngFor="let lia of lineitem.attributes()">
+    <ng-container *ngIf="lia.attr_name() === col.path">
+      {{lia.attr_value()}}
+    </ng-container>
+  </ng-container>
+</ng-template>
+
+<ng-template #providerTmpl let-lineitem="row">
+  <a href="/eg/staff/admin/acq/conify/provider/{{lineitem.provider().id()}}"
+     target="_blank">
+    {{lineitem.provider().name()}}
+  </a>
+</ng-template>
+
+<ng-template #liLinksTmpl let-lineitem="row">
+  <ul>
+    <li><a href="/eg/staff/cat/catalog/record/{{lineitem.eg_bib_id()}}"
+     target="_blank" i18n>Catalog</a></li>
+    <li><a href="/eg/staff/acq/legacy/lineitem/worksheet/{{lineitem.id()}}"
+           target="_blank" i18n>Worksheet</a></li>
+    <li *ngIf="lineitem.purchase_order()">
+      <a href="/eg/staff/acq/legacy/po/view/{{lineitem.purchase_order()}}"
+          target="_blank" i18n>Purchase Order</a></li>
+    <li><a href="/eg/staff/acq/requests/lineitem/{{lineitem.id()}}"
+           target="_blank" i18n>Requests</a></li>
+    <li>Invoices TODO; awaits Angular invoice search</li>
+    <li *ngIf="lineitem.queued_record()">
+      <a routerLink="/staff/cat/vandelay/queue/bib/{{lineitem.queued_record().queue()}}"
+        target="_blank" i18n>Queue</a></li>
+    <li *ngIf="lineitem.picklist()">
+      <a href="/eg/staff/acq/legacy/picklist/view/{{lineitem.picklist()}}"
+        target="_blank" i18n>Selection List</a></li>
+  </ul>
+</ng-template>
+
+<eg-grid #acqSearchLineitemsGrid
+  persistKey="acq.search.lineitems"
+  idlClass="jub" [dataSource]="gridSource"
+  [showDeclaredFieldsOnly]="true">
+
+  <eg-grid-column path="id" [cellTemplate]="idTmpl"></eg-grid-column>
+  <eg-grid-column i18n-label label="Title" path="title" [cellTemplate]="liAttrTmpl"></eg-grid-column>
+  <eg-grid-column i18n-label label="Author" path="author" [cellTemplate]="liAttrTmpl"></eg-grid-column>
+  <eg-grid-column path="provider.name" [cellTemplate]="providerTmpl"></eg-grid-column>
+  <eg-grid-column i18n-label label="Links" path="_links" [cellTemplate]="liLinksTmpl"></eg-grid-column>
+  <eg-grid-column path="claim_policy.name"></eg-grid-column>
+  <eg-grid-column i18n-label label="Status" path="state"></eg-grid-column>
+  <eg-grid-column path="estimated_unit_price"></eg-grid-column>
+</eg-grid>
diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts
new file mode 100644 (file)
index 0000000..ba63b50
--- /dev/null
@@ -0,0 +1,56 @@
+import {Component, OnInit, ViewChild} from '@angular/core';
+import {Observable} from 'rxjs';
+import {map} from 'rxjs/operators';
+import {Router, ActivatedRoute, ParamMap} from '@angular/router';
+import {Pager} from '@eg/share/util/pager';
+import {IdlObject} from '@eg/core/idl.service';
+import {NetService} from '@eg/core/net.service';
+import {AuthService} from '@eg/core/auth.service';
+import {GridComponent} from '@eg/share/grid/grid.component';
+import {GridDataSource} from '@eg/share/grid/grid';
+
+@Component({
+  selector: 'eg-lineitem-results',
+  templateUrl: 'lineitem-results.component.html'
+})
+export class LineitemResultsComponent {
+
+    gridSource: GridDataSource;
+    @ViewChild('acqSearchLineitemsGrid', { static: true }) lineitemResultsGrid: GridComponent;
+
+    constructor(
+        private router: Router,
+        private route: ActivatedRoute,
+        private net: NetService,
+        private auth: AuthService) {
+
+        this.gridSource = new GridDataSource();
+
+        this.gridSource.getRows = (pager: Pager) => {
+            return this.net.request(
+                'open-ils.acq',
+                'open-ils.acq.lineitem.unified_search',
+                    this.auth.token(),
+                    {
+                        jub: [{
+                            id: "0",
+                            __gte: true
+                        }]
+                    },
+                    null,
+                    null,
+                    {
+                        flesh_attrs: true,
+                        flesh_cancel_reason: true,
+                        flesh_notes: true,
+                        flesh_provider: true,
+                        flesh_claim_policy: true,
+                        flesh_queued_record: true,
+                        offset: pager.offset,
+                        limit: pager.limit
+                    }
+            );
+        };
+    }
+
+}