mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°3907 - Polishing: Run query
This commit is contained in:
@@ -389,14 +389,16 @@ class SQLObjectQuery extends SQLQuery
|
|||||||
if (count($this->__aSelectedIdFields) > 0)
|
if (count($this->__aSelectedIdFields) > 0)
|
||||||
{
|
{
|
||||||
$aCountFields = array();
|
$aCountFields = array();
|
||||||
foreach ($this->__aSelectedIdFields as $sFieldExpr)
|
$i = 0;
|
||||||
{
|
foreach ($this->__aSelectedIdFields as $sFieldExpr) {
|
||||||
$aCountFields[] = "COALESCE($sFieldExpr, 0)"; // Null values are excluded from the count
|
$aCountFields[] = "COALESCE($sFieldExpr, 0) AS idCount$i"; // Null values are excluded from the count
|
||||||
|
$aCountI[] = 'idCount'.$i++;
|
||||||
}
|
}
|
||||||
$sCountFields = implode(', ', $aCountFields);
|
$sCountFields = implode(', ', $aCountFields);
|
||||||
|
$sCountI = implode('+ ', $aCountI);
|
||||||
// Count can be limited for performance reason, in this case the total amount is not important,
|
// Count can be limited for performance reason, in this case the total amount is not important,
|
||||||
// we only need to know if the number of entries is greater than a certain amount.
|
// we only need to know if the number of entries is greater than a certain amount.
|
||||||
$sSQL = "SELECT COUNT(*) AS COUNT FROM (SELECT$sLineSep DISTINCT $sCountFields $sLineSep FROM $sFrom$sLineSep WHERE $sWhere $sLimit) AS _alderaan_";
|
$sSQL = "SELECT COUNT(*) AS COUNT FROM (SELECT$sLineSep DISTINCT $sCountFields $sLineSep FROM $sFrom$sLineSep WHERE $sWhere $sLimit) AS _alderaan_ WHERE $sCountI>0";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ $.fn.dataTable.pipeline = function (opts) {
|
|||||||
"data": request,
|
"data": request,
|
||||||
"dataType": "json",
|
"dataType": "json",
|
||||||
"cache": false,
|
"cache": false,
|
||||||
"success": function ( json ) {
|
"success": function (json) {
|
||||||
cacheLastJson = $.extend(true, {}, json);
|
cacheLastJson = $.extend(true, {}, json);
|
||||||
|
|
||||||
if (cacheLower != drawStart && requestLength != -1) {
|
if (cacheLower != drawStart && requestLength != -1) {
|
||||||
@@ -142,6 +142,28 @@ $.fn.dataTable.pipeline = function (opts) {
|
|||||||
json.data.splice(requestLength, json.data.length);
|
json.data.splice(requestLength, json.data.length);
|
||||||
}
|
}
|
||||||
drawCallback(json);
|
drawCallback(json);
|
||||||
|
},
|
||||||
|
error: function (data) {
|
||||||
|
let oDlg = $('<div></div>');
|
||||||
|
$('body').append(oDlg);
|
||||||
|
oDlg.html(data.responseText);
|
||||||
|
oDlg.dialog({
|
||||||
|
title: settings["oLanguage"]["errorMessage"],
|
||||||
|
modal: true,
|
||||||
|
width: 'auto',
|
||||||
|
height: 'auto',
|
||||||
|
maxHeight: $(window).height() * 0.7,
|
||||||
|
maxWidth: '500',
|
||||||
|
position: {my: "center", at: "center", of: window},
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
text: settings["oLanguage"]["buttonOk"],
|
||||||
|
class: "ibo-is-primary ibo-is-neutral",
|
||||||
|
click: function () {
|
||||||
|
$(this).dialog('close');
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ class AjaxRenderController
|
|||||||
while ($aObject = $oSet->FetchAssoc()) {
|
while ($aObject = $oSet->FetchAssoc()) {
|
||||||
$aObj = [];
|
$aObj = [];
|
||||||
foreach ($aClassAliases as $sAlias => $sClass) {
|
foreach ($aClassAliases as $sAlias => $sClass) {
|
||||||
if (isset($aObject[$sAlias])) {
|
if (isset($aObject[$sAlias]) && !is_null($aObject[$sAlias])) {
|
||||||
$aObj[$sAlias."/_key_"] = $aObject[$sAlias]->GetKey();
|
$aObj[$sAlias."/_key_"] = $aObject[$sAlias]->GetKey();
|
||||||
$aObj[$sAlias."/hyperlink"] = $aObject[$sAlias]->GetHyperlink();
|
$aObj[$sAlias."/hyperlink"] = $aObject[$sAlias]->GetHyperlink();
|
||||||
foreach ($aColumnsLoad[$sAlias] as $sAttCode) {
|
foreach ($aColumnsLoad[$sAlias] as $sAttCode) {
|
||||||
@@ -415,10 +415,14 @@ class AjaxRenderController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($sIdName != "") {
|
if (isset($aObject)) {
|
||||||
$aObj["id"] = $aObj[$sIdName];
|
if ($sIdName != "") {
|
||||||
}
|
if (isset($aObj[$sIdName])) {
|
||||||
if (isset($aObj)) {
|
$aObj["id"] = $aObj[$sIdName];
|
||||||
|
} else {
|
||||||
|
throw new Exception(Dict::Format('UI:Error:AnErrorOccuredWhileRunningTheQuery_Message', $oSet->GetFilter()->ToOQL()));
|
||||||
|
}
|
||||||
|
}
|
||||||
array_push($aResult["data"], $aObj);
|
array_push($aResult["data"], $aObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -508,8 +508,6 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sSelectMode = 'none';
|
|
||||||
|
|
||||||
$oDefaultSettings = DataTableSettings::GetDataModelSettings($aAuthorizedClasses, $bViewLink, $aList);
|
$oDefaultSettings = DataTableSettings::GetDataModelSettings($aAuthorizedClasses, $bViewLink, $aList);
|
||||||
|
|
||||||
$bDisplayLimit = isset($aExtraParams['display_limit']) ? $aExtraParams['display_limit'] : true;
|
$bDisplayLimit = isset($aExtraParams['display_limit']) ? $aExtraParams['display_limit'] : true;
|
||||||
@@ -563,9 +561,15 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
|||||||
$aColumnDefinition = [];
|
$aColumnDefinition = [];
|
||||||
$aSortOrder = [];
|
$aSortOrder = [];
|
||||||
$iIndexColumn = 0;
|
$iIndexColumn = 0;
|
||||||
if ($sSelectMode != "") {
|
|
||||||
|
$bSelectMode = isset($aExtraParams['selection_mode']) ? $aExtraParams['selection_mode'] == true : false;
|
||||||
|
$bSingleSelectMode = isset($aExtraParams['selection_type']) ? ($aExtraParams['selection_type'] == 'single') : false;
|
||||||
|
$sSelectMode = '';
|
||||||
|
if ($bSelectMode) {
|
||||||
|
$sSelectMode = $bSingleSelectMode ? 'single' : 'multiple';
|
||||||
$iIndexColumn++;
|
$iIndexColumn++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$aSortDatable = [];
|
$aSortDatable = [];
|
||||||
foreach ($aAuthorizedClasses as $sClassAlias => $sClassName) {
|
foreach ($aAuthorizedClasses as $sClassAlias => $sClassName) {
|
||||||
if (isset($oCustomSettings->aColumns[$sClassAlias])) {
|
if (isset($oCustomSettings->aColumns[$sClassAlias])) {
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
|
|||||||
infoEmpty: "{{ 'UI:Datatables:Language:InfoEmpty'|dict_s }}",
|
infoEmpty: "{{ 'UI:Datatables:Language:InfoEmpty'|dict_s }}",
|
||||||
infoFiltered: "({{ 'UI:Datatables:Language:InfoFiltered'|dict_s }})",
|
infoFiltered: "({{ 'UI:Datatables:Language:InfoFiltered'|dict_s }})",
|
||||||
emptyTable: "{{ 'UI:Datatables:Language:EmptyTable'|dict_s }}",
|
emptyTable: "{{ 'UI:Datatables:Language:EmptyTable'|dict_s }}",
|
||||||
|
errorMessage: "{{ 'UI:RunQuery:Error'|dict_s }}",
|
||||||
|
buttonOk: "{{ 'UI:Button:Ok' |dict_s }}",
|
||||||
paginate: {
|
paginate: {
|
||||||
first: "<i class=\"fas fa-angle-double-left\"></i>",
|
first: "<i class=\"fas fa-angle-double-left\"></i>",
|
||||||
previous: "<i class=\"fas fa-angle-left\"></i>",
|
previous: "<i class=\"fas fa-angle-left\"></i>",
|
||||||
|
|||||||
Reference in New Issue
Block a user