OSDN Git Service
(root)
/
pettanr
/
pettanr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
clean
[pettanr/pettanr.git]
/
lib
/
locmare
/
list_group
/
list
/
filter.rb
diff --git
a/lib/locmare/list_group/list/filter.rb
b/lib/locmare/list_group/list/filter.rb
index
b105091
..
4f98930
100644
(file)
--- a/
lib/locmare/list_group/list/filter.rb
+++ b/
lib/locmare/list_group/list/filter.rb
@@
-7,6
+7,8
@@
module Locmare
super
@filter_key = @list_manifest.filter_key
@filter_item_name = @list_manifest.filter_item_name
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
end
def where_condition filter_item_id
@@
-21,14
+23,32
@@
module Locmare
w
end
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]
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]
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
end
end