Sha256: 2ceb8185f1a707bcabd551bf965491b3862013c60bfb4e2dcc91d27feccf036a

Contents?: true

Size: 1.51 KB

Versions: 49

Compression:

Stored size: 1.51 KB

Contents

module Noodall
  module Admin
    module NodesHelper
      include Noodall::Permalinks
      include AssetsHelper

      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

      def can_change_templates?(node)
        can_publish?(node) and !node.is_a?(Home) and (node.parent.nil? ? Node.template_names : node.parent.class.template_names).length > 1
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
noodall-ui-0.3.20 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.19 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.4.4 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.4.1 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.4.0 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.17 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.16 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.15 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.14 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.13 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.12 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.11 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.8 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.7 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.6 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.5 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.4 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.3 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.2 app/helpers/noodall/admin/nodes_helper.rb
noodall-ui-0.3.1 app/helpers/noodall/admin/nodes_helper.rb