Class: AdminWidgets::WizardWidget
- Inherits:
-
BaseFormWidget
- Object
- Erector::Widget
- BaseWidget
- BaseFormWidget
- AdminWidgets::WizardWidget
- Defined in:
- lib/admin_widgets/wizard_widget.rb
Instance Attribute Summary collapse
-
#current_step ⇒ Object
readonly
Returns the value of attribute current_step.
Attributes inherited from BaseFormWidget
Instance Method Summary collapse
- #buttons ⇒ Object
-
#fieldset(name, options = {}, &block) ⇒ Object
DSL methods.
- #form_content ⇒ Object
- #step(name, &block) ⇒ Object
- #steps_header ⇒ Object
- #view(&block) ⇒ Object
Methods inherited from BaseFormWidget
#around_form, #autofocus!, #autofocus_done?, #builder, #content, #field
Methods inherited from BaseWidget
#capture, #content_block, #helper, #method_missing, #root
Methods included from Memoization
Methods included from Delegation
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class AdminWidgets::BaseWidget
Instance Attribute Details
#current_step ⇒ Object (readonly)
Returns the value of attribute current_step.
9 10 11 |
# File 'lib/admin_widgets/wizard_widget.rb', line 9 def current_step @current_step end |
Instance Method Details
#buttons ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/admin_widgets/wizard_widget.rb', line 41 def div :class => ['group', 'navform', 'wat-cf'] do rawtext helper.(:class => 'big button finish', :name => 'change_step', :value => @steps.size + 1) { helper.image_tag('icons/tick.png') + helper.t('resources.actions.finish') } if && @current_step == @steps.count rawtext helper.(:class => 'big button next', :name => 'change_step', :value => @current_step + 1) { helper.image_tag('icons/next.png') + helper.t('resources.actions.next') } if @current_step < @steps.count rawtext helper.(:class => 'big button previous', :name => 'change_step', :value => @current_step - 1) { helper.image_tag('icons/previous.png') + helper.t('resources.actions.previous') } if @current_step > 1 end end |
#fieldset(name, options = {}, &block) ⇒ Object
DSL methods
13 14 15 |
# File 'lib/admin_widgets/wizard_widget.rb', line 13 def fieldset(name, = {}, &block) AdminWidgets::Form::FieldsetWidget.new(.merge(:name => name, :parent => self, :block => block)) end |
#form_content ⇒ Object
34 35 36 37 38 39 |
# File 'lib/admin_widgets/wizard_widget.rb', line 34 def form_content content_block steps_header rawtext @content_buffer end |
#step(name, &block) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/admin_widgets/wizard_widget.rb', line 58 def step(name, &block) @current_step ||= 1 @content_buffer ||= '' @steps = [] if !@steps @steps << name @content_buffer += capture do div :class => 'step' do instance_eval &block if block end if @current_step == @steps.count end end |
#steps_header ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/admin_widgets/wizard_widget.rb', line 17 def steps_header # Default button rawtext helper.(:class => "default-step-button", :style => 'border:0;display:block;height:0;overflow:hidden;padding:0;', :name => 'change_step', :value => (@current_step.to_i + 1)) { 'Next' } ul :class => 'steps' do @steps.each_with_index do |step, index| li do active = @current_step == index + 1 ? ' active' : '' rawtext helper.(:class => "step#{active}", :name => 'change_step', :value => index + 1) { helper.t(step, :scope => "wizards.#{resource_plural_name}.steps", :index => index + 1) } end end end end |
#view(&block) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/admin_widgets/wizard_widget.rb', line 70 def view(&block) @content_buffer ||= '' @content_buffer += capture do instance_eval &block if block end end |