Skip to content

Commit

Permalink
feat(accounts): migrate all typeaheads to uiSelect
Browse files Browse the repository at this point in the history
This commit removes all account `uib-typeahead`s from the application
and replaces them with `ui-select` components for better usability.  All
tests have been updated accordingly.

It also removes a large number of unused directives and templates from
the directives/components/partials folders.  Any regression should be
reported (but tests pass)!

Closes #727.
  • Loading branch information
Jonathan Niles committed Sep 26, 2016
1 parent bf9ff9a commit e737b1a
Show file tree
Hide file tree
Showing 29 changed files with 308 additions and 646 deletions.
122 changes: 0 additions & 122 deletions client/src/js/directives/findaccount.js

This file was deleted.

64 changes: 0 additions & 64 deletions client/src/js/directives/findaccount.md

This file was deleted.

109 changes: 0 additions & 109 deletions client/src/js/directives/findconvention.js

This file was deleted.

23 changes: 13 additions & 10 deletions client/src/partials/billing_services/modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@ <h4>{{ BillingServicesFormCtrl.title | translate }}<span ng-show="BillingService
<!-- account input -->
<div
class="form-group"
ng-class="{ 'has-error' : BillingServicesForm.$submitted && BillingServicesForm.account.$invalid }"
data-component-find-account
>
ng-class="{ 'has-error' : BillingServicesForm.$submitted && BillingServicesForm.account.$invalid }">
<label class="control-label">
{{ "FORM.LABELS.ACCOUNT" | translate }}
</label>
<input
class="form-control"

<ui-select
name="account"
ng-model="BillingServicesFormCtrl.model.account"
placeholder="{{ 'FORM.PLACEHOLDERS.ACCOUNT' | translate }}"
uib-typeahead="account as account.hrlabel for account in BillingServicesFormCtrl.accounts | filter:$viewValue | limitTo:6"
typeahead-editable="false"
typeahead-template-url="partials/templates/typeahead/accounts.html"
required>
theme="bootstrap">
<ui-select-match placeholder="{{ 'FORM.PLACEHOLDERS.ACCOUNT' | translate }}">
<strong>{{$select.selected.number}}</strong> <span>{{$select.selected.label}}</span>
</ui-select-match>
<ui-select-choices ui-select-focus-patch repeat="account in BillingServicesFormCtrl.accounts | filter:$select.search">
<strong ng-bind-html="account.number | highlight:$select.search"></strong>
<span ng-bind-html="account.label | highlight:$select.search"></span>
</ui-select-choices>
</ui-select>

<div class="help-block" ng-messages="BillingServicesForm.account.$error" ng-show="BillingServicesForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/partials/billing_services/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function BillingServicesUpdateController($state, BillingServices, Accounts, Moda
vm.accounts = accounts;

// loop through the accounts and select the correct account to display
// in the typeahead
// in the ui-select
vm.model.account = accounts.reduce(function (value, account) {

// if the value is not false, we have found the account, so return it
Expand Down
14 changes: 8 additions & 6 deletions client/src/partials/debtors/groups.create.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
angular.module('bhima.controllers')
.controller('DebtorGroupCreateController', DebtorGroupCreateController);
.controller('DebtorGroupCreateController', DebtorGroupCreateController);

DebtorGroupCreateController.$inject = [
'$state', 'ScrollService', 'SessionService', 'DebtorGroupService', 'AccountService', 'PriceListService', 'uuid', 'NotifyService', '$translate'
'$state', 'ScrollService', 'SessionService', 'DebtorGroupService', 'AccountService', 'PriceListService', 'uuid', 'NotifyService'
];

/**
Expand All @@ -12,7 +13,7 @@ DebtorGroupCreateController.$inject = [
*
* @module debtor/groups/create
*/
function DebtorGroupCreateController($state, ScrollTo, SessionService, DebtorGroups, Accounts, Prices, Uuid, Notify, $translate) {
function DebtorGroupCreateController($state, ScrollTo, SessionService, DebtorGroups, Accounts, Prices, Uuid, Notify) {
var vm = this;

// default new group policies
Expand All @@ -26,14 +27,16 @@ function DebtorGroupCreateController($state, ScrollTo, SessionService, DebtorGro
Accounts.read()
.then(function (accounts) {
vm.accounts = accounts;
});
})
.catch(Notify.handleError);

/* @todo This controller should not be concerned about individual price lists */
/* @todo All read/ list API methods should be uniform on the client */
Prices.read()
.then(function (priceLists) {
vm.priceLists = priceLists;
});
})
.catch(Notify.handleError);

// expose state for optional view elements
vm.state = $state;
Expand Down Expand Up @@ -73,7 +76,6 @@ function DebtorGroupCreateController($state, ScrollTo, SessionService, DebtorGro
// in order to display account correctly the entire account is stored in the
// ng-model, we should extract this
submitGroup = angular.copy(vm.group);
submitGroup.account_id = vm.group.account_id.id;

DebtorGroups.create(submitGroup)
.then(function (result) {
Expand Down
Loading

0 comments on commit e737b1a

Please sign in to comment.