0
0
Fork 0

refs #7355 fix search exprBuilder

This commit is contained in:
Carlos Satorres 2024-07-23 13:03:12 +02:00
parent b4f801e328
commit 369e730670
3 changed files with 25 additions and 38 deletions

View File

@ -1,7 +1,6 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { ref, computed } from 'vue';
import AclFilter from './Acls/AclFilter.vue';
import { useStateStore } from 'stores/useStateStore';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
@ -98,8 +97,8 @@ const deleteAcl = async ({ id }) => {
.dialog({
component: VnConfirm,
componentProps: {
title: t('CAMBIA-HO'),
message: t('CAMBIA-HO'),
title: t('Remove ACL'),
message: t('Do you want to remove this ACL?'),
},
})
.onOk(() => {
@ -161,4 +160,6 @@ es:
ACL removed: ACL eliminado
ACL will be removed: El ACL será eliminado
Are you sure you want to continue?: ¿Seguro que quieres continuar?
Remove ACL: Eliminar Acl
Do you want to remove this ACL?: ¿Quieres eliminar este ACL?
</i18n>

View File

@ -57,12 +57,31 @@ const columns = computed(() => [
],
},
]);
const exprBuilder = (param, value) => {
switch (param) {
case 'search':
return /^\d+$/.test(value)
? { id: value }
: {
or: [
{ name: { like: `%${value}%` } },
{ nickname: { like: `%${value}%` } },
],
};
case 'name':
case 'nickname':
return { [param]: { like: `%${value}%` } };
case 'roleFk':
return { [param]: value };
}
};
</script>
<template>
<VnSearchbar
:label="t('account.search')"
data-key="AccountUsers"
:expr-builder="exprBuilder"
:info="t('account.searchInfo')"
/>

View File

@ -1,15 +1,12 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import { computed, ref } from 'vue';
import VnTable from 'components/VnTable/VnTable.vue';
import { useRoute } from 'vue-router';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
import AccountRolesFilter from './AccountRolesFilter.vue';
import { useStateStore } from 'stores/useStateStore';
const route = useRoute();
const stateStore = useStateStore();
const router = useRouter();
const { t } = useI18n();
const $props = defineProps({
id: {
@ -19,7 +16,6 @@ const $props = defineProps({
});
const tableRef = ref();
const entityId = computed(() => $props.id || route.params.id);
const roleCreateDialogRef = ref(null);
const columns = computed(() => [
{
@ -63,49 +59,20 @@ const exprBuilder = (param, value) => {
return { [param]: { like: `%${value}%` } };
}
};
const openCreateModal = () => roleCreateDialogRef.value.show();
const getApiUrl = () => new URL(window.location).origin;
const navigate = (event, id) => {
if (event.ctrlKey || event.metaKey)
return window.open(`${getApiUrl()}/#/account/role/${id}/summary`);
router.push({ name: 'RoleSummary', params: { id } });
};
</script>
<template>
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#searchbar">
<VnSearchbar
data-key="RolesList"
data-key="Roles"
url="VnRoles"
:expr-builder="exprBuilder"
:label="t('role.searchRoles')"
:info="t('role.searchInfo')"
/>
</Teleport>
<Teleport to="#actions-append">
<div class="row q-gutter-x-sm">
<QBtn
flat
@click="stateStore.toggleRightDrawer()"
round
dense
icon="menu"
>
<QTooltip bottom anchor="bottom right">
{{ t('globals.collapseMenu') }}
</QTooltip>
</QBtn>
</div>
</Teleport>
</template>
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
<QScrollArea class="fit text-grey-8">
<AccountRolesFilter data-key="RolesList" :expr-builder="exprBuilder" />
</QScrollArea>
</QDrawer>
<VnTable
ref="tableRef"
data-key="Roles"