diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index fbe537188bb..c1644cc8a6d 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -107,7 +107,7 @@ top_httphead(); // Load original field value if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element)) { $ext_element = GETPOST('ext_element', 'alpha', 2); - $field = substr($field, 8); // remove prefix val_ + $field = substr($field, 8); // remove prefix editval_ $type = GETPOST('type', 'alpha', 2); $value = ($type == 'ckeditor' ? GETPOST('value', '', 2) : GETPOST('value', 'alpha', 2)); $loadmethod = GETPOST('loadmethod', 'alpha', 2); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index fce9f8a175d..2027c7a7441 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1621,5 +1621,59 @@ $(document).on('select2:open', (e) => { } ?> + + // Code to manage drag and drop inside kanban group by view - handles sortable columns and item movement between status columns + + $(document).ready(function() { + if ($('.kanban .column:not(.kanbancollapsed)').length > 0) { + $('.kanban .column:not(.kanbancollapsed)').sortable({ + items: '.kanban-draggable', + connectWith: '.kanban .column:not(.kanbancollapsed)', + cursor: 'move', + opacity: 0.8, + tolerance: 'pointer', + start: function(_, ui) { + ui.item.data('original-column', ui.item.parent()); + ui.placeholder.height(ui.item.outerHeight()); + }, + receive: function(_, ui) { + var originalColumn = ui.item.data('original-column'); + var newColumn = $(this); + + if (!originalColumn.is(newColumn)) { + onKanbanColumnChange(ui.item, newColumn); + } + } + }); + } + }); + + /** + * Function called when an item is moved to a different column + * @param {jQuery} item - The dragged item + * @param {jQuery} newColumn - The new column + */ + function onKanbanColumnChange(item, newColumn) { + jQuery.ajax({ + method: "POST", + url: "/core/ajax/saveinplace.php", + data: { + field: 'editval_'+newColumn.data('groupbyfield'), + element: item.data('element'), + table_element: item.data('tableelement'), + fk_element: item.data('itemid'), + value: newColumn.data('groupbyid') + }, + context: document.body + }); + item.data('original-column', newColumn); + } + + + // End of lib_head.js.php diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index a6cf2487e11..a684abd5f8f 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2534,7 +2534,7 @@ class Project extends CommonObject } } - $return = '
'; + $return = '
'; $return .= '
'; $return .= ''; $return .= img_picto('', $this->public ? 'projectpub' : $this->picto); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 194615e7d05..a75f9fe6e42 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -1768,7 +1768,7 @@ while ($i < $imaxinloop) { print '
'.$langs->trans($tmpgroupbyvalue).'
'; print '
'; // Start and end the new column } - print '
'; // Start new column + print '
'; // Start new column print '
'.$langs->trans(empty($groupbyvalues[$groupbyvalue]) ? 'Undefined' : $groupbyvalues[$groupbyvalue]).'
'; } $groupbyold = $groupbyvalue; @@ -1784,7 +1784,7 @@ while ($i < $imaxinloop) { $selected = 1; } } - $arrayofdata = array('assignedusers' => $stringassignedusers, 'thirdparty' => $companystatic, 'selected' => $selected); + $arrayofdata = array('assignedusers' => $stringassignedusers, 'thirdparty' => $companystatic, 'selected' => $selected, 'mode' => $mode); print $object->getKanbanView('', $arrayofdata, ($groupby ? 'small' : ''));