<ng-template ngbTabContent><eg-lineitem-results></eg-lineitem-results></ng-template>
</ngb-tab>
<ngb-tab title="Purchase Orders Search" i18n-title id="purchaseorders">
+ <ng-template ngbTabContent><eg-purchase-order-results></eg-purchase-order-results></ng-template>
</ngb-tab>
<ngb-tab title="Invoices Search" i18n-title id="invoices">
+ <ng-template ngbTabContent><eg-invoice-results></eg-invoice-results></ng-template>
</ngb-tab>
<ngb-tab title="Selection Lists Search" i18n-title id="selectionlists">
+ <ng-template ngbTabContent><eg-picklist-results></eg-picklist-results></ng-template>
</ngb-tab>
</ngb-tabset>
</div>
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'
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 {
--- /dev/null
+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;
+ }
+}
--- /dev/null
+<eg-grid #acqSearchInvoicesGrid
+ persistKey="acq.search.invoices"
+ idlClass="acqinv" [dataSource]="gridSource">
+</eg-grid>
--- /dev/null
+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');
+ }
+
+}
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 {
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');
}
}
--- /dev/null
+<eg-grid #acqSearchPicklistsGrid
+ persistKey="acq.search.selectionlists"
+ idlClass="acqpl" [dataSource]="gridSource">
+</eg-grid>
--- /dev/null
+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');
+ }
+
+}
--- /dev/null
+<eg-grid #acqSearchPurchaseOrdersGrid
+ persistKey="acq.search.purchaseorders"
+ idlClass="acqpo" [dataSource]="gridSource">
+</eg-grid>
--- /dev/null
+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');
+ }
+
+}