From d63b8d0dfa9e3ec1c4a9f0c6506554d350049523 Mon Sep 17 00:00:00 2001 From: Guilherme Chaguri Date: Thu, 14 Jul 2022 16:11:44 -0300 Subject: [PATCH] Add username column to the member list --- .../templates/admin/members/members.html | 16 +++++++++------- app/services/members/list_service.rb | 5 ++++- app/views/api/members/list.json.jbuilder | 1 + config/locales/app.admin.de.yml | 1 + config/locales/app.admin.en.yml | 1 + config/locales/app.admin.es.yml | 1 + config/locales/app.admin.fr.yml | 1 + config/locales/app.admin.no.yml | 1 + config/locales/app.admin.pt.yml | 1 + config/locales/app.admin.zu.yml | 1 + 10 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/frontend/templates/admin/members/members.html b/app/frontend/templates/admin/members/members.html index fdd7d70c7..6bc791e19 100644 --- a/app/frontend/templates/admin/members/members.html +++ b/app/frontend/templates/admin/members/members.html @@ -38,13 +38,14 @@ - {{ 'app.admin.members.surname' | translate }} - {{ 'app.admin.members.first_name' | translate }} - {{ 'app.admin.members.email' | translate }} - {{ 'app.admin.members.phone' | translate }} - {{ 'app.admin.members.user_type' | translate }} - {{ 'app.admin.members.subscription' | translate }} - + {{ 'app.admin.members.username' | translate }} + {{ 'app.admin.members.surname' | translate }} + {{ 'app.admin.members.first_name' | translate }} + {{ 'app.admin.members.email' | translate }} + {{ 'app.admin.members.phone' | translate }} + {{ 'app.admin.members.user_type' | translate }} + {{ 'app.admin.members.subscription' | translate }} + @@ -52,6 +53,7 @@ + {{ m.username }} {{ m.profile.last_name }} {{ m.profile.first_name }} {{ m.email }} diff --git a/app/services/members/list_service.rb b/app/services/members/list_service.rb index 2731d0f3c..8886c1f79 100644 --- a/app/services/members/list_service.rb +++ b/app/services/members/list_service.rb @@ -26,7 +26,8 @@ class Members::ListService # ILIKE => PostgreSQL case-insensitive LIKE if params[:search].size.positive? - @query = @query.where('profiles.first_name ILIKE :search OR ' \ + @query = @query.where('username ILIKE :search OR ' \ + 'profiles.first_name ILIKE :search OR ' \ 'profiles.last_name ILIKE :search OR ' \ 'profiles.phone ILIKE :search OR ' \ 'email ILIKE :search OR ' \ @@ -83,6 +84,8 @@ class Members::ListService offset = ((params[:page]&.to_i || 1) - 1) * (params[:size]&.to_i || 1) order_key = case order_key + when 'username' + 'username' when 'last_name' 'profiles.last_name' when 'first_name' diff --git a/app/views/api/members/list.json.jbuilder b/app/views/api/members/list.json.jbuilder index ee443adb1..38dd1b1a2 100644 --- a/app/views/api/members/list.json.jbuilder +++ b/app/views/api/members/list.json.jbuilder @@ -1,6 +1,7 @@ json.array!(@members) do |member| json.maxMembers @max_members json.id member.id + json.username member.username json.email member.email if current_user json.profile do json.first_name member.profile.first_name diff --git a/config/locales/app.admin.de.yml b/config/locales/app.admin.de.yml index de7d5e514..d45eaf7c8 100644 --- a/config/locales/app.admin.de.yml +++ b/config/locales/app.admin.de.yml @@ -823,6 +823,7 @@ de: search_for_an_user: "Nach einem Benutzer suchen" add_a_new_member: "Neues Mitglied hinzufügen" reservations: "Reservierungen" + username: "Username" surname: "Nachname" first_name: "Vorname" email: "E-Mail" diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index 517a86b46..99c8e1775 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -823,6 +823,7 @@ en: search_for_an_user: "Search for an user" add_a_new_member: "Add a new member" reservations: "Reservations" + username: "Username" surname: "Last name" first_name: "First name" email: "Email" diff --git a/config/locales/app.admin.es.yml b/config/locales/app.admin.es.yml index b52ef9b0e..8a46fcc73 100644 --- a/config/locales/app.admin.es.yml +++ b/config/locales/app.admin.es.yml @@ -823,6 +823,7 @@ es: search_for_an_user: "Buscar un usuario" add_a_new_member: "Añadir un nuevo miembro" reservations: "Reservas" + username: "Username" surname: "Last name" first_name: "First name" email: "Email" diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index de6d05e04..7a1ff72c0 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -823,6 +823,7 @@ fr: search_for_an_user: "Recherchez un utilisateur" add_a_new_member: "Ajouter un nouveau membre" reservations: "Réservations" + username: "Username" surname: "Nom" first_name: "Prénom" email: "Courriel" diff --git a/config/locales/app.admin.no.yml b/config/locales/app.admin.no.yml index 36ce0777e..18a1d84ce 100644 --- a/config/locales/app.admin.no.yml +++ b/config/locales/app.admin.no.yml @@ -823,6 +823,7 @@ search_for_an_user: "Søk etter bruker" add_a_new_member: "Legge til nytt medlem" reservations: "Reservasjoner" + username: "Username" surname: "Etternavn" first_name: "Fornavn" email: "E-post" diff --git a/config/locales/app.admin.pt.yml b/config/locales/app.admin.pt.yml index 9f3e311e5..0de16f51b 100755 --- a/config/locales/app.admin.pt.yml +++ b/config/locales/app.admin.pt.yml @@ -823,6 +823,7 @@ pt: search_for_an_user: "Buscar por usuário" add_a_new_member: "Adicionar novo membro" reservations: "Reservas" + username: "Username" surname: "Sobrenome" first_name: "Primeiro nome" email: "Email" diff --git a/config/locales/app.admin.zu.yml b/config/locales/app.admin.zu.yml index cc5fa2c44..5f1073973 100644 --- a/config/locales/app.admin.zu.yml +++ b/config/locales/app.admin.zu.yml @@ -823,6 +823,7 @@ zu: search_for_an_user: "crwdns7741:0crwdne7741:0" add_a_new_member: "crwdns7743:0crwdne7743:0" reservations: "crwdns7745:0crwdne7745:0" + username: "Username" surname: "crwdns7747:0crwdne7747:0" first_name: "crwdns7749:0crwdne7749:0" email: "crwdns7751:0crwdne7751:0"