Admin option to add banners and show banners
This commit is contained in:
@@ -43,6 +43,13 @@
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<li <%= "class=active" if controller_name == "banners" %>>
|
||||
<%= link_to admin_banners_path do %>
|
||||
<span class="icon-eye"></span>
|
||||
<%= t("admin.menu.banner") %>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
<li <%= "class=active" if controller_name == "users" %>>
|
||||
<%= link_to admin_users_path do %>
|
||||
<span class="icon-eye"></span>
|
||||
|
||||
15
app/views/admin/banners/_errors.html.erb
Normal file
15
app/views/admin/banners/_errors.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
<% if @banner.errors.any? %>
|
||||
|
||||
<div id="error_explanation" data-alert class="callout alert" data-closable>
|
||||
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
|
||||
<strong>
|
||||
<%= @banner.errors.count %>
|
||||
<%= t("admin.banners.errors.form.error", count: @banner.errors.count) %>
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
69
app/views/admin/banners/_form.html.erb
Normal file
69
app/views/admin/banners/_form.html.erb
Normal file
@@ -0,0 +1,69 @@
|
||||
<%= form_for [:admin, @banner] do |f| %>
|
||||
|
||||
<%= render 'errors' %>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-3 column">
|
||||
<%= f.label :style, t("admin.banners.banner.style") %>
|
||||
<%= f.select :style, options_for_select(@banner_styles, @banner.style),:include_blank => '-',
|
||||
label: false,placeholder: t("admin.banners.banner.style") %>
|
||||
</div>
|
||||
<div class="small-3 column">
|
||||
<%= f.label :image, t("admin.banners.banner.image") %>
|
||||
<%= f.select :image, options_for_select(@banner_imgs, @banner.image),:include_blank => '-',
|
||||
label: false, placeholder: t("admin.banners.banner.image") %>
|
||||
</div>
|
||||
<div class="small-12 column">
|
||||
<%= f.label :title, t("admin.banners.banner.title") %>
|
||||
<%= f.text_field :title, placeholder: t("admin.banners.banner.title"), label: false,
|
||||
data: {js_banner_title: "js_banner_title"} %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.label :description, t("admin.banners.banner.description") %>
|
||||
<%= f.text_field :description,
|
||||
label: false,
|
||||
data: {js_banner_description: "js_banner_description"},
|
||||
placeholder: t("admin.banners.banner.description") %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.label :target_url, t("admin.banners.banner.target_url") %>
|
||||
<%= f.text_field :target_url,
|
||||
label: false,
|
||||
placeholder: t("admin.banners.banner.target_url") %>
|
||||
</div>
|
||||
<% date_started_at = @banner.post_started_at.present? ? I18n.localize(@banner.post_started_at) : "" %>
|
||||
<div class="small-3 column">
|
||||
<%= f.label :post_started_at, t("admin.banners.banner.post_started_at") %>
|
||||
<%= f.text_field :post_started_at,
|
||||
label: false,
|
||||
placeholder: t("admin.banners.banner.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-3 column">
|
||||
<%= f.label :post_ended_at, t("admin.banners.banner.post_ended_at") %>
|
||||
<%= f.text_field :post_ended_at,
|
||||
label: false,
|
||||
placeholder: t("admin.banners.banner.post_ended_at"),
|
||||
value: date_ended_at,
|
||||
class: "js-calendar-full",
|
||||
id: "post_ended_at" %>
|
||||
</div>
|
||||
|
||||
<div class="actions small-12 column">
|
||||
<%= f.submit(class: "button", value: t("admin.banners.edit.form.submit_button")) %>
|
||||
</div>
|
||||
</div>
|
||||
<div id="js-banner-style" class="<%= @banner.style %>">
|
||||
<div id="js-banner-image" class="<%= @banner.image %>">
|
||||
<%= link_to @banner.target_url do %>
|
||||
<h2 id="js-banner-title"><%= @banner.title %></h2>
|
||||
<h3 id="js-banner-description"><%= @banner.description %></h3>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
13
app/views/admin/banners/edit.html.erb
Normal file
13
app/views/admin/banners/edit.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<div class="banner-edit row">
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= link_to admin_banners_path, class: "back" do %>
|
||||
<span class="icon-angle-left"></span>
|
||||
<%= t("admin.banners.edit.back") %>
|
||||
<% end %>
|
||||
|
||||
<h1><%= t("admin.banners.edit.editing") %></h1>
|
||||
|
||||
<%= render "form" %>
|
||||
</div>
|
||||
</div>
|
||||
45
app/views/admin/banners/index.html.erb
Normal file
45
app/views/admin/banners/index.html.erb
Normal file
@@ -0,0 +1,45 @@
|
||||
<%= link_to t("admin.banners.index.create"),
|
||||
new_admin_banner_path, class: "button large success float-right" %>
|
||||
|
||||
<h2 class="inline-block"><%= t("admin.banners.index.title") %></h2>
|
||||
|
||||
<%= render 'shared/filter_subnav', i18n_namespace: "admin.banners.index" %>
|
||||
|
||||
<h3><%= page_entries_info @banners %></h3>
|
||||
|
||||
<table>
|
||||
<% @banners.each do |banner| %>
|
||||
<tr id="<%= dom_id(banner) %>">
|
||||
<td class="samll-12 medium-9">
|
||||
<div class="<%= banner.style %>">
|
||||
<div class="<%= banner.image %>">
|
||||
<%= link_to banner.target_url do %>
|
||||
<h2><%= banner.title %></h2>
|
||||
<h3><%= banner.description %></h3>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= t("admin.banners.banner.post_started_at")%> <strong><%= banner.post_started_at %></strong>
|
||||
|
|
||||
<%= t("admin.banners.banner.post_ended_at")%> <strong><%= banner.post_ended_at%></strong>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<%= link_to edit_admin_banner_path(banner),
|
||||
class: 'edit-banner button' do %>
|
||||
<span class="icon-edit"></span>
|
||||
<%= t("admin.banners.index.edit") %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to admin_banner_path(banner), method: :delete,
|
||||
class: 'delete' do %>
|
||||
<span class="icon-delete"></span>
|
||||
<%= t("admin.banners.index.delete") %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<%= paginate @banners %>
|
||||
13
app/views/admin/banners/new.html.erb
Normal file
13
app/views/admin/banners/new.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<div class="banner-new row">
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= link_to admin_banners_path, class: "back" do %>
|
||||
<span class="icon-angle-left"></span>
|
||||
<%= t("admin.banners.new.back") %>
|
||||
<% end %>
|
||||
|
||||
<h1><%= t("admin.banners.new.creating") %></h1>
|
||||
|
||||
<%= render "form" %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -32,3 +32,37 @@
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<% if @banner_styles.present? %>
|
||||
<h2><%= t("admin.settings.index.banners") %></h2>
|
||||
|
||||
<ul class="admin-list">
|
||||
<% @banner_styles.each do |setting| %>
|
||||
<li>
|
||||
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||
|
||||
<%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %>
|
||||
<%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %>
|
||||
<%= f.submit(t('admin.settings.index.update_setting'), class: "button small success") %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if @banner_imgs.present?%>
|
||||
<h2><%= t("admin.settings.index.banner_imgs") %></h2>
|
||||
|
||||
<ul class="admin-list">
|
||||
<% @banner_imgs.each do |setting| %>
|
||||
<li>
|
||||
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||
|
||||
<%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %>
|
||||
<%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %>
|
||||
<%= f.submit(t('admin.settings.index.update_setting'), class: "button small success") %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user