+<eg-string #successString i18n-text text="Fund Update Succeeded"></eg-string>
+<eg-string #updateFailedString i18n-text text="Fund Update Failed"></eg-string>
+
+<ng-template #summaryField let-field="field" let-value="value">
+ <div class="col-2">
+ <label style="font-weight: bold" for="fund-{{field}}">{{idlDef.field_map[field].label}}</label>
+ </div>
+ <div class="col-2">
+ <span id="fund-{{field}}">
+ {{value}}
+ </span>
+ </div>
+</ng-template>
<ng-template #dialogContent>
<div class="modal-header bg-info" *ngIf="fund">
<h3 class="modal-title" i18n>Fund Details - {{fund.name()}} ({{fund.code()}} {{fund.year()}})</h3>
<span aria-hidden="true">×</span>
</button>
</div>
- <div class="modal-body">
+ <div class="modal-body" *ngIf="fund">
<ul ngbNav #fundDetailsNav="ngbNav" class="nav-tabs">
<li ngbNavItem>
<a ngbNavLink i18n>Summary</a>
<ng-template ngbNavContent>
<div class="mt-2">
- </div>
+ <div class="row">
+ <button class="btn btn-info ml-3" (click)="openEditDialog()" i18n>Edit Fund</button>
+ </div>
+ <div class="row">
+ <ng-container *ngTemplateOutlet="summaryField;context:{value:fund.code(),field:'code'}"></ng-container>
+ <ng-container *ngTemplateOutlet="summaryField;context:{value:fund.name(),field:'name'}"></ng-container>
+ </div>
+ <div class="row">
+ <ng-container *ngTemplateOutlet="summaryField;context:{value:fund.id(),field:'id'}"></ng-container>
+ <ng-container *ngTemplateOutlet="summaryField;context:{value:fund.year(),field:'year'}"></ng-container>
+ </div>
+ <div class="row">
+ <ng-container *ngTemplateOutlet="summaryField;context:{value:fund.org().shortname(),field:'org'}"></ng-container>
+ <ng-container *ngTemplateOutlet="summaryField;context:{value:fund.currency_type().code(),field:'currency_type'}"></ng-container>
+ </div>
+ <div class="row">
+ <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.combined_balance()?.amount()),field:'combined_balance'}"></ng-container>
+ <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.allocation_total()?.amount()),field:'allocation_total'}"></ng-container>
+ </div>
+ <div class="row">
+ <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.spent_balance()?.amount()),field:'spent_balance'}"></ng-container>
+ <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.debit_total()?.amount()),field:'debit_total'}"></ng-container>
+ </div>
+ <div class="row">
+ <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.spent_total()?.amount()),field:'spent_total'}"></ng-container>
+ <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.encumbrance_total()?.amount()),field:'encumbrance_total'}"></ng-container>
+ </div>
+ </div>
</ng-template>
</li>
<li ngbNavItem>
</div>
</ng-template>
+<eg-fm-record-editor #editDialog idlClass="acqf"
+ [fieldOptions]="fieldOptions"
+ [fieldOrder]="fieldOrder"
+ [defaultNewRecord]="defaultNewRecord"
+ [preloadLinkedValues]="true"
+ [readonlyFields]="readonlyFields">
+</eg-fm-record-editor>
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',
@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,
private net: NetService,
private auth: AuthService,
private pcrud: PcrudService,
+ private format: FormatService,
+ private toast: ToastService,
private modal: NgbModal
) {
super(modal);
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');
'spent_total',
'encumbrance_total',
'debit_total',
- 'allocation_total'
+ 'allocation_total',
+ 'org',
+ 'currency_type'
]
}
}).subscribe(res => this.fund = res);
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));
+ }
+ );
+ }
}
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';
classLabel: string;
@ViewChild('fundDetailsDialog', { static: false }) fundDetailsDialog: FundDetailsDialogComponent;
+ @ViewChild('grid', { static: true }) grid: GridComponent;
cellTextGenerator: GridCellTextGenerator;
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()
);
}
}