Don't store/show the state of write-only toggle switches

This commit is contained in:
Fabio Manganiello 2022-10-23 00:28:01 +02:00
parent 8cd5cb3338
commit 3e6ebdd23b
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -11,8 +11,11 @@
</div> </div>
<div class="col-2 switch pull-right"> <div class="col-2 switch pull-right">
<ToggleSwitch :value="value.state" @input="toggle" <ToggleSwitch
@click.stop :disabled="loading || value.is_read_only" /> :value="value.is_write_only ? false : value.state"
:disabled="loading || value.is_read_only"
@input="toggle"
@click.stop />
</div> </div>
</div> </div>
</div> </div>
@ -38,6 +41,13 @@ export default {
id: this.value.id, id: this.value.id,
action: 'toggle', action: 'toggle',
}) })
if (this.value.is_write_only) {
// Show a quick on/off animation for write-only switches
const self = this
self.value.state = true
setTimeout(() => self.value.state = false, 250)
}
} finally { } finally {
this.$emit('loading', false) this.$emit('loading', false)
} }