-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'vanga/master' into feature-patient-visits
- Loading branch information
Showing
88 changed files
with
1,427 additions
and
3,201 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
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
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,70 @@ | ||
angular.module('bhima.components') | ||
.component('bhRendererDropdown', { | ||
bindings : { | ||
reportUrl : '@', | ||
reportOptions : '<' | ||
}, | ||
templateUrl : 'partials/templates/bhRendererDropdown.tmpl.html', | ||
controller : bhRendererController | ||
}); | ||
|
||
bhRendererController.$inject = [ 'appcache', '$http', '$timeout', '$sce', '$window' ]; | ||
|
||
function bhRendererController(AppCache, $http, $timeout, $sce, $window) { | ||
var $ctrl = this; | ||
|
||
var cache = new AppCache('bhRendererComponent'); | ||
|
||
// delay between GET request completion and loading indication, this is used | ||
// to compensate for the delay in browsers opening the print dialog | ||
var loadingIndicatorDelay = 1000; | ||
|
||
$ctrl.$onInit = function () { | ||
$ctrl.options = [ | ||
{ icon : 'file-code-o', key : 'DOWNLOADS.JSON', parameters : { renderer: 'json'}, type : 'application/json' }, | ||
{ icon : 'file-excel-o', key : 'DOWNLOADS.CSV', parameters : { renderer: 'csv'}, type : 'application/csv' }, | ||
{ icon : 'file-pdf-o', key : 'DOWNLOADS.PDF', parameters : { renderer: 'pdf'}, type : 'application/pdf' } | ||
]; | ||
|
||
$ctrl.selection = cache.selection || $ctrl.options[0]; | ||
|
||
$ctrl.reportOptions = $ctrl.reportOptions || {}; | ||
|
||
$ctrl.$loading = false; | ||
}; | ||
|
||
$ctrl.select = function (option) { | ||
$ctrl.selection = cache.selection = option; | ||
}; | ||
|
||
$ctrl.execute = function () { | ||
var url = $ctrl.reportUrl; | ||
|
||
var parameters = {}; | ||
angular.extend(parameters, $ctrl.reportOptions, $ctrl.selection.parameters); | ||
|
||
$http.get(url, { params : parameters, responseType : 'arraybuffer' }) | ||
.then(function (response) { | ||
var blob = new Blob([response.data], { type: $ctrl.selection.type }); | ||
var objectUrl = $sce.trustAsResourceUrl(URL.createObjectURL(blob)); | ||
$window.open(objectUrl); | ||
}) | ||
.catch(function (error) { | ||
console.log(error); | ||
}) | ||
.finally(function () { | ||
$timeout(toggleLoading, loadingIndicatorDelay); | ||
}); | ||
}; | ||
|
||
/** | ||
* @method toggleLoading | ||
* | ||
* @description | ||
* This method is responsible for updating the loading state for the controllers | ||
* HTTP requests. | ||
*/ | ||
function toggleLoading() { | ||
$ctrl.$loading = !$ctrl.$loading; | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
angular.module('bhima.services') | ||
.factory('GridAggregatorService', GridAggregatorService); | ||
|
||
GridAggregatorService.$inject = [ | ||
'uiGridGroupingConstants', '$filter', 'SessionService' | ||
]; | ||
|
||
/** | ||
* Grid Aggregator Service | ||
* | ||
* This service contains all aggregators used in bhima, keyed on the column ID. These should | ||
* provide enough detail, along with the aggregation detail. | ||
* | ||
* @todo - finish aggregation for footers | ||
*/ | ||
function GridAggregatorService(uiGridGroupingConstants, $filter, Session) { | ||
|
||
// cache the enterprise currency id for easy lookup | ||
var enterpriseCurrencyId= Session.enterprise.currency_id; | ||
|
||
// cache the currency filter for later lookup | ||
var $currency = $filter('currency'); | ||
var $date = $filter('date'); | ||
|
||
// alias copy | ||
var extend = angular.extend; | ||
|
||
/** | ||
* @const TREE_DEFAULTS | ||
* | ||
* @description | ||
* These are to be used with ui-grid-tree-view or ui-grid-grouping. Otherwise, they are not | ||
* hooked up. This is separate from regular aggregators embedded on ui-grid (by setting | ||
* aggregationType on the columnDef). Those do not allow you to set a custom label. | ||
*/ | ||
var TREE_DEFAULTS = { | ||
|
||
// used to render amounts in the aggregate columns | ||
cost : { | ||
customTreeAggregationFinalizerFn : function (aggregation) { | ||
aggregation.rendered = $currency(aggregation.value, enterpriseCurrencyId); | ||
}, | ||
|
||
treeAggregationType : uiGridGroupingConstants.aggregation.SUM, | ||
hideAggregationLabel : true | ||
}, | ||
|
||
quanity : { | ||
treeAggregationType : uiGridGroupingConstants.aggregation.SUM, | ||
}, | ||
|
||
single : { | ||
treeAggregationType: uiGridGroupingConstants.aggregation.MAX, | ||
customTreeAggregationFinalizerFn: function (aggregation) { | ||
aggregation.rendered = aggregation.value; | ||
}, | ||
hideAggregationLabel : true | ||
}, | ||
|
||
date : { | ||
treeAggregationType: uiGridGroupingConstants.aggregation.AVG, | ||
customTreeAggregationFinalizerFn: function (aggregation) { | ||
aggregation.rendered = $date(aggregation.value); | ||
}, | ||
hideAggregationLabel : true | ||
} | ||
}; | ||
|
||
// list of aggregators to be returned | ||
var aggregators = { | ||
tree : { | ||
debit : extend({}, TREE_DEFAULTS.cost), | ||
credit : extend({}, TREE_DEFAULTS.cost), | ||
debit_equiv : extend({}, TREE_DEFAULTS.cost), | ||
credit_equiv : extend({}, TREE_DEFAULTS.cost), | ||
date : extend({}, TREE_DEFAULTS.date), | ||
trans_date : extend({}, TREE_DEFAULTS.date), | ||
description : extend({}, TREE_DEFAULTS.single) | ||
}, | ||
}; | ||
|
||
|
||
/** | ||
* @function extendColumnWithAggregator | ||
* | ||
* @param {Object} column - the grid column to be extended | ||
* @param {Object} aggregator - an aggregator to attach to the column. | ||
* | ||
* @description | ||
* This function provides an easy way to attache an aggregation function | ||
* from the controller. | ||
*/ | ||
function extendColumnWithAggregator(column, aggregator) { | ||
extend(column, aggregator); | ||
} | ||
|
||
// return the aggregators and methods | ||
return { | ||
aggregators : aggregators, | ||
extendColumnWithAggregator : extendColumnWithAggregator | ||
}; | ||
} |
Oops, something went wrong.