Skip to content

Commit

Permalink
Merge #3097
Browse files Browse the repository at this point in the history
3097: Fix bh-currency-select unhandled error logging  r=jniles a=sfount

This commit removes a method forcing validation on form elements that
are updated by changes propegated in `ng-form` and closes #3096. 

It also updates the relevant controller code to repository standards. 

Co-authored-by: Steven Fountain <stevenfountain@imaworldhealth.org>
  • Loading branch information
bors[bot] and sfount committed Aug 30, 2018
2 parents 29facb0 + 9ee26e3 commit 5139d89
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions client/src/js/components/bhCurrencySelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ bhCurrencySelect.$inject = ['CurrencyService'];
* @requires services/CurrencyService
*/
function bhCurrencySelect(Currencies) {
var $ctrl = this;
var isArray = angular.isArray;
const $ctrl = this;
const { isArray } = angular;

$ctrl.$onInit = function onInit() {
// load all the available currencies
Currencies.read()
.then(function (currencies) {
.then(currencies => {
// cache a label for faster view rendering
currencies.forEach(function (currency) {
currencies.forEach(currency => {
currency.label = Currencies.format(currency.id);
});

Expand Down Expand Up @@ -104,8 +104,8 @@ function bhCurrencySelect(Currencies) {

// loop through the currencies, disabling the currencies with ids in the
// disableIds array.
$ctrl.currencies.forEach(function (currency) {
var disabled = disabledIds.indexOf(currency.id) > -1;
$ctrl.currencies.forEach(currency => {
const disabled = disabledIds.indexOf(currency.id) > -1;
currency.disabled = disabled;
currency.title = disabled ? 'FORM.INFO.DISABLED_CURRENCY' : '';
});
Expand All @@ -119,6 +119,5 @@ function bhCurrencySelect(Currencies) {
// if the two array lengths are equal, it means every currency is disabled.
// there is no possible $valid state.
$ctrl.valid = ($ctrl.currencies.length !== disabledIds.length);
$ctrl.form.currency.$setValidity('currency', $ctrl.valid);
}
}

0 comments on commit 5139d89

Please sign in to comment.