diff --git a/ui/src/core/forms.js b/ui/src/core/forms.js index a4743d0fee..cd94ef3c4e 100644 --- a/ui/src/core/forms.js +++ b/ui/src/core/forms.js @@ -3187,13 +3187,17 @@ window.forms = { * @param {*} baseObject - The base object to replace */ handleFormReplacements: function(container, baseObject) { + const regExpMatchBetweenPercent = /%([^%\s]+)%/g; + const replaceHTML = function(htmlString) { - htmlString = htmlString.replace(/\%(.*?)\%/g, function(_m, group) { - // Replace trimmed match with the value of the base object - return group.split('.').reduce((a, b) => { - return (a[b]) || `%${b}%`; - }, baseObject); - }); + htmlString = htmlString.replace( + regExpMatchBetweenPercent, + function(_m, group) { + // Replace trimmed match with the value of the base object + return group.split('.').reduce((a, b) => { + return (a[b]) || `%${b}%`; + }, baseObject); + }); return htmlString; }; @@ -3206,8 +3210,11 @@ window.forms = { const elementAlternativeTitle = $element.attr('data-original-title'); // If theres title and it contains a replacement special character - if (elementTitle && elementTitle.indexOf('%') > -1) { - $element.attr('title', replaceHTML(elementTitle)); + if (elementTitle) { + const matches = elementTitle.match(regExpMatchBetweenPercent); + if (matches) { + $element.attr('title', replaceHTML(elementTitle)); + } } // If theres an aletrnative title and it @@ -3216,9 +3223,13 @@ window.forms = { elementAlternativeTitle && elementAlternativeTitle.indexOf('%') > -1 ) { - $element.attr( - 'data-original-title', - replaceHTML(elementAlternativeTitle)); + const matches = elementAlternativeTitle + .match(regExpMatchBetweenPercent); + if (matches) { + $element.attr( + 'data-original-title', + replaceHTML(elementAlternativeTitle)); + } } }); @@ -3229,8 +3240,11 @@ window.forms = { const elementInnerHTML = $element.html(); // If theres inner html and it contains a replacement special character - if (elementInnerHTML && elementInnerHTML.indexOf('%') > -1) { - $element.html(replaceHTML(elementInnerHTML)); + if (elementInnerHTML) { + const matches = elementInnerHTML.match(regExpMatchBetweenPercent); + if (matches) { + $element.html(replaceHTML(elementInnerHTML)); + } } }); }, diff --git a/ui/src/editor-core/properties-panel.js b/ui/src/editor-core/properties-panel.js index b5fcf72bc7..d6dcfd41b8 100644 --- a/ui/src/editor-core/properties-panel.js +++ b/ui/src/editor-core/properties-panel.js @@ -144,6 +144,12 @@ PropertiesPanel.prototype.save = function( const errorMessage = Object.values(errors).join('
'); // Display message in form formHelpers.displayErrorMessage(form, errorMessage, 'danger'); + + // Call callback without waiting for the request + (callbackNoWait) && callbackNoWait(); + + // Mark form as not needed to be saved anymore + this.toSave = false; return false; } else { formHelpers.clearErrorMessage(form);