Sha256: 4adacd5930dd335e08d06bf11e0fd84fd9daddeaa1c9475b190f97f6c67c0ffd

Contents?: true

Size: 1.59 KB

Versions: 46

Compression:

Stored size: 1.59 KB

Contents

module ViewMixins
  module Breadcrumb
    def breadcrumb_for(*args)
      # ToDo dodělat caching tohoto, invalidovat budu pokud nastane SAVE u OBJECT
      breadcrumb = []
      args.each do |object|
        if !object.blank?
          if is_tree_node?(object)
            tree_node = object
            unless tree_node.blank?
              bread_crumb_load_tree_recursive(breadcrumb, tree_node)
            end
          elsif object.respond_to?(:tree_nodes)
            if !object.tree_nodes.blank? && !object.tree_nodes.first.blank? && is_tree_node?(object.tree_nodes.first)
              tree_node = object.tree_nodes.first if !object.tree_nodes.blank? && !object.tree_nodes.first.blank?
              unless tree_node.blank?
                bread_crumb_load_tree_recursive(breadcrumb, tree_node)
              end
            end
          elsif object.kind_of?(Hash)
            breadcrumb << object
          elsif object.kind_of?(Array)
            object.each do |o|
              breadcrumb << o
            end
          end
        end
      end
      render :partial => '/helpers/build_breadcrumb', :layout => false, :locals => {:breadcrumb => breadcrumb}
    end

    def bread_crumb_load_tree_recursive(breadcrumb, tree_node)
      unless tree_node.blank?
        if tree_node.parent_node_id > 0
          bread_crumb_load_tree_recursive(breadcrumb, tree_node.parent_node)
        end
        breadcrumb << tree_node
      end
    end

    def is_tree_node?(object)
      false
      #object.kind_of?(Intranet::TreeNode) #|| object.kind_of?(Web::TreeNode) || object.kind_of?(Organizer::TreeNode)
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
it-logica-application-backbone-0.2.15 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.14 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.13 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.12 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.11 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.10 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.9 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.8 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.7 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.6 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.5 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.4 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.3 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.2 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.1 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.2.0 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.37 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.36 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.35 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.34 lib/view_mixins/breadcrumb.rb