5 attr :list, :items, :count, :paginate
7 def initialize list, items, count, paginate, operators, options
10 @count = count # total count
12 @operators = operators
17 if list_manifest.has_id?
18 filter_item_id = @options[:id]
19 if list_manifest.pre_id?
20 '/' + list_manifest.model.path_name + '/' + filter_item_id.to_s + '/' + list_manifest.action_name
22 '/' + list_manifest.model.path_name + '/' + list_manifest.action_name + '/' + filter_item_id.to_s
25 '/' + list_manifest.model.path_name + '/' + list_manifest.action_name
35 attr :item_name, :list_name,
36 :model_manifest, :model_list_manifest, :list_manifest, :model,
37 :default_page_size, :max_page_size
38 def initialize item_name, list_name
39 @item_name = item_name
40 @list_name = list_name
45 @list_group_manifest = LocalManifest.manifest.list_groups[@item_name]
46 @list_manifest = @list_group_manifest.lists[@list_name]
47 @where = @list_manifest.where
48 @includes = @list_manifest.includes
49 @order = @list_manifest.order
50 @model_manifest = ::Manifest.manifest.models[@item_name]
51 @model_list_manifest = @model_manifest.list
52 @model = ::Manifest.item_name_to_model @item_name
53 @table_name = @model.table_name
64 def page_number prm = nil
72 page_size = self.max_page_size if page_size > self.max_page_size
73 page_size = self.default_page_size if page_size < 1
78 @model_list_manifest.default_page_size
82 @model_list_manifest.max_page_size
85 def base_where_condition
86 method_name = @where.conditions do |name|
89 @model.__send__ method_name
101 @model.__send__ @order.order
104 def items operators, options, offset, page_size
105 @model.where(self.where_condition).includes(self.include_hash).order(self.order).offset(offset).limit(page_size)
108 def count operators, options
109 @model.where(self.where_condition).includes(self.include_hash).count
112 def paginate count, page, page_size
113 c = count ? count.to_i : 0
114 Kaminari.paginate_array(Array.new(c, nil)).page(page).per(page_size)
118 @model.my_peta.boost.select do |boost_name, boost_manifest|
119 boost_manifest.level == 'show'
124 manifests = self.boost_manifests
126 manifests.each do |boost_manifest|
127 item.boost_manifest # ?
132 def open operators, options
133 page = self.page_number(options[:page])
134 page_size = self.page_size options[:page_size]
135 offset = (page -1) * page_size
136 items = self.items operators, options, offset, page_size
137 count = self.count operators, options
138 pg = self.paginate count, page, page_size
140 ListResult.new self, items, count, pg, operators, options