Banners created through the admin form were getting the default color. However, banners created by other means (like the `db:dev_seed` rake task) were not getting these default values. This feature was originally implemented when we were using Rails 4. With Rails 5, we can provide default values to all new banners and simplify the code at the same time thanks to its `attribute` method. Now, when creating a new banner, instead of getting a blank space, we get an empty line with the banner's default background color, which most users won't know what it's about until they fill in the banner's title. So we're not displaying the content of the banner when it's empty, thanks to the `:empty` CSS pseudoclass.
91 lines
3.1 KiB
Plaintext
91 lines
3.1 KiB
Plaintext
<%= render "shared/globalize_locales", resource: @banner %>
|
|
|
|
<%= translatable_form_for [:admin, @banner] do |f| %>
|
|
|
|
<%= render "shared/errors", resource: @banner %>
|
|
|
|
<div class="row">
|
|
<% date_started_at = @banner.post_started_at.present? ? I18n.localize(@banner.post_started_at) : "" %>
|
|
<div class="small-12 medium-3 column">
|
|
<%= f.text_field :post_started_at,
|
|
value: date_started_at,
|
|
class: "js-calendar-full",
|
|
id: "post_started_at" %>
|
|
</div>
|
|
<% date_ended_at = @banner.post_ended_at.present? ? I18n.localize(@banner.post_ended_at) : "" %>
|
|
<div class="small-12 medium-3 column end">
|
|
<%= f.text_field :post_ended_at,
|
|
value: date_ended_at,
|
|
class: "js-calendar-full",
|
|
id: "post_ended_at" %>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<%= f.translatable_fields do |translations_form| %>
|
|
<div class="small-12 medium-6 column">
|
|
<%= translations_form.text_field :title,
|
|
data: { js_banner_title: "js_banner_title" } %>
|
|
</div>
|
|
|
|
<div class="small-12 column">
|
|
<%= translations_form.text_field :description,
|
|
data: { js_banner_description: "js_banner_description" } %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="small-12 medium-6 column">
|
|
<%= f.text_field :target_url %>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="small-12 column">
|
|
<%= f.label :sections, t("admin.banners.banner.sections_label") %>
|
|
<%= f.collection_check_boxes(:web_section_ids, @banner_sections, :id, :name) do |b| %>
|
|
<%= b.check_box %> <%= t("admin.banners.banner.sections.#{b.text}") %><br>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="small-12 medium-6 large-3 column">
|
|
<%= f.label :background_color, nil, for: "background_color_input" %>
|
|
<p class="help-text"><%= t("admin.shared.color_help") %></p>
|
|
<div class="row collapse">
|
|
<div class="small-12 medium-6 column">
|
|
<%= f.text_field :background_color, label: false, type: :color %>
|
|
</div>
|
|
<div class="small-12 medium-6 column">
|
|
<%= f.text_field :background_color, label: false, id: "background_color_input" %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="small-12 medium-6 large-3 column end">
|
|
<%= f.label :font_color, nil, for: "font_color_input" %>
|
|
<p class="help-text"><%= t("admin.shared.color_help") %></p>
|
|
<div class="row collapse">
|
|
<div class="small-12 medium-6 column">
|
|
<%= f.text_field :font_color, label: false, type: :color %>
|
|
</div>
|
|
<div class="small-12 medium-6 column">
|
|
<%= f.text_field :font_color, label: false, id: "font_color_input" %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="actions small-12 medium-3 column">
|
|
<%= f.submit(class: "button expanded", value: t("admin.banners.edit.form.submit_button")) %>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<%= render "shared/banner", banner: @banner %>
|
|
</div>
|
|
<% end %>
|