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