Sha256: 839629056f8ab2d72c594df53d342ba7ae74742513eafb7a9a0358dfcde0ec59

Contents?: true

Size: 839 Bytes

Versions: 18

Compression:

Stored size: 839 Bytes

Contents

require_dependency "push_type/admin_controller"

module PushType
  class TaxonomiesController < AdminController
    
    def index
      @taxonomies = PushType::Taxonomy.descendants
    end

    def show
      @terms = taxonomy.hash_tree.map { |parent, children| json_map(parent, children) }
    end

    private

    def initial_breadcrumb
      breadcrumbs.add 'Taxonomies', push_type.taxonomies_path
    end

    def taxonomy
      @taxonomy ||= PushType::Taxonomy.descendants.find { |t| t.name.underscore == params[:id] }
    end

    def json_map(parent, children)
      {
        id:         parent.id,
        title:      parent.title,
        slug:       parent.slug,
        sort_order: parent.sort_order,
        parent_id:  parent.parent_id,
        children:   children.map { |p, c| json_map(p, c) }
      }
    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
push_type_admin-0.7.0 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.7.0.beta.1 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.6.0 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.6.0.beta.4 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.6.0.beta.3 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.6.0.beta.2 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.6.0.beta.1 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.5.3 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.5.2 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.5.1 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.5.0 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.5.0.alpha.5 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.5.0.alpha.4 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.5.0.alpha.3 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.5.0.alpha.2 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.5.0.alpha.1 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.4.0 app/controllers/push_type/taxonomies_controller.rb
push_type_admin-0.4.0.beta.3 app/controllers/push_type/taxonomies_controller.rb