Commit 9787b165 authored by Oliver Bartsch's avatar Oliver Bartsch Committed by Benni Mack

[BUGFIX] Fix RenameFile and FileDelete in EXT:filelist

The RenameFile JavaScript handles renaming of files
and folders. If renaming a folder, some input fields are
not available in the form and must therefore be checked
for existence, before accessing their value.

Furthermore does the file delete modal now display the
modal content again. The corresponding data attribute
was renamed in the bootstrap v5 migration.

Resolves: #93277
Releases: master
Change-Id: I4ba6bc625a152d7e97ba6c44612a17b782799d31
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67438Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 60dab029
......@@ -35,7 +35,7 @@ class FileDelete {
const deleteUrl = eventTarget.dataset.deleteUrl + '&data[delete][0][data]=' + encodeURIComponent(identifier);
const target = deleteUrl + '&data[delete][0][redirect]=' + redirectUrl;
if (eventTarget.dataset.check) {
const $modal = Modal.confirm(eventTarget.dataset.title, eventTarget.dataset.content, SeverityEnum.warning, [
const $modal = Modal.confirm(eventTarget.dataset.title, eventTarget.dataset.bsContent, SeverityEnum.warning, [
{
text: TYPO3.lang['buttons.confirm.delete_file.no'] || 'Cancel',
active: true,
......
......@@ -45,10 +45,15 @@ class RenameFile {
const destinationField = form.querySelector('input[name="data[rename][0][destination]"]') as HTMLInputElement;
const conflictModeField = form.querySelector('input[name="data[rename][0][conflictMode]"]') as HTMLInputElement;
new AjaxRequest(TYPO3.settings.ajaxUrls.file_exists).withQueryArguments({
fileName: fileNameField.value,
fileTarget: destinationField.value,
}).get({cache: 'no-cache'}).then(async (response: AjaxResponse): Promise<void> => {
const data: any = {
fileName: fileNameField.value
};
// destination is not set if we deal with a folder
if (destinationField !== null) {
data.fileTarget = destinationField.value;
}
new AjaxRequest(TYPO3.settings.ajaxUrls.file_exists).withQueryArguments(data).get({cache: 'no-cache'}).then(async (response: AjaxResponse): Promise<void> => {
const result = await response.resolve();
const fileExists: boolean = typeof result.uid !== 'undefined';
......@@ -84,7 +89,10 @@ class RenameFile {
modal.on('button.clicked', (event: any): void => {
if (event.target.name !== 'cancel') {
conflictModeField.value = event.target.name;
// conflictMode is not set if we deal with a folder
if (conflictModeField !== null) {
conflictModeField.value = event.target.name;
}
form.submit();
}
Modal.dismiss();
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","TYPO3/CMS/Backend/Enum/Severity","TYPO3/CMS/Core/Event/RegularEvent","TYPO3/CMS/Core/DocumentService","TYPO3/CMS/Backend/Modal"],(function(e,t,n,a,o,i){"use strict";a=__importDefault(a);return new class{constructor(){o.ready().then(()=>{new a.default("click",(e,t)=>{e.preventDefault();let a=t.dataset.redirectUrl;a=a?encodeURIComponent(a):encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search);const o=t.dataset.identifier,l=t.dataset.deleteType,r=t.dataset.deleteUrl+"&data[delete][0][data]="+encodeURIComponent(o)+"&data[delete][0][redirect]="+a;if(t.dataset.check){i.confirm(t.dataset.title,t.dataset.content,n.SeverityEnum.warning,[{text:TYPO3.lang["buttons.confirm.delete_file.no"]||"Cancel",active:!0,btnClass:"btn-default",name:"no"},{text:TYPO3.lang["buttons.confirm."+l+".yes"]||"Yes, delete this file or folder",btnClass:"btn-warning",name:"yes"}]).on("button.clicked",e=>{const t=e.target.name;"no"===t?i.dismiss():"yes"===t&&(i.dismiss(),top.list_frame.location.href=r)})}else top.list_frame.location.href=r}).delegateTo(document,".t3js-filelist-delete")})}}}));
\ No newline at end of file
var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","TYPO3/CMS/Backend/Enum/Severity","TYPO3/CMS/Core/Event/RegularEvent","TYPO3/CMS/Core/DocumentService","TYPO3/CMS/Backend/Modal"],(function(e,t,n,a,o,i){"use strict";a=__importDefault(a);return new class{constructor(){o.ready().then(()=>{new a.default("click",(e,t)=>{e.preventDefault();let a=t.dataset.redirectUrl;a=a?encodeURIComponent(a):encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search);const o=t.dataset.identifier,l=t.dataset.deleteType,r=t.dataset.deleteUrl+"&data[delete][0][data]="+encodeURIComponent(o)+"&data[delete][0][redirect]="+a;if(t.dataset.check){i.confirm(t.dataset.title,t.dataset.bsContent,n.SeverityEnum.warning,[{text:TYPO3.lang["buttons.confirm.delete_file.no"]||"Cancel",active:!0,btnClass:"btn-default",name:"no"},{text:TYPO3.lang["buttons.confirm."+l+".yes"]||"Yes, delete this file or folder",btnClass:"btn-warning",name:"yes"}]).on("button.clicked",e=>{const t=e.target.name;"no"===t?i.dismiss():"yes"===t&&(i.dismiss(),top.list_frame.location.href=r)})}else top.list_frame.location.href=r}).delegateTo(document,".t3js-filelist-delete")})}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","TYPO3/CMS/Backend/Enum/Severity","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Core/DocumentService"],(function(e,t,a,n,i,r){"use strict";return new class{constructor(){r.ready().then(()=>{this.initialize()})}initialize(){const e=document.querySelector(".t3js-submit-file-rename");null!==e&&e.addEventListener("click",this.checkForDuplicate)}checkForDuplicate(e){e.preventDefault();const t=e.currentTarget.form,r=t.querySelector('input[name="data[rename][0][target]"]'),c=t.querySelector('input[name="data[rename][0][destination]"]'),l=t.querySelector('input[name="data[rename][0][conflictMode]"]');new n(TYPO3.settings.ajaxUrls.file_exists).withQueryArguments({fileName:r.value,fileTarget:c.value}).get({cache:"no-cache"}).then(async e=>{const n=void 0!==(await e.resolve()).uid,c=r.dataset.original,s=r.value;if(n&&c!==s){const e=TYPO3.lang["file_rename.exists.description"].replace("{0}",c).replace(/\{1\}/g,s);i.confirm(TYPO3.lang["file_rename.exists.title"],e,a.SeverityEnum.warning,[{active:!0,btnClass:"btn-default",name:"cancel",text:TYPO3.lang["file_rename.actions.cancel"]},{btnClass:"btn-primary",name:"rename",text:TYPO3.lang["file_rename.actions.rename"]},{btnClass:"btn-default",name:"replace",text:TYPO3.lang["file_rename.actions.override"]}]).on("button.clicked",e=>{"cancel"!==e.target.name&&(l.value=e.target.name,t.submit()),i.dismiss()})}else t.submit()})}}}));
\ No newline at end of file
define(["require","exports","TYPO3/CMS/Backend/Enum/Severity","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Core/DocumentService"],(function(e,t,a,n,i,r){"use strict";return new class{constructor(){r.ready().then(()=>{this.initialize()})}initialize(){const e=document.querySelector(".t3js-submit-file-rename");null!==e&&e.addEventListener("click",this.checkForDuplicate)}checkForDuplicate(e){e.preventDefault();const t=e.currentTarget.form,r=t.querySelector('input[name="data[rename][0][target]"]'),l=t.querySelector('input[name="data[rename][0][destination]"]'),c=t.querySelector('input[name="data[rename][0][conflictMode]"]'),s={fileName:r.value};null!==l&&(s.fileTarget=l.value),new n(TYPO3.settings.ajaxUrls.file_exists).withQueryArguments(s).get({cache:"no-cache"}).then(async e=>{const n=void 0!==(await e.resolve()).uid,l=r.dataset.original,s=r.value;if(n&&l!==s){const e=TYPO3.lang["file_rename.exists.description"].replace("{0}",l).replace(/\{1\}/g,s);i.confirm(TYPO3.lang["file_rename.exists.title"],e,a.SeverityEnum.warning,[{active:!0,btnClass:"btn-default",name:"cancel",text:TYPO3.lang["file_rename.actions.cancel"]},{btnClass:"btn-primary",name:"rename",text:TYPO3.lang["file_rename.actions.rename"]},{btnClass:"btn-default",name:"replace",text:TYPO3.lang["file_rename.actions.override"]}]).on("button.clicked",e=>{"cancel"!==e.target.name&&(null!==c&&(c.value=e.target.name),t.submit()),i.dismiss()})}else t.submit()})}}}));
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment