From bff160a904613fb5f6132aedd72b90383d4e7dcc Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Wed, 1 Oct 2025 14:33:05 +0200 Subject: [PATCH 1/3] remove side effects from validator, transform community_switch to field --- frontend/src/components/CommunitySwitch.vue | 8 ++++- .../components/GddSend/TransactionForm.vue | 32 +++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/CommunitySwitch.vue b/frontend/src/components/CommunitySwitch.vue index f460efa8e..1e4fff5ff 100644 --- a/frontend/src/components/CommunitySwitch.vue +++ b/frontend/src/components/CommunitySwitch.vue @@ -33,6 +33,10 @@ const props = defineProps({ type: Object, default: () => ({}), }, + communityIdentifier: { + type: String, + default: '', + }, }) const emit = defineEmits(['update:modelValue', 'communitiesLoaded']) @@ -57,7 +61,9 @@ onResult(({ data }) => { } }) -const communityIdentifier = computed(() => route.params.communityIdentifier) +const communityIdentifier = computed( + () => route.params.communityIdentifier || props.communityIdentifier, +) function updateCommunity(community) { // console.log('CommunitySwitch.updateCommunity...community=', community) diff --git a/frontend/src/components/GddSend/TransactionForm.vue b/frontend/src/components/GddSend/TransactionForm.vue index b66b39ed1..e14beb812 100644 --- a/frontend/src/components/GddSend/TransactionForm.vue +++ b/frontend/src/components/GddSend/TransactionForm.vue @@ -48,8 +48,9 @@ @@ -173,6 +174,7 @@ const entityDataToForm = computed(() => ({ ...props })) const form = reactive({ ...entityDataToForm.value }) const disableSmartValidState = ref(false) const communities = ref([]) +const autoCommunityIdentifier = ref('') const emit = defineEmits(['set-transaction']) @@ -220,6 +222,7 @@ const validationSchema = computed(() => { return object({ memo: memoSchema, amount: amountSchema, + // todo: found a better way, because this validation test has side effects identifier: identifierSchema.test( 'community-is-reachable', 'form.validation.identifier.communityIsReachable', @@ -229,18 +232,13 @@ const validationSchema = computed(() => { if (parts.length !== 2) { return true } - const com = communities.value.find((community) => { + return communities.value.some((community) => { return ( community.uuid === parts[0] || community.name === parts[0] || community.url === parts[0] ) }) - if (com) { - form.targetCommunity = com - return true - } - return false }, ), }) @@ -286,6 +284,26 @@ watch(userError, (error) => { } }) +// if identifier contain valid community identifier of a reachable community: +// set it as target community and change community-switch to show only current value, instead of select +watch( + () => form.identifier, + (value) => { + autoCommunityIdentifier.value = '' + const parts = value.split('/') + if (parts.length === 2) { + const com = communities.value.find( + (community) => + community.uuid === parts[0] || community.name === parts[0] || community.url === parts[0], + ) + if (com) { + form.targetCommunity = com + autoCommunityIdentifier.value = com.uuid + } + } + }, +) + function onSubmit() { const transformedForm = validationSchema.value.cast(form) const parts = transformedForm.identifier.split('/') From 84ebba4070892dc11f09df289f5080e721139b3b Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Wed, 1 Oct 2025 14:40:34 +0200 Subject: [PATCH 2/3] add debug log --- frontend/src/components/CommunitySwitch.vue | 9 ++++++++- frontend/src/components/GddSend/TransactionForm.vue | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/CommunitySwitch.vue b/frontend/src/components/CommunitySwitch.vue index 1e4fff5ff..ed1292a7c 100644 --- a/frontend/src/components/CommunitySwitch.vue +++ b/frontend/src/components/CommunitySwitch.vue @@ -22,7 +22,7 @@