')
+ .addClass('no-data-message')
+ .append(properties.noDataMessage)
+ );
+} else {
+ // Add items to container
+ for (var i = 0; i < items.length; i++) {
+ var item = items[i];
+
+ // Replace the template with the item content
+ var content = properties.template.replace(/\[(.*?)\]/g, function(match, column) {
+ var itemId = column.split('|')[0];
+ var itemCol = column.split('|')[1];
+ var itemType = (itemCol) ? columnInfo[itemCol].type : '';
+ var itemValue = item[itemId];
+
+ // If this is an image column, wrap it in an image tag
+ if (itemType === 4 || itemType === 5) {
+ itemValue = itemValue ? '
' : '';
+ }
+
+ return itemValue ? itemValue : '';
+ });
+
+ // Add the content to the target
+ if(content != "") {
+ hasAddedItems = true;
+ $(target).find('#content').append(
+ $('
')
+ .addClass('item')
+ .append(content)
+ );
+ }
+ }
}
// Copyright
-if (properties.copyright) {
+if (hasAddedItems && properties.copyright) {
var copyrightTemplate = '
' + properties.copyright + '';
- items.push(copyrightTemplate);
-}
-
-// Clear container
-$(target).find('#content').empty();
-
-// Add items to container
-for (var i = 0; i < items.length; i++) {
- var item = items[i];
-
- // Replace the template with the item content
- var content = properties.template.replace(/\[(.*?)\]/g, function (match, column) {
- var itemId = column.split('|')[0];
- var itemCol = column.split('|')[1];
- var itemType = (itemCol) ? columnInfo[itemCol].type : '';
- var itemValue = item[itemId];
-
- // If this is an image column, wrap it in an image tag
- if (itemType === 4 || itemType === 5) {
- itemValue = itemValue ? '
' : '';
- }
-
- return itemValue ? itemValue : '';
- });
-
- // Add the content to the target
$(target).find('#content').append(
$('
')
.addClass('item')
- .append(content)
+ .append(copyrightTemplate)
);
}
diff --git a/ui/src/core/forms.js b/ui/src/core/forms.js
index 44baac2ba5..dc26cd2ab7 100644
--- a/ui/src/core/forms.js
+++ b/ui/src/core/forms.js
@@ -2735,7 +2735,9 @@ window.forms = {
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) => a[b], baseObject);
+ return group.split('.').reduce((a, b) => {
+ return (a[b]) || `%${b}%`;
+ }, baseObject);
});
return htmlString;