Skip to content

Commit

Permalink
feat(users): add cashboxes to user grid
Browse files Browse the repository at this point in the history
This commit achieves the final part of #4021 by adding the cashboxes a
user has access to onto the user grid.
  • Loading branch information
jniles committed Feb 13, 2020
1 parent 24f3406 commit cb266e9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 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 @@ -15,6 +15,7 @@
"CANCEL": "Cancel",
"CANCEL_EDIT": "Cancel Edit",
"CASHBOX_MANAGEMENT": "Cashbox Management",
"CASHBOXES": "Cashboxes",
"CLEAR": "Clear",
"CLOSE": "Close",
"CONFIGURE": "Configure",
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 @@ -15,6 +15,7 @@
"CANCEL": "Annuler",
"CANCEL_EDIT": "Annuler Modifier",
"CASHBOX_MANAGEMENT": "Gestion des Caisses",
"CASHBOXES": "Caisses",
"CLEAR": "Effacer",
"CLOSE": "Fermer",
"CONFIGURE": "Configurer",
Expand Down
7 changes: 7 additions & 0 deletions client/src/modules/users/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ function UsersController($state, $uibModal, Users, Notify, Modal, uiGridConstant
enableFiltering : true,
cellClass : muteDisabledCells,
},
{
field : 'cashboxes',
displayName : 'FORM.LABELS.CASHBOXES',
headerCellFilter : 'translate',
enableFiltering : true,
cellClass : muteDisabledCells,
},
{
field : 'action',
displayName : '',
Expand Down
3 changes: 3 additions & 0 deletions client/src/modules/users/users.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ function UserService(Api) {
delete user.lastLogin;
delete user.id;
delete user.active;
delete user.roles;
delete user.cashboxes;
delete user.depots;

return service.$http.put(`/users/${id}`, user)
.then(service.util.unwrapHttpResponse);
Expand Down
10 changes: 8 additions & 2 deletions server/controllers/admin/users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ async function lookupUser(id) {
SELECT user.id, user.username, user.email, user.display_name,
user.active, user.last_login AS lastLogin, user.deactivated,
GROUP_CONCAT(DISTINCT role.label ORDER BY role.label DESC SEPARATOR ', ') AS roles,
GROUP_CONCAT(DISTINCT depot.text ORDER BY depot.text DESC SEPARATOR ', ') AS depots
GROUP_CONCAT(DISTINCT depot.text ORDER BY depot.text DESC SEPARATOR ', ') AS depots,
GROUP_CONCAT(DISTINCT cb.label ORDER BY cb.label DESC SEPARATOR ', ') AS cashboxes
FROM user
LEFT JOIN user_role ur ON user.id = ur.user_id
LEFT JOIN role ON role.uuid = ur.role_uuid
LEFT JOIN depot_permission dp ON dp.user_id = user.id
LEFT JOIN depot ON dp.depot_uuid = depot.uuid
LEFT JOIN cashbox_permission ON user.id = cashbox_permission.user_id
LEFT JOIN cash_box cb ON cashbox_permission.cashbox_id = cb.id
WHERE user.id = ?
GROUP BY user.id;
`.trim();
Expand Down Expand Up @@ -91,12 +94,15 @@ async function list(req, res, next) {
const sql = `
SELECT user.id, user.display_name, user.username, user.deactivated,
GROUP_CONCAT(DISTINCT role.label ORDER BY role.label DESC SEPARATOR ', ') AS roles,
GROUP_CONCAT(DISTINCT depot.text ORDER BY depot.text DESC SEPARATOR ', ') AS depots
GROUP_CONCAT(DISTINCT depot.text ORDER BY depot.text DESC SEPARATOR ', ') AS depots,
GROUP_CONCAT(DISTINCT cb.label ORDER BY cb.label DESC SEPARATOR ', ') AS cashboxes
FROM user
LEFT JOIN user_role ur ON user.id = ur.user_id
LEFT JOIN role ON role.uuid = ur.role_uuid
LEFT JOIN depot_permission dp ON dp.user_id = user.id
LEFT JOIN depot ON dp.depot_uuid = depot.uuid
LEFT JOIN cashbox_permission ON user.id = cashbox_permission.user_id
LEFT JOIN cash_box cb ON cashbox_permission.cashbox_id = cb.id
GROUP BY user.id;
`.trim();

Expand Down

0 comments on commit cb266e9

Please sign in to comment.