From: Galen Charlton Date: Tue, 16 Mar 2021 22:05:21 +0000 (-0400) Subject: Ang: start work on fund details dialog X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d51f4e2caadef8a9801347022b4ac26d216dd0c3;p=working%2FEvergreen.git Ang: start work on fund details dialog Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/fund-details-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/fund-details-dialog.component.html new file mode 100644 index 0000000000..5cbcd85b0e --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/fund-details-dialog.component.html @@ -0,0 +1,93 @@ + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/fund-details-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/fund-details-dialog.component.ts new file mode 100644 index 0000000000..a7c8b5fb9f --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/fund-details-dialog.component.ts @@ -0,0 +1,110 @@ +import {Component, Input, ViewChild, TemplateRef, OnInit} from '@angular/core'; +import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {IdlService, IdlObject} from '@eg/core/idl.service'; +import {EventService} from '@eg/core/event.service'; +import {NetService} from '@eg/core/net.service'; +import {AuthService} from '@eg/core/auth.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {GridDataSource} from '@eg/share/grid/grid'; +import {Pager} from '@eg/share/util/pager'; +import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; + +@Component({ + selector: 'eg-fund-details-dialog', + templateUrl: './fund-details-dialog.component.html' +}) + +export class FundDetailsDialogComponent + extends DialogComponent implements OnInit { + + @Input() fundId: number; + fund: IdlObject; + acqfaDataSource: GridDataSource + acqftrDataSource: GridDataSource + acqfdebDataSource: GridDataSource + + constructor( + private idl: IdlService, + private evt: EventService, + private net: NetService, + private auth: AuthService, + private pcrud: PcrudService, + private modal: NgbModal + ) { + super(modal); + } + + ngOnInit() { + this.fund = null; + this.onOpen$.subscribe(() => this.initRecord()); + } + + private initRecord() { + this.acqfaDataSource = this._getDataSource('acqfa', 'create_time ASC'); + this.acqftrDataSource = this._getDataSource('acqftr', 'transfer_time ASC'); + this.acqfdebDataSource = this._getDataSource('acqfdeb', 'create_time ASC'); + this.pcrud.retrieve('acqf', this.fundId, { + flesh: 1, + flesh_fields: { + acqf: [ + 'spent_balance', + 'combined_balance', + 'spent_total', + 'encumbrance_total', + 'debit_total', + 'allocation_total' + ] + } + }).subscribe(res => this.fund = res); + } + + _getDataSource(idlClass: string, sortField: string): GridDataSource { + const gridSource = new GridDataSource(); + + gridSource.getRows = (pager: Pager, sort: any[]) => { + const orderBy: any = {}; + if (sort.length) { + // Sort specified from grid + orderBy[idlClass] = sort[0].name + ' ' + sort[0].dir; + } else if (sortField) { + // Default sort field + orderBy[idlClass] = sortField; + } + + const searchOps = { + offset: pager.offset, + limit: pager.limit, + order_by: orderBy, + }; + const reqOps = { + fleshSelectors: true, + }; + + const search: any = new Array(); + if (idlClass === 'acqfa') { + search.push({ fund: this.fundId }); + } else if (idlClass === 'acqftr') { + search.push({ + '-or': [ + { src_fund: this.fundId }, + { dest_fund: this.fundId } + ] + }); + } else if (idlClass === 'acqfdeb') { + search.push({ fund: this.fundId }); + } + + Object.keys(gridSource.filters).forEach(key => { + Object.keys(gridSource.filters[key]).forEach(key2 => { + search.push(gridSource.filters[key][key2]); + }); + }); + + return this.pcrud.search( + idlClass, search, searchOps, reqOps); + }; + + return gridSource; + } + +} diff --git a/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funds-manager.component.html b/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funds-manager.component.html index e9a623b0c4..26f478a2dd 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funds-manager.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funds-manager.component.html @@ -50,6 +50,9 @@ + + @@ -96,4 +99,4 @@ [readonlyFields]="readonlyFields"> - + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funds-manager.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funds-manager.component.ts index d48643c9f3..b998184210 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funds-manager.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funds-manager.component.ts @@ -13,6 +13,7 @@ import {PermService} from '@eg/core/perm.service'; import {AuthService} from '@eg/core/auth.service'; import {NetService} from '@eg/core/net.service'; import {StringComponent} from '@eg/share/string/string.component'; +import {FundDetailsDialogComponent} from './fund-details-dialog.component'; @Component({ selector: 'eg-funds-manager', @@ -23,6 +24,8 @@ export class FundsManagerComponent extends AdminPageComponent implements OnInit idlClass = 'acqf'; classLabel: string; + @ViewChild('fundDetailsDialog', { static: true }) fundDetailsDialog: FundDetailsDialogComponent; + constructor( route: ActivatedRoute, ngLocation: Location, @@ -105,4 +108,12 @@ export class FundsManagerComponent extends AdminPageComponent implements OnInit this.classLabel = this.idlClassDef.label; this.includeOrgDescendants = true; } + + openFundDetailsDialog(rows: IdlObject[]) { + if (rows.length > 0) { + this.fundDetailsDialog.fundId = rows[0].id(); + this.fundDetailsDialog.open({size: 'xl'}).subscribe( + ); + } + } } diff --git a/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funds.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funds.module.ts index 7f3deff131..cf371e0fc4 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funds.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funds.module.ts @@ -4,11 +4,13 @@ import {AdminCommonModule} from '@eg/staff/admin/common.module'; import {FundsComponent} from './funds.component'; import {FundsRoutingModule} from './routing.module'; import {FundsManagerComponent} from './funds-manager.component'; +import {FundDetailsDialogComponent} from './fund-details-dialog.component'; @NgModule({ declarations: [ FundsComponent, - FundsManagerComponent + FundsManagerComponent, + FundDetailsDialogComponent ], imports: [ StaffCommonModule,