Adjust filter for platform_admin user search and update views

This commit is contained in:
Janis Vaneylen
2022-09-09 17:51:24 +02:00
committed by Sebastian Serth
parent 02c65af034
commit 998a12e6bc
8 changed files with 25 additions and 25 deletions

View File

@ -66,7 +66,7 @@ class User < ApplicationRecord
def self.ransackable_attributes(auth_object)
if auth_object.admin?
%w[name email external_id consumer_id role]
%w[name email external_id consumer_id platform_admin]
else
%w[name external_id]
end

View File

@ -15,8 +15,7 @@ h1 = ExternalUser.model_name.human(count: 2)
= f.search_field(:external_id_cont, class: 'form-control', placeholder: t('activerecord.attributes.external_user.external_id'))
.row
.col-auto
= f.label(:role_eq, t('activerecord.attributes.external_user.role'), class: 'visually-hidden form-label')
= f.select(:role_eq, User::ROLES.map { |role| [t("users.roles.#{role}"), role] }, { include_blank: true }, class: 'form-control', prompt: t('activerecord.attributes.external_user.role'))
= f.select :platform_admin_true, [[t('shared.admin_filter.only'), 1], [t('shared.admin_filter.none'), 0]], { include_blank: t('shared.admin_filter.all'), selected: params[:q] ? params[:q][:platform_admin_true] : '' }
.col-auto.mt-3.mt-lg-0
= f.label(:consumer_id_eq, t('activerecord.attributes.external_user.consumer'), class: 'visually-hidden form-label')
= f.collection_select(:consumer_id_eq, Consumer.with_external_users, :id, :name, class: 'form-control', include_blank: true, prompt: t('activerecord.attributes.external_user.consumer') )

View File

@ -6,7 +6,7 @@ h1 = @user.displayname
code
= @user.external_id
= row(label: 'external_user.consumer', value: link_to_if(policy(@user.consumer).show?, @user.consumer, @user.consumer))
= row(label: 'external_user.role', value: t("users.roles.#{@user.role}"))
= row(label: 'external_user.platform_admin', value: @user.platform_admin?)
h4.mt-4 = link_to(t('.exercise_statistics'), statistics_external_user_path(@user)) if policy(@user).statistics?

View File

@ -9,7 +9,8 @@
.mb-3
= f.label(:name, class: 'form-label')
= f.text_field(:name, class: 'form-control', required: true)
.mb-3
= f.label(:role, class: 'form-label')
= f.select(:role, User::ROLES.map { |role| [t("users.roles.#{role}"), role] }, {selected: @user.role || 'teacher'}, class: 'form-control')
.form-check
label.form-check-label
= f.check_box(:platform_admin, class: 'form-check-input')
= f.label(:platform_admin, t('activerecord.attributes.external_user.platform_admin'), class: 'form-label')
.actions = render('shared/submit_button', f: f, object: @user)

View File

@ -8,23 +8,21 @@ h1 = InternalUser.model_name.human(count: 2)
= f.label(:email_cont, t('activerecord.attributes.internal_user.email'), class: 'visually-hidden form-label')
= f.search_field(:email_cont, class: 'form-control', placeholder: t('activerecord.attributes.internal_user.email'))
.col-auto
= f.label(:role_eq, t('activerecord.attributes.internal_user.role'), class: 'visually-hidden form-label')
= f.select(:role_eq, User::ROLES.map { |role| [t("users.roles.#{role}"), role] }, {}, class: 'form-control', prompt: t('activerecord.attributes.internal_user.role'))
= f.select :platform_admin_true, [[t('shared.admin_filter.only'), 1], [t('shared.admin_filter.none'), 0]], { include_blank: t('shared.admin_filter.all'), selected: params[:q] ? params[:q][:platform_admin_true] : '' }
.table-responsive
table.table.mt-4
thead
tr
th = t('activerecord.attributes.internal_user.name')
th = t('activerecord.attributes.internal_user.consumer')
th = t('activerecord.attributes.internal_user.role')
th = t('activerecord.attributes.internal_user.platform_admin')
th colspan=3 = t('shared.actions')
tbody
- @users.each do |user|
tr
td = link_to_if(policy(user).show?, user.name, user)
td = user.consumer ? link_to_if(policy(user.consumer).show?, user.consumer, user.consumer) : empty
td = t("users.roles.#{user.role}")
td = symbol_for(user.platform_admin?)
td = link_to(t('shared.show'), user) if policy(user).show?
td = link_to(t('shared.edit'), edit_internal_user_path(user)) if policy(user).edit?
td = link_to(t('shared.destroy'), user, data: {confirm: t('shared.confirm_destroy')}, method: :delete) if policy(user).destroy?

View File

@ -5,7 +5,7 @@ h1
= row(label: 'internal_user.email', value: @user.email)
= row(label: 'internal_user.name', value: @user.name)
= row(label: 'internal_user.consumer', value: @user.consumer ? link_to_if(policy(@user.consumer).show?, @user.consumer, @user.consumer) : nil)
= row(label: 'internal_user.role', value: t("users.roles.#{@user.role}"))
= row(label: 'internal_user.platform_admin', value: @user.platform_admin?)
= row(label: 'internal_user.activated', value: @user.activated?)
= row(label: 'codeharbor_link.profile_label', value: @user.codeharbor_link.nil? ? link_to(t('codeharbor_link.new'), new_codeharbor_link_path, class: 'btn btn-secondary') : link_to(t('codeharbor_link.edit'), edit_codeharbor_link_path(@user.codeharbor_link), class: 'btn btn-secondary'))

View File

@ -58,7 +58,7 @@ de:
email: E-Mail
external_id: Externe ID
name: Name
role: Rolle
platform_admin: Platform Admin
file:
content: Inhalt
feedback_message: Feedback-Nachricht
@ -95,7 +95,7 @@ de:
name: Name
password: Passwort
password_confirmation: Passwort-Bestätigung
role: Rolle
platform_admin: Platform Admin
request_for_comments:
comments: Kommentare
exercise: Aufgabe
@ -843,6 +843,10 @@ de:
new: Hinzufügen
new_model: '%{model} hinzufügen'
number: Nummer
admin_filter:
only: Plattform-Administratoren
none: Reguläre Nutzer:innen
all: Alle Nutzer:innen
object_cloned: '%{model} wurde erfolgreich dupliziert.'
object_created: '%{model} wurde erfolgreich erstellt.'
object_destroyed: '%{model} wurde erfolgreich gelöscht.'
@ -877,10 +881,7 @@ de:
percentage: Prozentzahl
siblings: Dazugehörige Abgaben
users:
roles:
admin: Administrator
learner: Lernender
teacher: Lehrer
platform_admin: Plattform Administrator
will_paginate:
next_label: 'Nächste Seite &#8594;'
page_gap: '&hellip;'

View File

@ -58,7 +58,7 @@ en:
email: Email
external_id: External ID
name: Name
role: Role
platform_admin: Platform Admin
file:
content: Content
feedback_message: Feedback Message
@ -95,7 +95,7 @@ en:
name: Name
password: Password
password_confirmation: Passwort Confirmation
role: Role
platform_admin: Platform Admin
request_for_comments:
comments: Comments
exercise: Exercise
@ -843,6 +843,10 @@ en:
new: Add
new_model: 'Add %{model}'
number: Number
admin_filter:
only: Platform admins
none: Regular users
all: All users
object_cloned: '%{model} has successfully been duplicated.'
object_created: '%{model} has successfully been created.'
object_destroyed: '%{model} has successfully been deleted.'
@ -877,10 +881,7 @@ en:
percentage: Percentage
siblings: Associated Submissions
users:
roles:
admin: Administrator
learner: Learner
teacher: Teacher
platform_admin: Platform Admin
will_paginate:
next_label: 'Next Page &#8594;'
page_gap: '&hellip;'