mirror of
https://github.com/wallabag/wallabag.git
synced 2025-03-13 22:52:39 +00:00
Extract Fake Radio controller
This commit is contained in:
parent
ebd89a169e
commit
a61fe358a1
3 changed files with 16 additions and 21 deletions
13
assets/controllers/fake_radio_controller.js
Normal file
13
assets/controllers/fake_radio_controller.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ['emailTwoFactor', 'googleTwoFactor'];
|
||||
|
||||
uncheckGoogle() {
|
||||
this.googleTwoFactorTarget.checked = false;
|
||||
}
|
||||
|
||||
uncheckEmail() {
|
||||
this.emailTwoFactorTarget.checked = false;
|
||||
}
|
||||
}
|
|
@ -43,24 +43,6 @@ $(document).ready(() => {
|
|||
}
|
||||
};
|
||||
});
|
||||
|
||||
// mimic radio button because emailTwoFactor is a boolean
|
||||
$('#update_user_googleTwoFactor').on('change', () => {
|
||||
$('#update_user_emailTwoFactor').prop('checked', false);
|
||||
});
|
||||
|
||||
$('#update_user_emailTwoFactor').on('change', () => {
|
||||
$('#update_user_googleTwoFactor').prop('checked', false);
|
||||
});
|
||||
|
||||
// same mimic for super admin
|
||||
$('#user_googleTwoFactor').on('change', () => {
|
||||
$('#user_emailTwoFactor').prop('checked', false);
|
||||
});
|
||||
|
||||
$('#user_emailTwoFactor').on('change', () => {
|
||||
$('#user_googleTwoFactor').prop('checked', false);
|
||||
});
|
||||
});
|
||||
|
||||
(function darkTheme() {
|
||||
|
|
|
@ -48,16 +48,16 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="row" data-controller="fake-radio">
|
||||
<div class="input-field col s12">
|
||||
<label for="{{ edit_form.emailTwoFactor.vars.id }}">
|
||||
{{ form_widget(edit_form.emailTwoFactor) }}
|
||||
{{ form_widget(edit_form.emailTwoFactor, {attr: {'data-fake-radio-target': 'emailTwoFactor', 'data-action': 'fake-radio#uncheckGoogle'}}) }}
|
||||
<span>{{ edit_form.emailTwoFactor.vars.label|trans }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="input-field col s12">
|
||||
<label for="{{ edit_form.googleTwoFactor.vars.id }}">
|
||||
{{ form_widget(edit_form.googleTwoFactor) }}
|
||||
{{ form_widget(edit_form.googleTwoFactor, {attr: {'data-fake-radio-target': 'googleTwoFactor', 'data-action': 'fake-radio#uncheckEmail'}}) }}
|
||||
<span>{{ edit_form.googleTwoFactor.vars.label|trans }}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue