lib/avo/base_resource.rb in avo-2.19.0 vs lib/avo/base_resource.rb in avo-2.20.0
- old
+ new
@@ -60,20 +60,22 @@
grid_collector.instance_eval(&block)
self.grid_loader = grid_collector
end
- def action(action_class)
+ def action(action_class, arguments: {})
self.actions_loader ||= Avo::Loaders::Loader.new
- self.actions_loader.use action_class
+ action = { class: action_class, arguments: arguments }
+ self.actions_loader.use action
end
- def filter(filter_class)
+ def filter(filter_class, arguments: {})
self.filters_loader ||= Avo::Loaders::Loader.new
- self.filters_loader.use filter_class
+ filter = { class: filter_class , arguments: arguments }
+ self.filters_loader.use filter
end
# This is the search_query scope
# This should be removed and passed to the search block
def scope
@@ -168,13 +170,25 @@
return [] if self.class.filters_loader.blank?
self.class.filters_loader.bag
end
+ def get_filter_arguments(filter_class)
+ filter = get_filters.find { |filter| filter[:class] == filter_class.constantize }
+
+ filter[:arguments]
+ end
+
def get_actions
return [] if self.class.actions_loader.blank?
self.class.actions_loader.bag
+ end
+
+ def get_action_arguments(action_class)
+ action = get_actions.find { |action| action[:class].to_s == action_class.to_s }
+
+ action[:arguments]
end
def default_panel_name
return @params[:related_name].capitalize if @params.present? && @params[:related_name].present?