diff --git a/js/extkeywidget.js b/js/extkeywidget.js index b0f3187ca..e0a3b13bc 100644 --- a/js/extkeywidget.js +++ b/js/extkeywidget.js @@ -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' ); diff --git a/js/linkswidget.js b/js/linkswidget.js index 41053222c..f65c256e9 100644 --- a/js/linkswidget.js +++ b/js/linkswidget.js @@ -91,6 +91,8 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates, oWizH let me = this; $('#'+me.id+'_indicatorAdd').html(' '); 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(''); + }); }) ; }; diff --git a/sources/application/WebPage/NiceWebPage.php b/sources/application/WebPage/NiceWebPage.php index 606e7a623..888318c48 100644 --- a/sources/application/WebPage/NiceWebPage.php +++ b/sources/application/WebPage/NiceWebPage.php @@ -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'); diff --git a/sources/application/search/searchform.class.inc.php b/sources/application/search/searchform.class.inc.php index d1ba2344c..5068fe17a 100644 --- a/sources/application/search/searchform.class.inc.php +++ b/sources/application/search/searchform.class.inc.php @@ -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();