-
-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: change account addition form to have top-down approach (#7919)
- Loading branch information
Showing
19 changed files
with
1,027 additions
and
845 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 58 additions & 19 deletions
77
frontend/app/src/components/accounts/management/AccountDialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,74 @@ | ||
<script setup lang="ts"> | ||
import type AccountForm from '@/components/accounts/management/AccountForm.vue'; | ||
import type { AccountManageState } from '@/composables/accounts/blockchain/use-account-manage'; | ||
const props = defineProps<{ | ||
value: AccountManageState | undefined; | ||
}>(); | ||
const emit = defineEmits<{ | ||
(e: 'input', value: AccountManageState | undefined): void; | ||
}>(); | ||
const { t } = useI18n(); | ||
const { | ||
dialogText, | ||
openDialog, | ||
clearDialog, | ||
trySubmit, | ||
setPostSubmitFunc, | ||
submitting, | ||
} = useAccountDialog(); | ||
const form = ref<InstanceType<typeof AccountForm>>(); | ||
const model = useSimpleVModel(props, emit); | ||
const title = computed<string>(() => props.value?.mode === 'edit' | ||
? t('blockchain_balances.form_dialog.edit_title') | ||
: t('blockchain_balances.form_dialog.add_title')); | ||
const subtitle = computed<string>(() => props.value?.mode === 'edit' | ||
? t('blockchain_balances.form_dialog.edit_subtitle') | ||
: ''); | ||
const { save, pending, errorMessages } = useAccountManage(); | ||
const { loading } = useAccountLoading(); | ||
function postSubmitFunc(result: boolean) { | ||
if (result) | ||
clearDialog(); | ||
function dismiss() { | ||
set(model, undefined); | ||
} | ||
setPostSubmitFunc(postSubmitFunc); | ||
async function confirm() { | ||
assert(isDefined(form)); | ||
const accountForm = get(form); | ||
const valid = await accountForm.validate(); | ||
if (!valid) | ||
return; | ||
const importState = await accountForm.importAccounts(); | ||
if (importState === null) | ||
return; | ||
const state = importState || get(model); | ||
assert(state); | ||
const success = await save(state); | ||
if (success) | ||
dismiss(); | ||
} | ||
</script> | ||
|
||
<template> | ||
<BigDialog | ||
:display="openDialog" | ||
:title="dialogText.title" | ||
:subtitle="dialogText.subtitle" | ||
:display="!!model" | ||
:title="title" | ||
:subtitle="subtitle" | ||
:primary-action="t('common.actions.save')" | ||
:secondary-action="t('common.actions.cancel')" | ||
:loading="loading || submitting" | ||
@confirm="trySubmit()" | ||
@cancel="clearDialog()" | ||
:loading="loading || pending" | ||
@confirm="confirm()" | ||
@cancel="dismiss()" | ||
> | ||
<AccountForm data-cy="blockchain-balance-form" /> | ||
<AccountForm | ||
v-if="model" | ||
ref="form" | ||
v-model="model" | ||
:error-messages.sync="errorMessages" | ||
:loading="loading" | ||
/> | ||
</BigDialog> | ||
</template> |
Oops, something went wrong.