Deletion confirmation dialog moved out of pankow

This commit is contained in:
Johannes Zellner
2023-10-23 16:16:00 +02:00
parent 2270f5789a
commit fc3bd3a0fe
3 changed files with 34 additions and 16 deletions
+29 -11
View File
@@ -355,21 +355,39 @@ export default {
async deleteHandler(files) {
if (!files) return;
window.addEventListener('beforeunload', beforeUnloadListener, { capture: true });
this.deleteInProgress = true;
for (let i in files) {
try {
await this.directoryModel.remove(this.directoryModel.buildFilePath(this.cwd, files[i].name));
} catch (e) {
console.error(`Failed to remove file ${files[i].name}:`, e);
function start_and_end(str) {
if (str.length > 100) {
return str.substr(0, 45) + ' ... ' + str.substr(str.length-45, str.length);
}
return str;
}
await this.loadCwd();
this.$confirm.require({
header: this.$t('filemanager.removeDialog.reallyDelete'),
message: start_and_end(files.map((f) => f.name).join(', ')),
icon: '',
acceptClass: 'p-button-danger',
accept: async () => {
window.addEventListener('beforeunload', beforeUnloadListener, { capture: true });
this.deleteInProgress = true;
for (let i in files) {
try {
await this.directoryModel.remove(this.directoryModel.buildFilePath(this.cwd, files[i].name));
} catch (e) {
console.error(`Failed to remove file ${files[i].name}:`, e);
}
}
await this.loadCwd();
this.$confirm.close();
window.removeEventListener('beforeunload', beforeUnloadListener, { capture: true });
this.deleteInProgress = false;
}
});
window.removeEventListener('beforeunload', beforeUnloadListener, { capture: true });
this.deleteInProgress = false;
},
async renameHandler(file, newName) {
await this.directoryModel.rename(this.directoryModel.buildFilePath(this.cwd, file.name), sanitize(this.cwd + '/' + newName));