mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 01:28:19 +01:00
Merge branch '15.0' of git@github.com:Dolibarr/dolibarr.git into 16.0
This commit is contained in:
@@ -1292,6 +1292,40 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
|
||||
// Code to manage the js for combo list with dependencies (called by extrafields_view.tpl.php)
|
||||
function showOptions(child_list, parent_list) {
|
||||
var parentInput = $("select[name="+parent_list+"]");
|
||||
if (parentInput.length === 0) { // when parent extra-field is in view mode and the child is edited directly on card (on line edit)
|
||||
parentInput = $("input[name="+parent_list+"]");
|
||||
}
|
||||
if (parentInput.length > 0) {
|
||||
var val = parentInput.val();
|
||||
var parentVal = parent_list + ":" + val;
|
||||
if (val > 0) {
|
||||
$("select[name=\""+child_list+"\"] option[parent]").prop("disabled", true).hide(); // hide not work with select2 element so disabled it
|
||||
$("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").prop('disabled', false).show(); // show not work with select2 element so enabled it
|
||||
} else {
|
||||
$("select[name=\""+child_list+"\"] option").prop("disabled", false).show(); // show not work with select2 element so enabled it
|
||||
}
|
||||
}
|
||||
}
|
||||
function setListDependencies() {
|
||||
console.log("setListDependencies");
|
||||
jQuery("select option[parent]").parent().each(function() {
|
||||
var child_list = $(this).attr("name");
|
||||
var parent = $(this).find("option[parent]:first").attr("parent");
|
||||
var infos = parent.split(":");
|
||||
var parent_list = infos[0];
|
||||
showOptions(child_list, parent_list);
|
||||
|
||||
/* Activate the handler to call showOptions on each future change */
|
||||
$("select[name=\""+parent_list+"\"]").change(function() {
|
||||
showOptions(child_list, parent_list);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Hacky fix for a bug in select2 with jQuery 3.6.0's new nested-focus "protection"
|
||||
* see: https://github.com/select2/select2/issues/5993
|
||||
@@ -1309,4 +1343,5 @@ $(document).on('select2:open', () => {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// End of lib_head.js.php
|
||||
|
||||
Reference in New Issue
Block a user