Skip to content

Commit

Permalink
fix(grid): enable inline date filtering
Browse files Browse the repository at this point in the history
The inline date filters were all broken previously during an API change
that did not update the grids with the new API.  Additionally, the old
method did not work due to a syntax issue with the `moment().format()`
call.  This has been corrected by using an upper-cased version of the
bhConstant's date format.

Additionally, this commit bumps ui-grid's version to 4.0.4 to take
advantage of performance improvements.
  • Loading branch information
Jonathan Niles authored and jniles committed Apr 8, 2017
1 parent 728f229 commit 4780410
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 24 deletions.
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
"angular-messages": "1.6.2",
"angular-bootstrap": "2.5.0",
"angular-ui-router": "~1.0.0",
"angular-ui-grid": "4.0.2",
"angular-ui-grid": "4.0.4",
"angular-translate": "2.15.1",
"angular-translate-loader-static-files": "2.15.1",
"angular-translate-loader-url": "2.15.1",
"jquery": "3.2.0",
"jquery": "3.2.1",
"ng-file-upload": "12.2.13",
"bootstrap": "3.3.7",
"angular-moment": "1.0.1",
Expand Down
10 changes: 5 additions & 5 deletions client/src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,15 @@ function constantConfig() {
},
utilBar : {
height : UTIL_BAR_HEIGHT,
expandedHeightStyle : { 'height': 'calc(100vh - '.concat(UTIL_BAR_HEIGHT, ')') },
collapsedHeightStyle : {}
expandedHeightStyle : { height: 'calc(100vh - '.concat(UTIL_BAR_HEIGHT, ')') },
collapsedHeightStyle : {},
},
identifiers : {
PATIENT : {
key : 'PA',
table : 'patient'
}
}
table : 'patient',
},
},
};
}

Expand Down
4 changes: 3 additions & 1 deletion client/src/js/services/grid/GridFiltering.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ GridFilteringService.$inject = ['appcache', 'uiGridConstants', 'util', 'moment',
function GridFilteringService(AppCache, uiGridConstants, util, moment, bhConstants) {
var serviceKey = '-Filtering';

var DATE_FORMAT = bhConstants.dates.format.toUpperCase();

function GridFiltering(gridOptions, cacheKey) {
this.gridOptions = gridOptions;

Expand All @@ -36,7 +38,7 @@ function GridFilteringService(AppCache, uiGridConstants, util, moment, bhConstan
* configured for the application.
*/
GridFiltering.prototype.filterByDate = function filterByDate(searchValue, cellValue) {
var cellDateString = moment(cellValue).format(bhConstants.dates.format);
var cellDateString = moment(cellValue).format(DATE_FORMAT);
return cellDateString.indexOf(searchValue.replace(/\\/g, '')) !== -1;
};

Expand Down
2 changes: 1 addition & 1 deletion client/src/partials/general_ledger/general_ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function GeneralLedgerController(GeneralLedger, Sorting, Grouping, Filtering, Co
displayName : 'TABLE.COLUMNS.DATE',
headerCellFilter: 'translate',
cellFilter : 'date:"mediumDate"',
filter : { condition : filtering.byDate },
filter : { condition : filtering.filterByDate },
footerCellTemplate:'<i></i>'
},
{ field : 'description', displayName : 'TABLE.COLUMNS.DESCRIPTION', headerCellFilter: 'translate', footerCellTemplate:'<i></i>' },
Expand Down
19 changes: 9 additions & 10 deletions client/src/partials/journal/journal.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function JournalController(Journal, Sorting, Grouping, Filtering, Columns, Confi
* other columns. This can be avoided by setting default sort and group.
*/
var columns = [
{ field: 'uuid', displayName : 'TABLE.COLUMNS.ID', headerCellFilter: 'translate', visible: false, enableCellEdit: false},
{ field: 'uuid', displayName : 'TABLE.COLUMNS.ID', headerCellFilter: 'translate', visible: false, enableCellEdit: false },
{ field: 'project_name', displayName : 'TABLE.COLUMNS.PROJECT', headerCellFilter: 'translate', visible: false, enableCellEdit: false },
{ field: 'period_end', displayName : 'TABLE.COLUMNS.PERIOD', headerCellFilter: 'translate' , cellTemplate : 'partials/templates/bhPeriod.tmpl.html', visible : false, enableCellEdit : false},
{ field: 'trans_id',
Expand All @@ -132,13 +132,12 @@ function JournalController(Journal, Sorting, Grouping, Filtering, Columns, Confi
enableCellEdit: false,
width : 110,
cellTemplate : 'partials/journal/templates/hide-groups-label.cell.html',
},
{
}, {
field : 'trans_date',
displayName : 'TABLE.COLUMNS.DATE',
headerCellFilter: 'translate',
cellFilter : 'date:"' + bhConstants.dates.format + '"',
filter : { condition : filtering.byDate },
filter : { condition : filtering.filterByDate },
editableCellTemplate: 'partials/journal/templates/date.edit.html',
enableCellEdit: true,
footerCellTemplate:'<i></i>',
Expand All @@ -154,8 +153,8 @@ function JournalController(Journal, Sorting, Grouping, Filtering, Columns, Confi
aggregation.rendered = aggregation.value;
},
enableFiltering: false
},
{ field : 'credit_equiv',
}, {
field : 'credit_equiv',
displayName : 'TABLE.COLUMNS.CREDIT',
headerCellFilter: 'translate',
treeAggregationType : uiGridGroupingConstants.aggregation.SUM,
Expand Down Expand Up @@ -315,11 +314,11 @@ function JournalController(Journal, Sorting, Grouping, Filtering, Columns, Confi
})
.catch(function (error) {
if(error === 'POSTING_JOURNAL.ERRORS.UNBALANCED_TRANSACTIONS'){
Notify.warn(error);
Notify.warn(error);
} else {
Notify.handleError(error);
}
});
Notify.handleError(error);
}
});
}

vm.toggleTransactionGroup = function toggleTransactionGroup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function StockFindPurchaseModalController(Instance, Purchase, Notify,
{
field : 'date',
cellFilter : 'date',
filter : { condition: filtering.byDate },
filter : { condition: filtering.filterByDate },
displayName : 'TABLE.COLUMNS.DATE',
headerCellFilter : 'translate',
sort : { priority: 0, direction: 'desc' },
Expand Down
6 changes: 3 additions & 3 deletions client/src/partials/templates/modals/findReference.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function FindReferenceModalController(Instance, Voucher, Cash, Filtering, Entity
{
field : 'date',
cellFilter:'date',
filter : { condition : filtering.byDate },
filter : { condition : filtering.filterByDate },
displayName : 'TABLE.COLUMNS.BILLING_DATE',
headerCellFilter : 'translate',
sort : { priority : 0, direction : 'desc'}
Expand Down Expand Up @@ -120,7 +120,7 @@ function FindReferenceModalController(Instance, Voucher, Cash, Filtering, Entity
{
field : 'date',
cellFilter:'date',
filter : { condition : filtering.byDate },
filter : { condition : filtering.filterByDate },
displayName : 'TABLE.COLUMNS.BILLING_DATE',
headerCellFilter : 'translate',
sort : { priority : 0, direction : 'desc'}
Expand Down Expand Up @@ -151,7 +151,7 @@ function FindReferenceModalController(Instance, Voucher, Cash, Filtering, Entity
field : 'date',
displayName : 'Date',
cellFilter : 'date:"mediumDate"',
filter : { condition : filtering.byDate },
filter : { condition : filtering.filterByDate },
sort : { priority : 0, direction : 'desc'}
},
{ field : 'description', displayName : 'Description'},
Expand Down
2 changes: 1 addition & 1 deletion client/src/partials/vouchers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function VoucherController(Vouchers, Notify, Filtering, uiGridGroupingConstants,
displayName : 'TABLE.COLUMNS.DATE',
headerCellFilter : 'translate',
cellFilter : 'date',
filter : { condition: filtering.byDate },
filter : { condition: filtering.filterByDate },
type : 'date',
groupingShowAggregationMenu : false,
}, {
Expand Down

0 comments on commit 4780410

Please sign in to comment.