Sha256: d9e8b3e3df2a5fc1a08683df62449dd5e01410188fe7c243156bcc8a1cd7fb37

Contents?: true

Size: 1001 Bytes

Versions: 6

Compression:

Stored size: 1001 Bytes

Contents

- model_name = controller_name.classify.constantize
.page-header
  %h1
    #{t('admin.common.sort')} 
    %small
      #{t('admin.common.sort_title')}

= form_tag action: :sort, method: :post do
  %table.table.table-striped
    %thead
      %tr
        %th.span12= model_name.human_attribute_name(attribute_name)
    %tbody
      - self.instance_variable_get("@#{controller_name}").each do |sortable|
        %tr
          = hidden_field_tag "#{controller_name}[#{sortable.id}]", sortable.id
          %td= sortable.send(attribute_name)
  = actions do
    = submit_tag t('admin.common.save'), class: 'btn btn-success'
    = cancel_action action: :index

:javascript
  $('#content tbody').sortable({
    axis: 'y',
    cursor: 'move',
    helper: function(e, tr) {
      var $originals = tr.children();
      var $helper = tr.clone();
      $helper.children().each(function(index) {
        $(this).width($originals.eq(index).width())
      });
      return $helper;
    }
  }).disableSelection();

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
coalla-cms-0.7.0.0 app/views/admin/base/_sort.haml
coalla-cms-0.5.2.4 app/views/admin/base/_sort.haml
coalla-cms-0.6.1.1 app/views/admin/base/_sort.haml
coalla-cms-0.6.0.9 app/views/admin/base/_sort.haml
coalla-cms-0.5.1.9 app/views/admin/base/_sort.haml
coalla-cms-0.5.1.8 app/views/admin/base/_sort.haml