forked from saurabh/orbit4-5
54 lines
1.6 KiB
Ruby
54 lines
1.6 KiB
Ruby
class OrbitAdminController < ApplicationController
|
|
include OrbitCoreLib::Authorize
|
|
include OrbitCoreLib::PermissionUtility
|
|
include Authorize
|
|
include OrbitBackendHelper
|
|
|
|
before_action :authenticate_user, :log_user_action
|
|
layout "back_end"
|
|
|
|
def sort
|
|
unless params[:sort].blank?
|
|
case params[:sort]
|
|
when "status"
|
|
@sort = [[:is_top, params[:order]],
|
|
[:is_hot, params[:order]],
|
|
[:is_hidden,params[:order]]]
|
|
when "category"
|
|
@sort = {:category_id=>params[:order]}
|
|
when "title"
|
|
@sort = {:title=>params[:order]}
|
|
when "start_date"
|
|
@sort = {:postdate=>params[:order]}
|
|
when "end_date"
|
|
@sort = {:deadline=>params[:order]}
|
|
when "last_modified"
|
|
@sort = {:update_user_id=>params[:order]}
|
|
end
|
|
else
|
|
@sort = {:created_at=>'desc'}
|
|
end
|
|
@sort
|
|
end
|
|
|
|
def filter_fields(categories, tags)
|
|
{
|
|
:status=>[{:title=>"is_top",:id=>"is_top"},{:title=>"is_hot",:id=>"is_hot"},{:title=>"is_hidden",:id=>"is_hidden"}],
|
|
:category=>categories.map{|c| {:title=>c.title, :id=>c.id}},
|
|
:tags=>tags.map{|tag| {:title=>tag.name, :id=>tag.id}}
|
|
}
|
|
end
|
|
|
|
def filters(type)
|
|
case type
|
|
when "status"
|
|
params[:filters][:status].blank? ? [] : params[:filters][:status] rescue []
|
|
when "category"
|
|
params[:filters][:category].blank? ? [] : params[:filters][:category] rescue []
|
|
when "tag"
|
|
params[:filters][:tags].blank? ? [] : params[:filters][:tags] rescue []
|
|
end
|
|
end
|
|
|
|
end
|