Sha256: 55a4157188ebf68fac863561c7fd86b16dd11e0a64d3d8d678dde093bc81ce53

Contents?: true

Size: 1.29 KB

Versions: 7

Compression:

Stored size: 1.29 KB

Contents

module Noodall
  module Admin
    module NodesHelper
      include Noodall::Permalinks

      def sorted_node_tree(tree)
        nodes = []
        tree.each do |node|
          nodes << node
          unless node.children.empty?
            nodes += sorted_node_tree(node.children)
          end
        end

        nodes
      end

      def formatted_node_tree_options
        sorted_node_tree(Node.roots).reject{|n| n._id == @node._id}.collect{|n|
          [n.title, n._id]
        }
      end

      def slot_link(node,type,index)
        link_to( "#{type.to_s.titleize} Slot", {:anchor => "#{type}_component_form_#{index}"}, :id=> "#{type}_slot_#{index}_selector", :class => 'slot_link') +
          "<span id=\"#{type}_slot_#{index}_tag\" class=\"slot_tag\">#{node.send("#{type}_slot_#{index}").class.name.titleize unless @node.send("#{type}_slot_#{index}").nil?}</span>".html_safe
      end

      def slot_form(node,type,index)
        component = @node.send("#{type}_slot_#{index}")
        options = options_for_select([''] + Component.positions_names(type), (component._type.titleize unless component.nil?))

        render :partial => 'slot_form', :locals => { :type => type, :index => index, :component => component, :options => options, :slot_name => "#{ type }_slot_#{ index }" }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
noodall-ui-0.0.8 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.0.7 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.0.6 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.0.5 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.0.4 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.0.3 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.0.2 app/helpers/noodall/admin/nodes_helper.rb