Sha256: 273508849bafcc0b836bbd236f6e3afb87622abe2b05e5eb84a70cc4eb813ec8

Contents?: true

Size: 964 Bytes

Versions: 62

Compression:

Stored size: 964 Bytes

Contents

module Workarea
  class BrowseNavigationSeeds
    def perform
      puts 'Adding browsing navigation...'

      if new = Catalog::Category.find_by(name: 'New') rescue nil
        taxon = Navigation::Taxon.root.children.create!(navigable: new)
        menu = Navigation::Menu.create!(taxon: taxon)
      end

      Workarea.config.default_seeds_taxonomy.each do |top_level, children|
        page = Content::Page.find_by(name: top_level)
        categories = Catalog::Category.any_in(name: children)
        taxon = Navigation::Taxon.root.children.create!(navigable: page)
        menu = Navigation::Menu.create!(taxon: taxon)
        next if categories.blank?

        content = Content.for(menu)
        content.blocks.create!(
          type: 'taxonomy',
          data: { start: taxon.id, show_starting_taxon: false }
        )

        categories.each do |category|
          taxon.children.create!(navigable: category)
        end
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.4.27 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.5.4 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.4.26 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.5.3 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.4.25 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.5.2 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.4.24 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.5.1 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.4.23 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.4.22 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.5.0 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.4.21 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.5.0.beta.1 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.4.20 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.4.19 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.4.18 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.4.17 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.4.16 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.4.15 app/seeds/workarea/browse_navigation_seeds.rb
workarea-core-3.4.14 app/seeds/workarea/browse_navigation_seeds.rb