Sha256: 66ee0204b40d8c14e4db093e6b01bd8b476ece9a8492c1befdfeb87b5da4c5cd

Contents?: true

Size: 1018 Bytes

Versions: 41

Compression:

Stored size: 1018 Bytes

Contents

module Spider; module Components
    
    class Confirm < Spider::Widget
        tag 'confirm'
        is_attr_accessor :actions
        
        def prepare
            @scene.params = collapse_params(@request.params)
            if (!@actions)
                add_action('_w'+param_name(self)+'[cancel]', 'Cancel')
                add_action('_w'+param_name(self)+'[ok]', 'Ok')
             end
        end
        
        def add_action(name, value)
            @actions ||= []
            @actions << [name, value]
        end
        
        def collapse_params(h, first=true)
            res = {}
            h.each do |k, v|
                res_key = first ? k : "[#{k}]"
                if (v.is_a?(Hash))
                    collapse_params(v, false).each do |v_k, v_v|
                        res["#{res_key}#{v_k}"] = v_v
                    end
                else
                    res[res_key] = v
                end
            end
            return res
        end
        
    end
    
end; end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
spiderfw-0.6.21 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.20 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.19 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.18 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.17 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.16 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.15 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.14 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.13 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.12 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.11 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.10 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.9 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.8 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.7 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.6 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.5 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.4 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.3 apps/core/components/widgets/confirm/confirm.rb
spiderfw-0.6.2 apps/core/components/widgets/confirm/confirm.rb