module Matestack::Ui::VueJs::Components::Collection::Helper
Public Instance Methods
_set_collection(id: nil, init_offset: 0, init_limit: nil, base_count: nil, filtered_count: nil, data: nil)
click to toggle source
# File lib/matestack/ui/vue_js/components/collection/helper.rb, line 40 def _set_collection id: nil, init_offset: 0, init_limit: nil, base_count: nil, filtered_count: nil, data: nil @collections = {} if @collections.nil? collection_config = CollectionConfig.new( id, init_offset, init_limit, filtered_count, base_count, data, controller_params, get_collection_filter(id) ) @collections[id.to_sym] = collection_config return collection_config end
controller_params()
click to toggle source
# File lib/matestack/ui/vue_js/components/collection/helper.rb, line 59 def controller_params return params.to_unsafe_h if defined? params raise 'collection component is missing access to params or context' end
get_collection_filter(collection_id, key=nil)
click to toggle source
# File lib/matestack/ui/vue_js/components/collection/helper.rb, line 4 def get_collection_filter collection_id, key=nil filter_hash = {} controller_params.each do |param_key, param_value| if param_key.start_with?("#{collection_id}-filter-") param_key.gsub("#{collection_id}-filter-", "") filter_hash[param_key.gsub("#{collection_id}-filter-", "").to_sym] = JSON.parse(param_value) end end if key.nil? return filter_hash else return filter_hash[key] end end
get_collection_order(collection_id, key=nil)
click to toggle source
# File lib/matestack/ui/vue_js/components/collection/helper.rb, line 19 def get_collection_order collection_id, key=nil order_hash = {} controller_params.each do |param_key, param_value| if param_key.start_with?("#{collection_id}-order-") param_key.gsub("#{collection_id}-order-", "") order_hash[param_key.gsub("#{collection_id}-order-", "").to_sym] = param_value end end if key.nil? return order_hash else return order_hash[key] end end
set_collection(options_hash)
click to toggle source
since ruby 3 changed hash <-> keyword argument transformation, we need to adjust this method call in order to stay compatible with ruby 2.x and ruby 3.x
# File lib/matestack/ui/vue_js/components/collection/helper.rb, line 36 def set_collection options_hash _set_collection **options_hash end