#6911 save on enter #207
|
@ -1,31 +1,50 @@
|
|||
import { getCurrentInstance } from 'vue';
|
||||
|
||||
const filterAvailableInput = (element) =>
|
||||
element.classList.contains('q-field__native') && !element.disabled;
|
||||
const filterAvailableText = (element) =>
|
||||
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';
|
||||
element.__vueParentComponent?.attrs?.class !== 'vn-input-date'
|
||||
);
|
||||
};
|
||||
|
||||
export default {
|
||||
mounted: function () {
|
||||
const vm = getCurrentInstance();
|
||||
if (vm.type.name === 'QForm')
|
||||
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;
|
||||
document.addEventListener('keyup', function (evt) {
|
||||
for (const availableInput of availableInputs) {
|
||||
availableInput.addEventListener('keydown', (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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -48,12 +48,12 @@ async function insert() {
|
|||
size="lg"
|
||||
autogrow
|
||||
autofocus
|
||||
@keyup.ctrl.enter.stop="insert"
|
||||
@keyup.enter.stop="insert"
|
||||
|
||||
clearable
|
||||
>
|
||||
<template #append
|
||||
><QBtn
|
||||
:title="t('Save (ctrl + Enter)')"
|
||||
<template #append>
|
||||
<QBtn
|
||||
:title="t('Save (Enter)')"
|
||||
alexm
commented
Cambiar traduccion Cambiar traduccion
jsegarra
commented
https://gitea.verdnatura.es/verdnatura/salix-front/commit/492e333d2fdb4aaa1d903f5b1f21d78e6641889f
|
||||
icon="save"
|
||||
color="primary"
|
||||
flat
|
||||
|
|
|
@ -155,7 +155,13 @@ const statesFilter = {
|
|||
v-model.number="data.packages"
|
||||
:label="t('globals.packages')"
|
||||
:rules="validate('claim.packages')"
|
||||
type="number"
|
||||
type="textarea"
|
||||
/>
|
||||
<QInput
|
||||
v-model.number="data.packages"
|
||||
:label="t('globals.packages')"
|
||||
:rules="validate('claim.packages')"
|
||||
type="text"
|
||||
/>
|
||||
</div>
|
||||
<div class="col">
|
||||
|
|
Loading…
Reference in New Issue
Con este cambio creo que haria falta añadir un
@keyup.shift.enter.(stop o prevent) y prevenir el insert sino se quedan sin poder saltar de linea
5139bba5a0