refs #6280 perf: improve component
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Javier Segarra 2024-01-24 08:30:09 +01:00
parent 5ebeb7fe47
commit 45dc9c355f
4 changed files with 49 additions and 12 deletions

View File

@ -54,11 +54,16 @@ const value = computed({
}, },
}); });
onMounted(() => {
locationFilter()
});
function setOptions(data) { function setOptions(data) {
myOptions.value = JSON.parse(JSON.stringify(data)); myOptions.value = JSON.parse(JSON.stringify(data));
myOptionsOriginal.value = JSON.parse(JSON.stringify(data)); myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
} }
setOptions(options.value); setOptions(options.value);
watch(options, (newValue) => { watch(options, (newValue) => {
setOptions(newValue); setOptions(newValue);
}); });
@ -67,17 +72,15 @@ function showLabel(data) {
return `${data.code} - ${data.town}(${data.province}), ${data.country}`; return `${data.code} - ${data.town}(${data.province}), ${data.country}`;
} }
onMounted(() => {
locationFilter()
})
function locationFilter(search) { function locationFilter(search) {
let args = { filter:{limit: 30}, search}; let where = { search };
postcodesRef.value.fetch({args}); postcodesRef.value.fetch({filter:{ where}, limit: 30});
} }
function handleFetch( data) { function handleFetch( data) {
postcodesOptions.value = data; postcodesOptions.value = data;
} }
async function onPostcodeCreated(){ async function onPostcodeCreated(){
locationFilter() locationFilter()
}; };

View File

@ -33,9 +33,10 @@ const businessTypesOptions = ref([]);
const postcodesOptions = ref([]); const postcodesOptions = ref([]);
function handleLocation(data, { city, postcode, provinceFk, countryFk }) { function handleLocation(data, location ) {
data.postcode = postcode; const { town, code, provinceFk, countryFk } = location ?? {}
data.city = city; data.postcode = code;
data.city = town;
data.provinceFk = provinceFk; data.provinceFk = provinceFk;
data.countryFk = countryFk; data.countryFk = countryFk;
} }

View File

@ -57,9 +57,10 @@ const onBankEntityCreated = (data) => {
}; };
function handleLocation(data, { city, postcode, provinceFk, countryFk }) { function handleLocation(data, location ) {
data.postcode = postcode; const { town, postcode: code, provinceFk, countryFk } = location ?? {}
data.city = city; data.postcode = code;
data.city = town;
data.provinceFk = provinceFk; data.provinceFk = provinceFk;
data.countryFk = countryFk; data.countryFk = countryFk;
} }

View File

@ -0,0 +1,32 @@
const inputLocation = ':nth-child(3) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control';
const locationOptions ='[role="listbox"] > div.q-virtual-scroll__content > .q-item'
describe('VnLocation', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('/#/worker/create');
cy.waitForElement('.q-card');
});
// it('Show all options', function() {
// cy.get(inputLocation).click();
// cy.get(locationOptions).should('have.length',5)
// // cy.get(':nth-child(3) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control > :nth-child(2) > .q-icon').click()
// });
// it('input filter location as "al"', function() {
// cy.get(inputLocation).click();
// cy.get(inputLocation).clear();
// cy.get(inputLocation).type('al');
// cy.get(locationOptions).should('have.length',3);
// });
it('input filter location as "ecuador"', function() {
cy.get(inputLocation).click();
cy.get(inputLocation).clear();
cy.get(inputLocation).type('ecuador');
cy.get(locationOptions).should('have.length',1);
cy.get(`${locationOptions}:nth-child(1)`).click();
cy.get(':nth-child(3) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control > :nth-child(2) > .q-icon').click();
});
})