Sha256: 47636e190e2b66665595a7f1121fb5c9d028b09f0458c3e6fb0c2ae7de19ad71

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

<def tag="start-lifecycle" attrs="model, name, parameters">
  <% 
  model   = model.constantize if model.is_a?(String) 
  creator = model::Lifecycle.creators[name]
  candidate = creator.candidate(current_user, parameters)
  %>
  <if with="&candidate">
    <div class="lifecycle #{name}" merge-attrs>
      <h2 param="heading"><name.titleize/></h2>

      <form lifecycle="#{name}" method="post" param>
        <field-list fields="&creator.parameters - parameters.keys" param/>
        <submit label="#{name.titleize}" param/>
      </form>
    </div>
  </if>
</def>

<def tag="transition-button" attrs="transition, update, label"><%= 
    transition = transition.name unless transition.is_a?(String)
    ajax_attributes, html_attributes = attributes.partition_hash(Hobo::RapidHelper::AJAX_ATTRS)

    url = object_url(this, transition, :method => :put)
    add_classes!(html_attributes, "transition-button #{transition}-button")
    label ||= transition.titleize
    if update || !ajax_attributes.empty?
      ajax_attributes[:message] ||= label
      func = ajax_updater(url, update, ajax_attributes)
      html_attributes.update(:onclick => "var e = this; " + func, :type =>'button', :value => label)
      element(:input, html_attributes, nil, true, true)
    else
      button_to(label, url, html_attributes)
    end
  %>
</def>
  
<def tag="transition-buttons">
  <div class="transitions">
    <% this.lifecycle.available_transitions_for(current_user).each do |t| %>
      <transition-button transition="&t"/>
    <% end %>
  </div>
</def>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hobo-0.8.1 taglibs/rapid_lifecycles.dryml
hobo-0.8.2 taglibs/rapid_lifecycles.dryml
hobo-0.8 taglibs/rapid_lifecycles.dryml