diff --git a/js/utils.js b/js/utils.js
index eb708930a1..ce98246453 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -262,7 +262,7 @@ function UpdateFileName(id, sNewFileName) {
* Reload a search form for the specified class
*/
function ReloadSearchForm(divId, sClassName, sBaseClass, sContext, sTableId, sExtraParams) {
- var oDiv = $('#'+divId);
+ var oDiv = $('#'+divId).parent();
oDiv.block();
// deprecated in jQuery 1.8
//var oFormEvents = $('#ds_'+divId+' form').data('events');
diff --git a/pages/UI.php b/pages/UI.php
index c5d98f6e75..a3d68e9392 100644
--- a/pages/UI.php
+++ b/pages/UI.php
@@ -211,6 +211,7 @@ function SetObjectBreadCrumbEntry(DBObject $oObj, WebPage $oPage)
*/
function DisplaySearchSet($oP, $oFilter, $bSearchForm = true, $sBaseClass = '', $sFormat = '', $bDoSearch = true, $bSearchFormOpen = true)
{
+ //search block
$oBlockForm=null;
if ($bSearchForm)
{
@@ -245,12 +246,15 @@ function DisplaySearchSet($oP, $oFilter, $bSearchForm = true, $sBaseClass = '',
$oP->SetBreadCrumbEntry($sPageId, $sLabel, '', '', 'fas fa-search', iTopWebPage::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_CSS_CLASSES);
}
if ($bSearchForm) {
- $oUIBlockForm=$oBlockForm->GetDisplay($oP,'0');
+ //add search block
$sTableId = utils::ReadParam('_table_id_', null, false, 'raw_data');
if($sTableId=='')
{
- $sTableId = '1';
+ $sTableId = 'result_1';
}
+ $aExtraParams['table_id']=$sTableId;
+ $oUIBlockForm=$oBlockForm->GetDisplay($oP,'search_1');
+ //add result block
$oUIBlock=$oBlock->GetDisplay($oP, $sTableId);
$oUIBlock->AddCSSClasses("display_block sf_results_area");
//$oUIBlockForm->AddSubBlock($oUIBlock);
diff --git a/pages/ajax.render.php b/pages/ajax.render.php
index 29d0081ed1..2ffa2a67c9 100644
--- a/pages/ajax.render.php
+++ b/pages/ajax.render.php
@@ -234,7 +234,7 @@ try
case 'search_and_refresh':
$oPage->SetContentType('application/json');
- $extraParams = utils::ReadParam('extra_param', '', false, 'raw_data');
+ $extraParams = utils::ReadParam('extra_params', '', false, 'raw_data');
$aExtraParams = array();
if (is_array($extraParams))
{
@@ -411,7 +411,15 @@ try
$aObj[$sAlias."/".$sAttCode ] = $aObject[$sAlias]->GetKey();
}
else {
- $aObj[$sAlias."/".$sAttCode ] = $aObject[$sAlias]->GetAsHTML($sAttCode);
+ $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
+ if ($oAttDef instanceof AttributeExternalKey)
+ {
+ $aObj[$sAlias."/".$sAttCode ] = $aObject[$sAlias]->Get($sAttCode);
+ }
+ else{
+ $aObj[$sAlias."/".$sAttCode ] = $aObject[$sAlias]->GetAsHTML($sAttCode);
+ }
+
}
}
}
diff --git a/sources/application/UI/Component/DataTable/DataTableFactory.php b/sources/application/UI/Component/DataTable/DataTableFactory.php
index 74071e4e4b..64dc544160 100644
--- a/sources/application/UI/Component/DataTable/DataTableFactory.php
+++ b/sources/application/UI/Component/DataTable/DataTableFactory.php
@@ -570,7 +570,7 @@ class DataTableFactory
public static function GetOptionsForRendering(array $aColumns, string $sSelectMode, string $sFilter, int $iLength, array $aClassAliases, array $aExtraParams)
{
$aOptions = [];
-
+ $sTableId=$aExtraParams["table_id"];
$aColumnsDefinitions = [];
$aColumnDefinition = [];
@@ -578,18 +578,22 @@ class DataTableFactory
$aColumnDefinition["width"] = "auto";
$aColumnDefinition["searchable"] = false;
$aColumnDefinition["sortable"] = false;
- $aColumnDefinition["title"] = "";
+ if ($sSelectMode != "single") {
+ $aColumnDefinition["title"] = "";
+ } else{
+ $aColumnDefinition["title"] = "";
+ }
$aColumnDefinition["type"] = "html";
$aColumnDefinition["data"] = "";
- $aColumnDefinition["render"] = "function (data, type, row) {
- var oCheckboxElem = $('');
- if (row.limited_access) {
- oCheckboxElem.html('-');
- } else {
- oCheckboxElem.find(':input').attr('data-object-id', row.id).attr('data-target-object-id', row.target_id);
- }
- return oCheckboxElem.prop('outerHTML');
- }";
+ $aColumnDefinition["render"]["display"] = "";
+ if ($sSelectMode != "single") {
+ $aColumnDefinition["render"]["display"] = $aColumnDefinition["render"]["display"] . " var oCheckboxElem = $('');";
+ }
+ else {
+ $aColumnDefinition["render"]["display"] = $aColumnDefinition["render"]["display"] . " var oCheckboxElem = $('');";
+ }
+ $aColumnDefinition["render"]["display"] = $aColumnDefinition["render"]["display"] . " if (row.limited_access) { oCheckboxElem.html('-'); } else { oCheckboxElem.find(':input').attr('data-object-id', row.id).attr('data-target-object-id', row.target_id); }";
+ $aColumnDefinition["render"]["display"] = $aColumnDefinition["render"]["display"]. " return oCheckboxElem.prop('outerHTML'); ";
array_push($aColumnsDefinitions, $aColumnDefinition);
}
diff --git a/templates/components/datatable/layout.js.twig b/templates/components/datatable/layout.js.twig
index 21d20461a1..c88fa2cec5 100644
--- a/templates/components/datatable/layout.js.twig
+++ b/templates/components/datatable/layout.js.twig
@@ -4,7 +4,7 @@ function checkAllDataTable(table, value) {
if (value) {
selectionMode = 'negative';
}
-
+ oSelectedItems{{ oUIBlock.GetOption('sListId') }} =[];
// Mark all the displayed items as check or unchecked depending on the value
$(table).find(':checkbox[name^=selectObj]:not([disabled])').each(function () {
var $currentCheckbox = $(this);
@@ -20,8 +20,10 @@ function checkAllDataTable(table, value) {
if (value) {
$(table).DataTable().rows().select();
+ $('#btn_ok_{{ oUIBlock.GetOption('sTableId') }}').prop('disabled', false);
} else {
$(table).DataTable().rows({page: 'current'}).deselect();
+ $('#btn_ok_{{ oUIBlock.GetOption('sTableId') }}').prop('disabled', true);
}
return true;
@@ -118,10 +120,10 @@ var oTable{{ oUIBlock.GetId() }} = $('#{{ oUIBlock.GetId() }}').DataTable({
data: "",
render: function (data, type, row) {
var oCheckboxElem =
- {% if oUIBlock.GetOption("select_mode") != "single" %}
+ {% if oUIBlock.GetOption("select_mode") != "single" %}
$('');
{% else %}
- $('');
+ $('');
{% endif %}
if (row.limited_access) {
oCheckboxElem.html('-');
@@ -172,104 +174,79 @@ var oTable{{ oUIBlock.GetId() }} = $('#{{ oUIBlock.GetId() }}').DataTable({
{% if oUIBlock.GetOption("select_mode") is not empty %}
{% if oUIBlock.GetOption("select_mode") != "single" %}
+console.warn('aa');
oTable{{ oUIBlock.GetId() }}.off('select').on('select', function (oEvent, dt, type, indexes) {
- var aData = oTable{{ oUIBlock.GetId() }}.rows(indexes).data().toArray();
- // Checking input
- $('#{{ oUIBlock.GetId() }} tr[role="row"].selected td:first-child input').prop('checked', true);
- // Saving values in temp array
- for (var i in aData) {
- var iItemId = aData[i].id;
- if (oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId) === -1) {
- oSelectedItems{{ oUIBlock.GetOption('sListId') }}.push(iItemId);
- }
+ var aData = oTable{{ oUIBlock.GetId() }}.rows(indexes).data().toArray();
+ if( $(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative")
+ {
+ // Checking input
+ $('#{{ oUIBlock.GetId() }} tr[role="row"].selected td:first-child input').prop('checked', true);
+ // Saving values in temp array
+ for (var i in aData) {
+ var iItemId = aData[i].id;
+ if (oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId) > -1) {
+ oSelectedItems{{ oUIBlock.GetOption('sListId') }}.splice(oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId), 1);
+ }
+ }
+ if (oSelectedItems{{ oUIBlock.GetOption('sListId') }}.length === oTable{{ oUIBlock.GetId() }}.page.info()["recordsTotal"] ) {
+ $('#btn_ok_{{ oUIBlock.GetOption('sTableId') }}').prop('disabled', true);
+ } else {
+ $('#btn_ok_{{ oUIBlock.GetOption('sTableId') }}').prop('disabled', false);
+ }
}
- if ((oSelectedItems{{ oUIBlock.GetOption('sListId') }}.length === oTable{{ oUIBlock.GetId() }}.page.info()["recordsTotal"] && $(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative")) {
- $('#btn_ok_{{ oUIBlock.GetOption('sTableId') }}').prop('disabled', true);
- } else {
- $('#btn_ok_{{ oUIBlock.GetOption('sTableId') }}').prop('disabled', false);
+ else {
+ // Checking input
+ $('#{{ oUIBlock.GetId() }} tr[role="row"].selected td:first-child input').prop('checked', true);
+ // Saving values in temp array
+ for (var i in aData) {
+ var iItemId = aData[i].id;
+ if (oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId) === -1) {
+ oSelectedItems{{ oUIBlock.GetOption('sListId') }}.push(iItemId);
+ }
+ }
+ $('#btn_ok_{{ oUIBlock.GetOption('sTableId') }}').prop('disabled', false);
}
});
oTable{{ oUIBlock.GetId() }}.off('deselect').on('deselect', function (oEvent, dt, type, indexes) {
- var aData = oTable{{ oUIBlock.GetId() }}.rows(indexes).data().toArray();
+ var aData = oTable{{ oUIBlock.GetId() }}.rows(indexes).data().toArray();
- // Checking input
- $('#{{ oUIBlock.GetId() }} tr[role="row"]:not(.selected) td:first-child input').prop('checked', false);
- // Saving values in temp array
- for (var i in aData) {
- var iItemId = aData[i].id;
- if (oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId) > -1) {
- oSelectedItems{{ oUIBlock.GetOption('sListId') }}.splice(oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId), 1);
- }
- }
- if ((oSelectedItems{{ oUIBlock.GetOption('sListId') }}.length === 0 && $(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "positive")) {
- $('#btn_ok_{{ oUIBlock.GetOption('sTableId') }}').prop('disabled', true);
- } else {
- $('#btn_ok_{{ oUIBlock.GetOption('sTableId') }}').prop('disabled', false);
- }
+ // Checking input
+ $('#{{ oUIBlock.GetId() }} tr[role="row"]:not(.selected) td:first-child input').prop('checked', false);
+ // Saving values in temp array
+ if ($(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative") {
+ for (var i in aData) {
+ var iItemId = aData[i].id;
+ if (oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId) === -1) {
+ oSelectedItems{{ oUIBlock.GetOption('sListId') }}.push(iItemId);
+ }
+ }
+ if (oSelectedItems{{ oUIBlock.GetOption('sListId') }}.length === oTable{{ oUIBlock.GetId() }}.page.info()["recordsTotal"]) {
+ $('#btn_ok_{{ oUIBlock.GetOption('sTableId') }}').prop('disabled', true);
+ } else {
+ $('#btn_ok_{{ oUIBlock.GetOption('sTableId') }}').prop('disabled', false);
+ }
+ } else {
+ for (var i in aData) {
+ var iItemId = aData[i].id;
+ if (oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId) > -1) {
+ oSelectedItems{{ oUIBlock.GetOption('sListId') }}.splice(oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId), 1);
+ }
+ }
+ if (oSelectedItems{{ oUIBlock.GetOption('sListId') }}.length === 0) {
+ $('#btn_ok_{{ oUIBlock.GetOption('sTableId') }}').prop('disabled', true);
+ } else {
+ $('#btn_ok_{{ oUIBlock.GetOption('sTableId') }}').prop('disabled', false);
+ }
+ }
});
{% else %}
-oTable{{ oUIBlock.GetId() }}.off('select').on('select', function (oEvent, dt, type, indexes) {
- var aData = oTable{{ oUIBlock.GetId() }}.rows(indexes).data().toArray();
- // Checking input
- $('#{{ oUIBlock.GetId() }} tr[role="row"].selected td:first-child input').prop('checked', true);
- // Saving values in temp array
- for (var i in aData) {
- var iItemId = aData[i].id;
- if (oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId) === -1) {
- oSelectedItems{{ oUIBlock.GetOption('sListId') }}.push(iItemId);
- }
- }
- if ((oSelectedItems{{ oUIBlock.GetOption('sListId') }}.length === oTable{{ oUIBlock.GetId() }}.page.info()["recordsTotal"] && $(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative")) {
- $('#btn_ok_{{ oUIBlock.GetOption('sListId') }}').prop('disabled', true);
- } else {
- $('#btn_ok_{{ oUIBlock.GetOption('sListId') }}').prop('disabled', false);
- }
-});
-
-oTable{{ oUIBlock.GetId() }}.off('deselect').on('deselect', function (oEvent, dt, type, indexes) {
- var aData = oTable{{ oUIBlock.GetId() }}.rows(indexes).data().toArray();
-
- // Checking input
- $('#{{ oUIBlock.GetId() }} tr[role="row"]:not(.selected) td:first-child input').prop('checked', false);
- // Saving values in temp array
- for (var i in aData) {
- var iItemId = aData[i].id;
- if (oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId) > -1) {
- oSelectedItems{{ oUIBlock.GetOption('sListId') }}.splice(oSelectedItems{{ oUIBlock.GetOption('sListId') }}.indexOf(iItemId), 1);
- }
- }
- if ((oSelectedItems{{ oUIBlock.GetOption('sListId') }}.length === 0 && $(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "positive")) {
- $('#btn_ok_{{ oUIBlock.GetOption('sListId') }}').prop('disabled', true);
- } else {
- $('#btn_ok_{{ oUIBlock.GetOption('sListId') }}').prop('disabled', false);
- }
-});
+ oTable{{ oUIBlock.GetId() }}.off('select').on('select', function (oEvent, dt, type, indexes) {
+ $('#btn_ok_{{ oUIBlock.GetOption('sListId') }}').prop('disabled', false);
+ });
{% endif %}
{% endif %}
-// Handles submit button
-//$('#form_{{ oUIBlock.GetId() }} .form_buttons .form_btn_submit').off('click').on('click', function(oEvent){
-// Extracting value(s) to be send back to the source form
-{% if bMultipleSelect %}
-//var oData = {values: oSelectedItems};
-{% else %}
-/*var oData = {value: {}};
-var sItemId = Object.keys(oSelectedItems)[0];
-var sItemName = oSelectedItems[sItemId];
-
-oData.value[sItemId] = sItemName;*/
-{% endif %}
-
-// Triggering value setting on the source field
-//$('[data-form-path="{{ aSource.sFormPath }}"][data-field-id="{{ aSource.sFieldId }}"]').triggerHandler('set_current_value', oData);
-
-// Closing the modal
-{% if tIsModal is defined and tIsModal == true %}
-//$('#{{ sFormId }}').closest('.modal').modal('hide');
-{% endif %}
-//});
-
$('#datatable_dlg_{{ oUIBlock.GetId() }}').dialog(
{
autoOpen: false,