From 091fe637e3bd020c545e875a58138577552615a5 Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Mon, 12 Aug 2024 14:52:27 -0300 Subject: [PATCH 1/6] call setBinaryFieldInputs on save --- .../ext/contentlet/edit_contentlet_js_inc.jsp | 2 + .../ext/contentlet/field/edit_field.jsp | 37 ++++++++++++------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp index 457c03623601..0e4e7910e9dd 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp @@ -731,6 +731,8 @@ customEvent.initCustomEvent('ng-event', false, false, customEventDetail); document.dispatchEvent(customEvent); + setBinaryFieldInputs() + } function refreshPermissionsTab(){ diff --git a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp index 3fdfaa405bba..d11839f978e4 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp @@ -62,6 +62,8 @@ Object inodeObj =(Object) request.getAttribute("inode"); String inode = inodeObj != null ? inodeObj.toString() : ""; + String contentletIdentifierGlobal = contentlet.getIdentifier(); + String counter = (String) request.getAttribute("counter"); boolean fullScreenField = Try.of(()->(boolean)request.getAttribute("DOT_FULL_SCREEN_FIELD")).getOrElse(false); @@ -216,7 +218,7 @@ String jsonField = "{}"; String contentletObj = "{}"; Boolean showVideoThumbnail = Config.getBooleanProperty("SHOW_VIDEO_THUMBNAIL", true); - + // If it can be parsed as a JSON, then it means that the value is already a Block Editor's value if (value != null) { try { @@ -287,7 +289,7 @@ field.value = !detail ? null : JSON.stringify(detail);; }); - // + // blockEditor.contentlet = contentlet; blockEditor.field = fieldData; @@ -730,16 +732,16 @@ helperText=fv.getValue(); } } - + %> - +

- <%= LanguageUtil.get(pageContext, "Do-you-want-to-replace-the-existing-asset-name") %> - " " - <%= LanguageUtil.get(pageContext, "with") %> + <%= LanguageUtil.get(pageContext, "Do-you-want-to-replace-the-existing-asset-name") %> + " " + <%= LanguageUtil.get(pageContext, "with") %> """
 

@@ -767,14 +769,14 @@ fileNameField?.setValue(newFileName); dijit.byId("confirmReplaceNameDialog-<%=field.getVelocityVarName()%>").hide(); } - + function closeConfirmReplaceName(){ dijit.byId("confirmReplaceNameDialog-<%=field.getVelocityVarName()%>").hide(); } <%}else{%> From cb606faee110129b63790bf3464db0a50b682033 Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Mon, 12 Aug 2024 16:25:15 -0300 Subject: [PATCH 2/6] make contenletIdentifier global and check for definition of function --- .../html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp | 6 +++++- .../html/portlet/ext/contentlet/field/edit_field.jsp | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp index 0e4e7910e9dd..2e1c9112c050 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp @@ -731,7 +731,11 @@ customEvent.initCustomEvent('ng-event', false, false, customEventDetail); document.dispatchEvent(customEvent); - setBinaryFieldInputs() + + + if(window.setBinaryFieldInputs) { + setBinaryFieldInputs() + } } diff --git a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp index d11839f978e4..5a6a68cbb7f5 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp @@ -62,7 +62,7 @@ Object inodeObj =(Object) request.getAttribute("inode"); String inode = inodeObj != null ? inodeObj.toString() : ""; - String contentletIdentifierGlobal = contentlet.getIdentifier(); + String contentletIdentifier = contentlet.getIdentifier(); String counter = (String) request.getAttribute("counter"); @@ -214,7 +214,6 @@ String textValue = UtilMethods.isSet(value) ? value.toString(): (UtilMethods.isSet(defaultValue) ? defaultValue : ""); String safeTextValue = "`" + StringEscapeUtils.escapeJavaScript(textValue.replaceAll("`", "`").replaceAll("\\$", "$")) + "`"; - String contentletIdentifier = contentlet.getIdentifier(); String jsonField = "{}"; String contentletObj = "{}"; Boolean showVideoThumbnail = Config.getBooleanProperty("SHOW_VIDEO_THUMBNAIL", true); @@ -785,7 +784,9 @@ * because there is no way to get the same contentlet the AP retreive from the dwr call. */ - const identifier = "<%=contentletIdentifierGlobal%>"; + const identifier = "<%=contentletIdentifier%>"; + + From e2eeb276dfb3679b18f6d55a4e38ba9a9233fac9 Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Tue, 13 Aug 2024 15:36:29 -0300 Subject: [PATCH 3/6] Cover the case for multiple binary fields in one content type --- .../ext/contentlet/edit_contentlet_js_inc.jsp | 9 ++++----- .../portlet/ext/contentlet/field/edit_field.jsp | 16 +++++++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp index 2e1c9112c050..03070448d4e6 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp @@ -731,12 +731,11 @@ customEvent.initCustomEvent('ng-event', false, false, customEventDetail); document.dispatchEvent(customEvent); + const binaryCallbacks = Object.keys(window.binaryFieldCallbacksMap || {}).map(key => window.binaryFieldCallbacksMap[key]); // Get the callbacks in an array - - if(window.setBinaryFieldInputs) { - setBinaryFieldInputs() - } - + binaryCallbacks.forEach(callback => { + callback(); // To reload all binary fields + }); } function refreshPermissionsTab(){ diff --git a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp index 5a6a68cbb7f5..32caca302f25 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp @@ -116,6 +116,11 @@ } + + +
<% if (hint != null) {%> @@ -786,10 +791,6 @@ const identifier = "<%=contentletIdentifier%>"; - - - - fetch(`/api/v1/content/${identifier}`, { method: 'GET', headers: { @@ -879,7 +880,12 @@ }) }; - setBinaryFieldInputs(); + setBinaryFieldInputs(); // Initialize the binary Field + + // This code covers the multiple binaries in a contentlet + if(!binaryCallbacksMap["<%=field.getVelocityVarName()%>"]) { + binaryCallbacksMap["<%=field.getVelocityVarName()%>"] = setBinaryFieldInputs; // Register the function to be called when the contentlet is saved + } <%}else{%> From 319c7c3bada2e39a68ae659c97ca573cf9b3d3d2 Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Thu, 15 Aug 2024 16:31:00 -0300 Subject: [PATCH 4/6] Update edit_field.jsp --- .../webapp/html/portlet/ext/contentlet/field/edit_field.jsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp index 32caca302f25..ba3b8ea0ddce 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp @@ -117,7 +117,7 @@ From 8b8b98dc072aad1c907235ff6b261f6da98d2273 Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Thu, 15 Aug 2024 16:35:40 -0300 Subject: [PATCH 5/6] Update edit_field.jsp --- .../webapp/html/portlet/ext/contentlet/field/edit_field.jsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp index ba3b8ea0ddce..804bff490c3b 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp @@ -883,8 +883,8 @@ var binaryFieldCallbacksMap = {} // This is a map to store the callbacks for the setBinaryFieldInputs(); // Initialize the binary Field // This code covers the multiple binaries in a contentlet - if(!binaryCallbacksMap["<%=field.getVelocityVarName()%>"]) { - binaryCallbacksMap["<%=field.getVelocityVarName()%>"] = setBinaryFieldInputs; // Register the function to be called when the contentlet is saved + if(!binaryFieldCallbacksMap["<%=field.getVelocityVarName()%>"]) { + binaryFieldCallbacksMap["<%=field.getVelocityVarName()%>"] = setBinaryFieldInputs; // Register the function to be called when the contentlet is saved } <%}else{%> From 9e7a05506751dd930f88adcd72cf0a04bafe0279 Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Thu, 15 Aug 2024 16:42:45 -0300 Subject: [PATCH 6/6] declare global variable correctly --- .../webapp/html/portlet/ext/contentlet/edit_contentlet.jsp | 5 +++-- .../html/portlet/ext/contentlet/field/edit_field.jsp | 7 +------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet.jsp b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet.jsp index dc3abd71b61f..8fc2678cd17f 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet.jsp @@ -109,6 +109,7 @@ <% diff --git a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp index 804bff490c3b..9b89e4af6144 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp @@ -115,12 +115,6 @@ } } - - - -
<% if (hint != null) {%> @@ -882,6 +876,7 @@ var binaryFieldCallbacksMap = {} // This is a map to store the callbacks for the setBinaryFieldInputs(); // Initialize the binary Field + // This code covers the multiple binaries in a contentlet if(!binaryFieldCallbacksMap["<%=field.getVelocityVarName()%>"]) { binaryFieldCallbacksMap["<%=field.getVelocityVarName()%>"] = setBinaryFieldInputs; // Register the function to be called when the contentlet is saved