Sha256: 42fa86217aa86dfe7d1ec97de6397c4ab3df11b9847fc08d5d77670160a3ca8c

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

module Sunrise
  module ManagerHelper
    
    def manage_form_for(object, *args, &block)
      options = args.extract_options!
      
      options[:builder] ||= Sunrise::Views::FormBuilder
      options[:url] ||= (object.new_record? ? new_path : edit_path(:id => object.id))
      
      simple_form_for(object, *(args << options), &block)
    end
    
    def manage_date_tag(datetime, options={})
      options = {:hide_time => datetime.is_a?(Date) }.merge(options)
      tags = []
      
      tags << content_tag(:div, datetime.strftime("%d.%m.%Y"), :class => 'date')
      tags << content_tag(:div, datetime.strftime("%H:%M"), :class => 'time') unless options[:hide_time]
      
      content_tag(:div, tags.join.html_safe, :class => 'date-time')
    end
    
    def manage_render_field(field, record)
      item = record.send(field.name)
      
      if [Date, DateTime, Time].detect{|klass| item.is_a?(klass)}
        manage_date_tag(item)
      elsif item.is_a?(String)
        item =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i ? mail_to(item) : item
      else
        item.to_s
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sunrise-cms-0.4.1 app/helpers/sunrise/manager_helper.rb
sunrise-cms-0.4.0 app/helpers/sunrise/manager_helper.rb
sunrise-cms-0.3.3 app/helpers/sunrise/manager_helper.rb
sunrise-cms-0.3.2 app/helpers/sunrise/manager_helper.rb
sunrise-cms-0.3.1 app/helpers/sunrise/manager_helper.rb
sunrise-cms-0.3.0 app/helpers/sunrise/manager_helper.rb
sunrise-cms-0.3.0.rc2 app/helpers/sunrise/manager_helper.rb