Merge pull request 'refactor: refs #8683 enhance sorting logic in VnSelect component' (!1522) from 8683-vnSelectSortByOptionLabel into dev
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1522
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Alex Moreno 2025-03-25 13:14:59 +00:00
commit a6bd91c918
3 changed files with 10 additions and 5 deletions

View File

@ -152,6 +152,10 @@ const value = computed({
},
});
const computedSortBy = computed(() => {
return $props.sortBy || $props.optionLabel + ' ASC';
});
watch(options, (newValue) => {
setOptions(newValue);
});
@ -186,7 +190,7 @@ function findKeyInOptions() {
}
function setOptions(data) {
data = dataByOrder(data, $props.sortBy);
data = dataByOrder(data, computedSortBy.value);
myOptions.value = JSON.parse(JSON.stringify(data));
myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
emit('update:options', data);
@ -216,7 +220,8 @@ function filter(val, options) {
async function fetchFilter(val) {
if (!$props.url) return;
const { fields, include, sortBy, limit } = $props;
const { fields, include, limit } = $props;
const sortBy = computedSortBy.value;
const key =
optionFilterValue.value ??
(new RegExp(/\d/g).test(val)

View File

@ -39,11 +39,11 @@ describe('UserPanel', () => {
cy.get(userCompany).should('have.value', 'Warehouse One').click();
//Actualizo la opción
cy.getOption(2);
cy.getOption(3);
//Compruebo la notificación
cy.get('.q-notification').should('be.visible');
cy.get(userCompany).should('have.value', 'Warehouse Two');
cy.get(userCompany).should('have.value', 'TestingWarehouse');
//Restauro el valor
cy.get(userCompany).click();

View File

@ -20,7 +20,7 @@ describe('VnLog', () => {
it('should filter by entity', () => {
cy.selectOption('.q-drawer--right .q-item > .q-select', 'Claim');
cy.get('.q-page').click();
cy.validateContent(chips[0], 'Claim');
cy.validateContent(chips[0], 'Beginning');
});
it('should show claimDescriptor', () => {