Skip to content

Commit

Permalink
chore(edit content): Revert Binary Field changes (#29675)
Browse files Browse the repository at this point in the history
### Proposed Changes
* Leave as it was
  • Loading branch information
zJaaal authored Aug 20, 2024
1 parent f758873 commit 74d235c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@
<% } %>

<script type="text/javascript">
var binaryFieldCallbacksMap = {} // 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
const relationsLoadedMap = {};
function waitForRelation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,11 +731,6 @@
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
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 @@ -62,8 +62,6 @@
Object inodeObj =(Object) request.getAttribute("inode");
String inode = inodeObj != null ? inodeObj.toString() : "";
String contentletIdentifier = contentlet.getIdentifier();
String counter = (String) request.getAttribute("counter");
boolean fullScreenField = Try.of(()->(boolean)request.getAttribute("DOT_FULL_SCREEN_FIELD")).getOrElse(false);
Expand Down Expand Up @@ -115,6 +113,7 @@
}
}
</style>

<div class="fieldWrapper" >
<div class="fieldName" id="<%=field.getVelocityVarName()%>_tag">
<% if (hint != null) {%>
Expand Down Expand Up @@ -213,6 +212,7 @@
String textValue = UtilMethods.isSet(value) ? value.toString(): (UtilMethods.isSet(defaultValue) ? defaultValue : "");
String safeTextValue = "`" + StringEscapeUtils.escapeJavaScript(textValue.replaceAll("`", "&#96;").replaceAll("\\$", "&#36;")) + "`";
String contentletIdentifier = contentlet.getIdentifier();
String jsonField = "{}";
String contentletObj = "{}";
Boolean showVideoThumbnail = Config.getBooleanProperty("SHOW_VIDEO_THUMBNAIL", true);
Expand Down Expand Up @@ -774,18 +774,15 @@
</script>
<script>
// Create a new scope so that variables defined here can have the same name without being overwritten.
function setBinaryFieldInputs() {
(function autoexecute() {
const binaryFieldContainer = document.getElementById("container-binary-field-<%=field.getVelocityVarName()%>");
/**
* Note: This is a temporary solution.
* This is a workaround to get the contentlet from the API
* because there is no way to get the same contentlet the AP retreive from the dwr call.
*/
const identifier = "<%=contentletIdentifier%>";
fetch(`/api/v1/content/${identifier}`, {
fetch('/api/v1/content/<%=inode%>', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
Expand Down Expand Up @@ -872,15 +869,7 @@
.catch(() => {
binaryFieldContainer.innerHTMl = '<div class="callOutBox">Error loading the binary field</div>';
})
};
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
}
})();
</script>
<%}else{%>
Expand Down

0 comments on commit 74d235c

Please sign in to comment.