Allow frontend item limitation
This commit is contained in:
parent
52e393a2df
commit
749bb8d184
|
@ -19,8 +19,16 @@ class Panel::Dictionary::FrontEnd::DictionaryVocabsController < OrbitWidgetContr
|
||||||
# end
|
# end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@item = Page.find(params[:page_id])
|
||||||
|
@title = @item.title
|
||||||
|
if !@item.frontend_data_count.blank?
|
||||||
|
@page_num = @item.frontend_data_count
|
||||||
|
else
|
||||||
|
@page_num = 10
|
||||||
|
end
|
||||||
|
|
||||||
if params[:search_query].empty?
|
if params[:search_query].empty?
|
||||||
@vocabs = DictionaryVocab.all
|
@vocabs = DictionaryVocab.page(params[:page_main]).per(@page_num)
|
||||||
else
|
else
|
||||||
@vocabs = DictionaryVocab.solr_search do
|
@vocabs = DictionaryVocab.solr_search do
|
||||||
fulltext params[:search_query]
|
fulltext params[:search_query]
|
||||||
|
|
|
@ -5,6 +5,7 @@ class DictionaryVocab
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
include Mongoid::Sortable
|
include Mongoid::Sortable
|
||||||
include Sunspot::Mongo
|
include Sunspot::Mongo
|
||||||
|
|
||||||
BelongsToCategory = :dictionary_vocab_category
|
BelongsToCategory = :dictionary_vocab_category
|
||||||
include OrbitCoreLib::BelongsToCategoryMayDisable
|
include OrbitCoreLib::BelongsToCategoryMayDisable
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ class DictionaryVocab
|
||||||
|
|
||||||
# field :is_top, :type => Boolean, :default => false
|
# field :is_top, :type => Boolean, :default => false
|
||||||
# field :is_hot, :type => Boolean, :default => false
|
# field :is_hot, :type => Boolean, :default => false
|
||||||
# field :is_hidden, :type => Boolean, :default => false
|
field :is_hidden, :type => Boolean, :default => false
|
||||||
|
|
||||||
scope :can_display, where(is_hidden: false)
|
scope :can_display, where(is_hidden: false)
|
||||||
|
|
||||||
|
@ -30,35 +31,20 @@ class DictionaryVocab
|
||||||
end
|
end
|
||||||
|
|
||||||
belongs_to :dictionary_vocab_category
|
belongs_to :dictionary_vocab_category
|
||||||
|
|
||||||
# has_many :archive_file_multiples, :autosave => true, :dependent => :destroy
|
# has_many :archive_file_multiples, :autosave => true, :dependent => :destroy
|
||||||
|
|
||||||
# accepts_nested_attributes_for :archive_file_multiples, :allow_destroy => true
|
# accepts_nested_attributes_for :archive_file_multiples, :allow_destroy => true
|
||||||
|
|
||||||
# after_save :save_archive_file_multiples
|
# after_save :save_archive_file_multiples
|
||||||
|
|
||||||
# searchable do
|
searchable do
|
||||||
# text :titles do
|
text :word, :definition
|
||||||
# title_translations.to_a.collect{|t| t[1]}
|
|
||||||
# end
|
|
||||||
# boolean :frontend_search do
|
|
||||||
# !is_hidden
|
|
||||||
# end
|
|
||||||
|
|
||||||
# end
|
boolean :frontend_search do
|
||||||
|
!is_hidden
|
||||||
# def self.search( category_id = nil )
|
end
|
||||||
|
end
|
||||||
# if category_id.to_s.size > 0
|
|
||||||
|
|
||||||
# find(:all, :conditions => {archive_file_category_id: category_id}).desc( :is_top, :title )
|
|
||||||
|
|
||||||
# else
|
|
||||||
|
|
||||||
# find(:all).desc( :is_top, :title)
|
|
||||||
|
|
||||||
# end
|
|
||||||
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
# def self.widget_datas
|
# def self.widget_datas
|
||||||
|
|
|
@ -28,3 +28,5 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<%= paginate( @vocabs, :param_name => :page_main, :params => {:inner => 'false'} ) rescue nil %>
|
|
@ -12,19 +12,15 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :front_end do
|
namespace :front_end do
|
||||||
get "dictionary_vocabs", to: "dictionary_vocabs#index"
|
match "dictionary_vocabs", to: "dictionary_vocabs#index"
|
||||||
resources :dictionary_vocabs
|
resources :dictionary_vocabs
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :widget do
|
namespace :widget do
|
||||||
get "dictionary_search_block", to: "dictionary_vocabs#dictionary_search_block"
|
match "dictionary_search_block", to: "dictionary_vocabs#dictionary_search_block"
|
||||||
get "dictionary_vocabs", to: "dictionary_vocabs#index"
|
match "dictionary_vocabs", to: "dictionary_vocabs#index"
|
||||||
resources :dictionary_vocabs
|
resources :dictionary_vocabs
|
||||||
end
|
end
|
||||||
# namespace :widget do
|
|
||||||
# match "index" => "archive_files#index"
|
|
||||||
# match "archive_search_block" => "archive_files#archive_search_block"
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
match "/appfront/*path" => redirect("/panel/*path")
|
match "/appfront/*path" => redirect("/panel/*path")
|
||||||
|
|
Loading…
Reference in New Issue