You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by nm...@apache.org on 2026/05/04 08:48:40 UTC
(ofbiz-framework) branch trunk updated: Improved: Lookup don't work on area just updated (OFBIZ-13332) (#953)
This is an automated email from the ASF dual-hosted git repository.
nmalin pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new c5e7acc298 Improved: Lookup don't work on area just updated (OFBIZ-13332) (#953)
c5e7acc298 is described below
commit c5e7acc298f0910861e114080821bca9a6297136
Author: MLeila <ml...@apache.org>
AuthorDate: Mon May 4 10:48:35 2026 +0200
Improved: Lookup don't work on area just updated (OFBIZ-13332) (#953)
Fix to avoid bindObserver events duplication when calling updateArea
Thanks to Leila Mekika and Florian Motteau to fix this issue with a better solution
---------
Co-authored-by: Leila <le...@nereide.fr>
---
.../webapp/common-theme/js/util/OfbizUtil.js | 140 +++++++++++----------
1 file changed, 76 insertions(+), 64 deletions(-)
diff --git a/themes/common-theme/webapp/common-theme/js/util/OfbizUtil.js b/themes/common-theme/webapp/common-theme/js/util/OfbizUtil.js
index 7e1349f236..30b424226f 100644
--- a/themes/common-theme/webapp/common-theme/js/util/OfbizUtil.js
+++ b/themes/common-theme/webapp/common-theme/js/util/OfbizUtil.js
@@ -40,6 +40,8 @@ $(document).ready(function () {
});
//initializing UI combobox dropdown by overriding its methods.
ajaxAutoCompleteDropDown();
+ //initializing events listener
+ initializeEvents();
// bindObservers will add observer on passed html section when DOM is ready.
bindObservers("body");
@@ -92,15 +94,11 @@ $(document).ready(function () {
}
});
-/* bindObservers function contains the code of adding observers and it can be called for specific section as well
- when we need to add observer on section which is updated by Ajax.
- Example: bindObservers("sectionSelector");
- sectionSelector can be Id, Class and Element name.
-*/
-function bindObservers(bind_element) {
+/* initializeEvents function contains the code of adding events at the loading of the page */
+function initializeEvents() {
// Adding observer for checkboxes for select all action.
- jQuery(bind_element).on("click", "[type=checkbox]", function () {
+ $("body").on("click", "[type=checkbox]", function () {
var action_checkbox = jQuery(this),
parent_action = action_checkbox.is(".selectAll") ? action_checkbox : getFormFields(getForm(action_checkbox)).filter(".selectAll");
if (parent_action.length !== 0) {
@@ -108,6 +106,70 @@ function bindObservers(bind_element) {
}
});
+ $("body").on("click", "[data-dialog-url]", function () {
+ var element = jQuery(this);
+ var url = element.data("dialog-url");
+ var title = element.data("dialog-title");
+ var width = element.data("dialog-width");
+ var height = element.data("dialog-height");
+ var params = element.data("dialog-params");
+ var dialogContainer = jQuery('<div/>');
+ dialogContainer.dialog({
+ autoOpen: false,
+ title: title,
+ height: height,
+ width: width,
+ modal: true,
+ closeOnEscape: true,
+ close: function () {
+ dialogContainer.dialog('destroy');
+ },
+ open: function () {
+ jQuery.ajax({
+ url: url,
+ type: "POST",
+ data: params,
+ success: function (data) {
+ dialogContainer.html(data);
+ bindObservers(dialogContainer);
+ },
+ error: (xhr) => {
+ // unauthorized user, reload page with the link id so we can reopen the modal
+ if (xhr.status === 401) {
+ const url = new URL(window.location.href);
+ url.searchParams.append(SP_CLICK_ON, element.attr('id'));
+ window.location.replace(url.toString());
+ } else {
+ // display some feedback in the modal body
+ dialogContainer.text(`An unexpected server error occurred (status : ${ xhr.status }).`);
+ }
+ }
+ });
+ }
+ });
+ dialogContainer.dialog("open");
+ dialogContainer.on("closeCurrentModalAfterAjaxSubmitFormUpdateAreasInSuccess", function () {
+ dialogContainer.dialog("destroy");
+ });
+ });
+
+ $("body").on("click", "[data-confirm-message]", function (e) {
+ var element = jQuery(this);
+ var confirmMessage = element.data("confirm-message");
+ if (!confirm(confirmMessage)) {
+ e.preventDefault();
+ }
+ });
+
+}
+
+/* bindObservers function contains the code of adding observers and it can be called for specific section as well
+ when we need to add observer on section which is updated by Ajax.
+ Example: bindObservers("sectionSelector");
+ sectionSelector can be Id, Class and Element name.
+*/
+function bindObservers(bind_element) {
+
// If parent checkbox is already checked on DOM ready then check its child checkboxes also.
if (jQuery(".selectAll").is(":checked")) {
jQuery(".selectAll").removeAttr("checked").trigger("click");
@@ -181,59 +243,7 @@ function bindObservers(bind_element) {
var params = element.data("inplace-editor-params");
ajaxInPlaceEditDisplayField(id, url, (new Function("return " + params + ";")()));
});
- jQuery(bind_element).on("click", "[data-dialog-url]", function () {
- var element = jQuery(this);
- var url = element.data("dialog-url");
- var title = element.data("dialog-title");
- var width = element.data("dialog-width");
- var height = element.data("dialog-height");
- var params = element.data("dialog-params");
- var dialogContainer = jQuery('<div/>');
- dialogContainer.dialog({
- autoOpen: false,
- title: title,
- height: height,
- width: width,
- modal: true,
- closeOnEscape: true,
- close: function () {
- dialogContainer.dialog('destroy');
- },
- open: function () {
- jQuery.ajax({
- url: url,
- type: "POST",
- data: params,
- success: function (data) {
- dialogContainer.html(data);
- bindObservers(dialogContainer);
- },
- error: (xhr) => {
- // unauthorized user, reload page with the link id so we can reopen the modal
- if (xhr.status === 401) {
- const url = new URL(window.location.href);
- url.searchParams.append(SP_CLICK_ON, element.attr('id'));
- window.location.replace(url.toString());
- } else {
- // display some feedback in the modal body
- dialogContainer.text(`An unexpected server error occurred (status : ${ xhr.status }).`);
- }
- }
- });
- }
- });
- dialogContainer.dialog("open");
- dialogContainer.on("closeCurrentModalAfterAjaxSubmitFormUpdateAreasInSuccess", function () {
- dialogContainer.dialog("destroy");
- });
- });
- jQuery(bind_element).on("click", "[data-confirm-message]", function (e) {
- var element = jQuery(this);
- var confirmMessage = element.data("confirm-message");
- if (!confirm(confirmMessage)) {
- e.preventDefault();
- }
- });
+
jQuery(bind_element).find("[data-lookup-presentation]").each(function () {
var element = jQuery(this);
var form = getForm(this);
@@ -666,15 +676,11 @@ function ajaxUpdateArea(areaId, target, targetParams) {
function updateArea(areaId, data) {
// If the area is indicate as embedded why replace the area instead inject into
- var bindObserversArea = "#" + areaId
if (/^embedded/.test(areaId)) {
jQuery("#" + areaId).replaceWith(data);
- const newContentId = $(data).filter('.embeddedScreen').attr('id');
- bindObserversArea = "#" + newContentId;
} else {
jQuery("#" + areaId).html(data);
}
- bindObservers(bindObserversArea);
}
/** Update multiple areas (HTML container elements).
@@ -847,6 +853,12 @@ function ajaxSubmitFormUpdateAreas(formName, areaCsvString, close) {
areaId = $form[0].target
}
updateArea(areaId, data)
+ var bindObserversArea = "#" + areaId
+ if (/^embedded/.test(areaId)) {
+ const newContentId = $(data).filter('.embeddedScreen').attr('id');
+ bindObserversArea = "#" + newContentId;
+ }
+ bindObservers(bindObserversArea);
} else {
if (containsErrorMessages(data)) {
displayErrorMessages(data)