Make the reset button select the default account
This commit is contained in:
parent
55ce44aebf
commit
824d5311ec
6 changed files with 20 additions and 2 deletions
|
@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- The style has been entirely reworked using Bootstrap instead of Bulma
|
- The style has been entirely reworked using Bootstrap instead of Bulma
|
||||||
- It is now impossible to include the separator in the dedicated name
|
- It is now impossible to include the separator in the dedicated name
|
||||||
- When adding a new account, error messages are displayed alongside each affected elements whenever possible
|
- When adding a new account, error messages are displayed alongside each affected elements whenever possible
|
||||||
|
- By default, the new sub-address form reset button switches to the default account
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
- Invalid preferences are now automatically corrected
|
- Invalid preferences are now automatically corrected
|
||||||
|
|
|
@ -6,3 +6,4 @@ export const allowedLocales = [
|
||||||
'en',
|
'en',
|
||||||
'fr',
|
'fr',
|
||||||
];
|
];
|
||||||
|
export const resetToDefaultAccount = true;
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
"title": "Preferences",
|
"title": "Preferences",
|
||||||
"language": "Language",
|
"language": "Language",
|
||||||
"colorMode": "Theme",
|
"colorMode": "Theme",
|
||||||
|
"resetToDefault": "Switch to the default account when the new sub-address form is reset",
|
||||||
"lightTheme": "Light",
|
"lightTheme": "Light",
|
||||||
"darkTheme": "Dark",
|
"darkTheme": "Dark",
|
||||||
"close": "@:invariants.controls.close"
|
"close": "@:invariants.controls.close"
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
"title": "Préférences",
|
"title": "Préférences",
|
||||||
"language": "Langue",
|
"language": "Langue",
|
||||||
"colorMode": "Thème",
|
"colorMode": "Thème",
|
||||||
|
"resetToDefault": "Basculer sur le compte par défaut lorsque le formulaire de sous-adresse est réinitialisé",
|
||||||
"lightTheme": "Clair",
|
"lightTheme": "Clair",
|
||||||
"darkTheme": "Sombre",
|
"darkTheme": "Sombre",
|
||||||
"close": "@:invariants.controls.close"
|
"close": "@:invariants.controls.close"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { resetToDefaultAccount } from '../const';
|
||||||
import { watch } from 'vue';
|
import { watch } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
@ -10,6 +11,7 @@ const router = useRouter();
|
||||||
const stored_locale = useStorage('sake-locale', '');
|
const stored_locale = useStorage('sake-locale', '');
|
||||||
const { t, locale } = useI18n({ useScope: 'global' });
|
const { t, locale } = useI18n({ useScope: 'global' });
|
||||||
const colorMode = useStorage('sake-color-mode');
|
const colorMode = useStorage('sake-color-mode');
|
||||||
|
const resetToDefault = useStorage('sake-reset-to-default', resetToDefaultAccount);
|
||||||
const allowedColorModes = [
|
const allowedColorModes = [
|
||||||
'light',
|
'light',
|
||||||
'dark',
|
'dark',
|
||||||
|
@ -45,6 +47,12 @@ watch(colorMode, async (newColorMode) => {
|
||||||
<option v-for="mode in allowedColorModes" :key="mode" :value="mode">{{ $t(`config.${mode}Theme`) }}</option>
|
<option v-for="mode in allowedColorModes" :key="mode" :value="mode">{{ $t(`config.${mode}Theme`) }}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input class="form-check-input" type="checkbox" role="switch" id="app-reset-to-default" v-model="resetToDefault">
|
||||||
|
<label class="form-check-label" for="app-reset-to-default">{{ $t("config.resetToDefault") }}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ButtonGroupComponent>
|
<ButtonGroupComponent>
|
||||||
<button type="button" class="btn btn-secondary" @click="toMainView">{{ $t("about.close") }}</button>
|
<button type="button" class="btn btn-secondary" @click="toMainView">{{ $t("about.close") }}</button>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { sortAccounts } from '../accounts';
|
import { sortAccounts } from '../accounts';
|
||||||
|
import { resetToDefaultAccount } from '../const';
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { RouterLink, useRouter } from 'vue-router';
|
import { RouterLink, useRouter } from 'vue-router';
|
||||||
import { useStorage } from '@vueuse/core';
|
import { useStorage } from '@vueuse/core';
|
||||||
|
@ -12,11 +13,13 @@ import NavBarComponent from '../components/NavBarComponent.vue';
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const accounts = useStorage('sake-accounts', []);
|
const accounts = useStorage('sake-accounts', []);
|
||||||
|
const resetToDefault = useStorage('sake-reset-to-default', resetToDefaultAccount);
|
||||||
const sortedAccounts = computed(() => sortAccounts(accounts.value));
|
const sortedAccounts = computed(() => sortAccounts(accounts.value));
|
||||||
const selectedAccountId = ref((() => {
|
const getDefaultAccount = () => {
|
||||||
const def = accounts.value.find((a) => a.isDefault);
|
const def = accounts.value.find((a) => a.isDefault);
|
||||||
return def ? def.id : accounts.value[0].id;
|
return def ? def.id : accounts.value[0].id;
|
||||||
})());
|
};
|
||||||
|
const selectedAccountId = ref(getDefaultAccount());
|
||||||
const subAddrName = ref('');
|
const subAddrName = ref('');
|
||||||
|
|
||||||
const fromRawAccount = (raw_account) => {
|
const fromRawAccount = (raw_account) => {
|
||||||
|
@ -56,6 +59,9 @@ const copyAddr = () => {
|
||||||
};
|
};
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
subAddrName.value = '';
|
subAddrName.value = '';
|
||||||
|
if (resetToDefault.value) {
|
||||||
|
selectedAccountId.value = getDefaultAccount();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue