mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°3685 - Performance checks on the front end - Avoid reload
This commit is contained in:
@@ -1126,7 +1126,7 @@ class OQLMenuNode extends MenuNode
|
||||
$oSearch = DBObjectSearch::FromOQL($sOql);
|
||||
|
||||
if ($bSearchPane) {
|
||||
$aParams = array_merge(['open' => $bSearchOpen, 'table_id' => $sUsageId, 'submit_on_load' => true], $aExtraParams);
|
||||
$aParams = array_merge(['open' => $bSearchOpen, 'table_id' => $sUsageId, 'submit_on_load' => false], $aExtraParams);
|
||||
$oBlock = new DisplayBlock($oSearch, 'search', false /* Asynchronous */, $aParams);
|
||||
$oBlock->Display($oPage, 0);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ $(function()
|
||||
/* Submit the search form automatically on criteria change */
|
||||
'auto_submit': true,
|
||||
/* Submit the search form when the page is first loaded */
|
||||
'submit_on_load': false,
|
||||
'show_obsolete_data' : true,
|
||||
'submit_on_load': true,
|
||||
'show_obsolete_data': true,
|
||||
'search': {
|
||||
'base_oql': '',
|
||||
'class_name': null,
|
||||
@@ -109,10 +109,10 @@ $(function()
|
||||
};
|
||||
|
||||
//init others widgets :
|
||||
this.element.search_form_handler_history({'itop_root_class':me.options.search.class_name});
|
||||
this.element.search_form_handler_history({'itop_root_class': me.options.search.class_name});
|
||||
|
||||
|
||||
// Prepare DOM elements
|
||||
// Prepare DOM elements
|
||||
this._prepareFormArea();
|
||||
this._prepareCriterionArea();
|
||||
this._prepareResultsArea();
|
||||
@@ -122,16 +122,15 @@ $(function()
|
||||
// Binding events (eg. from search_form_criteria widgets)
|
||||
this._bindEvents();
|
||||
|
||||
//memorize the initial state so on first criteria close, we do not trigger a refresh if nothing has changed
|
||||
this._updateSearch();
|
||||
//memorize the initial state so on first criteria close, we do not trigger a refresh if nothing has changed
|
||||
this._updateSearch();
|
||||
this.oPreviousAjaxParams = JSON.stringify({
|
||||
'base_oql': this.options.search.base_oql,
|
||||
'criterion': this.options.search.criterion,
|
||||
});
|
||||
'base_oql': this.options.search.base_oql,
|
||||
'criterion': this.options.search.criterion,
|
||||
});
|
||||
|
||||
// If auto submit is enabled, also submit on first display
|
||||
if(this.options.auto_submit === true || this.options.submit_on_load === true)
|
||||
{
|
||||
if (this.options.auto_submit === true && this.options.submit_on_load === true) {
|
||||
this._submit();
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +176,8 @@ function DisplaySearchSet($oP, $oFilter, $bSearchForm = true, $sBaseClass = '',
|
||||
$sTableId = 'result_1';
|
||||
}
|
||||
$aExtraParams['table_id'] = $sTableId;
|
||||
$oUIBlockForm = $oBlockForm->GetDisplay($oP, 'search_1',$aExtraParams);
|
||||
$aExtraParams['submit_on_load'] = false;
|
||||
$oUIBlockForm = $oBlockForm->GetDisplay($oP, 'search_1', $aExtraParams);
|
||||
//add result block
|
||||
$oUIBlock = $oBlock->GetDisplay($oP, $sTableId);
|
||||
$oUIBlock->AddCSSClasses(['display_block', 'sf_results_area']);
|
||||
|
||||
@@ -200,8 +200,7 @@ class SearchForm
|
||||
}
|
||||
|
||||
$bUseApplicationContext = true;
|
||||
if (isset($aExtraParams['selection_mode']) && ($aExtraParams['selection_mode']))
|
||||
{
|
||||
if (isset($aExtraParams['selection_mode']) && ($aExtraParams['selection_mode'])) {
|
||||
// Don't use application context for selections
|
||||
$bUseApplicationContext = false;
|
||||
}
|
||||
@@ -211,34 +210,49 @@ class SearchForm
|
||||
$aCriterion = $this->GetCriterion($oSearch, $aFields, $aArgs, $bIsRemovable, $bUseApplicationContext);
|
||||
$aClasses = $oSearch->GetSelectedClasses();
|
||||
$sClassAlias = '';
|
||||
foreach($aClasses as $sAlias => $sClass)
|
||||
{
|
||||
foreach ($aClasses as $sAlias => $sClass) {
|
||||
$sClassAlias = $sAlias;
|
||||
}
|
||||
|
||||
$oBaseSearch = $oSearch->DeepClone();
|
||||
if ($oSearch instanceof DBObjectSearch)
|
||||
{
|
||||
if ($oSearch instanceof DBObjectSearch) {
|
||||
$oBaseSearch->ResetCondition();
|
||||
}
|
||||
$sBaseOQL = str_replace(' WHERE 1', '', $oBaseSearch->ToOQL());
|
||||
|
||||
if (!isset($aExtraParams['table_inner_id']))
|
||||
{
|
||||
if (!isset($aExtraParams['table_inner_id'])) {
|
||||
$aListParams['table_inner_id'] = "table_inner_id_{$sSearchFormId}";
|
||||
}
|
||||
$bSubmitOnLoad = (isset($aExtraParams['submit_on_load'])) ? $aExtraParams['submit_on_load'] : false;
|
||||
$bSubmitOnLoad = (isset($aExtraParams['submit_on_load'])) ? $aExtraParams['submit_on_load'] : true;
|
||||
|
||||
$sDebug = utils::ReadParam('debug', 'false', false, 'parameter');
|
||||
if ($sDebug == 'true')
|
||||
{
|
||||
if ($sDebug == 'true') {
|
||||
$aListParams['debug'] = 'true';
|
||||
}
|
||||
|
||||
$aDaysMin = array(Dict::S('DayOfWeek-Sunday-Min'), Dict::S('DayOfWeek-Monday-Min'), Dict::S('DayOfWeek-Tuesday-Min'), Dict::S('DayOfWeek-Wednesday-Min'),
|
||||
Dict::S('DayOfWeek-Thursday-Min'), Dict::S('DayOfWeek-Friday-Min'), Dict::S('DayOfWeek-Saturday-Min'));
|
||||
$aMonthsShort = array(Dict::S('Month-01-Short'), Dict::S('Month-02-Short'), Dict::S('Month-03-Short'), Dict::S('Month-04-Short'), Dict::S('Month-05-Short'), Dict::S('Month-06-Short'),
|
||||
Dict::S('Month-07-Short'), Dict::S('Month-08-Short'), Dict::S('Month-09-Short'), Dict::S('Month-10-Short'), Dict::S('Month-11-Short'), Dict::S('Month-12-Short'));
|
||||
$aDaysMin = array(
|
||||
Dict::S('DayOfWeek-Sunday-Min'),
|
||||
Dict::S('DayOfWeek-Monday-Min'),
|
||||
Dict::S('DayOfWeek-Tuesday-Min'),
|
||||
Dict::S('DayOfWeek-Wednesday-Min'),
|
||||
Dict::S('DayOfWeek-Thursday-Min'),
|
||||
Dict::S('DayOfWeek-Friday-Min'),
|
||||
Dict::S('DayOfWeek-Saturday-Min'),
|
||||
);
|
||||
$aMonthsShort = array(
|
||||
Dict::S('Month-01-Short'),
|
||||
Dict::S('Month-02-Short'),
|
||||
Dict::S('Month-03-Short'),
|
||||
Dict::S('Month-04-Short'),
|
||||
Dict::S('Month-05-Short'),
|
||||
Dict::S('Month-06-Short'),
|
||||
Dict::S('Month-07-Short'),
|
||||
Dict::S('Month-08-Short'),
|
||||
Dict::S('Month-09-Short'),
|
||||
Dict::S('Month-10-Short'),
|
||||
Dict::S('Month-11-Short'),
|
||||
Dict::S('Month-12-Short'),
|
||||
);
|
||||
|
||||
$sDateTimeFormat = \AttributeDateTime::GetFormat()->ToDatePicker();
|
||||
$iDateTimeSeparatorPos = strpos($sDateTimeFormat, ' ');
|
||||
@@ -246,16 +260,16 @@ class SearchForm
|
||||
$sTimeFormat = substr($sDateTimeFormat, $iDateTimeSeparatorPos + 1);
|
||||
|
||||
$aSearchParams = array(
|
||||
'criterion_outer_selector' => "#fs_{$sSearchFormId}_criterion_outer",
|
||||
'criterion_outer_selector' => "#fs_{$sSearchFormId}_criterion_outer",
|
||||
'result_list_outer_selector' => "#{$aExtraParams['result_list_outer_selector']}",
|
||||
'data_config_list_selector' => "#{$aExtraParams['result_list_outer_selector']}",
|
||||
'endpoint' => utils::GetAbsoluteUrlAppRoot().'pages/ajax.searchform.php?'.$sContext,
|
||||
'init_opened' => $bOpen,
|
||||
'submit_on_load' => $bSubmitOnLoad,
|
||||
'auto_submit' => $bAutoSubmit,
|
||||
'list_params' => $aListParams,
|
||||
'show_obsolete_data' => $bShowObsoleteData,
|
||||
'search' => array(
|
||||
'data_config_list_selector' => "#{$aExtraParams['result_list_outer_selector']}",
|
||||
'endpoint' => utils::GetAbsoluteUrlAppRoot().'pages/ajax.searchform.php?'.$sContext,
|
||||
'init_opened' => $bOpen,
|
||||
'submit_on_load' => $bSubmitOnLoad,
|
||||
'auto_submit' => $bAutoSubmit,
|
||||
'list_params' => $aListParams,
|
||||
'show_obsolete_data' => $bShowObsoleteData,
|
||||
'search' => array(
|
||||
'has_hidden_criteria' => (array_key_exists('hidden_criteria', $aListParams) && !empty($aListParams['hidden_criteria'])),
|
||||
'fields' => $aFields,
|
||||
'criterion' => $aCriterion,
|
||||
|
||||
@@ -167,7 +167,7 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
|
||||
method: "post",
|
||||
pages: 1
|
||||
}, // number of pages to cache
|
||||
{{ oUIBlock.GetJsonData() |raw }}
|
||||
{{ oUIBlock.GetJsonInitDisplayData() |raw }}
|
||||
),
|
||||
createdRow: function (row, data, dataIndex) {
|
||||
if (data['@class'] !== undefined)
|
||||
@@ -300,9 +300,9 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
|
||||
{% endif %}
|
||||
|
||||
{% if oUIBlock.GetDisabledSelect() is not empty %}
|
||||
{% for key in oUIBlock.GetDisabledSelect() %}
|
||||
$('.selectList{{ oUIBlock.GetId() }}[value={{ key }}]').prop("disabled","disabled");
|
||||
{% endfor %}
|
||||
{% for key in oUIBlock.GetDisabledSelect() %}
|
||||
$('.selectList{{ oUIBlock.GetId() }}[value={{ key }}]').prop("disabled", "disabled");
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user