Sha256: 2b02ac63000516faf30c57f991f7b0bc05d67e651c4a8c8f605c49acd265b054

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

class TabbedContentWidget < Widget

  DEFAULT_TABS = 2

  def self.valid_widget_classes_for(field_name)
    # unfortunately this does not work with the current sdk, the valid_widget_classes_for method is for Objs only:
    %w[TabbedContentTabWidget]
  end

  def description_for_editor
    "Tabbed Content"
  end

  def tabs_with_default
    _tabs = tabs.clone
    missing_tabs.times do
      _tabs << PlaceholderTabWidgetElement.new
    end
    _tabs
  end

  private

  def missing_tabs
    DEFAULT_TABS - tabs.size
  end

  class PlaceholderTabWidgetElement

    def id
      @id ||= SecureRandom.hex(2)
    end

    def headline
      'Widget Placeholder'
    end

    def content
      []
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scrivito_tabbed_content_widget-0.0.1 app/models/tabbed_content_widget.rb