Sha256: 6e603b1d4f793de8d4ad94dfc02f8976d1dec0e338d8814d007703d30fa0997f

Contents?: true

Size: 1.07 KB

Versions: 43

Compression:

Stored size: 1.07 KB

Contents

module ExpressAdmin
  class CodeEditor < ExpressTemplates::Components::Forms::FormComponent

    has_option :mode, "Language of the editor", type: :string
    has_option :rows, "Define the number of rows", type: :int, default: 10

    contains -> {
      base_styles = "position: relative; height: 300px;"
      text_area_tag object, object.send(field), field_helper_options.merge( id: field_id, name: field_name ) #field_name_attribute, field_helper_options
      content_tag(:div, '', id: "ace_#{field_name}",
                  class: "ace-input", style: base_styles,
                  data: { target: field_id, mode: config[:mode] })
    }

    def field_helper_options
      {rows: rows, class: "hide", hidden: true}.merge(super)
    end

    def object
      self.send resource_name
    end

    def field
      config[:id]
    end

    def rows
      config[:rows]
    end

    def field_name
      "#{object_type}[#{field}]"
    end

    def field_id
      "#{object_type}_#{field}_#{object.id}"
    end

    def object_type
      object.class.to_s.demodulize.underscore
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
express_admin-2.0.0.b app/components/express_admin/code_editor.rb
express_admin-2.0.0.a app/components/express_admin/code_editor.rb
express_admin-1.8.1 app/components/express_admin/code_editor.rb
express_admin-1.8.0 app/components/express_admin/code_editor.rb
express_admin-1.7.32 app/components/express_admin/code_editor.rb
express_admin-1.7.31 app/components/express_admin/code_editor.rb
express_admin-1.7.30 app/components/express_admin/code_editor.rb
express_admin-1.7.29 app/components/express_admin/code_editor.rb
express_admin-1.7.28 app/components/express_admin/code_editor.rb
express_admin-1.7.27 app/components/express_admin/code_editor.rb
express_admin-1.7.26 app/components/express_admin/code_editor.rb
express_admin-1.7.25 app/components/express_admin/code_editor.rb
express_admin-1.7.24 app/components/express_admin/code_editor.rb
express_admin-1.7.23 app/components/express_admin/code_editor.rb
express_admin-1.7.22 app/components/express_admin/code_editor.rb
express_admin-1.7.21 app/components/express_admin/code_editor.rb
express_admin-1.7.20 app/components/express_admin/code_editor.rb
express_admin-1.7.19 app/components/express_admin/code_editor.rb
express_admin-1.7.18 app/components/express_admin/code_editor.rb
express_admin-1.7.17 app/components/express_admin/code_editor.rb