This commit is contained in:
rulingcom 2026-06-11 14:44:33 +08:00
parent 62e085f07a
commit a53073bd3d
4 changed files with 19 additions and 5 deletions

View File

@ -20,9 +20,9 @@ class Admin::AdBannersController < OrbitAdminController
def show
@banner = Banner.find(params[:id])
if params[:show] == "expired"
@images = @banner.ad_images.is_expired.asc(:sort_number).page(params[:page]).per(10)
@images = @banner.ad_images.is_expired.order_by(is_top: -1, sort_number: 1).page(params[:page]).per(10)
else
@images = @banner.ad_images.not_expired.asc(:sort_number).page(params[:page]).per(10)
@images = @banner.ad_images.not_expired.order_by(is_top: -1, sort_number: 1).page(params[:page]).per(10)
end
@table_fields = [:banner, :title, "ad_banner.duration", :link]
end

View File

@ -19,6 +19,7 @@ class AdImage
field :deadline , :type => DateTime
field :youtube , :type => String
field :sort_number, :type => Integer
field :is_top, :type => Boolean, :default => false
field :language_enabled, :type => Array, :default => ["en","zh_tw"]
field :exchange_item, :default => "1"
LINK_OPEN_TYPES = ["local", "new_window"]

View File

@ -50,7 +50,10 @@
<tbody>
<% @images.each do |image| %>
<tr>
<td>
<td>
<% if image.is_top? %>
<span class="label label-warning"><%= t(:top) %></span>
<% end %>
<% if image.exchange_item == "1" %>
<%= image_tag image.file.thumb, :class => "banner-image" %>
<% elsif image.exchange_item == "2" %>
@ -115,11 +118,11 @@
</div>
<div class="modal-body">
<ul class="order-list">
<% @banner.ad_images.not_expired.asc(:sort_number).each do |image| %>
<% @banner.ad_images.not_expired.order_by(is_top: -1, sort_number: 1).each do |image| %>
<li class="order-list-image" data-image-id="<%= image.id.to_s %>">
<i class="icons-list-2"></i>
<img src="<%= image.exchange_item == "1" ? image.file.thumb.url : image.youtube_thumb %>"/>
<h4><%= image.title %>
<h4><%= image.title %><%= "<span class='label label-warning'>#{t(:top)}</span>".html_safe if image.is_top? %>
</li>
<% end %>
</ul>

View File

@ -29,6 +29,15 @@
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- TOP -->
<div class="control-group">
<label class="control-label muted"><%= t(:top) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @ad_image.is_top? %>">
<%= f.check_box :is_top %> <%= t(:top) %>
</label>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t("ad_banner.type") %></label>
@ -168,6 +177,7 @@
</div>
</div>
<!-- Date Time Picker -->
<div class="control-group">
<label class="control-label muted"><%= t(:start_date) %></label>