diff --git a/core/sqlobjectquery.class.inc.php b/core/sqlobjectquery.class.inc.php index e50a04324..eb261f644 100644 --- a/core/sqlobjectquery.class.inc.php +++ b/core/sqlobjectquery.class.inc.php @@ -389,14 +389,16 @@ class SQLObjectQuery extends SQLQuery if (count($this->__aSelectedIdFields) > 0) { $aCountFields = array(); - foreach ($this->__aSelectedIdFields as $sFieldExpr) - { - $aCountFields[] = "COALESCE($sFieldExpr, 0)"; // Null values are excluded from the count + $i = 0; + foreach ($this->__aSelectedIdFields as $sFieldExpr) { + $aCountFields[] = "COALESCE($sFieldExpr, 0) AS idCount$i"; // Null values are excluded from the count + $aCountI[] = 'idCount'.$i++; } $sCountFields = implode(', ', $aCountFields); + $sCountI = implode('+ ', $aCountI); // 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. - $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 { diff --git a/js/dataTables.pipeline.js b/js/dataTables.pipeline.js index 7a5982c95..05d12c950 100644 --- a/js/dataTables.pipeline.js +++ b/js/dataTables.pipeline.js @@ -132,7 +132,7 @@ $.fn.dataTable.pipeline = function (opts) { "data": request, "dataType": "json", "cache": false, - "success": function ( json ) { + "success": function (json) { cacheLastJson = $.extend(true, {}, json); if (cacheLower != drawStart && requestLength != -1) { @@ -142,6 +142,28 @@ $.fn.dataTable.pipeline = function (opts) { json.data.splice(requestLength, json.data.length); } drawCallback(json); + }, + error: function (data) { + let oDlg = $('
'); + $('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 { diff --git a/sources/Controller/AjaxRenderController.php b/sources/Controller/AjaxRenderController.php index 457b05af3..1942eb52c 100644 --- a/sources/Controller/AjaxRenderController.php +++ b/sources/Controller/AjaxRenderController.php @@ -403,7 +403,7 @@ class AjaxRenderController while ($aObject = $oSet->FetchAssoc()) { $aObj = []; 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."/hyperlink"] = $aObject[$sAlias]->GetHyperlink(); foreach ($aColumnsLoad[$sAlias] as $sAttCode) { @@ -415,10 +415,14 @@ class AjaxRenderController } } } - if ($sIdName != "") { - $aObj["id"] = $aObj[$sIdName]; - } - if (isset($aObj)) { + if (isset($aObject)) { + if ($sIdName != "") { + if (isset($aObj[$sIdName])) { + $aObj["id"] = $aObj[$sIdName]; + } else { + throw new Exception(Dict::Format('UI:Error:AnErrorOccuredWhileRunningTheQuery_Message', $oSet->GetFilter()->ToOQL())); + } + } array_push($aResult["data"], $aObj); } } diff --git a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php index deba6301b..625e4e5da 100644 --- a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php +++ b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php @@ -508,8 +508,6 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory } } - $sSelectMode = 'none'; - $oDefaultSettings = DataTableSettings::GetDataModelSettings($aAuthorizedClasses, $bViewLink, $aList); $bDisplayLimit = isset($aExtraParams['display_limit']) ? $aExtraParams['display_limit'] : true; @@ -563,9 +561,15 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory $aColumnDefinition = []; $aSortOrder = []; $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++; } + $aSortDatable = []; foreach ($aAuthorizedClasses as $sClassAlias => $sClassName) { if (isset($oCustomSettings->aColumns[$sClassAlias])) { diff --git a/templates/base/components/datatable/layout.ready.js.twig b/templates/base/components/datatable/layout.ready.js.twig index cdf9f2fb8..1fc742611 100644 --- a/templates/base/components/datatable/layout.ready.js.twig +++ b/templates/base/components/datatable/layout.ready.js.twig @@ -28,6 +28,8 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({ infoEmpty: "{{ 'UI:Datatables:Language:InfoEmpty'|dict_s }}", infoFiltered: "({{ 'UI:Datatables:Language:InfoFiltered'|dict_s }})", emptyTable: "{{ 'UI:Datatables:Language:EmptyTable'|dict_s }}", + errorMessage: "{{ 'UI:RunQuery:Error'|dict_s }}", + buttonOk: "{{ 'UI:Button:Ok' |dict_s }}", paginate: { first: "", previous: "",