mirror of https://github.com/itflow-org/itflow
ticket tasks moving order
This commit is contained in:
parent
c40d15a545
commit
942f5bff52
19
ajax.php
19
ajax.php
|
|
@ -529,3 +529,22 @@ if (isset($_GET['get_totp_token_via_id'])) {
|
|||
if (isset($_GET['get_readable_pass'])) {
|
||||
echo json_encode(GenerateReadablePassword(4));
|
||||
}
|
||||
|
||||
if (isset($_POST['update_ticket_tasks_order'])) {
|
||||
// Update multiple ticket tasks order
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$positions = $_POST['positions'];
|
||||
$ticket_id = intval($_POST['ticket_id']);
|
||||
|
||||
foreach ($positions as $position) {
|
||||
$id = intval($position['id']);
|
||||
$order = intval($position['order']);
|
||||
|
||||
mysqli_query($mysqli, "UPDATE tasks SET task_order = $order WHERE task_ticket_id = $ticket_id AND task_id = $id");
|
||||
}
|
||||
|
||||
// return a response
|
||||
echo json_encode(['status' => 'success']);
|
||||
exit;
|
||||
}
|
||||
50
ticket.php
50
ticket.php
|
|
@ -11,7 +11,7 @@ if (isset($_GET['client_id'])) {
|
|||
enforceUserPermission('module_support');
|
||||
|
||||
// Initialize the HTML Purifier to prevent XSS
|
||||
require "plugins/htmlpurifier/HTMLPurifier.standalone.php";
|
||||
require_once "plugins/htmlpurifier/HTMLPurifier.standalone.php";
|
||||
|
||||
$purifier_config = HTMLPurifier_Config::createDefault();
|
||||
$purifier_config->set('Cache.DefinitionImpl', null); // Disable cache by setting a non-existent directory or an invalid one
|
||||
|
|
@ -345,6 +345,7 @@ if (isset($_GET['ticket_id'])) {
|
|||
$ticket_collaborators = nullable_htmlentities($row['user_names']);
|
||||
|
||||
?>
|
||||
<link rel="stylesheet" href="/plugins/dragula/dragula.min.css">
|
||||
|
||||
<!-- Breadcrumbs-->
|
||||
<ol class="breadcrumb d-print-none">
|
||||
|
|
@ -926,7 +927,7 @@ if (isset($_GET['ticket_id'])) {
|
|||
$task_completion_estimate = intval($row['task_completion_estimate']);
|
||||
$task_completed_at = nullable_htmlentities($row['task_completed_at']);
|
||||
?>
|
||||
<tr>
|
||||
<tr data-task-id="<?php echo $task_id; ?>">
|
||||
<td>
|
||||
<?php if ($task_completed_at) { ?>
|
||||
<i class="far fa-fw fa-check-square text-primary"></i>
|
||||
|
|
@ -963,10 +964,9 @@ if (isset($_GET['ticket_id'])) {
|
|||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
<?php
|
||||
|
||||
require "modals/task_edit_modal.php";
|
||||
require "modals/task_edit_modal.php";
|
||||
} ?>
|
||||
</table>
|
||||
</div>
|
||||
|
|
@ -1229,3 +1229,43 @@ $('#summaryModal').on('shown.bs.modal', function (e) {
|
|||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script src="/plugins/dragula/dragula.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var container = $('.table tbody')[0];
|
||||
|
||||
dragula([container])
|
||||
.on('drop', function (el, target, source, sibling) {
|
||||
// Handle the drop event to update the order in the database
|
||||
var rows = $(container).children();
|
||||
var positions = rows.map(function(index, row) {
|
||||
return {
|
||||
id: $(row).data('taskId'),
|
||||
order: index
|
||||
};
|
||||
}).get();
|
||||
|
||||
//console.log('New positions:', positions);
|
||||
|
||||
// Send the new order to the server (example using fetch)
|
||||
$.ajax({
|
||||
url: 'ajax.php',
|
||||
method: 'POST',
|
||||
data: {
|
||||
update_ticket_tasks_order: true,
|
||||
ticket_id: <?php echo $ticket_id; ?>,
|
||||
positions: positions
|
||||
},
|
||||
success: function(data) {
|
||||
//console.log('Order updated:', data);
|
||||
},
|
||||
error: function(error) {
|
||||
console.error('Error updating order:', error);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue