First of all: I'm new to both Ruby, Rails and OpenWFE, so forgive if I'm
asking the obvious... Also excuse me for being a bit verbose here -- can
you tell I'm a bit insecure? ;-)

John Mettraux (thanks for a great OpenWFE and Densha) explained that
Densha can use another "form handler" via the field
"__workitem_partial". In
http://openwferu.rubyforge.org/svn/trunk/densha/app/helpers/workitem_hel
per.rb one finds:

  TEMPLATE_PREFIX = "#{RAILS_ROOT}/app/views/workitem/_"

  def find_partial (key, default)
    t_name = @workitem.fields_hash[key]
    return default unless t_name
    t_name_view = t_name + "_view"
    if @view_only and
File.exist?("#{TEMPLATE_PREFIX}#{t_name_view}.rhtml")
      t_name_view  
    elsif File.exist?("#{TEMPLATE_PREFIX}#{t_name}.rhtml")
      t_name
    else
      default
    end
  end

So, using

  set :f => "__workitem_partial", :value => "my_activity"

will render /app/views/workitem/_my_activity.rhtml, if it is found.

For this to work, one needs to change the value of __workitem_partial
for each activity that needs its own form. So, if I understand correctly
then http://openwferu.rubyforge.org/examples/about_state.rb would then
read:

  sequence do
    set :f => "__workitem_partial", :value => "write"
    alice :tag => "redaction"
    set :f => "__workitem_partial", :value => "correct"
    sequence :tag => "correction" do
      bob
      alice
    end
    set :f => "__workitem_partial", :value => "approve"
    charly :tag => "approval"
  end

So: is this indeed how "__workitem_partial" should be used?

Of course I know one can easily change Densha to specific needs. In my
little app I've changed find_partial to fall back to using the activity
name if __workitem_partial is not set:

  def find_partial (key, default)
    t_name = @workitem.fields_hash[key]

    unless t_name
      if key == '__workitem_partial'
        t_activity = @workitem.fields_hash['params']['activity']
        t_name = t_activity.downcase.gsub(/[^a-z0-9]/, '_')
      end
    end

    return default unless t_name

    [the rest as above]
  end

Thanks for any thoughts on this!

Arjan.




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"OpenWFEru users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/openwferu-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to