Skip to content

Commit

Permalink
Add locals declarations in several views and partial calls
Browse files Browse the repository at this point in the history
  • Loading branch information
moveson committed Dec 22, 2024
1 parent 0a5f40c commit b54ca58
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 20 deletions.
4 changes: 3 additions & 1 deletion app/controllers/subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class SubscriptionsController < ApplicationController
def new
@subscription = @subscribable.subscriptions.new(user: current_user)
authorize @subscription

render :new, locals: { subscription: @subscription }
end

# POST /subscribable/:subscribable_id/subscriptions
Expand All @@ -35,7 +37,7 @@ def create
render :create, locals: { subscription: @subscription, subscribable: @subscribable, protocol: protocol }
else
if @subscription.subscribable.is_a?(Event)
render :new, status: :unprocessable_entity
render :new, locals: { subscription: @subscription }, status: :unprocessable_entity
else
flash.now[:danger] = @subscription.errors.full_messages.to_sentence
render turbo_stream: turbo_stream.replace("flash", partial: "layouts/flash")
Expand Down
2 changes: 1 addition & 1 deletion app/views/event_groups/finish_line.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<li class="breadcrumb-item active">Finish Line</li>
</ul>
</div>
<%= render "events/time_and_course_info" %>
<%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>
</div>
</div>
<!-- Navigation -->
Expand Down
2 changes: 1 addition & 1 deletion app/views/event_groups/follow.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<li class="breadcrumb-item">Follow</li>
</ul>
</div>
<%= render 'events/time_and_course_info' %>
<%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>
</div>
</div>
<!-- Navigation -->
Expand Down
2 changes: 1 addition & 1 deletion app/views/event_groups/raw_times.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<li class="breadcrumb-item active">List</li>
</ul>
</div>
<%= render "events/time_and_course_info" %>
<%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>
</div>
</div>
<!-- Navigation -->
Expand Down
2 changes: 1 addition & 1 deletion app/views/event_groups/roster.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<li class="breadcrumb-item active">Roster</li>
</ul>
</div>
<%= render "events/time_and_course_info" %>
<%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>
</div>
</div>
<!-- Navigation -->
Expand Down
2 changes: 1 addition & 1 deletion app/views/event_groups/split_raw_times.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<li class="breadcrumb-item active">Splits</li>
</ul>
</div>
<%= render 'events/time_and_course_info' %>
<%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>
</div>
</div>
<!-- Navigation -->
Expand Down
2 changes: 1 addition & 1 deletion app/views/event_groups/stats.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<li class="breadcrumb-item active">Stats</li>
</ul>
</div>
<%= render 'events/time_and_course_info' %>
<%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>
</div>
</div>
<!-- Navigation -->
Expand Down
2 changes: 1 addition & 1 deletion app/views/event_groups/traffic.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<li class="breadcrumb-item active"><%= @presenter.split_name %></li>
</ul>
</div>
<%= render 'events/time_and_course_info' %>
<%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>
</div>
</div>
<!-- Navigation -->
Expand Down
6 changes: 3 additions & 3 deletions app/views/event_groups/webhooks.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<li class="breadcrumb-item">Webhooks</li>
</ul>
</div>
<%= render "events/time_and_course_info" %>
<%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>
</div>
</div>
<!-- Navigation -->
<%= render "events/view_buttons", view_object: @presenter %>
<%= render partial: "events/view_buttons", locals: { view_object: @presenter } %>
</div>
</header>

Expand Down Expand Up @@ -50,7 +50,7 @@
<div class="col">
<h4>
<span class="fw-bold"><%= event.name %></span>
<%= render "subscriptions/subscriptions_count", subscribable: event, current_user: current_user %>
<%= render partial: "subscriptions/subscriptions_count", locals: { subscribable: event, current_user: current_user } %>
</h4>
</div>
<div class="col-4 col-md-2 text-end d-grid">
Expand Down
8 changes: 5 additions & 3 deletions app/views/events/_time_and_course_info.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<%# locals: (presenter:) %>

<div class="ost-subtitle">
<p><%= l(@presenter.scheduled_start_time_local, format: :full_day_time_and_zone) %>
<% if @presenter.respond_to?(:course) %>
on <%= link_to @presenter.course_name, organization_course_path(@presenter.organization, @presenter.course) %>
<p><%= l(presenter.scheduled_start_time_local, format: :full_day_time_and_zone) %>
<% if presenter.respond_to?(:course) %>
on <%= link_to presenter.course_name, organization_course_path(presenter.organization, presenter.course) %>
<% end %>
</p>
</div>
2 changes: 2 additions & 0 deletions app/views/events/_view_buttons.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%# locals: (view_object:) %>

<ul class="nav nav-tabs nav-tabs-ost d-print-none">
<%= results_dropdown_menu(view_object) %>
<%= raw_times_dropdown_menu(view_object) if current_user&.authorized_to_edit?(view_object.event_group) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/events/finish_history.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<li class="breadcrumb-item active">Finish history</li>
</ul>
</div>
<%= render "time_and_course_info" %>
<%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>
</div>
</div>
<!-- Navigation -->
Expand Down
2 changes: 1 addition & 1 deletion app/views/events/podium.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<li class="breadcrumb-item active">Podium</li>
</ul>
</div>
<%= render "time_and_course_info" %>
<%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>
</div>
</div>
<!-- Navigation -->
Expand Down
2 changes: 1 addition & 1 deletion app/views/events/spread.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<li class="breadcrumb-item active">Full results</li>
</ul>
</div>
<%= render "time_and_course_info" %>
<%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>
</div>
<aside class="col-auto">
<%= link_to_beacon_button(@presenter) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/events/summary.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<li class="breadcrumb-item active">Results summary</li>
</ul>
</div>
<%= render "time_and_course_info" %>
<%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>
</div>
</div>
<!-- Navigation -->
Expand Down
4 changes: 3 additions & 1 deletion app/views/subscriptions/_subscriptions_count.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%# locals: (subscribable:, current_user:) %>

<span id="<%= dom_id(subscribable, :subscriptions_count) %>" class="h5 text-muted"><%= "#{pluralize_with_delimiter(subscribable.subscriptions.for_user(current_user).count, 'subscription')}" %></span>
<span id="<%= dom_id(subscribable, :subscriptions_count) %>" class="h5 text-muted">
<%= "#{pluralize_with_delimiter(subscribable.subscriptions.for_user(current_user).count, 'subscription')}" %>
</span>
2 changes: 1 addition & 1 deletion app/views/subscriptions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<% end %>

<article class="ost-article container">
<%= render "new_modal", subscription: @subscription %>
<%= render partial: "new_modal", locals: { subscription: subscription } %>
</article>

0 comments on commit b54ca58

Please sign in to comment.