diff --git a/src/boot/qformMixin.js b/src/boot/qformMixin.js index 8c89c9202..a809140b0 100644 --- a/src/boot/qformMixin.js +++ b/src/boot/qformMixin.js @@ -1,21 +1,48 @@ import { getCurrentInstance } from 'vue'; -const filterAvailableInput = element => element.classList.contains('q-field__native') && !element.disabled -const filterAvailableText = element => element.__vueParentComponent.type.name === 'QInput' && element.__vueParentComponent?.attrs?.class !== 'vn-input-date'; - +const filterAvailableInput = (element) => { + return element.classList.contains('q-field__native') && !element.disabled; +}; +const filterAvailableText = (element) => { + return ( + element.__vueParentComponent.type.name === 'QInput' && + element.__vueParentComponent?.attrs?.class !== 'vn-input-date' + ); +}; export default { mounted: function () { const vm = getCurrentInstance(); - if (vm.type.name === 'QForm') - if (!['searchbarForm','filterPanelForm'].includes(this.$el?.id)) { + if (vm.type.name === 'QForm') { + if (!['searchbarForm', 'filterPanelForm'].includes(this.$el?.id)) { // AUTOFOCUS const elementsArray = Array.from(this.$el.elements); - const firstInputElement = elementsArray.filter(filterAvailableInput).find(filterAvailableText); + const availableInputs = elementsArray.filter(filterAvailableInput); + const firstInputElement = availableInputs.find(filterAvailableText); if (firstInputElement) { firstInputElement.focus(); } + const that = this; + this.$el.addEventListener('keyup', function (evt) { + if (evt.key === 'Enter') { + const input = evt.target; + console.log('input', input); + if (input.type == 'textarea' && evt.shiftKey) { + evt.preventDefault(); + let { selectionStart, selectionEnd } = input; + input.value = + input.value.substring(0, selectionStart) + + '\n' + + input.value.substring(selectionEnd); + selectionStart = selectionEnd = selectionStart + 1; + return; + } + evt.preventDefault(); + that.onSubmit(); + } + }); } + } }, }; diff --git a/src/components/EditPictureForm.vue b/src/components/EditPictureForm.vue index a51ca11ad..8a22debda 100644 --- a/src/components/EditPictureForm.vue +++ b/src/components/EditPictureForm.vue @@ -155,7 +155,7 @@ const rotateRight = () => { editor.value.rotate(-90); }; -const onUploadAccept = () => { +const onSubmit = () => { try { if (!newPhoto.files && !newPhoto.url) { notify(t('Select an image'), 'negative'); @@ -206,7 +206,7 @@ const makeRequest = async () => { @on-fetch="(data) => (allowedContentTypes = data.join(', '))" auto-load /> - + diff --git a/src/components/EditTableCellValueForm.vue b/src/components/EditTableCellValueForm.vue index b1df9525b..9d56ba738 100644 --- a/src/components/EditTableCellValueForm.vue +++ b/src/components/EditTableCellValueForm.vue @@ -50,7 +50,7 @@ const onDataSaved = () => { closeForm(); }; -const submitData = async () => { +const onSubmit = async () => { try { isLoading.value = true; const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk })); @@ -74,7 +74,7 @@ const closeForm = () => { - - - - + + + + {{ t('Edit document') }} + - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - + + + + {{ t('Create document') }} - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + +