Add view for StudyGroups

This commit is contained in:
Sebastian Serth
2018-12-14 14:52:04 +01:00
parent 9061a07763
commit 7983c0797a
13 changed files with 168 additions and 9 deletions

View File

@@ -0,0 +1,19 @@
= form_for(@study_group) do |f|
= render('shared/form_errors', object: @study_group)
.form-group
= f.label(:name)
= f.text_field(:name, class: 'form-control', required: true)
h3 = t('activerecord.attributes.study_group.members')
.table-responsive
table.table
thead
tr
th = t('activerecord.attributes.exercise.selection')
th = sort_link(@search, :name, t('navigation.sections.users'))
= collection_check_boxes :study_group, :study_group_membership_ids, @members, :id, :id do |b|
tr
td = b.check_box
td = link_to_if(policy(b.object.user).show?, b.object.user.displayname, b.object.user)
.actions = render('shared/submit_button', f: f, object: @study_group)

View File

@@ -0,0 +1,3 @@
h1 = @study_group
= render('form')

View File

@@ -0,0 +1,32 @@
h1 = StudyGroup.model_name.human(count: 2)
= render(layout: 'shared/form_filters') do |f|
.form-group
= f.label(:consumer_id_eq, t('activerecord.attributes.internal_user.consumer'), class: 'sr-only')
= f.collection_select(:consumer_id_eq, Consumer.with_study_groups, :id, :name, class: 'form-control', prompt: t('activerecord.attributes.internal_user.consumer'))
.form-group
= f.label(:name_cont, t('activerecord.attributes.study_group.name'), class: 'sr-only')
= 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.users.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('shared/pagination', collection: @study_groups)

View File

@@ -0,0 +1,21 @@
h1
= @study_group
- if policy(@study_group).edit?
= render('shared/edit_button', object: @study_group)
= row(label: 'study_group.name', value: @study_group.name)
= row(label: 'study_group.external_id') do
code = @study_group.external_id
= row(label: 'study_group.consumer', value: link_to_if(policy(@study_group).show?, @study_group.consumer, @study_group.consumer))
= row(label: 'study_group.member_count', value: @study_group.users.count)
h2.mt-4 = t('activerecord.attributes.study_group.members')
.table-responsive
table.table
thead
tr
th = sort_link(@search, :name, t('navigation.sections.users'))
- @study_group.users.each do |user|
tr
td = link_to_if(policy(user).show?, user.displayname, user)