Skip to content

Commit

Permalink
style: extract attached info from role && create new col in user list
Browse files Browse the repository at this point in the history
  • Loading branch information
Dim145 committed Mar 21, 2024
1 parent ccd0e02 commit ac2ae92
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 18 additions & 11 deletions frontend/components/UserList.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,6 @@ class UserList extends React.Component {
Adhérent
</a>
);
} else if (d.attached_to_id) {
return (
<a
href={`/users/${d.id}`}
className="badge"
style={{ backgroundColor: "#009f9a", color: "white" }}
>
Utilisateur rattaché
</a>
);
} else {
return (
<a
Expand All @@ -311,10 +301,27 @@ class UserList extends React.Component {
<option value="user">Autres</option>
<option value="student">Élèves</option>
<option value="teacher">Professeurs</option>
<option value="attached">Utilisateur rattachés</option>
</select>
),
},
{
id: "attached",
Header: "Type de compte",
sortable: false,
filterable: true,
Filter: ({ filter, onChange }) => (
<select
onChange={event => onChange(event.target.value)}
style={{ width: "100%" }}
value={filter ? filter.value : "all"}
>
<option value="">Tous les comptes</option>
<option value="true">Comptes principaux</option>
<option value="false">Comptes rattachés</option>
</select>
),
accessor: d => d.attached_to_id ? "Rattaché" : "Principal"
},
{
id: "last_name",
Header: "Nom",
Expand Down

0 comments on commit ac2ae92

Please sign in to comment.