Class: Runo::Workflow::Attachment

Inherits:
Runo::Workflow show all
Defined in:
lib/_workflow/attachment.rb

Overview

Author

Akira FUNAI

Copyright

Copyright © 2009 Akira FUNAI

Constant Summary collapse

DEFAULT_META =
{
  :p_size     => 0,
  :item_label => Runo::I18n.n_('attachment', 'attachments', 1),
}
PERM =
{
  :create => 0b00000,
  :read   => 0b00000,
  :update => 0b00000,
  :delete => 0b00000,
}

Constants inherited from Runo::Workflow

DEFAULT_SUB_ITEMS, ROLE_ADMIN, ROLE_GROUP, ROLE_NONE, ROLE_OWNER, ROLE_USER

Instance Attribute Summary

Attributes inherited from Runo::Workflow

#sd

Instance Method Summary collapse

Methods inherited from Runo::Workflow

#after_commit, #before_commit, #default_sub_items, #initialize, instance, #next_action, roles

Methods included from I18n

_, bindtextdomain, domain, domain=, find_msg, lang, lang=, merge_msg!, msg, n_, parse_msg, po_dir, po_dir=

Constructor Details

This class inherits a constructor from Runo::Workflow

Instance Method Details

#_get(arg) ⇒ Object



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

def _get(arg)
  @sd.instance_eval {
    if arg[:action] == :create || arg[:action] == :update
      new_item = item_instance '_001'

      item_outs = _g_default(arg) {|item, item_arg|
        action = item[:id][Runo::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)
    end
  }
end

#_hide?(arg) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/_workflow/attachment.rb', line 46

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

#permit?(roles, action) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/_workflow/attachment.rb', line 20

def permit?(roles, action)
  (action == :login) ||
  (@sd[:parent] && @sd[:parent].permit?(action))
end