Module: Bike::Workflow::Attachment::SD

Defined in:
lib/_workflow/attachment.rb

Instance Method Summary collapse

Instance Method Details

#_get(arg) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/_workflow/attachment.rb', line 21

def _get(arg)
  if _hide? arg
    # hidden
  elsif arg[:action] == :create || arg[:action] == :update
    new_item = item_instance '_001'

    item_outs = _g_default(arg) {|item, item_arg|
      action = item[:id][Bike::REX::ID_NEW] ? :create : :delete
      button_tmpl = my[:tmpl][:"submit_#{action}"] || <<_html.chomp
<input type="submit" name="@(short_name).action-#{action}" value="#{_ action.to_s}" />
_html
      button = item.send(:_get_by_tmpl, {}, button_tmpl)
      item_arg[:action] = :create if action == :create
      item_tmpl = item[:tmpl][:index].sub(/[\w\W]*\$\(.*?\)/, "\\&#{button}")
      item.send(:_get_by_tmpl, item_arg, item_tmpl)
    }
    tmpl = my[:tmpl][:index].gsub('$()', item_outs)
    _get_by_tmpl({:p_action => arg[:p_action], :action => :update}, tmpl)
  else
    super
  end
end

#_get_by_self_reference(arg) ⇒ Object



44
45
46
# File 'lib/_workflow/attachment.rb', line 44

def _get_by_self_reference(arg)
  super unless _hide? arg
end

#_hide?(arg) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/_workflow/attachment.rb', line 48

def _hide?(arg)
  arg[:action] == :submit
end