From 93797a665de07cfd9b8fd70a6a4375a599218798 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Wed, 27 Sep 2017 16:37:52 +0200 Subject: [PATCH] Implement index page --- .../exercise_collections_controller.rb | 2 +- .../exercise_collections/index.html.slim | 25 ++++++++++++++++++- config/locales/de.yml | 8 ++++++ config/locales/en.yml | 8 ++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercise_collections_controller.rb b/app/controllers/exercise_collections_controller.rb index 359ed7b8..fb4e9ba2 100644 --- a/app/controllers/exercise_collections_controller.rb +++ b/app/controllers/exercise_collections_controller.rb @@ -3,7 +3,7 @@ class ExerciseCollectionsController < ApplicationController before_action :set_exercise_collection, only: [:show] def index - @exercise_collections = ExerciseCollection.all + @exercise_collections = ExerciseCollection.all.paginate(:page => params[:page]) authorize! end diff --git a/app/views/exercise_collections/index.html.slim b/app/views/exercise_collections/index.html.slim index 03f4829c..98de8a20 100644 --- a/app/views/exercise_collections/index.html.slim +++ b/app/views/exercise_collections/index.html.slim @@ -1 +1,24 @@ -h1 = 'ExerciseCollections#index' +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) \ No newline at end of file diff --git a/config/locales/de.yml b/config/locales/de.yml index 2ab23322..23232f19 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -111,6 +111,11 @@ de: name: "Name" file_type: "Dateityp" content: "Code" + exercise_collections: + id: "ID" + name: "Name" + updated_at: "Letzte Änderung" + exercises: "Aufgaben" models: code_harbor_link: one: CodeHarbor-Link @@ -127,6 +132,9 @@ de: exercise: one: Aufgabe other: Aufgaben + exercise_collection: + one: Aufgabesammlung + other: Aufgabensammlungen proxy_exercise: one: Proxy Aufgabe other: Proxy Aufgaben diff --git a/config/locales/en.yml b/config/locales/en.yml index e2cba090..543d9cd0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -111,6 +111,11 @@ en: name: "Name" file_type: "File Type" content: "Content" + exercise_collections: + id: "ID" + name: "Name" + updated_at: "Last Update" + exercises: "Exercises" models: code_harbor_link: one: CodeHarbor Link @@ -127,6 +132,9 @@ en: exercise: one: Exercise other: Exercises + exercise_collection: + one: Exercise Collection + other: Exercise Collections proxy_exercise: one: Proxy Exercise other: Proxy Exercises