refs #6863 fix: VnSelect + url, VnLocation
gitea/salix-front/pipeline/pr-test This commit looks good Details

This commit is contained in:
Alex Moreno 2024-02-19 10:50:35 +01:00
parent 87f81eb80a
commit c916bd5945
3 changed files with 15 additions and 19 deletions

View File

@ -50,7 +50,10 @@ const value = computed({
return $props.modelValue; return $props.modelValue;
}, },
set(value) { set(value) {
emit('update:modelValue', value); emit(
'update:modelValue',
postcodesOptions.value.find((p) => p.code === value)
);
}, },
}); });
@ -101,16 +104,11 @@ function handleFetch(data) {
:label="t('Location')" :label="t('Location')"
:placeholder="t('Search by postalcode, town, province or country')" :placeholder="t('Search by postalcode, town, province or country')"
@input-value="locationFilter" @input-value="locationFilter"
:default-filter="true" :default-filter="false"
:input-debounce="300" :input-debounce="300"
:class="{ required: $attrs.required }" :class="{ required: $attrs.required }"
v-bind="$attrs" v-bind="$attrs"
emit-value
map-options
use-input
clearable clearable
hide-selected
fill-input
> >
<template #form> <template #form>
<CreateNewPostcode @on-data-saved="locationFilter()" /> <CreateNewPostcode @on-data-saved="locationFilter()" />

View File

@ -111,15 +111,15 @@ async function fetchFilter(val) {
return dataRef.value.fetch({ fields, where, order: sortBy, limit }); return dataRef.value.fetch({ fields, where, order: sortBy, limit });
} }
function filterHandler(val, update) { async function filterHandler(val, update) {
if (!$props.defaultFilter) return update();
let newOptions;
if ($props.url) {
newOptions = await fetchFilter(val);
} else newOptions = filter(val, myOptionsOriginal.value);
update( update(
async () => { () => {
if (!$props.defaultFilter) return; myOptions.value = newOptions;
// if ($props.url) {
// myOptions.value = await fetchFilter(val);
// return;
// }
myOptions.value = filter(val, myOptionsOriginal.value);
}, },
(ref) => { (ref) => {
if (val !== '' && ref.options.length > 0) { if (val !== '' && ref.options.length > 0) {

View File

@ -1,6 +1,6 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('InvoiceInBasicData', () => { describe('InvoiceInBasicData', () => {
const selects = '.q-form .q-select'; const selects = ':nth-child(1) > :nth-child(1) > .q-field';
const appendBtns = 'label button'; const appendBtns = 'label button';
const dialogAppendBtns = '.q-dialog label button'; const dialogAppendBtns = '.q-dialog label button';
const dialogInputs = '.q-dialog input'; const dialogInputs = '.q-dialog input';
@ -12,9 +12,7 @@ describe('InvoiceInBasicData', () => {
}); });
it('should edit the provideer and supplier ref', () => { it('should edit the provideer and supplier ref', () => {
cy.get(selects).eq(0).click(); cy.selectOption(selects, 'Bros');
cy.get(selects).eq(0).type('Bros');
cy.get(selects).eq(0).type('{enter}');
cy.get('[title="Reset"]').click(); cy.get('[title="Reset"]').click();
cy.get(appendBtns).eq(0).click(); cy.get(appendBtns).eq(0).click();