Skip to content

Commit 08ebede

Browse files
authored
Merge pull request #1165 from ssteeltm/tasks_moves
ticket tasks moving order
2 parents a69b607 + eac46d0 commit 08ebede

File tree

1 file changed

+45
-5
lines changed

1 file changed

+45
-5
lines changed

ticket.php

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
enforceUserPermission('module_support');
1212

1313
// Initialize the HTML Purifier to prevent XSS
14-
require "plugins/htmlpurifier/HTMLPurifier.standalone.php";
14+
require_once "plugins/htmlpurifier/HTMLPurifier.standalone.php";
1515

1616
$purifier_config = HTMLPurifier_Config::createDefault();
1717
$purifier_config->set('Cache.DefinitionImpl', null); // Disable cache by setting a non-existent directory or an invalid one
@@ -345,6 +345,7 @@
345345
$ticket_collaborators = nullable_htmlentities($row['user_names']);
346346

347347
?>
348+
<link rel="stylesheet" href="/plugins/dragula/dragula.min.css">
348349

349350
<!-- Breadcrumbs-->
350351
<ol class="breadcrumb d-print-none">
@@ -927,7 +928,7 @@
927928
$task_completion_estimate = intval($row['task_completion_estimate']);
928929
$task_completed_at = nullable_htmlentities($row['task_completed_at']);
929930
?>
930-
<tr>
931+
<tr data-task-id="<?php echo $task_id; ?>">
931932
<td>
932933
<?php if ($task_completed_at) { ?>
933934
<i class="far fa-fw fa-check-square text-primary"></i>
@@ -964,10 +965,9 @@
964965
</div>
965966
</td>
966967
</tr>
968+
<?php
967969

968-
<?php
969-
970-
require "modals/task_edit_modal.php";
970+
require "modals/task_edit_modal.php";
971971
} ?>
972972
</table>
973973
</div>
@@ -1231,3 +1231,43 @@
12311231
});
12321232
});
12331233
</script>
1234+
1235+
1236+
<script src="/plugins/dragula/dragula.min.js"></script>
1237+
<script>
1238+
$(document).ready(function() {
1239+
var container = $('.table tbody')[0];
1240+
1241+
dragula([container])
1242+
.on('drop', function (el, target, source, sibling) {
1243+
// Handle the drop event to update the order in the database
1244+
var rows = $(container).children();
1245+
var positions = rows.map(function(index, row) {
1246+
return {
1247+
id: $(row).data('taskId'),
1248+
order: index
1249+
};
1250+
}).get();
1251+
1252+
//console.log('New positions:', positions);
1253+
1254+
// Send the new order to the server (example using fetch)
1255+
$.ajax({
1256+
url: 'ajax.php',
1257+
method: 'POST',
1258+
data: {
1259+
update_ticket_tasks_order: true,
1260+
ticket_id: <?php echo $ticket_id; ?>,
1261+
positions: positions
1262+
},
1263+
success: function(data) {
1264+
//console.log('Order updated:', data);
1265+
},
1266+
error: function(error) {
1267+
console.error('Error updating order:', error);
1268+
}
1269+
});
1270+
});
1271+
});
1272+
</script>
1273+

0 commit comments

Comments
 (0)