diff --git a/cypress/e2e/direct.spec.js b/cypress/e2e/direct.spec.js index 902eb74511..d4ce2232e0 100644 --- a/cypress/e2e/direct.spec.js +++ b/cypress/e2e/direct.spec.js @@ -183,7 +183,7 @@ describe('Direct editing (legacy)', function() { .should('be.visible') cy.get('.saveas-dialog input[type=text]') .should('be.visible') - .should('have.value', 'document.rtf') + .should('have.value', '/document.rtf') cy.get('.saveas-dialog button.button-vue--vue-primary').click() diff --git a/src/components/Modal/SaveAs.vue b/src/components/Modal/SaveAs.vue index d033f5216b..8b8f6fb6d8 100644 --- a/src/components/Modal/SaveAs.vue +++ b/src/components/Modal/SaveAs.vue @@ -19,6 +19,7 @@ {{ t('richdocuments', 'Cancel') }} {{ t('richdocuments', 'Save') }} @@ -66,13 +67,13 @@ export default { emits: ['close'], data() { return { - selectedPath: '', + selectedPath: null, } }, computed: { newFileName: { get() { - if (this.selectedPath !== '') { + if (this.selectedPath !== null) { return this.selectedPath } const filename = this.path @@ -84,6 +85,20 @@ export default { this.selectedPath = value }, }, + isValidName() { + const value = this.newFileName.trim() + if (value === '') { + return false + } + const base = value.split('/').pop() + const parts = base.split('.') + let valid = true + // filename is non-empty + valid &&= base !== '' + // filename has both a name part and an extension + valid &&= parts.length >= 2 && parts.at(-2).length > 0 && parts.at(-1).length > 0 + return valid + }, }, mounted() { // prepare filename for having a separate picker for the path (.split('/').pop()) diff --git a/src/document.js b/src/document.js index 351886b1d4..2dcf0c32ef 100644 --- a/src/document.js +++ b/src/document.js @@ -470,10 +470,14 @@ const documentsMain = { } if (msgId === 'UI_SaveAs') { + let docPath = documentsMain.fileName + if (documentsMain.fullPath && documentsMain.fullPath !== '/') { + docPath = documentsMain.fullPath + } spawnDialog( SaveAs, { - path: documentsMain.fileName, + path: docPath, format: args.format, }, (value) => value && PostMessages.sendWOPIPostMessage('loolframe', 'Action_SaveAs', { Filename: value, Notify: true }),