From 664110f8f10ee7440db4915d7f3fcc5b7f226a6c Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Tue, 20 Sep 2022 14:34:09 +0200 Subject: [PATCH] Show all study groups per consumer --- app/views/consumers/show.html.slim | 2 ++ app/views/study_groups/_table.html.slim | 20 ++++++++++++++++++++ app/views/study_groups/index.html.slim | 22 +--------------------- 3 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 app/views/study_groups/_table.html.slim diff --git a/app/views/consumers/show.html.slim b/app/views/consumers/show.html.slim index 9da38f3b..9bd5a093 100644 --- a/app/views/consumers/show.html.slim +++ b/app/views/consumers/show.html.slim @@ -6,3 +6,5 @@ h1 - %w[oauth_key oauth_secret].each do |attribute| = row(label: "consumer.#{attribute}") do = content_tag(:input, nil, class: 'form-control bg-secondary', readonly: true, value: @consumer.send(attribute)) + += render('study_groups/table', study_groups: @consumer.study_groups.sort) diff --git a/app/views/study_groups/_table.html.slim b/app/views/study_groups/_table.html.slim new file mode 100644 index 00000000..98d695a5 --- /dev/null +++ b/app/views/study_groups/_table.html.slim @@ -0,0 +1,20 @@ +.table-responsive + table.table.mt-4 + thead + tr + th = t('activerecord.attributes.study_group.name') + th = t('activerecord.attributes.study_group.external_id') + th = t('activerecord.attributes.study_group.consumer') + th = t('activerecord.attributes.study_group.member_count') + th colspan=3 = t('shared.actions') + tbody + - study_groups.each do |group| + tr + td = link_to_if(policy(group).show?, group.to_s, group) + td + code = group.external_id + td = link_to_if(policy(group.consumer).show?, group.consumer, group.consumer) + td = group.user_count + td = link_to(t('shared.show'), group) if policy(group).show? + td = link_to(t('shared.edit'), edit_study_group_path(group)) if policy(group).edit? + td = link_to(t('shared.destroy'), group, data: {confirm: t('shared.confirm_destroy')}, method: :delete) if policy(group).destroy? diff --git a/app/views/study_groups/index.html.slim b/app/views/study_groups/index.html.slim index ae41914a..088b904c 100644 --- a/app/views/study_groups/index.html.slim +++ b/app/views/study_groups/index.html.slim @@ -8,25 +8,5 @@ h1 = StudyGroup.model_name.human(count: 2) = f.label(:name_cont, t('activerecord.attributes.study_group.name'), class: 'visually-hidden form-label') = f.search_field(:name_cont, class: 'form-control', placeholder: t('activerecord.attributes.study_group.name')) -.table-responsive - table.table.mt-4 - thead - tr - th = t('activerecord.attributes.study_group.name') - th = t('activerecord.attributes.study_group.external_id') - th = t('activerecord.attributes.study_group.consumer') - th = t('activerecord.attributes.study_group.member_count') - th colspan=3 = t('shared.actions') - tbody - - @study_groups.each do |group| - tr - td = link_to_if(policy(group).show?, group.to_s, group) - td - code = group.external_id - td = link_to_if(policy(group.consumer).show?, group.consumer, group.consumer) - td = group.user_count - td = link_to(t('shared.show'), group) if policy(group).show? - td = link_to(t('shared.edit'), edit_study_group_path(group)) if policy(group).edit? - td = link_to(t('shared.destroy'), group, data: {confirm: t('shared.confirm_destroy')}, method: :delete) if policy(group).destroy? - += render('table', study_groups: @study_groups) = render('shared/pagination', collection: @study_groups)