LP#1737019: (follow-up) more tweaks
authorGalen Charlton <gmc@equinoxOLI.org>
Tue, 21 Sep 2021 14:25:03 +0000 (10:25 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Tue, 21 Sep 2021 14:25:03 +0000 (10:25 -0400)
- When creating a new funding source, default the active flag
  in the modal to checked
- Disable actions to allocate from a funding source or
  apply credits to it if it is not active

Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funding-source-transactions-dialog.component.html
Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funding-sources.component.html
Open-ILS/src/eg2/src/app/staff/admin/acq/funds/funding-sources.component.ts

index 100c8de..22d4495 100644 (file)
@@ -29,7 +29,8 @@
                 [sortable]="true" persistKey="acq.funding_source.credit"
                 [filterable]="true" [stickyHeader]="true">
 
-              <eg-grid-toolbar-button label="Apply Credits" i18n-label (onClick)="createCredit(creditsGrid)">
+              <eg-grid-toolbar-button label="Apply Credits" i18n-label
+                [disabled]="fundingSource?.active() !== 't'" (onClick)="createCredit(creditsGrid)">
               </eg-grid-toolbar-button>
               <eg-grid-column path="amount"></eg-grid-column>
               <eg-grid-column path="effective_date" [datePlusTime]="true"></eg-grid-column>
@@ -49,7 +50,8 @@
                 [sortable]="true" persistKey="acq.funding_source.fund_allocation"
                 [filterable]="true" [stickyHeader]="true" [cellTextGenerator]="cellTextGenerator">
 
-              <eg-grid-toolbar-button label="Allocate to Fund" i18n-label (onClick)="allocateToFund(allocationsGrid)">
+              <eg-grid-toolbar-button label="Allocate to Fund" i18n-label
+                [disabled]="fundingSource?.active() !== 't'" (onClick)="allocateToFund(allocationsGrid)">
               </eg-grid-toolbar-button>
               <ng-template #fundTmpl let-row="row">
                 <a href="/eg2/staff/admin/acq/funds/fund/{{row.fund().id()}}" target="_blank">
index 4af5546..5601e3b 100644 (file)
     group="Selected" i18n-group [disableOnRows]="notOneSelectedRow">
   </eg-grid-toolbar-action>
   <eg-grid-toolbar-action label="Apply Credit" i18n-label (onClick)="createCredit($event)"
-    group="Credits" i18n-group [disableOnRows]="notOneSelectedRow">
+    group="Credits" i18n-group [disableOnRows]="notOneSelectedActiveRow">
   </eg-grid-toolbar-action>
   <eg-grid-toolbar-action label="Allocate to Fund" i18n-label (onClick)="allocateToFund($event)"
-    group="Allocations" i18n-group [disableOnRows]="notOneSelectedRow">
+    group="Allocations" i18n-group [disableOnRows]="notOneSelectedActiveRow">
   </eg-grid-toolbar-action>
   <eg-grid-toolbar-action label="View Credits" i18n-label (onClick)="openTransactionsDialog($event, 'credits')"
     group="Credits" i18n-groups [disableOnRows]="notOneSelectedRow">
index d5d541c..a3809a6 100644 (file)
@@ -42,6 +42,7 @@ export class FundingSourcesComponent extends AdminPageComponent implements OnIni
 
     cellTextGenerator: GridCellTextGenerator;
     notOneSelectedRow: (rows: IdlObject[]) => boolean;
+    notOneSelectedActiveRow: (rows: IdlObject[]) => boolean;
 
     constructor(
         route: ActivatedRoute,
@@ -64,8 +65,10 @@ export class FundingSourcesComponent extends AdminPageComponent implements OnIni
             name: row => row.name()
         };
         this.notOneSelectedRow = (rows: IdlObject[]) => (rows.length !== 1);
+        this.notOneSelectedActiveRow = (rows: IdlObject[]) => (rows.length !== 1 || rows[0].active() !== 't');
         this.fieldOrder = 'name,code,year,org,active,currency_type,balance_stop_percentage,balance_warning_percentage,propagate,rollover';
         this.defaultNewRecord = this.idl.create('acqfs');
+        this.defaultNewRecord.active(true);
         this.defaultNewRecord.owner(this.auth.user().ws_ou());
 
         this.dataSource.getRows = (pager: Pager, sort: any[]) => {