diff --git a/app/controllers/request_for_comments_controller.rb b/app/controllers/request_for_comments_controller.rb index 90e7f871..f9fabb7d 100644 --- a/app/controllers/request_for_comments_controller.rb +++ b/app/controllers/request_for_comments_controller.rb @@ -11,7 +11,8 @@ class RequestForCommentsController < ApplicationController # GET /request_for_comments # GET /request_for_comments.json def index - @request_for_comments = RequestForComment.last_per_user(2).order('created_at DESC').paginate(page: params[:page]) + @search = RequestForComment.last_per_user(2).search(params[:q]) + @request_for_comments = @search.result.order('created_at DESC').paginate(page: params[:page]) authorize! end diff --git a/app/policies/request_for_comment_policy.rb b/app/policies/request_for_comment_policy.rb index a0762abf..0c5fcb4c 100644 --- a/app/policies/request_for_comment_policy.rb +++ b/app/policies/request_for_comment_policy.rb @@ -8,6 +8,10 @@ class RequestForCommentPolicy < ApplicationPolicy everyone end + def search? + everyone + end + def show? everyone end diff --git a/app/views/request_for_comments/index.html.slim b/app/views/request_for_comments/index.html.slim index b7ada0a2..db16b562 100644 --- a/app/views/request_for_comments/index.html.slim +++ b/app/views/request_for_comments/index.html.slim @@ -1,12 +1,20 @@ h1 = RequestForComment.model_name.human(count: 2) += render(layout: 'shared/form_filters') do |f| + .form-group + = f.label(:exercise_title_cont, t('activerecord.attributes.request_for_comments.exercise'), class: 'sr-only') + = f.search_field(:exercise_title_cont, class: 'form-control', placeholder: t('activerecord.attributes.request_for_comments.exercise')) + .form-group + = f.label(:title_cont, t('request_for_comments.solved'), class: 'sr-only') + = f.select(:solved_not_eq, [[t('request_for_comments.show_all'), 2], [t('request_for_comments.show_unsolved'), 1], [t('request_for_comments.show_solved'), 0]]) + .table-responsive table.table.sortable thead tr th i class="fa fa-lightbulb-o" aria-hidden="true" title = t('request_for_comments.solved') align="right" - th = t('activerecord.attributes.request_for_comments.exercise') + th = sort_link(@search, :title, t('activerecord.attributes.request_for_comments.exercise')) th = t('activerecord.attributes.request_for_comments.question') th i class="fa fa-comment" aria-hidden="true" title = t('request_for_comments.comments') align="center" diff --git a/config/locales/de.yml b/config/locales/de.yml index 699566a4..80f88c2a 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -146,6 +146,9 @@ de: internal_user: one: Interner Nutzer other: Interne Nutzer + request_for_comment: + one: Kommentaranfrage + other: Kommentaranfragen submission: one: Abgabe other: Abgaben @@ -417,6 +420,9 @@ de: all: "Alle Kommentaranfragen" no_question: "Der Autor hat keine Frage zu dieser Anfrage gestellt." mark_as_solved: "Diese Frage als beantwortet markieren" + show_all: "Alle Anfragen anzeigen" + show_solved: "Nur gelöste Anfragen anzeigen" + show_unsolved: "Nur ungelöste Anfragen anzeigen" solved: "Diese Frage wurde erfolgreich beantwortet" comment_exercise: "Ich möchte die Aufgabenstellung kommentieren" sessions: diff --git a/config/locales/en.yml b/config/locales/en.yml index dce861f7..853c703f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -167,6 +167,9 @@ en: internal_user: one: Internal User other: Internal Users + request_for_comment: + one: Request for Comments + other: Requests for Comments submission: one: Submission other: Submissions @@ -438,6 +441,9 @@ en: get_my_comment_requests: My Requests for Comments no_question: "The author did not enter a question for this request." mark_as_solved: "Mark this question as answered" + show_all: "All requests" + show_solved: "Solved requests" + show_unsolved: "Unvsolved requests" solved: "This question has been answered" comment_exercise: "I would like to give feedback for this exercise" sessions: