Skip to content

Commit

Permalink
feat(account): add excludeTitleAccounts option to bhAccountSelect
Browse files Browse the repository at this point in the history
Sometimes, the account select should just remove title accounts from the view (rather than just
disabling them).  Such is the case for a search modal.  This commit implments `excludeTitleAccounts`
boolean binding on the `bhAccountSelect` to provide this case.  Defaults to false.

Closes #1544.
  • Loading branch information
Jonathan Niles authored and sfount committed May 2, 2017
1 parent 2d48163 commit da56265
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions client/src/js/components/bhAccountSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ angular.module('bhima.components')
required : '<?',
label : '@?',
name : '@?',
excludeTitleAccounts : '@?',
},
});

Expand All @@ -32,9 +33,6 @@ function AccountSelectController(Accounts, AppCache, $timeout, bhConstants, $sco

// fired at the beginning of the account select
$ctrl.$onInit = function () {
// load accounts
loadAccounts();

// cache the title account ID for convenience
$ctrl.TITLE_ACCOUNT_ID = bhConstants.accounts.TITLE;

Expand All @@ -54,6 +52,10 @@ function AccountSelectController(Accounts, AppCache, $timeout, bhConstants, $sco
$ctrl.required = true;
}

$ctrl.excludeTitleAccounts = $ctrl.excludeTitleAccounts || false;

// load accounts
loadAccounts();

// alias the name as AccountForm
$timeout(aliasComponentForm);
Expand Down Expand Up @@ -90,7 +92,13 @@ function AccountSelectController(Accounts, AppCache, $timeout, bhConstants, $sco
.then(function (elements) {

// bind the accounts to the controller
$ctrl.accounts = Accounts.order(elements);
var accounts = Accounts.order(elements);

if ($ctrl.excludeTitleAccounts) {
accounts = Accounts.filterTitleAccounts(accounts);
}

$ctrl.accounts = accounts;

// writes the accounts into localstorage
//cacheAccounts($ctrl.accounts);
Expand Down
4 changes: 2 additions & 2 deletions client/src/modules/journal/modals/search.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@
</div>

<bh-account-select
account-id="ModalCtrl.searchQueries.account_id"
account-id="ModalCtrl.options.account_id"
name="account_id"
on-select-callback="ModalCtrl.onSelectAccount(account)"
exclude-title-accounts="true"
required="0">
<bh-clear on-clear="ModalCtrl.clear('account_id')"></bh-clear>
</bh-account-select>
Expand Down Expand Up @@ -158,7 +159,6 @@
</uib-tab>

</uib-tabset>

</div>

<div class="modal-footer">
Expand Down

0 comments on commit da56265

Please sign in to comment.