Sha256: fcb9c587fda5364e8b7656f946aea16dd497acd2431aa3d6ee8bf75a45a4486e
Contents?: true
Size: 1.19 KB
Versions: 5
Compression:
Stored size: 1.19 KB
Contents
class Para.ResourceTable constructor: (@$table) -> @$tbody = @$table.find('tbody') @initializeOrderable() initializeOrderable: -> @orderable = @$table.hasClass('orderable') return unless @orderable @orderUrl = @$table.data('order-url') @$tbody.sortable handle: '.order-anchor' forcePlaceholderSize: true items: 'tr' placeholder: "<tr><td colspan=\"100%\" class=\"sortable-placeholder\"></td></tr>" @$tbody.on('sortupdate', $.proxy(@sortUpdate, this)) sortUpdate: -> @$tbody.find('tr').each (i, el) -> $(el).find('.resource-position-field').val(i) @updateOrder() updateOrder: -> Para.ajax( url: @orderUrl method: 'patch' data: resources: @buildOrderedData() success: $.proxy(@orderUpdated, this) ) buildOrderedData: -> for i, field of @$tbody.find('.resource-position-field').get() $field = $(field) { id: $field.closest('.order-anchor').data('id'), position: $field.val() } orderUpdated: -> # TODO: Add flash message to display ordering success $(document).on 'page:change', -> $('.para-component-relation-table').each (i, el) -> new Para.ResourceTable($(el))
Version data entries
5 entries across 5 versions & 1 rubygems