Sha256: 68b100a7b4f90fddf6eb05f048b266ab0dbe068801966df58314877fc359e870

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 KB

Contents

module Plugins
  module Core
    class TextCell < Plugins::Core::Cell
      def input
        render
      end

      def wysiwyg
        render
      end

      def multiline_input
        render
      end

      private

      def input_display
        @options[:input_options]&.[](:display)
      end

      def input_classes
        input_display&.[](:classes)
      end

      def input_styles
        input_display&.[](:styles)
      end

      def value
        data&.[]('text') || @options[:default_value]
      end

      def render_label_and_input
        render_label(:text) do
          render_input
        end
      end

      def render_label
        @options[:form].label 'data[text]', field.name, class: 'mdl-textfield__label'
      end

      def render_input
        @options[:form].text_field 'data[text]', value: value, placeholder: @options[:placeholder], class: 'mdl-textfield__input'
      end

      def render_wysiwyg
        @options[:form].text_area 'data[text]', value: value, class: "#{input_classes} wysiwyg_ckeditor", style: input_styles
      end

      def render_multiline_input
        @options[:form].text_area 'data[text]', value: value , placeholder: @options[:placeholder], rows: input_display&.[](:rows) , class: 'mdl-textfield__input'
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cortex-plugins-core-0.10.2 app/cells/plugins/core/text_cell.rb
cortex-plugins-core-0.10.1 app/cells/plugins/core/text_cell.rb
cortex-plugins-core-0.10.0 app/cells/plugins/core/text_cell.rb
cortex-plugins-core-0.9.1 app/cells/plugins/core/text_cell.rb
cortex-plugins-core-0.9.0 app/cells/plugins/core/text_cell.rb
cortex-plugins-core-0.8.0 app/cells/plugins/core/text_cell.rb
cortex-plugins-core-0.7.2 app/cells/plugins/core/text_cell.rb
cortex-plugins-core-0.7.1 app/cells/plugins/core/text_cell.rb