Merge pull request #130 from openHPI/exercise-collections-ui
Exercise Collections UI
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
- if current_user.admin?
|
||||
li = link_to(t('breadcrumbs.dashboard.show'), admin_dashboard_path)
|
||||
li.divider
|
||||
- models = [ExecutionEnvironment, Exercise, ProxyExercise, Tag, Consumer, CodeHarborLink, ExternalUser, FileType, FileTemplate, InternalUser].sort_by { |model| model.model_name.human(count: 2) }
|
||||
- models = [ExecutionEnvironment, Exercise, ExerciseCollection, ProxyExercise, Tag, Consumer, CodeHarborLink, ExternalUser, FileType, FileTemplate, InternalUser].sort_by { |model| model.model_name.human(count: 2) }
|
||||
- models.each do |model|
|
||||
- if policy(model).index?
|
||||
li = link_to(model.model_name.human(count: 2), send(:"#{model.model_name.collection}_path"))
|
||||
|
11
app/views/exercise_collections/_form.html.slim
Normal file
11
app/views/exercise_collections/_form.html.slim
Normal file
@@ -0,0 +1,11 @@
|
||||
- exercises = Exercise.order(:title)
|
||||
|
||||
= form_for(@exercise_collection, data: {exercises: exercises}, multipart: true) do |f|
|
||||
= render('shared/form_errors', object: @exercise_collection)
|
||||
.form-group
|
||||
= f.label(:name)
|
||||
= f.text_field(:name, class: 'form-control', required: true)
|
||||
.form-group
|
||||
= f.label(:exercises)
|
||||
= f.collection_select(:exercise_ids, exercises, :id, :title, {}, {class: 'form-control', multiple: true})
|
||||
.actions = render('shared/submit_button', f: f, object: @exercise_collection)
|
3
app/views/exercise_collections/edit.html.slim
Normal file
3
app/views/exercise_collections/edit.html.slim
Normal file
@@ -0,0 +1,3 @@
|
||||
h1 = @exercise_collection
|
||||
|
||||
= render('form')
|
24
app/views/exercise_collections/index.html.slim
Normal file
24
app/views/exercise_collections/index.html.slim
Normal file
@@ -0,0 +1,24 @@
|
||||
h1 = ExerciseCollection.model_name.human(count: 2)
|
||||
|
||||
.table-responsive
|
||||
table.table
|
||||
thead
|
||||
tr
|
||||
th = t('activerecord.attributes.exercise_collections.id')
|
||||
th = t('activerecord.attributes.exercise_collections.name')
|
||||
th = t('activerecord.attributes.exercise_collections.updated_at')
|
||||
th = t('activerecord.attributes.exercise_collections.exercises')
|
||||
th colspan=3 = t('shared.actions')
|
||||
tbody
|
||||
- @exercise_collections.each do |collection|
|
||||
tr
|
||||
td = collection.id
|
||||
td = link_to(collection.name, collection)
|
||||
td = collection.updated_at
|
||||
td = collection.exercises.size
|
||||
td = link_to(t('shared.show'), collection)
|
||||
td = link_to(t('shared.edit'), edit_exercise_collection_path(collection))
|
||||
td = link_to(t('shared.destroy'), collection, data: {confirm: t('shared.confirm_destroy')}, method: :delete)
|
||||
|
||||
= render('shared/pagination', collection: @exercise_collections)
|
||||
p = render('shared/new_button', model: ExerciseCollection)
|
3
app/views/exercise_collections/new.html.slim
Normal file
3
app/views/exercise_collections/new.html.slim
Normal file
@@ -0,0 +1,3 @@
|
||||
h1 = t('shared.new_model', model: ExerciseCollection.model_name.human)
|
||||
|
||||
= render('form')
|
11
app/views/exercise_collections/show.html.slim
Normal file
11
app/views/exercise_collections/show.html.slim
Normal file
@@ -0,0 +1,11 @@
|
||||
h1
|
||||
= @exercise_collection
|
||||
= render('shared/edit_button', object: @exercise_collection)
|
||||
|
||||
= row(label: 'exercise_collections.name', value: @exercise_collection.name)
|
||||
= row(label: 'exercise_collections.updated_at', value: @exercise_collection.updated_at)
|
||||
|
||||
h4 = t('activerecord.attributes.exercise_collections.exercises')
|
||||
ul.list-unstyled
|
||||
- @exercise_collection.exercises.sort_by{|c| c.title}.each do |exercise|
|
||||
li = link_to(exercise, exercise)
|
Reference in New Issue
Block a user