From: Bill Erickson Date: Fri, 10 Jan 2020 20:48:51 +0000 (-0500) Subject: LPXXX Angular patron search component X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=38c7ee683654ecbeb31a7590c782ecfefee1d064;p=working%2FEvergreen.git LPXXX Angular patron search component Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts index 3d9860471f..316cd9a1f9 100644 --- a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts +++ b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts @@ -73,16 +73,19 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit { // Allow the selected entry ID to be passed via the template // This does NOT not emit onChange events. @Input() set selectedId(id: any) { - if (id) { - if (this.entrylist.length) { - this.selected = this.entrylist.filter(e => e.id === id)[0]; - } + if (id === undefined) { return; } - if (!this.selected) { - // It's possible the selected ID lives in a set of entries - // that are yet to be provided. - this.startId = id; - } + // clear on explicit null + if (id === null) { this.selected = null; } + + if (this.entrylist.length) { + this.selected = this.entrylist.filter(e => e.id === id)[0]; + } + + if (!this.selected) { + // It's possible the selected ID lives in a set of entries + // that are yet to be provided. + this.startId = id; } } 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 87dfc2bd9a..e662fd9bba 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.ts @@ -229,9 +229,11 @@ export class GridColumnSet { if (idlInfo) { col.idlFieldDef = idlInfo.idlField; col.idlClass = idlInfo.idlClass.name; + if (!col.datatype) { + col.datatype = col.idlFieldDef.datatype; + } if (!col.label) { col.label = col.idlFieldDef.label || col.idlFieldDef.name; - col.datatype = col.idlFieldDef.datatype; } } } 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 810b9507fd..fe82873505 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 @@ -6,6 +6,7 @@ import {CatalogRoutingModule} from './routing.module'; import {HoldsModule} from '@eg/staff/share/holds/holds.module'; import {HoldingsModule} from '@eg/staff/share/holdings/holdings.module'; import {BookingModule} from '@eg/staff/share/booking/booking.module'; +import {PatronModule} from '@eg/staff/share/patron/patron.module'; import {CatalogComponent} from './catalog.component'; import {SearchFormComponent} from './search-form.component'; import {ResultsComponent} from './result/results.component'; @@ -64,6 +65,7 @@ import {MarcEditModule} from '@eg/staff/share/marc-edit/marc-edit.module'; HoldsModule, HoldingsModule, BookingModule, + PatronModule, MarcEditModule ], providers: [ diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html index fa04d86ede..dca200dace 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html @@ -1,3 +1,7 @@ + + + +

Place Hold @@ -7,7 +11,7 @@

- +
+ + + + diff --git a/Open-ILS/src/eg2/src/app/staff/share/patron/search-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/share/patron/search-dialog.component.ts new file mode 100644 index 0000000000..98e1c22d72 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/patron/search-dialog.component.ts @@ -0,0 +1,36 @@ +import {Component, OnInit, Input, Output, ViewChild} from '@angular/core'; +import {IdlService, IdlObject} from '@eg/core/idl.service'; +import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; +import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {PatronSearchComponent} from './search.component'; + +/** + * Dialog container for patron search component + * + * + * + */ + +@Component({ + selector: 'eg-patron-search-dialog', + templateUrl: 'search-dialog.component.html' +}) + +export class PatronSearchDialogComponent + extends DialogComponent implements OnInit { + + @ViewChild('searchForm', {static: false}) + searchForm: PatronSearchComponent; + + constructor(private modal: NgbModal) { super(modal); } + + ngOnInit() {} + + // Fired when a row in the search grid is dbl-clicked / activated + patronsSelected(patrons: IdlObject[]) { + this.close(patrons); + } +} + + + diff --git a/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.html b/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.html index 040c420f57..f2e363217e 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.html @@ -120,9 +120,12 @@ -
+ +
diff --git a/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts b/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts index 481d8b34fc..43f4fe18db 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts @@ -40,10 +40,12 @@ const INCLUDE_INACTIVE = 'eg.circ.patron.search.include_inactive'; export class PatronSearchComponent implements OnInit, AfterViewInit { @ViewChild('searchGrid', {static: false}) searchGrid: GridComponent; + + // Fired on dbl-click of a search result row. @Output() patronsSelected: EventEmitter; search: any = {}; - searchOrg: number; + searchOrg: IdlObject; expandForm: boolean; dataSource: GridDataSource; profileGroups: IdlObject[] = []; @@ -63,7 +65,7 @@ export class PatronSearchComponent implements OnInit, AfterViewInit { } ngOnInit() { - this.searchOrg = this.org.root().id(); + this.searchOrg = this.org.root(); this.store.getItemBatch([EXPAND_FORM, INCLUDE_INACTIVE]) .then(settings => { this.expandForm = settings[EXPAND_FORM]; @@ -96,17 +98,18 @@ export class PatronSearchComponent implements OnInit, AfterViewInit { this.patronsSelected.emit([].concat(rows)); } + getSelected(): IdlObject[] { + return this.searchGrid ? + this.searchGrid.context.getSelectedRows() : []; + } + go() { this.searchGrid.reload(); } clear() { - this.search = {}; - this.searchOrg = this.org.root().id(); - } - - homeOrgChange(orgId: number) { - this.searchOrg = orgId; + this.search = {profile: null}; + this.searchOrg = this.org.root(); } getRows(pager: Pager, sort: any[]): Observable { @@ -142,7 +145,7 @@ export class PatronSearchComponent implements OnInit, AfterViewInit { pager.limit, sorter, null, // ? - this.searchOrg, + this.searchOrg.id(), DEFAULT_FLESH, pager.offset );