Skip to content

Commit

Permalink
fix(bhFindEmployee): make search work
Browse files Browse the repository at this point in the history
Searching by the employee name or reference often didn't work in the
bhFindEmployee component.  Here, we use the `hrlabel` like in accounts
to make that more seamless.
  • Loading branch information
jniles committed Nov 23, 2020
1 parent 37ba489 commit 55898f8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
7 changes: 6 additions & 1 deletion client/src/js/components/bhEmployeeSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ angular.module('bhima.components')
controller : EmployeeSelectController,
transclude : true,
bindings : {
employeeUuid : '<',
employeeUuid : '<?',
onSelectCallback : '&',
required : '<?',
},
Expand All @@ -25,6 +25,11 @@ function EmployeeSelectController(Employees, Notify) {
// load all Employee
Employees.read()
.then(employees => {

employees.forEach(employee => {
employee.hrlabel = `${employee.reference} - ${employee.display_name}`;
});

$ctrl.employees = employees;
})
.catch(Notify.handleError);
Expand Down
9 changes: 4 additions & 5 deletions client/src/modules/templates/bhEmployeeSelect.tmpl.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<fieldset
ng-form="EmployeeForm"
ng-model-options="{ updateOn: 'default' }"
novalidate
bh-employee-select>

<div class="form-group"
Expand All @@ -19,10 +18,10 @@
ng-required="$ctrl.required"
on-select="$ctrl.onSelect($item)">
<ui-select-match placeholder="{{ 'FORM.SELECT.EMPLOYEE' | translate }}"><span>{{$select.selected.display_name}}</span></ui-select-match>
<ui-select-choices
ui-select-focus-patch
repeat="employee.uuid as employee in $ctrl.employees | filter: { 'display_name': $select.search, 'reference' : $select.search}">
<strong ng-bind-html="employee.reference | highlight:$select.search"></strong> -
<ui-select-choices
ui-select-focus-patch
repeat="employee.uuid as employee in $ctrl.employees | filter: { 'hrlabel': $select.search }">
<strong ng-bind-html="employee.reference | highlight:$select.search"></strong> -
<span ng-bind-html="employee.display_name | highlight:$select.search"></span>
</ui-select-choices>
</ui-select>
Expand Down
1 change: 1 addition & 0 deletions server/controllers/finance/accounts/references.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ async function list(req, res, next) {
filters.custom('number', `a.number LIKE '${params.number}%'`);

filters.setGroup('GROUP BY ar.id');
filters.setOrder('ORDER BY ar.abbr');

// applies filters and limits to defined sql, get parameters in correct order
const query = filters.applyQuery(sql);
Expand Down
12 changes: 6 additions & 6 deletions test/data/accounts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ SET collation_database = 'utf8mb4_unicode_ci';
SET CHARACTER SET utf8mb4, CHARACTER_SET_CONNECTION = utf8mb4;

/**
* the accounts.sql file contains data about :
* the accounts.sql file contains data about :
* - account
*
*
* dependencies :
* - enterprise
*/

--
--
-- Accounts
--
--

INSERT INTO `account` (`id`, `type_id`, `enterprise_id`, `number`, `label`, `parent`, `locked`, `created`, `reference_id`) VALUES
(1, 6, 1, 1, 'CLASSE 1: COMPTES DE RESSOURCES DURABLES', 0, 0, '2016-10-22 14:37:09', NULL),
Expand Down Expand Up @@ -298,8 +298,8 @@ INSERT INTO `account` (`id`, `type_id`, `enterprise_id`, `number`, `label`, `par
(357, 6, 1, 6141, 'Transport du Personnel', 48, 0, '2018-03-14 14:58:55', NULL),
(358, 5, 1, 61411010, 'Transport personnel', 357, 0, '2018-03-14 14:59:59', NULL);

--
--
-- Attach gain/loss accounts to the enterprise
--
--

UPDATE enterprise SET `gain_account_id` = 267, `loss_account_id` = 134;

0 comments on commit 55898f8

Please sign in to comment.