From 2ab5ff2f940b24fb98409aeabbdaaaef751a1f27 Mon Sep 17 00:00:00 2001 From: Jonathan Niles Date: Tue, 9 Aug 2016 11:35:12 +0100 Subject: [PATCH] fix(journal): ensure col aggregates are displayed This commit ensures that the column aggregates for debits, credits, descriptions, and dates are shown on the grid group headers. Because of careless cell template design, these values were not substituted into the templates in a previous iteration. Closes #626. --- client/src/js/components/bhInfo.js | 2 +- client/src/js/services/grid/GridGrouping.js | 29 ++++++++++++++----- .../journal/templates/credit.cell.html | 8 +++-- .../journal/templates/credit_equiv.cell.html | 6 +++- .../journal/templates/debit.cell.html | 10 +++++-- .../journal/templates/debit_equiv.cell.html | 6 +++- 6 files changed, 47 insertions(+), 14 deletions(-) diff --git a/client/src/js/components/bhInfo.js b/client/src/js/components/bhInfo.js index 37c2a48ea3..14f61e26e2 100644 --- a/client/src/js/components/bhInfo.js +++ b/client/src/js/components/bhInfo.js @@ -6,7 +6,7 @@ angular.module('bhima.components') ' uib-popover-template="$ctrl.template" ' + ' popover-placement="right" ' + ' popover-append-to-body="true" ' + - ' popover-trigger="mouseenter"> ' + + ' popover-trigger="\'mouseenter\'"> ' + ' ', bindings : { template: '@', diff --git a/client/src/js/services/grid/GridGrouping.js b/client/src/js/services/grid/GridGrouping.js index 65a2a1f533..7f0d26ba98 100644 --- a/client/src/js/services/grid/GridGrouping.js +++ b/client/src/js/services/grid/GridGrouping.js @@ -20,12 +20,15 @@ function GridGroupingService(uiGridGroupingConstants, $filter, Session, $timeout // cache the currency filter for later lookup var $currency = $filter('currency'); + // alias copy + var copy = angular.copy; + /** @const renders any currencied amount */ var DEFAULT_COST_AGGREGATOR = { // used to render amounts in the aggregate columns // TODO - this should render the currency from the row set. - customTreeAggregationFinalizerFn : function amountRenderer(aggregation) { + customTreeAggregationFinalizerFn : function (aggregation) { aggregation.rendered = $currency(aggregation.value, currencyId); }, @@ -33,17 +36,29 @@ function GridGroupingService(uiGridGroupingConstants, $filter, Session, $timeout }; /** @const aggregates quantities as needed */ - var DEFAULT_QUANTITY_AGGREGATOR= { + var DEFAULT_QUANTITY_AGGREGATOR = { treeAggregationType : uiGridGroupingConstants.aggregation.SUM, }; + /** @const aggregates by choosing a single item to display */ + /** @todo - this currently defaults to MAX, should be implemented as its own custom aggregator */ + var DEFAULT_SINGLE_AGGREGATOR = { + treeAggregationType: uiGridGroupingConstants.aggregation.MAX, + customTreeAggregationFinalizerFn: function (aggregation) { + aggregation.rendered = aggregation.value; + } + }; + /** @const aggregators assigned by column ids */ var DEFAULT_AGGREGATORS = { - 'debit_equiv' : DEFAULT_COST_AGGREGATOR, - 'credit_equiv' : DEFAULT_COST_AGGREGATOR, - 'cost' : DEFAULT_COST_AGGREGATOR, - 'quantity' : DEFAULT_QUANTITY_AGGREGATOR, - 'amount' : DEFAULT_QUANTITY_AGGREGATOR + 'debit_equiv' : copy(DEFAULT_COST_AGGREGATOR), + 'credit_equiv' : copy(DEFAULT_COST_AGGREGATOR), + 'cost' : copy(DEFAULT_COST_AGGREGATOR), + 'quantity' : copy(DEFAULT_QUANTITY_AGGREGATOR), + 'amount' : copy(DEFAULT_QUANTITY_AGGREGATOR), + 'description' : copy(DEFAULT_SINGLE_AGGREGATOR), + 'date' : copy(DEFAULT_SINGLE_AGGREGATOR), + 'trans_date' : copy(DEFAULT_SINGLE_AGGREGATOR), // TODO - eliminate this in favor of "date" }; /** diff --git a/client/src/partials/journal/templates/credit.cell.html b/client/src/partials/journal/templates/credit.cell.html index e5f1f99aa9..cfff2a5dd9 100644 --- a/client/src/partials/journal/templates/credit.cell.html +++ b/client/src/partials/journal/templates/credit.cell.html @@ -1,3 +1,7 @@ -
- {{ row.entity.credit_equiv | currency:row.entity.currency_id }} +
+ {{ row.entity.credit | currency:row.entity.currency_id }} +
+ +
+ {{ COL_FIELD CUSTOM_FILTERS }}
diff --git a/client/src/partials/journal/templates/credit_equiv.cell.html b/client/src/partials/journal/templates/credit_equiv.cell.html index 9550f4a27c..2b8ea3b56f 100644 --- a/client/src/partials/journal/templates/credit_equiv.cell.html +++ b/client/src/partials/journal/templates/credit_equiv.cell.html @@ -1,3 +1,7 @@ -
+
{{ row.entity.credit_equiv | currency:grid.appScope.enterprise.currency_id }}
+ +
+ {{ COL_FIELD CUSTOM_FILTERS }} +
diff --git a/client/src/partials/journal/templates/debit.cell.html b/client/src/partials/journal/templates/debit.cell.html index 73fcacb939..a2225cb128 100644 --- a/client/src/partials/journal/templates/debit.cell.html +++ b/client/src/partials/journal/templates/debit.cell.html @@ -1,3 +1,9 @@ -
- {{ row.entity.debit_equiv | currency:row.entity.currency_id }} +
+ {{ row.entity.debit | currency:row.entity.currency_id }}
+ +
+ {{COL_FIELD CUSTOM_FILTERS}} +
+ + diff --git a/client/src/partials/journal/templates/debit_equiv.cell.html b/client/src/partials/journal/templates/debit_equiv.cell.html index 0ba2df420d..577d3d653f 100644 --- a/client/src/partials/journal/templates/debit_equiv.cell.html +++ b/client/src/partials/journal/templates/debit_equiv.cell.html @@ -1,3 +1,7 @@ -
+
{{ row.entity.debit_equiv | currency:grid.appScope.enterprise.currency_id }}
+ +
+ {{ COL_FIELD CUSTOM_FILTERS }} +