2
0
forked from Wavyzz/dolibarr

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

@@ -65,6 +65,8 @@ savemethod:
savemethodname:
*/
print 'field='.$field.' - element='.$element.' - table_element='.$table_element.' - id/fk_element='.$fk_element."\n";
// Load object according to $id and $element
$element_ref = '';
if (is_numeric($fk_element)) {
@@ -74,6 +76,9 @@ if (is_numeric($fk_element)) {
$id = 0;
}
$object = fetchObjectByElement($id, $element, $element_ref);
if (! is_object($object)) {
httponly_accessforbidden('Not allowed, bad combination of parameters for fetchObjectByElement');
}
$module = $object->module;
$element = $object->element;
@@ -81,8 +86,7 @@ $usesublevelpermission = ($module != $element ? $element : '');
if ($usesublevelpermission && !$user->hasRight($module, $element)) { // There is no permission on object defined, we will check permission on module directly
$usesublevelpermission = '';
}
//print $object->id.' - '.$object->module.' - '.$object->element.' - '.$object->table_element.' - '.$usesublevelpermission."\n";
print 'object->id='.$object->id.' - object->module='.$object->module.' - object->element='.$object->element.' - object->table_element='.$object->table_element.' - usesublevelpermission='.$usesublevelpermission."\n";
// Security check
$result = restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission, 'fk_soc', 'rowid', 0, 1); // Call with mode return
@@ -90,10 +94,6 @@ if (!$result) {
httponly_accessforbidden('Not allowed by restrictArea');
}
if (!getDolGlobalString('MAIN_USE_JQUERY_JEDITABLE')) {
httponly_accessforbidden('Can be used only when option MAIN_USE_JQUERY_JEDITABLE is set');
}
/*
* View
@@ -106,13 +106,22 @@ 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 editval_
$type = GETPOST('type', 'alpha', 2);
$field = preg_replace('/^editval_/', '', $field); // remove prefix "editval_"
$type = GETPOST('type', 'alpha', 2); // type string by default
$value = ($type == 'ckeditor' ? GETPOST('value', '', 2) : GETPOST('value', 'alpha', 2));
$loadmethod = GETPOST('loadmethod', 'alpha', 2);
$savemethod = GETPOST('savemethod', 'alpha', 2);
$savemethodname = (!empty($savemethod) ? $savemethod : 'setValueFrom');
//$ext_element = GETPOST('ext_element', 'alpha', 2);
$ext_element = 'notused';
//$loadmethod = GETPOST('loadmethod', 'alpha', 2);
$loadmethod = 'notused';
//$savemethod = GETPOST('savemethod', 'alpha', 2);
//$savemethodname = (!empty($savemethod) ? $savemethod : 'setValueFrom');
$savemethodname = 'setValueFrom';
$newelement = $element;
$subelement = null;
@@ -233,7 +242,7 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
}
if (!$error) {
if ((isset($object) && !is_object($object)) || empty($savemethod)) {
if ((isset($object) && !is_object($object))) {
$object = new GenericObject($db);
}

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