Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(edit content): Revert Binary Field changes #29675

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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