Skip to content

Commit

Permalink
search option cash box, select user
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebed-meleck committed Nov 22, 2023
1 parent 5585328 commit 97e6594
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
26 changes: 17 additions & 9 deletions client/src/modules/users/search.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
<uib-tabset>
<uib-tab index="0" heading="{{ 'FORM.LABELS.SEARCH_QUERIES' | translate }}" data-custom-filter-tab>
<div class="tab-body">
<!--user name-->
<div class="form-group" ng-class="{ 'has-error' : ModalForm.$submitted && ModalForm.display_name.$invalid }">
<label class="control-label" translate> FORM.LABELS.USERNAME </label>
<bh-clear on-clear="$ctrl.clear('display_name')"></bh-clear>
<input type="text" class="form-control" name="display_name" ng-model="$ctrl.searchQueries.display_name">
<div class="help-block" ng-messages="ModalForm.display_name.$error" ng-show="ModalForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
<!-- user -->
<bh-user-select
user-id="$ctrl.searchQueries.id"
label="FORM.LABELS.USERNAME"
require="false"
on-select-callback="$ctrl.onSelectUser(user)">
<bh-clear on-clear="$ctrl.clear('id')"></bh-clear>
</bh-user-select>

<!-- depot -->
<bh-depot-select
Expand All @@ -32,6 +31,15 @@
on-select-callback="$ctrl.onSelectDepot(depot)">
<bh-clear on-clear="$ctrl.clear('depot_uuid')"></bh-clear>
</bh-depot-select>

<!-- cashbox -->
<bh-cashbox-select
cashbox-id="$ctrl.searchQueries.cashbox_id"
name="cashbox_id"
restrict-to-user="false"
on-select-callback="$ctrl.onSelectCashbox(cashbox)">
<bh-clear on-clear="$ctrl.clear('cashbox_id')"></bh-clear>
</bh-cashbox-select>

</div>
</uib-tab>
Expand Down
13 changes: 12 additions & 1 deletion client/src/modules/users/search.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function UserRegistryModalController(ModalInstance, filters, Store, util, Period
const displayValues = {};

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

vm.filters = filters;
Expand Down Expand Up @@ -63,6 +63,17 @@ function UserRegistryModalController(ModalInstance, filters, Store, util, Period
});
};

// custom filter user - assign the value to the params object
vm.onSelectUser = function onSelectUser(user) {
vm.searchQueries.id = user.id;
displayValues.id = user.display_name;
};

// custom filter cashbox
vm.onSelectCashbox = function onSelectCashbox(cash) {
vm.searchQueries.cashbox_id = cash.id;
displayValues.cashbox_id = cash.label;
};
// custom filter depot_uuid - assign the value to the params object
vm.onSelectDepot = function onSelectDepot(depot) {
vm.searchQueries.depot_uuid = depot.uuid;
Expand Down
1 change: 1 addition & 0 deletions client/src/modules/users/users.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function UserService(Api, $uibModal, Filters, bhConstants, AppCache, Periods) {
{ key : 'cashbox_id', label : 'FORM.LABELS.CASHBOX' },
{ key : 'depot_uuid', label : 'FORM.LABELS.DEPOT' },
{ key : 'display_name', label : 'FORM.LABELS.USERNAME' },
{ key : 'id', label : 'FORM.LABELS.USERNAME' },
]);

if (filterCache.filters) {
Expand Down
1 change: 1 addition & 0 deletions server/controllers/admin/users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ async function list(req, res, next) {
filters.equals('id');
filters.equals('role_uuid', 'role_uuid', 'ur');
filters.equals('depot_uuid', 'depot_uuid', 'dp');
filters.equals('cashbox_id', 'id', 'cb');
filters.fullText('display_name');

filters.setGroup('GROUP BY user.id');
Expand Down

0 comments on commit 97e6594

Please sign in to comment.