Sha256: 570c4133e478129b44d88a7506f318257cb4e14d84b89275741f6d3d61a6039f

Contents?: true

Size: 918 Bytes

Versions: 21

Compression:

Stored size: 918 Bytes

Contents

module Spina
  module Pages
    class PageComponent < ApplicationComponent
      attr_reader :sortable
  
      def initialize(page:, sortable: true)
        @page = page
        @sortable = sortable
      end
      
      def label
        labels = []
        labels << t("spina.pages.concept") if @page.draft?
        labels << t("spina.pages.show_in_menu") unless @page.show_in_menu?
        labels << t("spina.pages.skip_to_first_child") if @page.skip_to_first_child?
        return nil if labels.size.zero?
        "(#{labels.join(", ")})"
      end
      
      def sortable?
        sortable
      end
  
      def depth
        @page.depth
      end
      
      def css_class
        case depth
        when 1
          "pl-5 bg-gray-100"
        when 2
          "pl-10 bg-gray-200"
        end
      end
  
      def children
        @children ||= @page.children.active.sorted
      end
  
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
spina-2.11.0 app/components/spina/pages/page_component.rb
spina-2.10.0 app/components/spina/pages/page_component.rb
spina-2.9.1 app/components/spina/pages/page_component.rb
spina-2.9.0 app/components/spina/pages/page_component.rb
spina-2.8.1 app/components/spina/pages/page_component.rb
spina-2.8.0 app/components/spina/pages/page_component.rb
spina-2.7.0 app/components/spina/pages/page_component.rb
spina-2.6.2 app/components/spina/pages/page_component.rb
spina-2.6.1 app/components/spina/pages/page_component.rb
spina-2.6.0 app/components/spina/pages/page_component.rb
spina-2.5.0 app/components/spina/pages/page_component.rb
spina-2.4.0 app/components/spina/pages/page_component.rb
spina-2.3.5 app/components/spina/pages/page_component.rb
spina-2.3.4 app/components/spina/pages/page_component.rb
spina-2.3.3 app/components/spina/pages/page_component.rb
spina-2.3.2 app/components/spina/pages/page_component.rb
spina-2.3.1 app/components/spina/pages/page_component.rb
spina-2.3.0 app/components/spina/pages/page_component.rb
spina-2.2.0 app/components/spina/pages/page_component.rb
spina-2.1.1 app/components/spina/pages/page_component.rb