Debug v22

This commit is contained in:
ldestailleur
2025-06-17 15:14:08 +02:00
parent 89da4b454b
commit 3c88a63172
2 changed files with 72 additions and 66 deletions

View File

@@ -1598,7 +1598,7 @@ function setListDependencies() {
<?php
if (!getDolGlobalString('MAIN_DISABLE_SELECT2_FOCUS_PROTECTION') && !defined('DISABLE_SELECT2_FOCUS_PROTECTION')) {
?>
/*
/**
* Hacky fix for a bug in select2 with jQuery 3.6.4's new nested-focus "protection"
* This fix the need to click a second time when clicking into a combo with ajax (see Test4d and Test5a in test_forms.php
* see: https://github.com/select2/select2/issues/5993
@@ -1606,12 +1606,13 @@ if (!getDolGlobalString('MAIN_DISABLE_SELECT2_FOCUS_PROTECTION') && !defined('DI
*
* TODO: Recheck with the select2 GH issue and remove once this is fixed on their side
*/
$(document).on('select2:open', (e) => {
console.log("Execute the focus (click on combo or use space when on component)");
const target = $(e.target);
if (target && target.length) {
let id = target[0].id || target[0].name;
if (id.substr(-2) == "[]") {
if (id.substr(-2) == '[]') {
id = id.substr(0,id.length-2);
}
document.querySelector('input[aria-controls*='+id+']').focus();
@@ -1621,65 +1622,61 @@ $(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').length > 0) {
$('.kanban .column').sortable({
items: '.kanban-draggable',
connectWith: '.kanban .column',
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);
/**
* Code to manage drag and drop inside kanban group by view - handles sortable columns and item movement between status columns
*/
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'),
token: "<?php echo currentToken() ?>"
$(document).ready(function() {
if ($('.kanban .column').length > 0) {
$('.kanban .column').sortable({
items: '.kanban-draggable',
connectWith: '.kanban .column',
cursor: 'move',
opacity: 0.8,
tolerance: 'pointer',
start: function(_, ui) {
ui.item.data('original-column', ui.item.parent());
ui.placeholder.height(ui.item.outerHeight());
},
context: document.body,
success: function() {
if (newColumn.hasClass('kanbancollapsed')) {
item.hide();
receive: function(_, ui) {
var originalColumn = ui.item.data('original-column');
var newColumn = $(this);
if (!originalColumn.is(newColumn)) {
onKanbanColumnChange(ui.item, newColumn);
}
}
});
item.data('original-column', newColumn);
}
<?php
}
?>
});
/**
* 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'),
token: '<?php echo currentToken() ?>'
},
context: document.body,
success: function() {
if (newColumn.hasClass('kanbancollapsed')) {
item.hide();
}
}
});
item.data('original-column', newColumn);
}
// End of lib_head.js.php