Sha256: 32de6a41e12b42adb445443ce7d88d4ff0c2dc0372c839c5c9e6a90ea84235df

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

module ConcurrentDraft::HelperExtensions
  def updated_stamp(model)
    unless model.new_record?
      updated_by = (model.updated_by || model.created_by) if model.respond_to?(:updated_by)
      login = updated_by ? updated_by.login : nil
      time = (model.updated_at || model.created_at)
      promoted_at = model.draft_promoted_at if model.respond_to?(:draft_promoted_at)
      html = %{<p style="clear: left"><small>}
      if login or time
        html << 'Last updated ' 
        html << %{by #{login} } if login
        html << %{at #{ timestamp(time) }} if time
        html << '. '
      end
      if promoted_at
        html << %{Last promoted at #{ timestamp(promoted_at) }.}
      end
      html << %{</small></p>}
      html
    else
      %{<p class="clear">&nbsp;</p>}
    end
  end

  def save_model_button(_model)
    label = _model.new_record? ? "Create" : "Save"
    submit_tag "#{label} and Exit", :class => 'button'
  end
  
  def save_model_and_continue_editing_button(_model)
    label = _model.new_record? ? "Create" : "Save"
    submit_tag label, :name => 'continue', :class => 'button' 
  end
  
  def save_model_and_promote_button(_model)
    label = _model.new_record? ? "Create" : "Save"
    submit_tag "#{label} and Promote Now", :name => 'promote', :class => 'button'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
radiant-concurrent_draft-extension-1.0.1 lib/concurrent_draft/helper_extensions.rb
radiant-concurrent_draft-extension-1.0.0 lib/concurrent_draft/helper_extensions.rb