Skip to content

Commit

Permalink
Cover the case for multiple binary fields in one content type
Browse files Browse the repository at this point in the history
  • Loading branch information
zJaaal committed Aug 13, 2024
1 parent 983abb4 commit e2eeb27
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@
}
</style>

<script>
var binaryCallbacksMap = {} // This is a map to store the callbacks for the binary fields, used to reload them when we publish or save a contentlet, look on dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet_js_inc.jsp on saveContentCallback function
</script>


<div class="fieldWrapper" >
<div class="fieldName" id="<%=field.getVelocityVarName()%>_tag">
<% if (hint != null) {%>
Expand Down Expand Up @@ -786,10 +791,6 @@
const identifier = "<%=contentletIdentifier%>";
fetch(`/api/v1/content/${identifier}`, {
method: 'GET',
headers: {
Expand Down Expand Up @@ -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
}
</script>
<%}else{%>
Expand Down

0 comments on commit e2eeb27

Please sign in to comment.