From ac2ae922119870f69e4eb1310077fdf84fd2f418 Mon Sep 17 00:00:00 2001 From: dim145 Date: Thu, 21 Mar 2024 16:44:38 +0100 Subject: [PATCH] style: extract attached info from role && create new col in user list --- app/controllers/users_controller.rb | 4 ++-- frontend/components/UserList.js | 29 ++++++++++++++++++----------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9cfd9f63..f0d0fab0 100755 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -153,13 +153,13 @@ def list query = query.members.not_students when "teacher", "admin" query = query.where("is_#{filter[:value]} = true") - when "attached" - query = query.where.not(attached_to_id: nil) else # type code here end when "adherent_number" query = query.where("adherent_number = ?", filter[:value].to_i) + when "attached" + query = filter[:value] == "true" ? query.where(attached_to_id: nil) : query.where.not(attached_to_id: nil) unless "#{filter[:value]}".empty? else query = query.where("#{filter[:id]} ILIKE ?", "#{filter[:value]}%") end diff --git a/frontend/components/UserList.js b/frontend/components/UserList.js index 68d2f485..bad19177 100755 --- a/frontend/components/UserList.js +++ b/frontend/components/UserList.js @@ -276,16 +276,6 @@ class UserList extends React.Component { Adhérent ); - } else if (d.attached_to_id) { - return ( - - Utilisateur rattaché - - ); } else { return ( Autres - ), }, + { + id: "attached", + Header: "Type de compte", + sortable: false, + filterable: true, + Filter: ({ filter, onChange }) => ( + + ), + accessor: d => d.attached_to_id ? "Rattaché" : "Principal" + }, { id: "last_name", Header: "Nom",