Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promotion start/expiration times #3158

Merged
merged 2 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions backend/app/helpers/spree/admin/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ def admin_hint(title, text)
end
end

def datepicker_field_value(date)
unless date.blank?
l(date, format: t('spree.date_picker.format', default: '%Y/%m/%d'))
def datepicker_field_value(date, with_time: false)
return if date.blank?

format = if with_time
t('spree.date_picker.format_with_time', default: '%Y/%m/%d %H:%M')
else
t('spree.date_picker.format', default: '%Y/%m/%d')
end

l(date, format: format)
end

# @deprecated Render `spree/admin/shared/preference_fields/\#{preference_type}' instead
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), placeholder: t(".starts_at_placeholder"), class: 'datepicker datepicker-from fullwidth' %>
<%= 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), placeholder: t(".expires_at_placeholder"), class: 'datepicker datepicker-to fullwidth' %>
<%= 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