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.1.33 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.32 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.31 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.30 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.29 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.28 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.27 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.26 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.25 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.24 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.23 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.22 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.21 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.20 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.19 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.18 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.17 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.16 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.15 lib/view_mixins/breadcrumb.rb
it-logica-application-backbone-0.1.14 lib/view_mixins/breadcrumb.rb