From 01f3cea5ffd26b8e6b815ea8059424687f6a046e Mon Sep 17 00:00:00 2001 From: Marco Ambrosini Date: Thu, 23 Jun 2022 14:29:37 +0200 Subject: Add file creation dialog Signed-off-by: Marco Ambrosini --- src/components/NewMessageForm/NewMessageForm.vue | 78 +++++++++++++++++++++++- 1 file changed, 75 insertions(+), 3 deletions(-) (limited to 'src/components') diff --git a/src/components/NewMessageForm/NewMessageForm.vue b/src/components/NewMessageForm/NewMessageForm.vue index 5223159cd..3efca3294 100644 --- a/src/components/NewMessageForm/NewMessageForm.vue +++ b/src/components/NewMessageForm/NewMessageForm.vue @@ -59,7 +59,7 @@ + @click.prevent="showTextFileDialog = true"> {{ t('spreed', 'Create text file') }} @@ -147,9 +147,35 @@ + + + + +
+

+ {{ t('spreed', 'Create and share a text file') }} +

+
+ + +
+ + {{ t('spreed', 'close') }} + + + {{ t('spreed', 'Create text file') }} + +
+
+
@@ -173,6 +199,8 @@ import AudioRecorder from './AudioRecorder/AudioRecorder.vue' import SimplePollsEditor from './SimplePollsEditor/SimplePollsEditor.vue' import Poll from 'vue-material-design-icons/Poll.vue' import TextBox from 'vue-material-design-icons/TextBox.vue' +import NcModal from '@nextcloud/vue/dist/Components/NcModal.js' +import InputVue from '../InputVue.vue' const picker = getFilePickerBuilder(t('spreed', 'File to share')) .setMultiSelect(false) @@ -182,7 +210,9 @@ const picker = getFilePickerBuilder(t('spreed', 'File to share')) .build() export default { + name: 'NewMessageForm', + components: { AdvancedInput, Quote, @@ -198,6 +228,8 @@ export default { SimplePollsEditor, Poll, TextBox, + NcModal, + InputVue, }, props: { @@ -215,6 +247,8 @@ export default { // True when the audiorecorder component is recording isRecordingAudio: false, showSimplePollsEditor: false, + showTextFileDialog: false, + textFileTitle: t('spreed', 'New text file'), } }, @@ -332,6 +366,14 @@ export default { this.text = '' } }, + + showTextFileDialog(newValue) { + if (newValue) { + this.$nextTick(() => { + this.focusTextDialogInput() + }) + } + }, }, mounted() { @@ -586,9 +628,22 @@ export default { // Create text file and share it to a conversation async handleCreateTextFile() { - const filePath = 'somesdsaddfsalkjnaasdasdme.md' + const filePath = this.textFileTitle + '.md' await createTextFile(filePath) - shareFile(filePath, this.token) + await shareFile(filePath, this.token) + this.dismissTextFileCreation() + }, + + dismissTextFileCreation() { + this.showTextFileDialog = false + this.textFileTitle = t('spreed', 'New text file') + }, + + // Focus and select the text within the input field + focusTextDialogInput() { + // this.$refs.textFileTitleInput.$el.focus() + this.$refs.textFileTitleInput.$el.select() + }, }, } @@ -663,4 +718,21 @@ export default { opacity: .5 !important; } } + +.new-text-file { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + gap: 28px; + padding: 20px; + &__buttons { + display: flex; + gap: 4px; + } + + &__form { + width: 100%; + } +} -- cgit v1.2.3