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): Add confirmation to re-add the file #27389 #27466

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
2 changes: 2 additions & 0 deletions dotCMS/src/main/webapp/WEB-INF/messages/Language.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,7 @@ Do-you-want-to-delete-assets=Are you sure you want to delete pushed assets histo
Do-you-want-to-delete-this-contentlet-s=Do you want to delete this content?
Do-you-want-to-drop-all-old-assets=Do you want to drop all old assets? (This operation cannot be undone)
Do-you-want-to-fix-assets-inconsistencies=Do you want to fix assets inconsistencies? (This operation cannot be undone)
Do-you-want-to-replace-the-existing-asset-name=Do you want to replace the existing asset-name
doesn-t-match-any-structure-field-this-column-of-data-will-be-ignored=doesn't match any Content Type field; this column of data will be ignored.
dont-have-permissions-msg=You don't have the required permissions to perform this action
dotcms.api.error.bad_request=Bad Request
Expand Down Expand Up @@ -4855,6 +4856,7 @@ Who-can-use-action=Who can Use
Whole-Number=Whole Number
Widget=Widget
width=Width
with=with
Width=Width
Will-be-Published=Will be published
Work-Address=Work Address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,22 @@
}

%>


<div id="confirmReplaceNameDialog" dojoType="dijit.Dialog" >
<div dojoType="dijit.layout.ContentPane" style="width:400px;height:120px;text-align:center" class="box" hasShadow="true" id="confirmReplaceNameDialogCP">
<%= LanguageUtil.get(pageContext, "Do-you-want-to-replace-the-existing-asset-name") %>
"<span id="confirmReplaceNameDialog-oldValue"> </span>"
<%= LanguageUtil.get(pageContext, "with") %>
"<span id="confirmReplaceNameDialog-newValue"></span>""
<br>&nbsp;<br>
<div class="buttonRow">
<button dojoType="dijit.form.Button" onClick="confirmReplaceName()" iconClass="cancelIcon"><%= LanguageUtil.get(pageContext, "yes") %></button>

<button dojoType="dijit.form.Button" onClick="closeConfirmReplaceName()" iconClass="cancelIcon"><%= LanguageUtil.get(pageContext, "no") %></button>
</div>
</div>
</div>

<div id="container-binary-field-<%=field.getVelocityVarName()%>">
<div class="spinner-container">
Expand All @@ -740,6 +756,20 @@
</div>
<input name="<%=field.getFieldContentlet()%>" id="binary-field-input-<%=field.getFieldContentlet()%>ValueField" type="hidden" />

<script>
function confirmReplaceName(){
let titleField = dijit.byId("title");
let fileNameField = dijit.byId("fileName");

titleField?.setValue(newFileName);
fileNameField?.setValue(newFileName);
dijit.byId("confirmReplaceNameDialog").hide();
}

function closeConfirmReplaceName(){
dijit.byId("confirmReplaceNameDialog").hide();
}
</script>
<script>
// Create a new scope so that variables defined here can have the same name without being overwritten.
(function autoexecute() {
Expand Down Expand Up @@ -788,9 +818,17 @@
if(contentBaseType === 4){ // FileAsset
let titleField = dijit.byId("title");
let fileNameField = dijit.byId("fileName");
if(!titleField.value ){
window.newFileName = fileName; //To use in confirmReplaceName function

if(!fileNameField.value){
titleField?.setValue(fileName);
}

if(fileNameField.value && fileName && fileNameField.value !== fileName) {
document.getElementById("confirmReplaceNameDialog-oldValue").innerHTML = fileNameField.value;
document.getElementById("confirmReplaceNameDialog-newValue").innerHTML = fileName;
dijit.byId("confirmReplaceNameDialog").show();
}

if(!fileNameField.value){
fileNameField?.setValue(fileName);
Expand Down Expand Up @@ -820,7 +858,6 @@
binaryFieldContainer.innerHTMl = '<div class="callOutBox">Error loading the binary field</div>';
})
})();

</script>
<%}else{%>

Expand Down
Loading