diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index b6dc226cc6..1e3a32f486 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -77,6 +77,10 @@ const $props = defineProps({ type: Object, default: null, }, + noOne: { + type: Boolean, + default: false, + }, }); const { t } = useI18n(); @@ -89,6 +93,11 @@ const myOptionsOriginal = ref([]); const vnSelectRef = ref(); const dataRef = ref(); const lastVal = ref(); +const noOneText = t('globals.noOne'); +const noOneOpt = ref({ + [optionValue.value]: false, + [optionLabel.value]: noOneText, +}); const value = computed({ get() { @@ -104,9 +113,11 @@ watch(options, (newValue) => { setOptions(newValue); }); -watch(modelValue, (newValue) => { +watch(modelValue, async (newValue) => { if (!myOptions.value.some((option) => option[optionValue.value] == newValue)) - fetchFilter(newValue); + await fetchFilter(newValue); + + if ($props.noOne) myOptions.value.unshift(noOneOpt.value); }); onMounted(() => { @@ -169,6 +180,7 @@ async function fetchFilter(val) { const fetchOptions = { where, include, limit }; if (fields) fetchOptions.fields = fields; if (sortBy) fetchOptions.order = sortBy; + return dataRef.value.fetch(fetchOptions); } @@ -189,6 +201,9 @@ async function filterHandler(val, update) { } else newOptions = filter(val, myOptionsOriginal.value); update( () => { + if ($props.noOne && noOneText.toLowerCase().includes(val.toLowerCase())) + newOptions.unshift(noOneOpt.value); + myOptions.value = newOptions; }, (ref) => { diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index a0dc6cc822..d0a31223d1 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -268,7 +268,7 @@ function sanitizer(params) { diff --git a/src/i18n/locale/en.yml b/src/i18n/locale/en.yml index d4437236e9..05e5fbf68d 100644 --- a/src/i18n/locale/en.yml +++ b/src/i18n/locale/en.yml @@ -272,6 +272,7 @@ globals: subtitle: Are you sure exit without saving? createInvoiceIn: Create invoice in myAccount: My account + noOne: No one errors: statusUnauthorized: Access denied statusInternalServerError: An internal server error has ocurred diff --git a/src/i18n/locale/es.yml b/src/i18n/locale/es.yml index 0ace95ff1a..bd36287a98 100644 --- a/src/i18n/locale/es.yml +++ b/src/i18n/locale/es.yml @@ -274,6 +274,7 @@ globals: subtitle: ¿Seguro que quiere salir sin guardar? createInvoiceIn: Crear factura recibida myAccount: Mi cuenta + noOne: Nadie errors: statusUnauthorized: Acceso denegado statusInternalServerError: Ha ocurrido un error interno del servidor diff --git a/src/pages/Monitor/Ticket/MonitorTicketFilter.vue b/src/pages/Monitor/Ticket/MonitorTicketFilter.vue index 9aea3d4b39..167a104656 100644 --- a/src/pages/Monitor/Ticket/MonitorTicketFilter.vue +++ b/src/pages/Monitor/Ticket/MonitorTicketFilter.vue @@ -112,12 +112,16 @@ const handleScopeDays = (params, days, callback) => { is-outlined option-value="code" option-label="name" + :no-one="true" >