mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 11:38:44 +02:00
Advanced Search: Dictionary compatible with the setup
SVN:b1162[5459]
This commit is contained in:
@@ -111,8 +111,10 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage
|
||||
$sSearchAny = addslashes(Dict::S('UI:SearchValue:Any'));
|
||||
$sSearchNbSelected = addslashes(Dict::S('UI:SearchValue:NbSelected'));
|
||||
$this->add_dict_entry('UI:FillAllMandatoryFields');
|
||||
$this->add_dict_entry('UI:Button:Cancel');
|
||||
$this->add_dict_entry('UI:Button:Done');
|
||||
|
||||
$this->add_dict_entries('UI:Search:');
|
||||
$this->add_dict_entries('UI:Button:');
|
||||
|
||||
|
||||
if (!$this->IsPrintableVersion())
|
||||
{
|
||||
|
||||
@@ -56,8 +56,8 @@ class NiceWebPage extends WebPage
|
||||
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_criteria_raw.js');
|
||||
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_criteria_string.js');
|
||||
|
||||
$this->add_dict_entries('UI:Search:');
|
||||
$this->add_dict_entries('UI:Button:');
|
||||
// $this->add_dict_entries('UI:Search:');
|
||||
// $this->add_dict_entries('UI:Button:');
|
||||
|
||||
$this->add_ready_script(
|
||||
<<< EOF
|
||||
|
||||
407
js/utils.js
407
js/utils.js
@@ -5,7 +5,7 @@ if (!Array.prototype.indexOf) {
|
||||
|
||||
if (false) // deactivated since it causes troubles: for(k in aData) => returns the indexOf function as first element on empty arrays !
|
||||
{
|
||||
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
|
||||
Array.prototype.indexOf = function (searchElement /*, fromIndex */) {
|
||||
"use strict";
|
||||
if (this == null) {
|
||||
throw new TypeError();
|
||||
@@ -27,7 +27,7 @@ if (!Array.prototype.indexOf) {
|
||||
if (n >= len) {
|
||||
return -1;
|
||||
}
|
||||
var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
|
||||
var k = n >= 0 ? n : Math.max(len-Math.abs(n), 0);
|
||||
for (; k < len; k++) {
|
||||
if (k in t && t[k] === searchElement) {
|
||||
return k;
|
||||
@@ -42,47 +42,38 @@ if (!Array.prototype.indexOf) {
|
||||
*/
|
||||
aTruncatedLists = {}; // To keep track of the list being loaded, each member is an ajaxRequest object
|
||||
|
||||
function ReloadTruncatedList(divId, sSerializedFilter, sExtraParams)
|
||||
{
|
||||
function ReloadTruncatedList(divId, sSerializedFilter, sExtraParams) {
|
||||
$('#'+divId).block();
|
||||
//$('#'+divId).blockUI();
|
||||
if (aTruncatedLists[divId] != undefined)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (aTruncatedLists[divId] != undefined) {
|
||||
try {
|
||||
aAjaxRequest = aTruncatedLists[divId];
|
||||
aAjaxRequest.abort();
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
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)
|
||||
{
|
||||
{operation: 'ajax', filter: sSerializedFilter, extra_params: sExtraParams},
|
||||
function (data) {
|
||||
aTruncatedLists[divId] = undefined;
|
||||
if (data.length > 0)
|
||||
{
|
||||
if (data.length > 0) {
|
||||
$('#'+divId).html(data);
|
||||
$('#'+divId+' .listResults').tableHover(); // hover tables
|
||||
$('#'+divId+' .listResults').each( function()
|
||||
{
|
||||
$('#'+divId+' .listResults').each(function () {
|
||||
var table = $(this);
|
||||
var id = $(this).parent();
|
||||
aTruncatedLists[divId] = undefined;
|
||||
var checkbox = (table.find('th:first :checkbox').length > 0);
|
||||
if (checkbox)
|
||||
{
|
||||
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
|
||||
table.tablesorter({headers: {0: {sorter: false}}, widgets: ['myZebra', 'truncatedList']}).tablesorterPager({container: $("#pager")}); // sortable and zebra tables
|
||||
}
|
||||
else
|
||||
{
|
||||
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
|
||||
table.tablesorter({widgets: ['myZebra', 'truncatedList']}).tablesorterPager({container: $("#pager"), totalRows: 97, filter: sSerializedFilter, extra_params: sExtraParams}); // sortable and zebra tables
|
||||
}
|
||||
});
|
||||
$('#'+divId).unblock();
|
||||
@@ -90,14 +81,14 @@ function ReloadTruncatedList(divId, sSerializedFilter, sExtraParams)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate a previously expanded list !
|
||||
*/
|
||||
function TruncateList(divId, iLimit, sNewLabel, sLinkLabel)
|
||||
{
|
||||
function TruncateList(divId, iLimit, sNewLabel, sLinkLabel) {
|
||||
$('#'+divId).block();
|
||||
var iCount = 0;
|
||||
$('#'+divId+' table.listResults tr:gt('+iLimit+')').each( function(){
|
||||
$('#'+divId+' table.listResults tr:gt('+iLimit+')').each(function () {
|
||||
$(this).remove();
|
||||
});
|
||||
$('#lbl_'+divId).html(sNewLabel);
|
||||
@@ -107,33 +98,29 @@ function TruncateList(divId, iLimit, sNewLabel, sLinkLabel)
|
||||
$('#'+divId+' .listResults').trigger("update"); // Reset the cache
|
||||
$('#'+divId).unblock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload any block -- used for periodic auto-reload
|
||||
*/
|
||||
function ReloadBlock(divId, sStyle, sSerializedFilter, sExtraParams)
|
||||
{
|
||||
function ReloadBlock(divId, sStyle, sSerializedFilter, sExtraParams) {
|
||||
// Check if the user is not editing the list properties right now
|
||||
var bDialogOpen = false;
|
||||
var oDataTable = $('#'+divId+' :itop-datatable');
|
||||
var bIsDataTable = false;
|
||||
if (oDataTable.length > 0)
|
||||
{
|
||||
if (oDataTable.length > 0) {
|
||||
bDialogOpen = oDataTable.datatable('IsDialogOpen');
|
||||
bIsDataTable = true;
|
||||
}
|
||||
if (!bDialogOpen)
|
||||
{
|
||||
if (bIsDataTable)
|
||||
{
|
||||
if (!bDialogOpen) {
|
||||
if (bIsDataTable) {
|
||||
oDataTable.datatable('DoRefresh');
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$('#'+divId).block();
|
||||
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?style='+sStyle,
|
||||
{ operation: 'ajax', filter: sSerializedFilter, extra_params: sExtraParams },
|
||||
function(data){
|
||||
{operation: 'ajax', filter: sSerializedFilter, extra_params: sExtraParams},
|
||||
function (data) {
|
||||
$('#'+divId).empty();
|
||||
$('#'+divId).append(data);
|
||||
$('#'+divId).removeClass('loading');
|
||||
@@ -143,29 +130,26 @@ function ReloadBlock(divId, sStyle, sSerializedFilter, sExtraParams)
|
||||
}
|
||||
}
|
||||
|
||||
function SaveGroupBySortOrder(sTableId, aValues)
|
||||
{
|
||||
function SaveGroupBySortOrder(sTableId, aValues) {
|
||||
var sDashboardId = $('#'+sTableId).closest('.dashboard_contents').attr('id');
|
||||
var sPrefKey = 'GroupBy_'+sDashboardId+'_'+sTableId;
|
||||
if (aValues.length != 0)
|
||||
{
|
||||
if (aValues.length != 0) {
|
||||
$sValue = JSON.stringify(aValues);
|
||||
if (GetUserPreference(sPrefKey, null) != $sValue)
|
||||
{
|
||||
if (GetUserPreference(sPrefKey, null) != $sValue) {
|
||||
SetUserPreference(sPrefKey, $sValue, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function LoadGroupBySortOrder(sTableId)
|
||||
{
|
||||
function LoadGroupBySortOrder(sTableId) {
|
||||
var sDashboardId = $('#'+sTableId).closest('.dashboard_contents').attr('id');
|
||||
var sPrefKey = 'GroupBy_'+sDashboardId+'_'+sTableId;
|
||||
var sValues = GetUserPreference(sPrefKey, null);
|
||||
if (sValues != null)
|
||||
{
|
||||
if (sValues != null) {
|
||||
aValues = JSON.parse(sValues);
|
||||
window.setTimeout(function () { $('#'+sTableId+' table.listResults').trigger('sorton', [aValues]); }, 50);
|
||||
window.setTimeout(function () {
|
||||
$('#'+sTableId+' table.listResults').trigger('sorton', [aValues]);
|
||||
}, 50);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -173,8 +157,7 @@ function LoadGroupBySortOrder(sTableId)
|
||||
/**
|
||||
* Update the display and value of a file input widget when the user picks a new file
|
||||
*/
|
||||
function UpdateFileName(id, sNewFileName)
|
||||
{
|
||||
function UpdateFileName(id, sNewFileName) {
|
||||
var aPath = sNewFileName.split('\\');
|
||||
var sNewFileName = aPath[aPath.length-1];
|
||||
|
||||
@@ -183,11 +166,11 @@ function UpdateFileName(id, sNewFileName)
|
||||
$('#name_'+id).text(sNewFileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload a search form for the specified class
|
||||
*/
|
||||
function ReloadSearchForm(divId, sClassName, sBaseClass, sContext)
|
||||
{
|
||||
function ReloadSearchForm(divId, sClassName, sBaseClass, sContext) {
|
||||
var oDiv = $('#ds_'+divId);
|
||||
oDiv.block();
|
||||
// deprecated in jQuery 1.8
|
||||
@@ -197,18 +180,16 @@ function ReloadSearchForm(divId, sClassName, sBaseClass, sContext)
|
||||
|
||||
// Save the submit handlers
|
||||
aSubmit = new Array();
|
||||
if ( (oFormEvents != null) && (oFormEvents.submit != undefined))
|
||||
{
|
||||
for(var index = 0; index < oFormEvents.submit.length; index++)
|
||||
{
|
||||
aSubmit [index ] = { data:oFormEvents.submit[index].data, namespace:oFormEvents.submit[index].namespace, handler: oFormEvents.submit[index].handler};
|
||||
if ((oFormEvents != null) && (oFormEvents.submit != undefined)) {
|
||||
for (var index = 0; index < oFormEvents.submit.length; index++) {
|
||||
aSubmit [index] = {data: oFormEvents.submit[index].data, namespace: oFormEvents.submit[index].namespace, handler: oFormEvents.submit[index].handler};
|
||||
}
|
||||
}
|
||||
sAction = $('#ds_'+divId+' form').attr('action');
|
||||
|
||||
// Save the current values in the form
|
||||
var oMap = {};
|
||||
$('#ds_'+divId+" form :input[name!='']").each(function() {
|
||||
$('#ds_'+divId+" form :input[name!='']").each(function () {
|
||||
oMap[this.name] = this.value;
|
||||
});
|
||||
oMap.operation = 'search_form';
|
||||
@@ -218,26 +199,21 @@ function ReloadSearchForm(divId, sClassName, sBaseClass, sContext)
|
||||
oMap.action = sAction;
|
||||
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?'+sContext, oMap,
|
||||
function(data) {
|
||||
function (data) {
|
||||
oDiv.empty();
|
||||
oDiv.append(data);
|
||||
if (aSubmit.length > 0)
|
||||
{
|
||||
if (aSubmit.length > 0) {
|
||||
var oForm = $('#ds_'+divId+' form'); // Form was reloaded, recompute it
|
||||
for(var index = 0; index < aSubmit.length; index++)
|
||||
{
|
||||
for (var index = 0; index < aSubmit.length; index++) {
|
||||
// Restore the previously bound submit handlers
|
||||
var sEventName = 'submit';
|
||||
if ((aSubmit[index].namespace != undefined) && (aSubmit[index].namespace != ''))
|
||||
{
|
||||
if ((aSubmit[index].namespace != undefined) && (aSubmit[index].namespace != '')) {
|
||||
sEventName += '.'+aSubmit[index].namespace;
|
||||
}
|
||||
if (aSubmit[index].data != undefined)
|
||||
{
|
||||
if (aSubmit[index].data != undefined) {
|
||||
oForm.bind(sEventName, aSubmit[index].data, aSubmit[index].handler)
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
oForm.bind(sEventName, aSubmit[index].handler)
|
||||
}
|
||||
}
|
||||
@@ -249,21 +225,19 @@ function ReloadSearchForm(divId, sClassName, sBaseClass, sContext)
|
||||
);
|
||||
}
|
||||
|
||||
function FixSearchFormsDisposition()
|
||||
{
|
||||
function FixSearchFormsDisposition() {
|
||||
// Fix search forms
|
||||
$('.search_box').each(function() {
|
||||
$('.search_box').each(function () {
|
||||
var colWidth = 0;
|
||||
var labelWidth = 0;
|
||||
$('label:visible', $(this)).each( function() {
|
||||
var l = $(this).parent().width() - $(this).width();
|
||||
$('label:visible', $(this)).each(function () {
|
||||
var l = $(this).parent().width()-$(this).width();
|
||||
colWidth = Math.max(l, colWidth);
|
||||
labelWidth = Math.max($(this).width(), labelWidth);
|
||||
});
|
||||
$('label:visible', $(this)).each( function() {
|
||||
if($(this).data('resized') != true)
|
||||
{
|
||||
$(this).parent().width(colWidth + labelWidth);
|
||||
$('label:visible', $(this)).each(function () {
|
||||
if ($(this).data('resized') != true) {
|
||||
$(this).parent().width(colWidth+labelWidth);
|
||||
$(this).width(labelWidth).css({display: 'inline-block'}).data('resized', true);
|
||||
}
|
||||
});
|
||||
@@ -276,22 +250,18 @@ function FixSearchFormsDisposition()
|
||||
* depends on a global variable oUserPreferences created/filled by the iTopWebPage
|
||||
* that acts as a local -write through- cache
|
||||
*/
|
||||
function SetUserPreference(sPreferenceCode, sPrefValue, bPersistent)
|
||||
{
|
||||
function SetUserPreference(sPreferenceCode, sPrefValue, bPersistent) {
|
||||
sPreviousValue = undefined;
|
||||
try
|
||||
{
|
||||
try {
|
||||
sPreviousValue = oUserPreferences[sPreferenceCode];
|
||||
}
|
||||
catch(err)
|
||||
{
|
||||
catch (err) {
|
||||
sPreviousValue = undefined;
|
||||
}
|
||||
oUserPreferences[sPreferenceCode] = sPrefValue;
|
||||
if (bPersistent && (sPrefValue != sPreviousValue))
|
||||
{
|
||||
if (bPersistent && (sPrefValue != sPreviousValue)) {
|
||||
ajax_request = $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php',
|
||||
{ operation: 'set_pref', code: sPreferenceCode, value: sPrefValue} ); // Make it persistent
|
||||
{operation: 'set_pref', code: sPreferenceCode, value: sPrefValue}); // Make it persistent
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,11 +270,9 @@ function SetUserPreference(sPreferenceCode, sPrefValue, bPersistent)
|
||||
* depends on a global variable oUserPreferences created/filled by the iTopWebPage
|
||||
* that acts as a local -write through- cache
|
||||
*/
|
||||
function GetUserPreference(sPreferenceCode, sDefaultValue)
|
||||
{
|
||||
function GetUserPreference(sPreferenceCode, sDefaultValue) {
|
||||
var value = sDefaultValue;
|
||||
if ( oUserPreferences[sPreferenceCode] != undefined)
|
||||
{
|
||||
if (oUserPreferences[sPreferenceCode] != undefined) {
|
||||
value = oUserPreferences[sPreferenceCode];
|
||||
}
|
||||
return value;
|
||||
@@ -313,12 +281,10 @@ function GetUserPreference(sPreferenceCode, sDefaultValue)
|
||||
/**
|
||||
* Check/uncheck a whole list of checkboxes
|
||||
*/
|
||||
function CheckAll(sSelector, bValue)
|
||||
{
|
||||
function CheckAll(sSelector, bValue) {
|
||||
var value = bValue;
|
||||
$(sSelector).each( function() {
|
||||
if (this.checked != value)
|
||||
{
|
||||
$(sSelector).each(function () {
|
||||
if (this.checked != value) {
|
||||
this.checked = value;
|
||||
$(this).trigger('change');
|
||||
}
|
||||
@@ -329,16 +295,13 @@ function CheckAll(sSelector, bValue)
|
||||
/**
|
||||
* Toggle (enabled/disabled) the specified field of a form
|
||||
*/
|
||||
function ToogleField(value, field_id)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
function ToogleField(value, field_id) {
|
||||
if (value) {
|
||||
$('#'+field_id).removeAttr('disabled');
|
||||
// In case the field is rendered as a div containing several inputs (e.g. RedundancySettings)
|
||||
$('#'+field_id+' :input').removeAttr('disabled');
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$('#'+field_id).attr('disabled', 'disabled');
|
||||
// In case the field is rendered as a div containing several inputs (e.g. RedundancySettings)
|
||||
$('#'+field_id+' :input').attr('disabled', 'disabled');
|
||||
@@ -351,14 +314,11 @@ function ToogleField(value, field_id)
|
||||
* 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 ** '});
|
||||
function BlockField(field_id, bBlocked) {
|
||||
if (bBlocked) {
|
||||
$('#'+field_id).block({message: ' ** disabled ** '});
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$('#'+field_id).unblock();
|
||||
}
|
||||
}
|
||||
@@ -366,22 +326,17 @@ function BlockField(field_id, bBlocked)
|
||||
/**
|
||||
* Updates (enables/disables) a "duration" field
|
||||
*/
|
||||
function ToggleDurationField(field_id)
|
||||
{
|
||||
function ToggleDurationField(field_id) {
|
||||
// Toggle all the subfields that compose the "duration" input
|
||||
aSubFields = new Array('d', 'h', 'm', 's');
|
||||
|
||||
if ($('#'+field_id).attr('disabled'))
|
||||
{
|
||||
for(var i=0; i<aSubFields.length; i++)
|
||||
{
|
||||
if ($('#'+field_id).attr('disabled')) {
|
||||
for (var i = 0; i < aSubFields.length; i++) {
|
||||
$('#'+field_id+'_'+aSubFields[i]).attr('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(var i=0; i<aSubFields.length; i++)
|
||||
{
|
||||
else {
|
||||
for (var i = 0; i < aSubFields.length; i++) {
|
||||
$('#'+field_id+'_'+aSubFields[i]).removeAttr('disabled');
|
||||
}
|
||||
}
|
||||
@@ -390,47 +345,38 @@ function ToggleDurationField(field_id)
|
||||
/**
|
||||
* PropagateCheckBox
|
||||
*/
|
||||
function PropagateCheckBox(bCurrValue, aFieldsList, bCheck)
|
||||
{
|
||||
if (bCurrValue == bCheck)
|
||||
{
|
||||
for(var i=0;i<aFieldsList.length;i++)
|
||||
{
|
||||
function PropagateCheckBox(bCurrValue, aFieldsList, bCheck) {
|
||||
if (bCurrValue == bCheck) {
|
||||
for (var i = 0; i < aFieldsList.length; i++) {
|
||||
$('#enable_'+aFieldsList[i]).attr('checked', bCheck);
|
||||
ToogleField(bCheck, aFieldsList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function FixTableSorter(table)
|
||||
{
|
||||
if (table[0].config == undefined)
|
||||
{
|
||||
function FixTableSorter(table) {
|
||||
if (table[0].config == undefined) {
|
||||
// Table is not sort-able, let's fix it
|
||||
var checkbox = (table.find('th:first :checkbox').length > 0);
|
||||
if (checkbox)
|
||||
{
|
||||
if (checkbox) {
|
||||
// There is a checkbox in the first column, don't make it sort-able
|
||||
table.tablesorter( { headers: { 0: {sorter: false}}, widgets: ['myZebra', 'truncatedList']} ); // sort-able and zebra tables
|
||||
table.tablesorter({headers: {0: {sorter: false}}, widgets: ['myZebra', 'truncatedList']}); // sort-able and zebra tables
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// There is NO checkbox in the first column, all columns are considered sort-able
|
||||
table.tablesorter( { widgets: ['myZebra', 'truncatedList']} ); // sort-able and zebra tables
|
||||
table.tablesorter({widgets: ['myZebra', 'truncatedList']}); // sort-able and zebra tables
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function DashletCreationDlg(sOQL, sContext)
|
||||
{
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?'+sContext, {operation: 'dashlet_creation_dlg', oql: sOQL}, function(data){
|
||||
function DashletCreationDlg(sOQL, sContext) {
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?'+sContext, {operation: 'dashlet_creation_dlg', oql: sOQL}, function (data) {
|
||||
$('body').append(data);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function ShortcutListDlg(sOQL, sDataTableId, sContext)
|
||||
{
|
||||
function ShortcutListDlg(sOQL, sDataTableId, sContext) {
|
||||
var sDataTableName = 'datatable_'+sDataTableId;
|
||||
var oTableSettings = {
|
||||
oColumns: $('#'+sDataTableName).datatable('option', 'oColumns'),
|
||||
@@ -438,28 +384,22 @@ function ShortcutListDlg(sOQL, sDataTableId, sContext)
|
||||
};
|
||||
var sTableSettings = JSON.stringify(oTableSettings);
|
||||
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?'+sContext, {operation: 'shortcut_list_dlg', oql: sOQL, table_settings: sTableSettings}, function(data){
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?'+sContext, {operation: 'shortcut_list_dlg', oql: sOQL, table_settings: sTableSettings}, function (data) {
|
||||
$('body').append(data);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function ExportListDlg(sOQL, sDataTableId, sFormat, sDlgTitle)
|
||||
{
|
||||
function ExportListDlg(sOQL, sDataTableId, sFormat, sDlgTitle) {
|
||||
var aFields = [];
|
||||
if (sDataTableId != '')
|
||||
{
|
||||
if (sDataTableId != '') {
|
||||
var sDataTableName = 'datatable_'+sDataTableId;
|
||||
var oColumns = $('#'+sDataTableName).datatable('option', 'oColumns');
|
||||
for(var j in oColumns)
|
||||
{
|
||||
for(var k in oColumns[j])
|
||||
{
|
||||
if (oColumns[j][k].checked)
|
||||
{
|
||||
for (var j in oColumns) {
|
||||
for (var k in oColumns[j]) {
|
||||
if (oColumns[j][k].checked) {
|
||||
var sCode = oColumns[j][k].code;
|
||||
if (sCode == '_key_')
|
||||
{
|
||||
if (sCode == '_key_') {
|
||||
sCode = 'id';
|
||||
}
|
||||
aFields.push(j+'.'+sCode);
|
||||
@@ -476,41 +416,33 @@ function ExportListDlg(sOQL, sDataTableId, sFormat, sDlgTitle)
|
||||
dialog_title: sDlgTitle
|
||||
};
|
||||
|
||||
if (sFormat !== null)
|
||||
{
|
||||
if (sFormat !== null) {
|
||||
oParams.format = sFormat;
|
||||
}
|
||||
|
||||
$.post(GetAbsoluteUrlAppRoot()+'webservices/export-v2.php', oParams, function(data) {
|
||||
$.post(GetAbsoluteUrlAppRoot()+'webservices/export-v2.php', oParams, function (data) {
|
||||
$('body').append(data);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function ExportToggleFormat(sFormat)
|
||||
{
|
||||
function ExportToggleFormat(sFormat) {
|
||||
$('.form_part').hide();
|
||||
for(k in window.aFormParts[sFormat])
|
||||
{
|
||||
for (k in window.aFormParts[sFormat]) {
|
||||
$('#form_part_'+window.aFormParts[sFormat][k]).show().trigger('form-part-activate');
|
||||
}
|
||||
}
|
||||
|
||||
function ExportStartExport()
|
||||
{
|
||||
function ExportStartExport() {
|
||||
var oParams = {};
|
||||
$('.form_part:visible :input').each(function() {
|
||||
if (this.name != '')
|
||||
{
|
||||
if ((this.type == 'radio') || (this.type == 'checkbox'))
|
||||
{
|
||||
if (this.checked)
|
||||
{
|
||||
$('.form_part:visible :input').each(function () {
|
||||
if (this.name != '') {
|
||||
if ((this.type == 'radio') || (this.type == 'checkbox')) {
|
||||
if (this.checked) {
|
||||
oParams[this.name] = $(this).val();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
oParams[this.name] = $(this).val();
|
||||
}
|
||||
}
|
||||
@@ -521,65 +453,54 @@ function ExportStartExport()
|
||||
oParams.operation = 'export_build';
|
||||
oParams.format = $('#export-form :input[name=format]').val();
|
||||
var sQueryMode = $(':input[name=query_mode]:checked').val();
|
||||
if($(':input[name=query_mode]:checked').length > 0)
|
||||
{
|
||||
if (sQueryMode == 'oql')
|
||||
{
|
||||
if ($(':input[name=query_mode]:checked').length > 0) {
|
||||
if (sQueryMode == 'oql') {
|
||||
oParams.expression = $('#export-form :input[name=expression]').val();
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
oParams.query = $('#export-form :input[name=query]').val();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
oParams.expression = $('#export-form :input[name=expression]').val();
|
||||
oParams.query = $('#export-form :input[name=query]').val();
|
||||
}
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data) {
|
||||
if (data == null)
|
||||
{
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function (data) {
|
||||
if (data == null) {
|
||||
ExportError('Export failed (no data provided), please contact your administrator');
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
ExportRun(data);
|
||||
}
|
||||
}, 'json')
|
||||
.fail(function() {
|
||||
.fail(function () {
|
||||
ExportError('Export failed, please contact your administrator');
|
||||
});
|
||||
}
|
||||
|
||||
function ExportError(sMessage)
|
||||
{
|
||||
function ExportError(sMessage) {
|
||||
$('.export-message').html(sMessage);
|
||||
$('.export-progress-bar').hide();
|
||||
$('#export-btn').hide();
|
||||
}
|
||||
|
||||
function ExportRun(data)
|
||||
{
|
||||
switch(data.code)
|
||||
{
|
||||
function ExportRun(data) {
|
||||
switch (data.code) {
|
||||
case 'run':
|
||||
// Continue
|
||||
$('.export-progress-bar').progressbar({value: data.percentage });
|
||||
$('.export-progress-bar').progressbar({value: data.percentage});
|
||||
$('.export-message').html(data.message);
|
||||
oParams = {};
|
||||
oParams.token = data.token;
|
||||
var sDataState = $('#export-form').attr('data-state');
|
||||
if (sDataState == 'cancelled')
|
||||
{
|
||||
if (sDataState == 'cancelled') {
|
||||
oParams.operation = 'export_cancel';
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
oParams.operation = 'export_build';
|
||||
}
|
||||
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data) {
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function (data) {
|
||||
ExportRun(data);
|
||||
},
|
||||
'json');
|
||||
@@ -592,29 +513,24 @@ function ExportRun(data)
|
||||
$('.export-progress-bar').hide();
|
||||
$('#export-btn').hide();
|
||||
$('#export-form').attr('data-state', 'done');
|
||||
if(data.text_result != undefined)
|
||||
{
|
||||
if (data.mime_type == 'text/html')
|
||||
{
|
||||
if (data.text_result != undefined) {
|
||||
if (data.mime_type == 'text/html') {
|
||||
$('#export_content').parent().html(data.text_result);
|
||||
$('#export_text_result').show();
|
||||
$('#export_text_result .listResults').tableHover();
|
||||
$('#export_text_result .listResults').tablesorter( { widgets: ['myZebra']} );
|
||||
$('#export_text_result .listResults').tablesorter({widgets: ['myZebra']});
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($('#export_text_result').closest('ui-dialog').length == 0)
|
||||
{
|
||||
else {
|
||||
if ($('#export_text_result').closest('ui-dialog').length == 0) {
|
||||
// not inside a dialog box, adjust the height... approximately
|
||||
var jPane = $('#export_text_result').closest('.ui-layout-content');
|
||||
var iTotalHeight = jPane.height();
|
||||
jPane.children(':visible').each(function() {
|
||||
if ($(this).attr('id') != '')
|
||||
{
|
||||
jPane.children(':visible').each(function () {
|
||||
if ($(this).attr('id') != '') {
|
||||
iTotalHeight -= $(this).height();
|
||||
}
|
||||
});
|
||||
$('#export_content').height(iTotalHeight - 80);
|
||||
$('#export_content').height(iTotalHeight-80);
|
||||
}
|
||||
$('#export_content').val(data.text_result);
|
||||
$('#export_text_result').show();
|
||||
@@ -625,7 +541,7 @@ function ExportRun(data)
|
||||
|
||||
case 'error':
|
||||
$('#export-form').attr('data-state', 'error');
|
||||
$('.export-progress-bar').progressbar({value: data.percentage });
|
||||
$('.export-progress-bar').progressbar({value: data.percentage});
|
||||
$('.export-message').html(data.message);
|
||||
$('#export-dlg-submit').button('option', 'label', Dict.S('UI:Button:Done')).button('enable');
|
||||
$('#export-btn').hide();
|
||||
@@ -633,30 +549,25 @@ function ExportRun(data)
|
||||
}
|
||||
}
|
||||
|
||||
function ExportInitButton(sSelector)
|
||||
{
|
||||
$(sSelector).on('click', function() {
|
||||
function ExportInitButton(sSelector) {
|
||||
$(sSelector).on('click', function () {
|
||||
var sDataState = $('#export-form').attr('data-state');
|
||||
switch(sDataState)
|
||||
{
|
||||
switch (sDataState) {
|
||||
case 'not-yet-started':
|
||||
$('.form_part:visible').each(function() {
|
||||
$('.form_part:visible').each(function () {
|
||||
$('#export-form').data('validation_messages', []);
|
||||
var ret = $(this).trigger('validate');
|
||||
});
|
||||
var aMessages = $('#export-form').data('validation_messages');
|
||||
|
||||
if(aMessages.length > 0)
|
||||
{
|
||||
if (aMessages.length > 0) {
|
||||
alert(aMessages.join(''));
|
||||
return;
|
||||
}
|
||||
if ($(this).hasClass('ui-button'))
|
||||
{
|
||||
if ($(this).hasClass('ui-button')) {
|
||||
$(this).button('option', 'label', Dict.S('UI:Button:Cancel'));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$(this).html(Dict.S('UI:Button:Cancel'));
|
||||
}
|
||||
$('#export-form').attr('data-state', 'running');
|
||||
@@ -664,12 +575,10 @@ function ExportInitButton(sSelector)
|
||||
break;
|
||||
|
||||
case 'running':
|
||||
if ($(this).hasClass('ui-button'))
|
||||
{
|
||||
if ($(this).hasClass('ui-button')) {
|
||||
$(this).button('disable');
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$(this).attr('disabled', 'disabled');
|
||||
}
|
||||
$('#export-form').attr('data-state', 'cancelled');
|
||||
@@ -686,66 +595,54 @@ function ExportInitButton(sSelector)
|
||||
});
|
||||
}
|
||||
|
||||
function DisplayHistory(sSelector, sFilter, iCount, iStart)
|
||||
{
|
||||
function DisplayHistory(sSelector, sFilter, iCount, iStart) {
|
||||
$(sSelector).block();
|
||||
var oParams = { operation: 'history_from_filter', filter: sFilter, start: iStart, count: iCount };
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data) {
|
||||
var oParams = {operation: 'history_from_filter', filter: sFilter, start: iStart, count: iCount};
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function (data) {
|
||||
$(sSelector).html(data).unblock();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Very simple equivalent to format: placeholders are %1$s %2$d ...
|
||||
function Format()
|
||||
{
|
||||
function Format() {
|
||||
var args = [];
|
||||
var str = '';
|
||||
if (arguments[0] instanceof Array)
|
||||
{
|
||||
if (arguments[0] instanceof Array) {
|
||||
str = arguments[0][0].toString();
|
||||
args = arguments[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
str = arguments[0].toString();
|
||||
if (arguments.length > 1)
|
||||
{
|
||||
if (arguments.length > 1) {
|
||||
var t = typeof arguments[1];
|
||||
args = ("string" === t || "number" === t) ? Array.prototype.slice.call(arguments) : arguments[1];
|
||||
}
|
||||
}
|
||||
var key;
|
||||
for (key in args)
|
||||
{
|
||||
str = str.replace(new RegExp("\\%" + key + "\\$.", "gi"), args[key]);
|
||||
for (key in args) {
|
||||
str = str.replace(new RegExp("\\%"+key+"\\$.", "gi"), args[key]);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
var Dict = {};
|
||||
if (aDictEntries == undefined)
|
||||
{
|
||||
if (typeof aDictEntries == 'undefined') {
|
||||
Dict._entries = {}; // Entries have not been loaded (we are in the setup ?)
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
Dict._entries = aDictEntries; // Entries were loaded asynchronously via their own js files
|
||||
}
|
||||
Dict.S = function(sEntry)
|
||||
{
|
||||
if (sEntry in Dict._entries)
|
||||
{
|
||||
Dict.S = function (sEntry) {
|
||||
if (sEntry in Dict._entries) {
|
||||
return Dict._entries[sEntry];
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
return sEntry;
|
||||
}
|
||||
};
|
||||
Dict.Format = function()
|
||||
{
|
||||
Dict.Format = function () {
|
||||
var args = Array.from(arguments);
|
||||
args[0] = Dict.S(arguments[0]);
|
||||
return Format(args);
|
||||
|
||||
Reference in New Issue
Block a user