refs #7355 fix search exprBuilder
gitea/salix-front/pipeline/pr-dev This commit looks good Details

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> <script setup>
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import AclFilter from './Acls/AclFilter.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import axios from 'axios'; import axios from 'axios';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
@ -98,8 +97,8 @@ const deleteAcl = async ({ id }) => {
.dialog({ .dialog({
component: VnConfirm, component: VnConfirm,
componentProps: { componentProps: {
title: t('CAMBIA-HO'), title: t('Remove ACL'),
message: t('CAMBIA-HO'), message: t('Do you want to remove this ACL?'),
}, },
}) })
.onOk(() => { .onOk(() => {
@ -161,4 +160,6 @@ es:
ACL removed: ACL eliminado ACL removed: ACL eliminado
ACL will be removed: El ACL será eliminado ACL will be removed: El ACL será eliminado
Are you sure you want to continue?: ¿Seguro que quieres continuar? 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> </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> </script>
<template> <template>
<VnSearchbar <VnSearchbar
:label="t('account.search')" :label="t('account.search')"
data-key="AccountUsers" data-key="AccountUsers"
:expr-builder="exprBuilder"
:info="t('account.searchInfo')" :info="t('account.searchInfo')"
/> />

View File

@ -1,15 +1,12 @@
<script setup> <script setup>
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import VnTable from 'components/VnTable/VnTable.vue'; import VnTable from 'components/VnTable/VnTable.vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import VnSearchbar from 'components/ui/VnSearchbar.vue'; import VnSearchbar from 'components/ui/VnSearchbar.vue';
import AccountRolesFilter from './AccountRolesFilter.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
const route = useRoute(); const route = useRoute();
const stateStore = useStateStore(); const stateStore = useStateStore();
const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const $props = defineProps({ const $props = defineProps({
id: { id: {
@ -19,7 +16,6 @@ const $props = defineProps({
}); });
const tableRef = ref(); const tableRef = ref();
const entityId = computed(() => $props.id || route.params.id); const entityId = computed(() => $props.id || route.params.id);
const roleCreateDialogRef = ref(null);
const columns = computed(() => [ const columns = computed(() => [
{ {
@ -63,49 +59,20 @@ const exprBuilder = (param, value) => {
return { [param]: { like: `%${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> </script>
<template> <template>
<template v-if="stateStore.isHeaderMounted()"> <template v-if="stateStore.isHeaderMounted()">
<Teleport to="#searchbar"> <Teleport to="#searchbar">
<VnSearchbar <VnSearchbar
data-key="RolesList" data-key="Roles"
url="VnRoles" url="VnRoles"
:expr-builder="exprBuilder"
:label="t('role.searchRoles')" :label="t('role.searchRoles')"
:info="t('role.searchInfo')" :info="t('role.searchInfo')"
/> />
</Teleport> </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> </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 <VnTable
ref="tableRef" ref="tableRef"
data-key="Roles" data-key="Roles"