N°3685 - Front-end performances: Include advanced search resources only when necessary

This commit is contained in:
Molkobain
2021-09-09 16:37:08 +02:00
parent 06f469faf2
commit df189bd1f2
4 changed files with 71 additions and 39 deletions

View File

@@ -360,7 +360,9 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper
} else {
$('#label_'+me.id).addClass('ac_dlg_loading');
}
var theMap = {
let sPromiseId = 'ajax_promise_'+me.id;
let theMap = {
sAttCode: me.sAttCode,
iInputId: me.id,
sTitle: me.sTitle,
@@ -368,7 +370,8 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper
sTargetClass: me.sTargetClass,
sFilter: me.sFilter,
bSearchMode: me.bSearchMode,
operation: 'objectSearchForm'
operation: 'objectSearchForm',
ajax_promise_id: sPromiseId
};
if (me.oWizardHelper == null) {
@@ -387,16 +390,18 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper
me.ajax_request = $.post(AddAppContext(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php'), theMap,
function (data) {
$('#ac_dlg_'+me.id).html(data);
$('#ac_dlg_'+me.id).dialog('open');
me.UpdateSizes();
me.UpdateButtons();
me.ajax_request = null;
$('#count_'+me.id+'_results').change(function () {
window[sPromiseId].then(function () {
$('#ac_dlg_'+me.id).dialog('open');
me.UpdateSizes();
me.UpdateButtons();
me.ajax_request = null;
$('#count_'+me.id+'_results').change(function () {
me.UpdateButtons();
});
if (me.bDoSearch) {
me.DoSearchObjects();
}
});
if (me.bDoSearch) {
me.DoSearchObjects();
}
},
'html'
);

View File

@@ -91,6 +91,8 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates, oWizH
let me = this;
$('#'+me.id+'_indicatorAdd').html('&nbsp;<img src="../images/indicator.gif"/>');
me.oWizardHelper.UpdateWizard();
let sPromiseId = 'ajax_promise_'+me.id;
let theMap = {
sAttCode: me.sAttCode,
iInputId: me.iInputId,
@@ -98,7 +100,8 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates, oWizH
bDuplicates: me.bDuplicates,
'class': me.sClass,
operation: 'addObjects',
json: me.oWizardHelper.ToJSON()
json: me.oWizardHelper.ToJSON(),
ajax_promise_id: sPromiseId
};
// Gather the already linked target objects
@@ -116,20 +119,22 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates, oWizH
})
.done(function (data) {
$('#dlg_'+me.id).html(data);
$('#dlg_'+me.id).dialog('open');
me.UpdateSizes(null, null);
if (me.bDoSearch)
{
me.SearchObjectsToAdd();
}
else
{
$('#count_'+me.id).change(function () {
let c = this.value;
me.UpdateButtons(c);
});
}
$('#'+me.id+'_indicatorAdd').html('');
window[sPromiseId].then(function () {
$('#dlg_'+me.id).dialog('open');
me.UpdateSizes(null, null);
if (me.bDoSearch)
{
me.SearchObjectsToAdd();
}
else
{
$('#count_'+me.id).change(function () {
let c = this.value;
me.UpdateButtons(c);
});
}
$('#'+me.id+'_indicatorAdd').html('');
});
})
;
};

View File

@@ -22,7 +22,26 @@
*/
class NiceWebPage extends WebPage
{
/** @inheritDoc */
protected const COMPATIBILITY_LINKED_SCRIPTS_REL_PATH = [
'js/search/search_form_handler.js',
'js/search/search_form_handler_history.js',
'js/search/search_form_criteria.js',
'js/search/search_form_criteria_raw.js',
'js/search/search_form_criteria_string.js',
'js/search/search_form_criteria_external_field.js',
'js/search/search_form_criteria_numeric.js',
'js/search/search_form_criteria_enum.js',
'js/search/search_form_criteria_tag_set.js',
'js/search/search_form_criteria_external_key.js',
'js/search/search_form_criteria_hierarchical_key.js',
'js/search/search_form_criteria_date_abstract.js',
'js/search/search_form_criteria_date.js',
'js/search/search_form_criteria_date_time.js',
];
const DEFAULT_PAGE_TEMPLATE_REL_PATH = 'pages/backoffice/nicewebpage/layout';
var $m_sRootUrl;
public function __construct($s_title, $bPrintable = false)
@@ -127,20 +146,6 @@ EOF
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.popupmenu.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/searchformforeignkeys.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/latinise/latinise.min.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_handler.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_handler_history.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_criteria.js');
$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_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_criteria_external_field.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_criteria_numeric.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_criteria_enum.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_criteria_tag_set.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_criteria_external_key.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_criteria_hierarchical_key.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_criteria_date_abstract.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_criteria_date.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/search/search_form_criteria_date_time.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/clipboard.min.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/clipboardwidget.js');
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/scrollmagic/scrollmagic/minified/ScrollMagic.min.js');

View File

@@ -55,6 +55,23 @@ class SearchForm
public function GetSearchFormUIBlock(WebPage $oPage, DBObjectSet $oSet, $aExtraParams = array())
{
$oUiBlock = new UIContentBlock();
$oUiBlock->AddMultipleJsFilesRelPaths([
'js/search/search_form_handler.js',
'js/search/search_form_handler_history.js',
'js/search/search_form_criteria.js',
'js/search/search_form_criteria_raw.js',
'js/search/search_form_criteria_string.js',
'js/search/search_form_criteria_external_field.js',
'js/search/search_form_criteria_numeric.js',
'js/search/search_form_criteria_enum.js',
'js/search/search_form_criteria_tag_set.js',
'js/search/search_form_criteria_external_key.js',
'js/search/search_form_criteria_hierarchical_key.js',
'js/search/search_form_criteria_date_abstract.js',
'js/search/search_form_criteria_date.js',
'js/search/search_form_criteria_date_time.js',
]);
$oAppContext = new ApplicationContext();
$sClassName = $oSet->GetFilter()->GetClass();
$aListParams = array();