refs: #6911-saveOnEnter
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
bdfafe9319
commit
4de9895b38
|
@ -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) =>
|
};
|
||||||
element.__vueParentComponent.type.name === 'QInput' &&
|
const filterAvailableText = (element) => {
|
||||||
element.__vueParentComponent?.attrs?.class !== 'vn-input-date';
|
return (
|
||||||
|
element.__vueParentComponent.type.name === 'QInput' &&
|
||||||
|
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) {
|
||||||
if (evt.key === 'Enter') {
|
availableInput.addEventListener('keydown', (evt) => {
|
||||||
that.onSubmit();
|
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"
|
size="lg"
|
||||||
autogrow
|
autogrow
|
||||||
autofocus
|
autofocus
|
||||||
@keyup.ctrl.enter.stop="insert"
|
@keyup.enter.stop="insert"
|
||||||
clearable
|
clearable
|
||||||
>
|
>
|
||||||
<template #append
|
<template #append>
|
||||||
><QBtn
|
<QBtn
|
||||||
:title="t('Save (ctrl + Enter)')"
|
:title="t('Save (Enter)')"
|
||||||
icon="save"
|
icon="save"
|
||||||
color="primary"
|
color="primary"
|
||||||
flat
|
flat
|
||||||
|
|
|
@ -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">
|
||||||
|
|
Loading…
Reference in New Issue