From 152765122effb4bfa0e4412ba29c56b7c59b2b1a Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 13 Aug 2024 18:08:49 +0200 Subject: [PATCH] Add better UI feedback when closing/opening discussions --- app/controllers/lectures_controller.rb | 2 ++ app/views/lectures/edit/_comments.html.erb | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/controllers/lectures_controller.rb b/app/controllers/lectures_controller.rb index 719f59540..12fb42bdd 100644 --- a/app/controllers/lectures_controller.rb +++ b/app/controllers/lectures_controller.rb @@ -250,11 +250,13 @@ def close_comments @lecture.lessons.each do |lesson| lesson.media.update(annotations_status: -1) end + @lecture.touch redirect_to "#{edit_lecture_path(@lecture)}#communication" end def open_comments @lecture.open_comments!(current_user) + @lecture.touch redirect_to "#{edit_lecture_path(@lecture)}#communication" end diff --git a/app/views/lectures/edit/_comments.html.erb b/app/views/lectures/edit/_comments.html.erb index 1018f65e1..60af9b03f 100644 --- a/app/views/lectures/edit/_comments.html.erb +++ b/app/views/lectures/edit/_comments.html.erb @@ -5,12 +5,19 @@
- <%= link_to t('buttons.close_comments'), - lecture_close_comments_path(lecture), - class: 'btn btn-sm btn-outline-secondary' %> - <%= link_to t('buttons.open_comments'), - lecture_open_comments_path(lecture), - class: 'btn btn-sm btn-outline-secondary' %> + <% if lecture.comments_closed? %> + <%= link_to lecture_open_comments_path(lecture), + class: "btn btn-sm btn-outline-secondary", role: :button do %> + + <%= t('buttons.open_comments') %> + <% end %> + <% else %> + <%= link_to lecture_close_comments_path(lecture), + class: "btn btn-sm btn-outline-secondary", role: :button do %> + + <%= t('buttons.close_comments') %> + <% end %> + <% end %>