Sha256: 2b8d5c241988f785fb34faad05eefe834a4158470f426bcac0ee8b52d1d2a7fb
Contents?: true
Size: 1.53 KB
Versions: 4
Compression:
Stored size: 1.53 KB
Contents
module Spider; module Components class Confirm < Spider::Widget tag 'confirm' is_attr_accessor :actions is_attribute :cancel_param is_attribute :ok_param is_attribute :cancel_text, :default => lambda{ _('Cancel') } is_attribute :ok_text, :default => lambda{ _('Ok') } def prepare @scene.params = collapse_params(@request.params) unless @actions @cancel_param ||= '_w'+param_name(self)+'[cancel]' @ok_param ||= '_w'+param_name(self)+'[ok]' add_action(@cancel_param, @cancel_text) add_action(@ok_param, @ok_text) end end def add_action(name, value, type=nil) @actions ||= [] @actions << [name, value, type] end def collapse_params(h, first=true) res = [] h.each do |k, v| res_key = first ? k : "[#{k}]" case v when Hash collapse_params(v, false).each do |v_k, v_v| res << ["#{res_key}#{v_k}", v_v] end when Array # NOTE: doesn't handle arrays of Hashes and arrays of Arrays v.each do |v_v| res << ["#{res_key}[]", v_v] end else res << [res_key, v] end end return res end end end; end
Version data entries
4 entries across 4 versions & 1 rubygems