From dd1c4bf09dd24f2bbb199885f0fb42126fb2c0a2 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 1 Nov 2019 11:16:26 -0400 Subject: [PATCH] first pass at AcqSearchService This adds AcqSearchService, which knows how to produce a GridDataSource of the appropriate type and default search parameters and options. This also adds results components for purchase orders, invoices, and selection lists. Note that the new results components don't customize the columns that are displayed. AcqSearchService is intentionally _not_ set up as a singleton, and instead is used as a provider by the four results components. This can be changed if a reason turns up later to have the service retain some state for the duration of the application session (as opposed to the duration of the results component; note that this may mean that the results component will need to embed the search form component so that it can readily share the grid data source with it). Signed-off-by: Galen Charlton --- .../app/staff/acq/search/acq-search.component.html | 3 + .../app/staff/acq/search/acq-search.component.ts | 3 + .../src/app/staff/acq/search/acq-search.module.ts | 10 ++- .../src/app/staff/acq/search/acq-search.service.ts | 85 ++++++++++++++++++++++ .../acq/search/invoice-results.component.html | 4 + .../staff/acq/search/invoice-results.component.ts | 35 +++++++++ .../staff/acq/search/lineitem-results.component.ts | 37 ++-------- .../acq/search/picklist-results.component.html | 4 + .../staff/acq/search/picklist-results.component.ts | 35 +++++++++ .../search/purchase-order-results.component.html | 4 + .../acq/search/purchase-order-results.component.ts | 35 +++++++++ 11 files changed, 224 insertions(+), 31 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.html index 43439aeee2..d1d43eeb9e 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.html @@ -11,10 +11,13 @@ + + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts index f294a108f8..9e92d5b46d 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts @@ -3,6 +3,9 @@ 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'; +import {PurchaseOrderResultsComponent} from './purchase-order-results.component'; +import {InvoiceResultsComponent} from './invoice-results.component'; +import {PicklistResultsComponent} from './picklist-results.component'; @Component({ templateUrl: './acq-search.component.html' diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.module.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.module.ts index b0d73e8e26..85515babe3 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.module.ts @@ -3,16 +3,22 @@ import {StaffCommonModule} from '@eg/staff/common.module'; import {AcqSearchRoutingModule} from './routing.module'; import {AcqSearchComponent} from './acq-search.component'; import {LineitemResultsComponent} from './lineitem-results.component'; +import {PurchaseOrderResultsComponent} from './purchase-order-results.component'; +import {InvoiceResultsComponent} from './invoice-results.component'; +import {PicklistResultsComponent} from './picklist-results.component'; @NgModule({ declarations: [ AcqSearchComponent, - LineitemResultsComponent + LineitemResultsComponent, + PurchaseOrderResultsComponent, + InvoiceResultsComponent, + PicklistResultsComponent ], imports: [ StaffCommonModule, AcqSearchRoutingModule - ], + ] }) export class AcqSearchModule { diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts new file mode 100644 index 0000000000..dbe224c828 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts @@ -0,0 +1,85 @@ +import {Injectable} from '@angular/core'; +import {NetService} from '@eg/core/net.service'; +import {AuthService} from '@eg/core/auth.service'; +import {GridDataSource} from '@eg/share/grid/grid'; +import {Pager} from '@eg/share/util/pager'; + +// TODO: replace with search parameters coming from +// search form and grid filters +const defaultSearch = { + lineitem: { + jub: [{ + id: "0", + __gte: true + }] + }, + purchase_order: { + acqpo: [{ + id: "0", + __gte: true + }] + }, + picklist: { + acqpl: [{ + id: "0", + __gte: true + }] + }, + invoice: { + acqinv: [{ + id: "0", + __gte: true + }] + }, +} + +const searchOptions = { + lineitem: { + flesh_attrs: true, + flesh_cancel_reason: true, + flesh_notes: true, + flesh_provider: true, + flesh_claim_policy: true, + flesh_queued_record: true, + }, + purchase_order: { + no_flesh_cancel_reason: true, + }, + picklist: { + flesh_lineitem_count: true, + flesh_owner: true + }, + invoice: { + no_flesh_misc: true + } +}; + +@Injectable() +export class AcqSearchService { + + constructor( + private net: NetService, + private auth: AuthService + ) { + } + + getAcqSearchDataSource(searchType: string): GridDataSource { + let gridSource = new GridDataSource(); + + gridSource.getRows = (pager: Pager) => { + let opts = { ...searchOptions[searchType] }; + opts['offset'] = pager.offset; + opts['limit'] = pager.limit; + return this.net.request( + 'open-ils.acq', + 'open-ils.acq.' + searchType + '.unified_search', + this.auth.token(), + defaultSearch[searchType], + null, + null, + opts + ); + }; + return gridSource; + } +} diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html new file mode 100644 index 0000000000..fd8b5928b8 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html @@ -0,0 +1,4 @@ + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.ts new file mode 100644 index 0000000000..d06c90d762 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.ts @@ -0,0 +1,35 @@ +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'; +import {AcqSearchService} from './acq-search.service'; + +@Component({ + selector: 'eg-invoice-results', + templateUrl: 'invoice-results.component.html', + providers: [AcqSearchService] +}) +export class InvoiceResultsComponent { + + gridSource: GridDataSource; + @ViewChild('acqSearchInvoicesGrid', { static: true }) invoiceResultsGrid: GridComponent; + + constructor( + private router: Router, + private route: ActivatedRoute, + private net: NetService, + private auth: AuthService, + private acqSearch: AcqSearchService) { + } + + ngOnInit() { + this.gridSource = this.acqSearch.getAcqSearchDataSource('invoice'); + } + +} 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 index ba63b504a9..fa96b96b2e 100644 --- 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 @@ -8,10 +8,12 @@ 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'; +import {AcqSearchService} from './acq-search.service'; @Component({ selector: 'eg-lineitem-results', - templateUrl: 'lineitem-results.component.html' + templateUrl: 'lineitem-results.component.html', + providers: [AcqSearchService] }) export class LineitemResultsComponent { @@ -22,35 +24,12 @@ export class LineitemResultsComponent { private router: Router, private route: ActivatedRoute, private net: NetService, - private auth: AuthService) { - - this.gridSource = new GridDataSource(); + private auth: AuthService, + private acqSearch: AcqSearchService) { + } - 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 - } - ); - }; + ngOnInit() { + this.gridSource = this.acqSearch.getAcqSearchDataSource('lineitem'); } } diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html new file mode 100644 index 0000000000..fab0164c8a --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html @@ -0,0 +1,4 @@ + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts new file mode 100644 index 0000000000..cfd2634f58 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts @@ -0,0 +1,35 @@ +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'; +import {AcqSearchService} from './acq-search.service'; + +@Component({ + selector: 'eg-picklist-results', + templateUrl: 'picklist-results.component.html', + providers: [AcqSearchService] +}) +export class PicklistResultsComponent { + + gridSource: GridDataSource; + @ViewChild('acqSearchPicklistsGrid', { static: true }) picklistResultsGrid: GridComponent; + + constructor( + private router: Router, + private route: ActivatedRoute, + private net: NetService, + private auth: AuthService, + private acqSearch: AcqSearchService) { + } + + ngOnInit() { + this.gridSource = this.acqSearch.getAcqSearchDataSource('picklist'); + } + +} diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.html new file mode 100644 index 0000000000..87e768ec09 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.html @@ -0,0 +1,4 @@ + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.ts new file mode 100644 index 0000000000..dcb1d247ff --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.ts @@ -0,0 +1,35 @@ +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'; +import {AcqSearchService} from './acq-search.service'; + +@Component({ + selector: 'eg-purchase-order-results', + templateUrl: 'purchase-order-results.component.html', + providers: [AcqSearchService] +}) +export class PurchaseOrderResultsComponent { + + gridSource: GridDataSource; + @ViewChild('acqSearchPurchaseOrdersGrid', { static: true }) purchaseOrderResultsGrid: GridComponent; + + constructor( + private router: Router, + private route: ActivatedRoute, + private net: NetService, + private auth: AuthService, + private acqSearch: AcqSearchService) { + } + + ngOnInit() { + this.gridSource = this.acqSearch.getAcqSearchDataSource('purchase_order'); + } + +} -- 2.11.0