Skip to content

Commit

Permalink
Display promotion start and expiration times in admin panel
Browse files Browse the repository at this point in the history
Admins can now specify the exact time a promotion starts or expires,
so we also need to display this information in the promotions list.
  • Loading branch information
aldesantis committed Apr 6, 2019
1 parent 2f24b2f commit 91dcc75
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/app/helpers/spree/admin/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def admin_hint(title, text)
end
end

def datepicker_field_value(date, with_time = false)
def datepicker_field_value(date, with_time: false)
return if date.blank?

format = if with_time
Expand Down
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/promotions/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
<div id="starts_at_field" class="field">
<%= f.label :starts_at %>
<%= f.field_hint :starts_at %>
<%= f.text_field :starts_at, value: datepicker_field_value(@promotion.starts_at, true), placeholder: t(".starts_at_placeholder"), class: 'datepicker datepicker-from fullwidth', data: { :'enable-time' => true, :'default-hour' => 0 } %>
<%= f.text_field :starts_at, value: datepicker_field_value(@promotion.starts_at, with_time: true), placeholder: t(".starts_at_placeholder"), class: 'datepicker datepicker-from fullwidth', data: { :'enable-time' => true, :'default-hour' => 0 } %>
</div>

<div id="expires_at_field" class="field">
<%= f.label :expires_at %>
<%= f.field_hint :expires_at %>
<%= f.text_field :expires_at, value: datepicker_field_value(@promotion.expires_at, true), placeholder: t(".expires_at_placeholder"), class: 'datepicker datepicker-to fullwidth', data: { :'enable-time' => true, :'default-hour' => 0 } %>
<%= f.text_field :expires_at, value: datepicker_field_value(@promotion.expires_at, with_time: true), placeholder: t(".expires_at_placeholder"), class: 'datepicker datepicker-to fullwidth', data: { :'enable-time' => true, :'default-hour' => 0 } %>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/promotions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@
<%= promotion.usage_count %>
</td>
<td>
<%= promotion.starts_at.to_date.to_s(:short_date) if promotion.starts_at %>
<%= promotion.starts_at.to_s(:long) if promotion.starts_at %>
</td>
<td>
<%= promotion.expires_at.to_date.to_s(:short_date) if promotion.expires_at %>
<%= promotion.expires_at.to_s(:long) if promotion.expires_at %>
</td>
<td class="actions">
<% if can?(:edit, promotion) %>
Expand Down

0 comments on commit 91dcc75

Please sign in to comment.