From 02a1554b21874c428260eafe233d6120b85ea567 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 18 Nov 2024 11:24:39 +0100 Subject: [PATCH] feat: refs #6919 sync role --- src/components/FormModel.vue | 13 +++++++++++-- src/components/common/VnCard.vue | 18 ++++++++---------- src/pages/Account/Role/AccountExprBuilder.js | 16 ++++++++++++++++ src/pages/Account/Role/AccountRoles.vue | 18 +----------------- src/pages/Account/Role/Card/RoleBasicData.vue | 14 +++----------- src/pages/Account/Role/Card/RoleCard.vue | 13 +++++++------ src/pages/Account/Role/Card/RoleDescriptor.vue | 17 ++++------------- src/pages/Account/Role/Card/RoleSummary.vue | 9 +++------ 8 files changed, 53 insertions(+), 65 deletions(-) create mode 100644 src/pages/Account/Role/AccountExprBuilder.js diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index c668769e5..733a7e3a0 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -131,7 +131,13 @@ onMounted(async () => { if (!$props.formInitialData) { if ($props.autoLoad && $props.url) await fetch(); - else if (arrayData.store.data) updateAndEmit('onFetch', arrayData.store.data); + else if (arrayData.store.data) + updateAndEmit( + 'onFetch', + Array.isArray(arrayData.store.data) + ? arrayData.store.data[0] + : arrayData.store.data + ); } if ($props.observeFormChanges) { watch( @@ -151,7 +157,10 @@ onMounted(async () => { if (!$props.url) watch( () => arrayData.store.data, - (val) => updateAndEmit('onFetch', val) + (val) => { + if (Array.isArray(val)) val = val[0] ?? {}; + updateAndEmit('onFetch', val); + } ); watch( diff --git a/src/components/common/VnCard.vue b/src/components/common/VnCard.vue index 504dd809f..c37b25675 100644 --- a/src/components/common/VnCard.vue +++ b/src/components/common/VnCard.vue @@ -47,17 +47,15 @@ onBeforeMount(async () => { } }); -if (!props.idInWhere) { - onBeforeRouteUpdate(async (to, from) => { - if (to.params.id !== from.params.id) { - arrayData.store.url = !regex.test(props.url) - ? `${props.url}/${to.params.id}` - : props.url.replace(regex, `/${to.params.id}`); +onBeforeRouteUpdate(async (to, from) => { + if (to.params.id !== from.params.id) { + arrayData.store.url = !regex.test(props.url) + ? `${props.url}/${to.params.id}` + : props.url.replace(regex, `/${to.params.id}`); - await arrayData.fetch({ append: false, updateRouter: false }); - } - }); -} + await arrayData.fetch({ append: false, updateRouter: false }); + } +});