Extract lecture actions into its own partial and add course homepage link

This commit is contained in:
Joshua Coles 2023-10-26 14:28:32 +01:00
parent b0d134fabd
commit 9d9d920eef
4 changed files with 38 additions and 52 deletions

View File

@ -28,31 +28,7 @@
</div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900">
<% 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: } %>
</div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900">

View File

@ -0,0 +1,27 @@
<% joinable_time = lecture.start_time - 5.minutes %>
<% if lecture == @current_lecture %>
<div class="py-1">
Started
</div>
<% 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 %>

View File

@ -1,4 +1,12 @@
<h1 class="text-3xl font-medium"><%= @course.title %></h1>
<div class="flex flex-row gap-2 items-center">
<h1 class="text-3xl font-medium"><%= @course.title %></h1>
<% if @course.homepage.present? %>
<a class="align-middle" href="<%= @course.homepage %>">
<i class="fa fa-link text-blue-600"></i>
</a>
<% end %>
</div>
<div class="flex flex-col gap-4">
<div class="mt-8 flow-root">

View File

@ -34,32 +34,7 @@
</div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900">
<% 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 %>
<div class="flex justify-center">
<%= button_to "Review",
lecture_start_review_path(id: lecture.id),
class: 'action-button'
%>
</div>
<% end %>
<%= render partial: 'lecture_action', locals: { lecture: } %>
</div>
</div>
<% end %>