-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(exchange): enterprise module exchange rate
This commit migrates the exchange rate module to the enterprise settings page. The exchange rate is now completely set in a hovering modal. Important changes : 1. Breaks out enterprise routes into enterprise.routes.js 2. Removes tests for exchange rates 3. Adds "limit" option to exchange rates for efficient loading. 4. Adds ui-view to embed the exchange rate panel. TODOs: 1. Remove the old exchange rate files. 2. Set default sort direction for data. 3. Implement exchange rate modal
- Loading branch information
Showing
15 changed files
with
195 additions
and
72 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,20 @@ | ||
angular.module('bhima.routes') | ||
.config(['$stateProvider', function ($stateProvider) { | ||
|
||
$stateProvider | ||
.state('enterprises', { | ||
abstract : true, | ||
url : '/enterprises', | ||
controller: 'EnterpriseController as EnterpriseCtrl', | ||
templateUrl: 'partials/enterprises/enterprises.html' | ||
}) | ||
.state('enterprises.page', { | ||
url : '', | ||
views : { | ||
'exchange@enterprises' : { | ||
templateUrl : 'partials/enterprises/exchange/exchange.html', | ||
controller : 'ExchangeController as ExchangeCtrl' | ||
} | ||
} | ||
}); | ||
}]); |
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,43 @@ | ||
<div class="panel panel-default"> | ||
|
||
<div class="panel-heading clearfix"> | ||
{{ "EXCHANGE.TITLE" | translate }} | ||
</div> | ||
|
||
<div class="panel-body" style="height : 300px; overflow : hidden"> | ||
|
||
<!-- show a loading indicator while loading --> | ||
<p | ||
ng-if="ExchangeCtrl.loading" | ||
class="text-muted"> | ||
<i class="fa fa-circle-o-notch fa-spin"></i> | ||
{{ "FORM.INFO.LOADING" | translate }} | ||
</p> | ||
|
||
<!-- button to set a new exchange rate --> | ||
<button class="btn btn-default btn-block" ng-click="ExchangeCtrl.setNewExchangeRate()"> | ||
<i class="fa fa-balance-scale"></i> | ||
{{ "FORM.BUTTONS.UPDATE" | translate }} {{ "EXCHANGE.EXCHANGE_RATES" | translate }} | ||
</button> | ||
|
||
<!-- show a warning if no rates exist --> | ||
<p | ||
ng-if="!ExchangeCtrl.loading && ExchangeCtrl.rates.length === 0" | ||
class="text-warning"> | ||
<span class="fa fa-warning"></span> | ||
{{ "EXCHANGE.ADD_EXCHANGE" | translate }} | ||
</p> | ||
|
||
<br /> | ||
|
||
<p>{{ "EXCHANGE.ENTERPRISE_CURRENCY" | translate}}: <i>{{ ExchangeCtrl.formatCurrency(ExchangeCtrl.enterpriseCurrencyId) }}</i></p> | ||
|
||
<ul class="list-unstyled"> | ||
<li data-exchange-rate-element ng-repeat="rate in ExchangeCtrl.rates"> | ||
<i class="fa fa-clock-o"></i> <b>{{ rate.rate }} {{ ExchangeCtrl.formatCurrency(rate.currency_id) }} </b> {{ "EXCHANGE.RATE_SET" | translate }} <span am-time-ago="rate.date"></span>. | ||
<br /> | ||
<span class="icon-spacer text-muted"><i>{{rate.date | date : 'medium'}}</i></span> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> |
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,44 @@ | ||
angular.module('bhima.controllers') | ||
.controller('ExchangeController', ExchangeController); | ||
|
||
ExchangeController.$inject = [ | ||
'SessionService', 'ExchangeRateService', 'NotifyService', 'CurrencyService', '$uibModal' | ||
]; | ||
|
||
// this powers the exchange rate ui-view in the enterprise page | ||
function ExchangeController(Session, Exchange, Notify, Currencies, $uibModal) { | ||
var vm = this; | ||
|
||
vm.loading = true; | ||
vm.enterpriseCurrencyId = Session.enterprise.currency_id; | ||
|
||
// load the exchange rates | ||
function loadRates() { | ||
Exchange.read({ limit : 5 }) | ||
.then(function (rates) { | ||
vm.rates = rates; | ||
}) | ||
.catch(Notify.handleError) | ||
.finally(function () { | ||
vm.loading = false; | ||
}); | ||
} | ||
|
||
// formats the currency nicely | ||
vm.formatCurrency = function formatCurrency(id) { | ||
return Currencies.name(id) + ' (' + Currencies.symbol(id) + ')'; | ||
}; | ||
|
||
// opens a modal to set a new exchange rate | ||
vm.setNewExchangeRate = function setNewExchangeRate() { | ||
var instance = $uibModal.open({ | ||
templateUrl : 'partials/enterprises/exchange/exchange.modal.html', | ||
controller : 'ExchangeRateModalController as ModalCtrl' | ||
}).result; | ||
|
||
instance | ||
.then(loadRates); | ||
}; | ||
|
||
loadRates(); | ||
} |
Empty file.
Empty file.
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
Oops, something went wrong.