From 9d9d920eefdf435708ca3b2cc77b6ce6210710a3 Mon Sep 17 00:00:00 2001 From: Joshua Coles Date: Thu, 26 Oct 2023 14:28:32 +0100 Subject: [PATCH] Extract lecture actions into its own partial and add course homepage link --- .../attendance_tracker/_course_table.erb | 26 +----------------- .../_lecture_action.html.erb | 27 +++++++++++++++++++ .../attendance_tracker/course_focus.html.erb | 10 ++++++- app/views/attendance_tracker/today.html.erb | 27 +------------------ 4 files changed, 38 insertions(+), 52 deletions(-) create mode 100644 app/views/attendance_tracker/_lecture_action.html.erb diff --git a/app/views/attendance_tracker/_course_table.erb b/app/views/attendance_tracker/_course_table.erb index fb7d8e6..caa233a 100644 --- a/app/views/attendance_tracker/_course_table.erb +++ b/app/views/attendance_tracker/_course_table.erb @@ -28,31 +28,7 @@
- <% joinable_time = lecture.start_time - 5.minutes %> - - <% if lecture == @current_lecture %> - Started - <% elsif joinable_time.future? %> - <%= button_to "Prepare", - lecture_start_preparation_path(id: lecture.id), - class: 'action-button' - %> - <% elsif joinable_time.past? && !lecture.attended? %> - <% start_label = if lecture.is_live? then - "Join" - else - "Start" - end %> - <%= button_to start_label, - lectures_start_path(id: lecture.id), - class: 'action-button' - %> - <% else %> - <%= button_to "Review", - lecture_start_review_path(id: lecture.id), - class: 'action-button' - %> - <% end %> + <%= render partial: 'lecture_action', locals: { lecture: } %>
diff --git a/app/views/attendance_tracker/_lecture_action.html.erb b/app/views/attendance_tracker/_lecture_action.html.erb new file mode 100644 index 0000000..0d3d8d9 --- /dev/null +++ b/app/views/attendance_tracker/_lecture_action.html.erb @@ -0,0 +1,27 @@ +<% joinable_time = lecture.start_time - 5.minutes %> + +<% if lecture == @current_lecture %> +
+ Started +
+<% elsif joinable_time.future? %> + <%= button_to "Prepare", + lecture_start_preparation_path(id: lecture.id), + class: 'action-button' + %> +<% elsif joinable_time.past? && !lecture.attended? %> + <% start_label = if lecture.is_live? then + "Join" + else + "Start" + end %> + <%= button_to start_label, + lectures_start_path(id: lecture.id), + class: 'action-button' + %> +<% else %> + <%= button_to "Review", + lecture_start_review_path(id: lecture.id), + class: 'action-button' + %> +<% end %> diff --git a/app/views/attendance_tracker/course_focus.html.erb b/app/views/attendance_tracker/course_focus.html.erb index 43dc73a..737bed4 100644 --- a/app/views/attendance_tracker/course_focus.html.erb +++ b/app/views/attendance_tracker/course_focus.html.erb @@ -1,4 +1,12 @@ -

<%= @course.title %>

+
+

<%= @course.title %>

+ + <% if @course.homepage.present? %> + + + + <% end %> +
diff --git a/app/views/attendance_tracker/today.html.erb b/app/views/attendance_tracker/today.html.erb index 6d2833a..cafe8ae 100644 --- a/app/views/attendance_tracker/today.html.erb +++ b/app/views/attendance_tracker/today.html.erb @@ -34,32 +34,7 @@
- <% joinable_time = lecture.start_time - 5.minutes %> - <% if lecture == @current_lecture %> - Started - <% elsif joinable_time.future? %> - <%= button_to "Prepare", - lecture_start_preparation_path(id: lecture.id), - class: 'action-button' - %> - <% elsif joinable_time.past? && !lecture.attended? %> - <% start_label = if lecture.is_live? then - "Join" - else - "Start" - end %> - <%= button_to start_label, - lectures_start_path(id: lecture.id), - class: 'action-button' - %> - <% else %> -
- <%= button_to "Review", - lecture_start_review_path(id: lecture.id), - class: 'action-button' - %> -
- <% end %> + <%= render partial: 'lecture_action', locals: { lecture: } %>
<% end %>