forked from Wavyzz/dolibarr
* #34417 [GroupByKanban] add: drag and drop with saveinplace * #34417 [LibHead] fix: whitespaces * #34417 [ProjectClass] fix: GETPOST and PHP inside JS
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -1621,5 +1621,59 @@ $(document).on('select2:open', (e) => {
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if (getDolGlobalString('MAIN_USE_JQUERY_JEDITABLE')) {
|
||||
?>
|
||||
// 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: "<?php echo DOL_URL_ROOT; ?>/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);
|
||||
}
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
// End of lib_head.js.php
|
||||
|
||||
@@ -2534,7 +2534,7 @@ class Project extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
$return = '<div class="box-flex-item '.($size == 'small' ? 'box-flex-item-small' : '').' box-flex-grow-zero">';
|
||||
$return = '<div class="box-flex-item '.($size == 'small' ? 'box-flex-item-small' : '').' box-flex-grow-zero '.($arraydata['mode'] == 'kanbangroupby' ? 'kanban-draggable" data-itemid="'.$this->id.'" data-element="'.$this->element.'" data-tableelement="'.$this->table_element.'"' : '"').'>';
|
||||
$return .= '<div class="info-box info-box-sm">';
|
||||
$return .= '<span class="info-box-icon bg-infobox-action">';
|
||||
$return .= img_picto('', $this->public ? 'projectpub' : $this->picto);
|
||||
|
||||
@@ -1768,7 +1768,7 @@ while ($i < $imaxinloop) {
|
||||
print '<div class="kanbanlabel">'.$langs->trans($tmpgroupbyvalue).'</div>';
|
||||
print '</div>'; // Start and end the new column
|
||||
}
|
||||
print '<div class="box-flex-container-column kanban column" data-groupbyid="'.preg_replace('/[^a-z0-9]/', '', $groupbyvalue).'">'; // Start new column
|
||||
print '<div class="box-flex-container-column kanban column" data-groupbyid="'.preg_replace('/[^a-z0-9]/', '', $groupbyvalue).'" data-groupbyfield="'.$groupbyfield.'">'; // Start new column
|
||||
print '<div class="kanbanlabel">'.$langs->trans(empty($groupbyvalues[$groupbyvalue]) ? 'Undefined' : $groupbyvalues[$groupbyvalue]).'</div>';
|
||||
}
|
||||
$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' : ''));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user