Skip to content

Commit

Permalink
fix search by period
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebed-meleck committed Nov 23, 2023
1 parent 05e10fb commit 5da1df3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 14 deletions.
1 change: 1 addition & 0 deletions client/src/i18n/en/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,7 @@
"RENDERER" : "Select a Renderer",
"REPORT_TYPE": "Select a Report Type",
"RESULT_ACCOUNT_SCT": "Select a Result Account section",
"ROLE": "Select a role",
"ROOM":"Select a Room",
"ROOM_TYPE":"Select a Room Type",
"ROOT_ACCOUNT": "Select a Root Account",
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/fr/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,7 @@
"RENDERER" : "Sélectionner un rendu",
"REPORT_TYPE": "Sélectionner le type de rapport",
"RESULT_ACCOUNT_SCT": "Sélectionnez une section de compte de résultats",
"ROLE": "Sélectionner un role",
"ROOM":"Sélectionner une chambre",
"ROOM_TYPE":"Sélectionner un type de lit",
"ROOT_ACCOUNT": "Sélectionner le compte titre",
Expand Down
39 changes: 28 additions & 11 deletions client/src/modules/users/search.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,38 @@
on-select-callback="$ctrl.onSelectDepot(depot)">
<bh-clear on-clear="$ctrl.clear('depot_uuid')"></bh-clear>
</bh-depot-select>


<!-- roles -->
<div class="form-group has-feedback">
<label class="control-label" translate>FORM.LABELS.ROLES</label>
<bh-clear on-clear="$ctrl.clear('role_uuid')"></bh-clear>
<ui-select name="role_uuid"
ng-model="$ctrl.searchQueries.role_uuid"
on-select="$ctrl.onSelectRole($item, $model)"
required="false"
>
<ui-select-match placeholder="{{ 'FORM.SELECT.ROLE' | translate }}"><span translate>{{$select.selected.label}}</span></ui-select-match>
<ui-select-choices ui-select-focus-patch repeat="role.uuid as role in ($ctrl.roles | filter:$select.search) track by role.uuid">
<span ng-bind-html="role.label | highlight:$select.search"></span>
</ui-select-choices>
</ui-select>
</div>

<!-- cashbox -->
<div class="form-group has-feedback">
<label class="control-label" translate>FORM.SELECT.CASHBOX_OPTIONAL</label>
<bh-clear on-clear="$ctrl.clear('cashbox_id')"></bh-clear>
<ui-select name="cashbox_id"
ng-model="$ctrl.searchQueries.cashbox_id"
on-select="$ctrl.onSelectCashbox($item, $model)"
required>
<ui-select-match placeholder="{{ 'FORM.SELECT.CASHBOX' | translate }}"><span translate>{{$select.selected.label}}</span></ui-select-match>
<ui-select-choices ui-select-focus-patch repeat="cashbox.id as cashbox in ($ctrl.cashboxes | filter:$select.search) track by cashbox.id">
<span ng-bind-html="cashbox.label | highlight:$select.search"></span>
</ui-select-choices>
</ui-select>
</div>
<ui-select name="cashbox_id"
ng-model="$ctrl.searchQueries.cashbox_id"
on-select="$ctrl.onSelectCashbox($item, $model)"
required="false"
>
<ui-select-match placeholder="{{ 'FORM.SELECT.CASHBOX' | translate }}"><span translate>{{$select.selected.label}}</span></ui-select-match>
<ui-select-choices ui-select-focus-patch repeat="cashbox.id as cashbox in ($ctrl.cashboxes | filter:$select.search) track by cashbox.id">
<span ng-bind-html="cashbox.label | highlight:$select.search"></span>
</ui-select-choices>
</ui-select>
</div>

</div>
</uib-tab>
Expand Down
21 changes: 18 additions & 3 deletions client/src/modules/users/search.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ angular.module('bhima.controllers')

UserRegistryModalController.$inject = [
'$uibModalInstance', 'filters', 'Store', 'util', 'PeriodService', 'UserService',
'SearchModalUtilService', 'CashboxService', 'NotifyService',
'SearchModalUtilService', 'CashboxService', 'NotifyService', 'RolesService',
];

/**
Expand All @@ -16,7 +16,7 @@ UserRegistryModalController.$inject = [
*/
function UserRegistryModalController(
ModalInstance, filters, Store, util, Periods,
Users, SearchModal, CashBox, Notify) {
Users, SearchModal, CashBox, Notify, RolesService) {
const vm = this;
const changes = new Store({ identifier : 'key' });

Expand All @@ -25,6 +25,7 @@ function UserRegistryModalController(

const searchQueryOptions = [
'display_name', 'depot_uuid', 'id', 'cashbox_id',
'role_uuid',
];

vm.filters = filters;
Expand Down Expand Up @@ -77,6 +78,12 @@ function UserRegistryModalController(
displayValues.cashbox_id = cash.label;
};

// custom filter cashbox
vm.onSelectRole = function onSelectRole(role) {
vm.searchQueries.role_uuid = role.uuid;
displayValues.role_uuid = role.label;
};

// custom filter depot_uuid - assign the value to the params object
vm.onSelectDepot = function onSelectDepot(depot) {
vm.searchQueries.depot_uuid = depot.uuid;
Expand All @@ -96,7 +103,14 @@ function UserRegistryModalController(
vm.cashboxes = data;
}).catch(Notify.handleError);
}

// loa all roles
function loadRoles() {
return RolesService.read()
.then(role => {
vm.roles = role;
})
.catch(Notify.handleError);
}
function clear(value) {
delete vm.searchQueries[value];
}
Expand All @@ -107,4 +121,5 @@ function UserRegistryModalController(
}

loadCashBoxes();
loadRoles();
}
3 changes: 3 additions & 0 deletions server/controllers/admin/users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ async function list(req, res, next) {
filters.equals('depot_uuid', 'depot_uuid', 'dp');
filters.equals('cashbox_id', 'id', 'cb');
filters.fullText('display_name');
filters.period('period', 'created_at');
filters.dateFrom('custom_period_start', 'created_at');
filters.dateTo('custom_period_end', 'created_at');

filters.setGroup('GROUP BY user.id');
filters.setOrder('ORDER BY user.display_name DESC');
Expand Down

0 comments on commit 5da1df3

Please sign in to comment.