Sha256: 14662fa40f56250e13a3ea3fa7074210fcae8f686f17e30148471825b5d779ad

Contents?: true

Size: 1.05 KB

Versions: 23

Compression:

Stored size: 1.05 KB

Contents

module ActiveAdmin
  module Views
    class IndexAsTable < ActiveAdmin::Component
      def editable_text_column resource, attr
        val = resource.send(attr)
        val = "&nbsp;" if val.blank?

        slug = ''
        begin
          slug = resource.slug
        rescue => e
          slug = resource.id
        end

        html = %{
                  <div  id='editable_text_column_#{resource.id}'
                        class='editable_text_column'
                        onclick='admin.editable_text_column_do(this)' >
                        #{val}
                   </div>

                   <input

                      data-path='#{resource.class.name.tableize}'
                      data-attr='#{attr}'
                      data-resource-id='#{resource.id}'
                      data-resource-slug='#{slug}'
                      class='editable_text_column admin-editable'
                      id='editable_text_column_#{resource.id}'

                      style='display:none;' />
              }
        html.html_safe
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
c80_yax-0.1.0.4 app/admin/c80_yax/lib/custom_columns.rb
c80_yax-0.1.0.3 app/admin/c80_yax/lib/custom_columns.rb
c80_yax-0.1.0.2 app/admin/c80_yax/lib/custom_columns.rb