-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(grid): transition journal to grid services
Closes #376. Closes #586. This commit completes the migration of specific posting journal services to grid services. It also removes the ability to paginate the posting journal as this increases the complexity of the process several fold. In addition to migrating the service, the GridFiltering service now provides the option to toggle (inline) filtering on and off. This could be useful for power users wanting to filter the view quickly.
- Loading branch information
Jonathan Niles
committed
Jul 21, 2016
1 parent
447bc8a
commit fc883df
Showing
10 changed files
with
99 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
angular.module('bhima.services') | ||
.service('GridFilteringService', GridFilteringService); | ||
|
||
GridFilteringService.$inject = ['appcache', 'uiGridConstants']; | ||
|
||
/** | ||
* Grid Filter Service | ||
* | ||
* This service is responsible for defining the global configuration for | ||
* filtering for ui-grids. | ||
*/ | ||
function GridFilteringService(AppCache, uiGridConstants) { | ||
|
||
/** @const service key */ | ||
var serviceKey = '-Filtering'; | ||
|
||
function GridFiltering(gridOptions, cacheKey) { | ||
this.gridOptions = gridOptions; | ||
|
||
var cache = this.cache = AppCache(cacheKey + serviceKey); | ||
|
||
// global filtering configuration | ||
cache.enableFiltering = cache.enableFiltering || true; | ||
gridOptions.enableFiltering = cache.enableFiltering; | ||
|
||
gridOptions.onRegisterApi = function onRegisterApi(api) { | ||
this.gridApi = api; | ||
}.bind(this); | ||
} | ||
|
||
/** | ||
* @method filterByDate | ||
* | ||
* @description | ||
* Matches the date string provided in the string. | ||
*/ | ||
GridFiltering.prototype.filterByDate = function filterByDate(searchValue, cellValue) { | ||
var cellDate = new Date(cellValue); | ||
|
||
var month = cellDate.getMonth(); | ||
var date = cellDate.getDate(); | ||
var year = cellDate.getFullYear(); | ||
|
||
var cellMonth = (month < 9) ? '0' + (month + 1) : (month + 1); | ||
var cellDateLong = (date < 10) ? '0' + date : date; | ||
var cellDateString = year + '-' + cellMonth + '-' + cellDateLong; | ||
|
||
searchValue = searchValue.replace(/\\/g, ''); | ||
|
||
return cellDateString.indexOf(searchValue) !== -1; | ||
}; | ||
|
||
/** | ||
* @method toggleInlineFiltering | ||
* | ||
* @description | ||
* This method toggles the inline grid filters on the column headers of a grid. | ||
*/ | ||
GridFiltering.prototype.toggleInlineFiltering = function toggleInlineFiltering() { | ||
if (!this.gridOptions) { return; } | ||
|
||
this.gridOptions.enableFiltering = !this.gridOptions.enableFiltering; | ||
this.cache.enableFiltering = this.gridOptions.enableFiltering; | ||
|
||
this.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN); | ||
}; | ||
|
||
return GridFiltering; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters