Module: Manage::BaseHelper
- Defined in:
- lib/generators/sunrise/templates/helpers/manage/base_helper.rb
Instance Method Summary collapse
- #add_child_link(name, f, method, options = {}) ⇒ Object
- #content_manager? ⇒ Boolean
- #cookie_content_tag(tag_name, options = {}, &block) ⇒ Object
- #link_to_sort(title, options = {}) ⇒ Object
- #link_to_unless_current_span2(name, options = {}, html_options = {}, &block) ⇒ Object
- #manage_icon(image, options = {}) ⇒ Object
- #new_child_fields(form_builder, method, options = {}) ⇒ Object
- #options_for_ckeditor(options = {}) ⇒ Object
- #remove_child_link(name, f) ⇒ Object
- #white_block_form(options = {}, &block) ⇒ Object
Instance Method Details
#add_child_link(name, f, method, options = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/generators/sunrise/templates/helpers/manage/base_helper.rb', line 50 def add_child_link(name, f, method, ={}) .symbolize_keys! = .delete(:html) || {} fields = new_child_fields(f, method, ) [:class] ||= "new" content_tag(:div, link_to_function(name, raw("insert_fields(this, \"#{method}\", \"#{escape_javascript(fields)}\")"), ), :class=>"add-bl") end |
#content_manager? ⇒ Boolean
2 3 4 |
# File 'lib/generators/sunrise/templates/helpers/manage/base_helper.rb', line 2 def content_manager? user_signed_in? && current_user.admin? end |
#cookie_content_tag(tag_name, options = {}, &block) ⇒ Object
73 74 75 76 77 |
# File 'lib/generators/sunrise/templates/helpers/manage/base_helper.rb', line 73 def (tag_name, ={}, &block) key = [:id] [:style] = "display:none;" if ![key].blank? && [key].to_i != 1 content_tag(tag_name, , &block) end |
#link_to_sort(title, options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/generators/sunrise/templates/helpers/manage/base_helper.rb', line 33 def link_to_sort(title, = {}) .symbolize_keys! order_type = [:order_type] || 'asc' order_column = [:name] || 'id' class_name = [:class] || nil = request.params[:search] || {} .update(:order_column => order_column, :order_type => order_type) link_to(title, :search => , :class => class_name) end |
#link_to_unless_current_span2(name, options = {}, html_options = {}, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/generators/sunrise/templates/helpers/manage/base_helper.rb', line 6 def link_to_unless_current_span2(name, = {}, = {}, &block) if current_page?() if block_given? block.arity <= 1 ? yield(name) : yield(name, , ) else content_tag(:span, content_tag(:span, name), ) end else link_to(name, , ) end end |
#manage_icon(image, options = {}) ⇒ Object
79 80 81 82 |
# File 'lib/generators/sunrise/templates/helpers/manage/base_helper.rb', line 79 def manage_icon(image, = {}) = { :alt => t(image, :scope => 'manage.icons'), :title => t(image, :scope => 'manage.icons') }.merge() image_tag("manage/ico_#{image}.gif", ) end |
#new_child_fields(form_builder, method, options = {}) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/generators/sunrise/templates/helpers/manage/base_helper.rb', line 63 def new_child_fields(form_builder, method, = {}) [:object] ||= form_builder.object.class.reflect_on_association(method).klass.new [:partial] ||= method.to_s.singularize [:form_builder_local] ||= :form form_builder.fields_for(method, [:object], :child_index => "new_#{method}") do |f| render(:partial => [:partial], :locals => { [:form_builder_local] => f }) end end |
#options_for_ckeditor(options = {}) ⇒ Object
18 19 20 |
# File 'lib/generators/sunrise/templates/helpers/manage/base_helper.rb', line 18 def ( = {}) { :width => 860, :height => 400 }.merge() end |
#remove_child_link(name, f) ⇒ Object
46 47 48 |
# File 'lib/generators/sunrise/templates/helpers/manage/base_helper.rb', line 46 def remove_child_link(name, f) f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)") end |
#white_block_form(options = {}, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/generators/sunrise/templates/helpers/manage/base_helper.rb', line 22 def white_block_form( = {}, &block) title = [:title] concat(content_tag(:div, {:class=>"edit-white-bl"}) do concat(content_tag(:div, {:class=>"bot-bg"}) do concat(content_tag(:div, title, :class=>"wh-title")) unless title.blank? yield if block_given? end) end) end |