N°7257 - Check and migrate old Combodo JS functions

This commit is contained in:
Anne-Cath
2025-08-29 16:15:31 +02:00
parent b56113aada
commit 0a4180f7fc
5 changed files with 1 additions and 240 deletions

View File

@@ -10,60 +10,6 @@
*/
aTruncatedLists = {}; // To keep track of the list being loaded, each member is an ajaxRequest object
function ReloadTruncatedList(divId, sSerializedFilter, sExtraParams) {
$('#'+divId).block();
//$('#'+divId).blockUI();
if (aTruncatedLists[divId] != undefined) {
try {
aAjaxRequest = aTruncatedLists[divId];
aAjaxRequest.abort();
} catch (e) {
// Do nothing special, just continue
console.log('Uh,uh, exception !');
}
}
aTruncatedLists[divId] = $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?style=list',
{operation: 'ajax', filter: sSerializedFilter, extra_params: sExtraParams},
function (data) {
aTruncatedLists[divId] = undefined;
if (data.length > 0) {
$('#'+divId).html(data);
//$('#'+divId+' .listResults').tableHover(); // hover tables
$('#'+divId+' .listResults').each(function () {
var table = $(this);
var id = $(this).parent();
aTruncatedLists[divId] = undefined;
var checkbox = (table.find('th').first().find(':checkbox').length > 0);
if (checkbox) {
// There is a checkbox in the first column, don't make it sortable
table.tablesorter({headers: {0: {sorter: false}}, widgets: ['myZebra', 'truncatedList']}).tablesorterPager({container: $("#pager")}); // sortable and zebra tables
} else {
// There is NO checkbox in the first column, all columns are considered sortable
table.tablesorter({widgets: ['myZebra', 'truncatedList']}).tablesorterPager({container: $("#pager"), totalRows: 97, filter: sSerializedFilter, extra_params: sExtraParams}); // sortable and zebra tables
}
});
$('#'+divId).unblock();
}
}
);
}
/**
* Truncate a previously expanded list !
*/
function TruncateList(divId, iLimit, sNewLabel, sLinkLabel) {
$('#'+divId).block();
var iCount = 0;
$('#'+divId+' table.listResults tr:gt('+iLimit+')').each(function () {
$(this).remove();
});
$('#lbl_'+divId).html(sNewLabel);
$('#'+divId+' table.listResults tr:last td').addClass('truncated');
$('#'+divId+' table.listResults').addClass('truncated');
$('#trc_'+divId).html(sLinkLabel);
$('#'+divId+' .listResults').trigger("update"); // Reset the cache
$('#'+divId).unblock();
}
/**
* Reload any block -- used for periodic auto-reload
@@ -98,30 +44,6 @@ function ReloadBlock(divId, sStyle, sSerializedFilter, sExtraParams) {
}
}
function SaveGroupBySortOrder(sTableId, aValues) {
var sDashboardId = $('#'+sTableId).closest('.ibo-dashboard').attr('id');
var sPrefKey = 'GroupBy_'+sDashboardId+'_'+sTableId;
if (aValues.length != 0) {
$sValue = JSON.stringify(aValues);
if (GetUserPreference(sPrefKey, null) != $sValue) {
SetUserPreference(sPrefKey, $sValue, true);
}
}
}
function LoadGroupBySortOrder(sTableId) {
var sDashboardId = $('#'+sTableId).closest('.ibo-dashboard').attr('id');
var sPrefKey = 'GroupBy_'+sDashboardId+'_'+sTableId;
var sValues = GetUserPreference(sPrefKey, null);
if (sValues != null) {
aValues = JSON.parse(sValues);
window.setTimeout(function () {
$('#'+sTableId+' table.listResults').trigger('sorton', [aValues]);
}, 50);
}
}
/**
* Update the display and value of a file input widget when the user picks a new file
*/
@@ -306,18 +228,6 @@ function ToggleField(value, field_id) {
$('#'+field_id).trigger('validate');
}
/**
* For the fields that cannot be visually disabled, they can be blocked
* @return
*/
function BlockField(field_id, bBlocked) {
if (bBlocked) {
$('#'+field_id).block({message: ' ** disabled ** ', enableValidation : true});
} else {
$('#'+field_id).unblock();
}
}
/**
* Updates (enables/disables) a "duration" field
*/
@@ -352,6 +262,7 @@ function PropagateCheckBox(bCurrValue, aFieldsList, bCheck) {
}
}
//used only in designer
function FixTableSorter(table) {
if (table[0].config == undefined) {
// Table is not sort-able, let's fix it

View File

@@ -1,147 +0,0 @@
//
// Set of functions to manage the controls in a wizard
//
function UpdateObjectList(sClass, sId, sExtKeyToRemote)
{
aRelatedObjectIds = GetObjectIds(sId, sExtKeyToRemote);
if (aRelatedObjectIds.length == 0)
{
aRelatedObjectIds[0] = 0;
}
var oql = "SELECT "+sClass+" AS c WHERE c.id IN (" + aRelatedObjectIds.join(", ") + ")";
$.post(GetAbsoluteUrlAppRoot()+"ajax.render.php?style=list&encoding=oql",
{ operation: "ajax", filter: oql },
function(data){
$("#related_objects_"+sId).empty();
$("#related_objects_"+sId).append(data);
$("#related_objects_"+sId).removeClass("loading");
});
}
function AddObject(sClass, sId, sExtKeyToRemote)
{
var sCurrentObjectId = new String($('#ac_current_object_id_'+sId).val());
// Display the additional dialog
$('#LinkDlg_'+sId).dialog('open');
return;
}
function ManageObjects(sTitle, sClass, sId, sExtKeyToRemote)
{
aObjList = GetObjectIds(sId, sExtKeyToRemote);
if (aObjList.length == 0)
{
aObjList[0] = 0;
}
Manage_LoadSelect('selected_objects_'+sId, 'SELECT '+sClass+' WHERE id IN (' + aObjList.join(', ') + ')'); // id is a reserved keyword always representing the primary key
Manage_LoadSelect('available_objects_'+sId, 'SELECT '+sClass+' WHERE id NOT IN (' + aObjList.join(', ') + ')');
$('#ManageObjectsDlg_'+sId).dialog('option', {title: sTitle});
$('#ManageObjectsDlg_'+sId).dialog('open');
}
function Manage_LoadSelect(sSelectedId, sFilter)
{
$('#'+sSelectedId).addClass('loading');
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php',
{ operation: 'combo_options', filter: sFilter },
function(data){
$('#'+sSelectedId).empty();
$('#'+sSelectedId).append(data);
$('#'+sSelectedId).removeClass('loading');
}
);
}
function Manage_SwapSelectedObjects(oSourceSelect, oDestinationSelect, sId)
{
j = oDestinationSelect.options.length;
for (i=oSourceSelect.length-1;i>=0;i--) // Count down because we are removing the indexes from the combo
{
if (oSourceSelect.options[i].selected)
{
var newOption = document.createElement('option');
newOption.text = oSourceSelect.options[i].text;
newOption.value = oSourceSelect.options[i].value;
oDestinationSelect.options[j++] = newOption;
oSourceSelect.remove(i);
}
}
Manage_UpdateButtons(sId);
}
function Manage_UpdateButtons(sId)
{
var oSrc = document.getElementById('available_objects_'+sId);
var oAddBtn = document.getElementById('btn_add_objects_'+sId)
var oDst = document.getElementById('selected_objects_'+sId);
var oRemoveBtn = document.getElementById('btn_remove_objects_'+sId)
if (oSrc.selectedIndex == -1)
{
oAddBtn.disabled = true;
}
else
{
oAddBtn.disabled = false;
}
if (oDst.selectedIndex == -1)
{
oRemoveBtn.disabled = true;
}
else
{
oRemoveBtn.disabled = false;
}
}
function Manage_AddObjects(sId)
{
var oSrc = document.getElementById('available_objects_'+sId);
var oDst = document.getElementById('selected_objects_'+sId);
Manage_SwapSelectedObjects(oSrc, oDst, sId);
}
function Manage_RemoveObjects(sId)
{
var oSrc = document.getElementById('selected_objects_'+sId);
var oDst = document.getElementById('available_objects_'+sId);
Manage_SwapSelectedObjects(oSrc, oDst, sId);
}
//function Manage_Ok(sClass, sExtKeyToRemote)
//{
// var objectsToAdd = document.getElementById('selected_objects');
// var aSelectedObjects = new Array();
// for (i=0; i<objectsToAdd.length;i++)
// {
// aSelectedObjects[aSelectedObjects.length] = objectsToAdd.options[i].value;
// }
// $('#related_object_ids').val(aSelectedObjects.join(' '));
// UpdateObjectList(sClass, sExtKeyToRemote);
//}
function FilterLeft(sClass)
{
alert('Not Yet Implemented');
}
function FilterRight(sClass)
{
alert('Not Yet Implemented');
}
function GetObjectIds(sInputId, sExtKeyToRemote)
{
aLinkedIds = new Array;
sLinkedSet = $('#'+sInputId).val();
//console.log('(sInputId: '+sInputId+') => sLinkedSet: '+sLinkedSet);
if (sLinkedSet != '')
{
aLinkedSet = JSON.parse(sLinkedSet);
for(i=0; i<aLinkedSet.length; i++)
{
aLinkedIds[aLinkedIds.length] = aLinkedSet[i][sExtKeyToRemote];
}
}
return aLinkedIds;
}