#6911 save on enter #207

Merged
jsegarra merged 50 commits from 6911-saveOnEnter into dev 2024-06-07 07:20:48 +00:00
3 changed files with 44 additions and 19 deletions
Showing only changes of commit 4de9895b38 - Show all commits

View File

@ -1,31 +1,50 @@
import { getCurrentInstance } from 'vue'; import { getCurrentInstance } from 'vue';
const filterAvailableInput = (element) => const filterAvailableInput = (element) => {
element.classList.contains('q-field__native') && !element.disabled; return element.classList.contains('q-field__native') && !element.disabled;
const filterAvailableText = (element) => };
const filterAvailableText = (element) => {
return (
element.__vueParentComponent.type.name === 'QInput' && element.__vueParentComponent.type.name === 'QInput' &&
element.__vueParentComponent?.attrs?.class !== 'vn-input-date'; element.__vueParentComponent?.attrs?.class !== 'vn-input-date'
);
};
export default { export default {
mounted: function () { mounted: function () {
const vm = getCurrentInstance(); const vm = getCurrentInstance();
if (vm.type.name === 'QForm') if (vm.type.name === 'QForm') {
if (!['searchbarForm', 'filterPanelForm'].includes(this.$el?.id)) { if (!['searchbarForm', 'filterPanelForm'].includes(this.$el?.id)) {
// AUTOFOCUS // AUTOFOCUS
const elementsArray = Array.from(this.$el.elements); const elementsArray = Array.from(this.$el.elements);
const firstInputElement = elementsArray const availableInputs = elementsArray.filter(filterAvailableInput);
.filter(filterAvailableInput) const firstInputElement = availableInputs.find(filterAvailableText);
.find(filterAvailableText);
if (firstInputElement) { if (firstInputElement) {
firstInputElement.focus(); firstInputElement.focus();
} }
const that = this; const that = this;
document.addEventListener('keyup', function (evt) { for (const availableInput of availableInputs) {
availableInput.addEventListener('keydown', (evt) => {
if (evt.key === 'Enter') { 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(); that.onSubmit();
} }
}); });
} }
}
}
}, },
}; };

View File

@ -48,12 +48,12 @@ async function insert() {
size="lg" size="lg"
autogrow autogrow
autofocus autofocus
@keyup.ctrl.enter.stop="insert" @keyup.enter.stop="insert"
Outdated
Review

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

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
https://gitea.verdnatura.es/verdnatura/salix-front/commit/5139bba5a0fd9b47d035bb25fd1334298c700731
clearable clearable
> >
<template #append <template #append>
><QBtn <QBtn
:title="t('Save (ctrl + Enter)')" :title="t('Save (Enter)')"
Outdated
Review

Cambiar traduccion

Cambiar traduccion
https://gitea.verdnatura.es/verdnatura/salix-front/commit/492e333d2fdb4aaa1d903f5b1f21d78e6641889f
icon="save" icon="save"
color="primary" color="primary"
flat flat

View File

@ -155,7 +155,13 @@ const statesFilter = {
v-model.number="data.packages" v-model.number="data.packages"
:label="t('globals.packages')" :label="t('globals.packages')"
:rules="validate('claim.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>
<div class="col"> <div class="col">