diff options
author | David Gay <david@davidgay.org> | 2021-06-10 09:09:34 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-06-10 09:09:34 -0400 |
commit | f00aea423bafe7889c7bcc8d85b3561e2c9606d9 (patch) | |
tree | cdfc5fe3ec0258e55e07c58880eb9ac914af83a9 /app | |
parent | 779f19c5b35f7c8c7690dac9fbf4606f49cfffde (diff) |
Fix bug in timer partial render caused by not having an active character (#11)
Diffstat (limited to 'app')
-rw-r--r-- | app/views/application/_timer.html.erb | 100 |
1 files changed, 51 insertions, 49 deletions
diff --git a/app/views/application/_timer.html.erb b/app/views/application/_timer.html.erb index d683c6a..51d9b81 100644 --- a/app/views/application/_timer.html.erb +++ b/app/views/application/_timer.html.erb @@ -1,61 +1,63 @@ -<% if current_char.activity %> - <h2 class="text-lg text-display text-center"><%= current_char.activity.name %></h2> - <div data-controller="timer" - data-timer-time-remaining-value="<%= current_char.activity_time_remaining %>" - data-timer-activity-duration-value="<%= current_char.activity_duration - current_char.rested_duration_to_spend_on_activity %>" - data-timer-post-url-value="<%= finish_activity_url %>"> - <div class="text-center"> - <span data-timer-target="timer" class="text-xl text-display"></span> - </div> - <div class="border border-gray-800 h-4 my-1"> - <div data-timer-target="progressBar" class="bg-gray-600 h-full" - style="width: <%= current_char.percentage_of_activity_completed %>%"> +<% if current_char %> + <% if current_char.activity %> + <h2 class="text-lg text-display text-center"><%= current_char.activity.name %></h2> + <div data-controller="timer" + data-timer-time-remaining-value="<%= current_char.activity_time_remaining %>" + data-timer-activity-duration-value="<%= current_char.activity_duration - current_char.rested_duration_to_spend_on_activity %>" + data-timer-post-url-value="<%= finish_activity_url %>"> + <div class="text-center"> + <span data-timer-target="timer" class="text-xl text-display"></span> + </div> + <div class="border border-gray-800 h-4 my-1"> + <div data-timer-target="progressBar" class="bg-gray-600 h-full" + style="width: <%= current_char.percentage_of_activity_completed %>%"> + </div> </div> </div> - </div> - - <% most_recent_cs = current_char.character_skills.order(:updated_at).last %> - <div class="text-center text-sm"> - <div class="text-xs"><%= most_recent_cs.skill.name %> level <%= most_recent_cs.level %></div> - <div><%= most_recent_cs.xp_to_next_level %> XP to next level</div> - </div> - <div class="text-center my-2"> - <%= button_to "Stop", stop_activity_path, class: "text-sm" %> - </div> - - <div class="text-center text-xs my-2"> - <% if current_char.activity.gid.include?("beastslay") %> - <%= current_char.wounds %> / <%= pluralize(current_char.max_wounds, "wound") %> - <% end %> - <% current_char.active_states.each do |state| %> - <div> - <%= state.condition.name %> - </div> - <div> - (expires in <%= distance_of_time_in_words_to_now(state.expires_at) %>) - </div> - <% end %> - </div> + <% most_recent_cs = current_char.character_skills.order(:updated_at).last %> + <div class="text-center text-sm"> + <div class="text-xs"><%= most_recent_cs.skill.name %> level <%= most_recent_cs.level %></div> + <div><%= most_recent_cs.xp_to_next_level %> XP to next level</div> + </div> -<% else %> - <div class="text-center"> - <% if current_char.resting? %> - <p>You're resting.</p> - <% else %> - <p>You're not doing anything.</p> - <% end %> + <div class="text-center my-2"> + <%= button_to "Stop", stop_activity_path, class: "text-sm" %> + </div> - <div class="my-2"> - <%= button_to current_char.resting? ? "Stop Resting" : "Start Resting", toggle_resting_path %> + <div class="text-center text-xs my-2"> + <% if current_char.activity.gid.include?("beastslay") %> + <%= current_char.wounds %> / <%= pluralize(current_char.max_wounds, "wound") %> + <% end %> + <% current_char.active_states.each do |state| %> + <div> + <%= state.condition.name %> + </div> + <div> + (expires in <%= distance_of_time_in_words_to_now(state.expires_at) %>) + </div> + <% end %> </div> - <div class="text-xs"> - You have <%= distance_of_time_in_words_to_now(current_char.rested_until) %> of rested time. + <% else %> + <div class="text-center"> <% if current_char.resting? %> - This does not include time from your current rest. That time will be added when you stop resting. + <p>You're resting.</p> + <% else %> + <p>You're not doing anything.</p> <% end %> + + <div class="my-2"> + <%= button_to current_char.resting? ? "Stop Resting" : "Start Resting", toggle_resting_path %> + </div> + + <div class="text-xs"> + You have <%= distance_of_time_in_words_to_now(current_char.rested_until) %> of rested time. + <% if current_char.resting? %> + This does not include time from your current rest. That time will be added when you stop resting. + <% end %> + </div> </div> - </div> + <% end %> <% end %> |