Set (or reset) icon on OTP type toggling in the Create form

This commit is contained in:
Bubka 2022-07-21 18:08:17 +02:00
parent 0bc59f7768
commit a066be8e38

View File

@ -64,7 +64,7 @@
<div class="field is-grouped"> <div class="field is-grouped">
<!-- i'm lucky button --> <!-- i'm lucky button -->
<div class="control"> <div class="control">
<v-button @click="fetchLogo" :color="'is-dark'" :nativeType="'button'" :isDisabled="form.service.length < 3"> <v-button @click="fetchLogo" :color="'is-dark'" :nativeType="'button'" :isDisabled="form.service.length < 1">
<span class="icon is-small"> <span class="icon is-small">
<font-awesome-icon :icon="['fas', 'globe']" /> <font-awesome-icon :icon="['fas', 'globe']" />
</span> </span>
@ -95,7 +95,7 @@
<p class="help" v-html="$t('twofaccounts.forms.i_m_lucky_legend')"></p> <p class="help" v-html="$t('twofaccounts.forms.i_m_lucky_legend')"></p>
</div> </div>
<!-- otp type --> <!-- otp type -->
<form-toggle @otp_type="setFormState" class="has-uppercased-button" :form="form" :choices="otp_types" fieldName="otp_type" :label="$t('twofaccounts.forms.otp_type.label')" :help="$t('twofaccounts.forms.otp_type.help')" :hasOffset="true" /> <form-toggle class="has-uppercased-button" :form="form" :choices="otp_types" fieldName="otp_type" :label="$t('twofaccounts.forms.otp_type.label')" :help="$t('twofaccounts.forms.otp_type.help')" :hasOffset="true" />
<div v-if="form.otp_type"> <div v-if="form.otp_type">
<!-- secret --> <!-- secret -->
<label class="label" v-html="$t('twofaccounts.forms.secret.label')"></label> <label class="label" v-html="$t('twofaccounts.forms.secret.label')"></label>
@ -249,6 +249,10 @@
this.$refs.QuickFormOtpDisplayer.internal_icon = val this.$refs.QuickFormOtpDisplayer.internal_icon = val
} }
}, },
'form.otp_type' : function(to, from) {
this.setFormState(from, to)
},
}, },
mounted: function () { mounted: function () {
@ -405,10 +409,19 @@
console.log('error', value) console.log('error', value)
}, },
setFormState (event) { setFormState (from, to) {
this.form.otp_type = event this.form.otp_type = to
this.form.service = event === 'steamtotp' ? 'Steam' : ''
this.secretIsBase32Encoded = event === 'steamtotp' ? 1 : this.secretIsBase32Encoded if (to === 'steamtotp') {
this.secretIsBase32Encoded = 1
this.form.service = 'Steam'
this.form.secret = ''
this.fetchLogo()
}
else if (from === 'steamtotp') {
this.form.service = ''
this.deleteIcon()
}
}, },
}, },