From 33e0d56f09a07203e2d97ebb1bc3ad280b47e106 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 24 Mar 2021 15:57:55 -0400 Subject: [PATCH] more work on fund details dialog Signed-off-by: Galen Charlton --- .../acq/funds/fund-details-dialog.component.html | 51 +++++++++++++++++++++- .../acq/funds/fund-details-dialog.component.ts | 44 +++++++++++++++++-- .../admin/acq/funds/funds-manager.component.ts | 5 +++ 3 files changed, 95 insertions(+), 5 deletions(-) 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 index ca24322929..f166e02ba6 100644 --- 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 @@ -1,3 +1,16 @@ + + + + +
+ +
+
+ + {{value}} + +
+
- + + 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 index a7c8b5fb9f..c67261e9b5 100644 --- 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 @@ -1,13 +1,17 @@ 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 {FormatService} from '@eg/core/format.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 {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component'; import {GridDataSource} from '@eg/share/grid/grid'; import {Pager} from '@eg/share/util/pager'; import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; +import {StringComponent} from '@eg/share/string/string.component'; +import {ToastService} from '@eg/share/toast/toast.service'; @Component({ selector: 'eg-fund-details-dialog', @@ -19,9 +23,15 @@ export class FundDetailsDialogComponent @Input() fundId: number; fund: IdlObject; + idlDef: any; + fieldOrder: any; acqfaDataSource: GridDataSource acqftrDataSource: GridDataSource acqfdebDataSource: GridDataSource + + @ViewChild('editDialog', { static: true }) editDialog: FmRecordEditorComponent; + @ViewChild('successString', { static: true }) successString: StringComponent; + @ViewChild('updateFailedString', { static: false }) updateFailedString: StringComponent; constructor( private idl: IdlService, @@ -29,6 +39,8 @@ export class FundDetailsDialogComponent private net: NetService, private auth: AuthService, private pcrud: PcrudService, + private format: FormatService, + private toast: ToastService, private modal: NgbModal ) { super(modal); @@ -36,10 +48,12 @@ export class FundDetailsDialogComponent ngOnInit() { this.fund = null; - this.onOpen$.subscribe(() => this.initRecord()); + this.onOpen$.subscribe(() => this._initRecord()); + this.idlDef = this.idl.classes['acqf'] + this.fieldOrder = 'name,code,year,org,active,currency_type,balance_stop_percentage,balance_warning_percentage,propagate,rollover'; } - private 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'); @@ -52,7 +66,9 @@ export class FundDetailsDialogComponent 'spent_total', 'encumbrance_total', 'debit_total', - 'allocation_total' + 'allocation_total', + 'org', + 'currency_type' ] } }).subscribe(res => this.fund = res); @@ -107,4 +123,26 @@ export class FundDetailsDialogComponent return gridSource; } + formatCurrency(value: any) { + return this.format.transform({ + value: value, + datatype: 'money' + }); + } + + openEditDialog() { + this.editDialog.recordId = this.fundId + this.editDialog.mode = 'update'; + this.editDialog.open({size: 'lg'}).subscribe( + result => { + this.successString.current() + .then(str => this.toast.success(str)); + this._initRecord(); + }, + error => { + this.updateFailedString.current() + .then(str => this.toast.danger(str)); + } + ); + } } 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 fddaca0d01..50cfd0b73a 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 @@ -2,6 +2,7 @@ import {Component, Input, ViewChild, OnInit} from '@angular/core'; import {Location} from '@angular/common'; import {FormatService} from '@eg/core/format.service'; import {GridDataSource, GridCellTextGenerator} from '@eg/share/grid/grid'; +import {GridComponent} from '@eg/share/grid/grid.component'; import {AdminPageComponent} from '@eg/staff/share/admin-page/admin-page.component'; import {Pager} from '@eg/share/util/pager'; import {ActivatedRoute} from '@angular/router'; @@ -25,6 +26,7 @@ export class FundsManagerComponent extends AdminPageComponent implements OnInit classLabel: string; @ViewChild('fundDetailsDialog', { static: false }) fundDetailsDialog: FundDetailsDialogComponent; + @ViewChild('grid', { static: true }) grid: GridComponent; cellTextGenerator: GridCellTextGenerator; @@ -117,6 +119,9 @@ export class FundsManagerComponent extends AdminPageComponent implements OnInit if (rows.length > 0) { this.fundDetailsDialog.fundId = rows[0].id(); this.fundDetailsDialog.open({size: 'xl'}).subscribe( + result => this.grid.reload(), + error => this.grid.reload(), + () => this.grid.reload() ); } } -- 2.11.0