fix ad_banner backend index sorting

This commit is contained in:
manson 2014-08-21 11:07:08 +08:00
parent 8aa5a4f7d6
commit 51d8577774
4 changed files with 10 additions and 5 deletions

View File

@ -32,7 +32,6 @@ function preview() {
var resize = 500/bannerW var resize = 500/bannerW
bannerW = Math.floor(bannerW*resize); bannerW = Math.floor(bannerW*resize);
bannerH = Math.floor(bannerH*resize); bannerH = Math.floor(bannerH*resize);
console.log(bannerW)
}; };
if(bannerH > 300) { if(bannerH > 300) {
var resize = 300/bannerH var resize = 300/bannerH

View File

@ -4,7 +4,7 @@ class Admin::AdBannersController < OrbitBackendController
open_for_sub_manager open_for_sub_manager
def index def index
@ad_banners = AdBanner.all.page(params[:page]).per(10) @ad_banners = get_sorted_and_filtered("ad_banner")
end end
def show def show

View File

@ -11,7 +11,7 @@ class Admin::AdImagesController < Admin::AdBannersController
end end
def index def index
@ad_images = AdImage.all.page(params[:page]).per(10) @ad_images = get_sorted_and_filtered("ad_image")
end end
def edit def edit

View File

@ -321,6 +321,8 @@ class ApplicationController < ActionController::Base
sorted_objects.flatten! sorted_objects.flatten!
sorted_objects.uniq! sorted_objects.uniq!
objects = get_with_nil(objects, option, sorted_objects) objects = get_with_nil(objects, option, sorted_objects)
elsif option.eql?('size')
objects = objects.order_by([ [:width, params[:direction]], [:height, params[:direction]] ])
end end
end end
end end
@ -361,8 +363,12 @@ class ApplicationController < ActionController::Base
end end
if pagination if pagination
# Kaminari.paginate_array(filter_authorized_objects(objects)).page(params[:page]).per(10) filtered_objects = filter_authorized_objects(objects)
filter_authorized_objects(objects).page(params[:page]).per(10) if filtered_objects.is_a?(Array)
Kaminari.paginate_array(filtered_objects).page(params[:page]).per(10)
else
filter_authorized_objects(objects).page(params[:page]).per(10)
end
else else
filter_authorized_objects(objects) filter_authorized_objects(objects)
end end