super
@filter_key = @list_manifest.filter_key
@filter_item_name = @list_manifest.filter_item_name
+ @filter_model = ::Manifest.manifest.models[@filter_item_name].classify
+ @filter_table_name = @filter_model.table_name
end
def where_condition filter_item_id
w
end
+ def visible? item_id, operators
+ r = nil
+ begin
+ r = @filter_model.show(item_id, operators)
+ rescue ActiveRecord::RecordNotFound, ActiveRecord::Forbidden
+ r = false
+ end
+ r
+ end
+
def items operators, options, offset, page_size
filter_item_id = options[:id]
- @model.where(self.where_condition(filter_item_id)).includes(self.include_hash).order(self.order).offset(offset).limit(page_size)
+ if self.visible? filter_item_id, operators
+ @model.where(self.where_condition(filter_item_id)).includes(self.include_hash).order(self.order).offset(offset).limit(page_size)
+ else
+ []
+ end
end
def count operators, options
filter_item_id = options[:id]
- @model.where(self.where_condition(filter_item_id)).includes(self.include_hash).count
+ if self.visible? filter_item_id, operators
+ @model.where(self.where_condition(filter_item_id)).includes(self.include_hash).count
+ else
+ 0
+ end
end
end