| @@ -83,8 +83,9 @@ | ||
| 83 | 83 | </div> |
| 84 | 84 | <table class="ticket-fields wpsc-setting-tbl"> |
| 85 | 85 | <thead> |
| 86 | 86 | <tr> |
| 87 | + <th style="width: 30px;"><?php esc_attr_e( 'Sort', 'supportcandy' ); ?></th> | |
| 87 | 88 | <th><?php esc_attr_e( 'Field', 'supportcandy' ); ?></th> |
| 88 | 89 | <th><?php esc_attr_e( 'Extra info', 'supportcandy' ); ?></th> |
| 89 | 90 | <th><?php esc_attr_e( 'Type', 'supportcandy' ); ?></th> |
| 90 | 91 | <th><?php esc_attr_e( 'Auto Fill', 'supportcandy' ); ?></th> |
| @@ -100,9 +101,10 @@ | ||
| 100 | 101 | if ( $cf->field != 'customer' ) { |
| 101 | 102 | continue; |
| 102 | 103 | } |
| 103 | 104 | ?> |
| 104 | - <tr> | |
| 105 | + <tr data-id="<?php echo esc_attr( $cf->id ); ?>"> | |
| 106 | + <td class="sort-handle"><?php WPSC_Icons::get( 'sort' ); ?></td> | |
| 105 | 107 | <td><?php echo esc_attr( $cf->name ); ?></td> |
| 106 | 108 | <td><?php echo esc_attr( $cf->extra_info ); ?></td> |
| 107 | 109 | <td><?php echo esc_attr( $custom_fields_types[ $cf->type::$slug ]['label'] ); ?></td> |
| 108 | 110 | <td><?php echo esc_attr( $cf->is_auto_fill ? __( 'Yes', 'supportcandy' ) : __( 'No', 'supportcandy' ) ); ?></td> |
| @@ -128,11 +130,13 @@ | ||
| 128 | 130 | </table> |
| 129 | 131 | <script> |
| 130 | 132 | jQuery('table.ticket-fields').DataTable({ |
| 131 | 133 | ordering: false, |
| 134 | + autoWidth: false, | |
| 132 | 135 | pageLength: 20, |
| 133 | 136 | bLengthChange: false, |
| 134 | - columnDefs: [ | |
| 137 | + columnDefs: [ | |
| 138 | + { targets: 0, width: '30px', searchable: false }, | |
| 135 | 139 | { targets: -1, searchable: false }, |
| 136 | 140 | { targets: '_all', className: 'dt-left' } |
| 137 | 141 | ], |
| 138 | 142 | layout: { |
| @@ -148,8 +152,37 @@ | ||
| 148 | 152 | ], |
| 149 | 153 | }, |
| 150 | 154 | }, |
| 151 | 155 | language: supportcandy.translations.datatables |
| 156 | + }); | |
| 157 | + | |
| 158 | + jQuery(function() { | |
| 159 | + // Enable sorting with jQuery UI. | |
| 160 | + jQuery('table.ticket-fields tbody').sortable({ | |
| 161 | + handle: '.sort-handle', | |
| 162 | + helper: function(e, tr) { | |
| 163 | + var $originals = tr.children(); | |
| 164 | + var $helper = tr.clone(); | |
| 165 | + $helper.children().each(function(index) { | |
| 166 | + jQuery(this).width($originals.eq(index).width()); | |
| 167 | + }); | |
| 168 | + return $helper; | |
| 169 | + }, | |
| 170 | + update: function(event, ui) { | |
| 171 | + var ids = jQuery(this).sortable('toArray', { attribute: 'data-id' }); | |
| 172 | + jQuery.post( | |
| 173 | + supportcandy.ajax_url, | |
| 174 | + { | |
| 175 | + action: 'wpsc_set_custom_field_load_order', | |
| 176 | + _ajax_nonce: '<?php echo esc_attr( wp_create_nonce( 'wpsc_set_custom_field_load_order' ) ); ?>', | |
| 177 | + ids: ids | |
| 178 | + }, | |
| 179 | + function(response) { | |
| 180 | + | |
| 181 | + } | |
| 182 | + ); | |
| 183 | + } | |
| 184 | + }); | |
| 152 | 185 | }); |
| 153 | 186 | </script> |
| 154 | 187 | </div> |
| 155 | 188 | <?php |