mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-13 07:50:41 -04:00
[web] Harmonise use use of rounded switches
Checkboxes have now the same appearance all over the UI.
This commit is contained in:
parent
bfd406206b
commit
5f433a2c20
@ -31,10 +31,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="checkbox is-size-7 is-small">
|
<input
|
||||||
<input v-model="rescan_metadata" type="checkbox" class="mr-2" />
|
id="rescan"
|
||||||
<span v-text="$t('dialog.update.rescan-metadata')" />
|
v-model="rescan_metadata"
|
||||||
</label>
|
type="checkbox"
|
||||||
|
class="switch is-rounded is-small"
|
||||||
|
/>
|
||||||
|
<label for="rescan" v-text="$t('dialog.update.rescan-metadata')" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="switch">
|
<input
|
||||||
<input
|
:id="option.name"
|
||||||
ref="setting"
|
v-model="option.value"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
:checked="value"
|
class="switch is-rounded mr-2"
|
||||||
class="mr-2"
|
@change="update_setting"
|
||||||
@change="set_update_timer"
|
/>
|
||||||
/>
|
<label :for="option.name">
|
||||||
<slot name="label" />
|
<slot name="label" />
|
||||||
<i
|
|
||||||
class="is-size-7"
|
|
||||||
:class="{ 'has-text-info': is_success, 'has-text-danger': is_error }"
|
|
||||||
v-text="info"
|
|
||||||
/>
|
|
||||||
</label>
|
</label>
|
||||||
|
<i
|
||||||
|
class="is-size-7"
|
||||||
|
:class="{ 'has-text-info': is_success, 'has-text-danger': is_error }"
|
||||||
|
v-text="info"
|
||||||
|
/>
|
||||||
<p v-if="$slots['info']" class="help">
|
<p v-if="$slots['info']" class="help">
|
||||||
<slot name="info" />
|
<slot name="info" />
|
||||||
</p>
|
</p>
|
||||||
@ -38,29 +38,25 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
category() {
|
|
||||||
return this.$store.state.settings.categories.find(
|
|
||||||
(elem) => elem.name === this.category_name
|
|
||||||
)
|
|
||||||
},
|
|
||||||
|
|
||||||
option() {
|
option() {
|
||||||
if (!this.category) {
|
const option = this.$store.getters.settings_option(
|
||||||
return {}
|
this.category_name,
|
||||||
}
|
this.option_name
|
||||||
return this.category.options.find(
|
|
||||||
(elem) => elem.name === this.option_name
|
|
||||||
)
|
)
|
||||||
},
|
if (!option) {
|
||||||
|
return {
|
||||||
value() {
|
category: this.category_name,
|
||||||
return this.option.value
|
name: this.option_name,
|
||||||
|
value: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return option
|
||||||
},
|
},
|
||||||
|
|
||||||
info() {
|
info() {
|
||||||
if (this.statusUpdate === 'success') {
|
if (this.is_success) {
|
||||||
return this.$t('setting.saved')
|
return this.$t('setting.saved')
|
||||||
} else if (this.statusUpdate === 'error') {
|
} else if (this.is_error) {
|
||||||
return this.$t('setting.not-saved')
|
return this.$t('setting.not-saved')
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
@ -76,42 +72,21 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
set_update_timer() {
|
|
||||||
if (this.timerId > 0) {
|
|
||||||
window.clearTimeout(this.timerId)
|
|
||||||
this.timerId = -1
|
|
||||||
}
|
|
||||||
|
|
||||||
this.statusUpdate = ''
|
|
||||||
const newValue = this.$refs.setting.checked
|
|
||||||
if (newValue !== this.value) {
|
|
||||||
this.timerId = window.setTimeout(this.update_setting, this.timerDelay)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
update_setting() {
|
update_setting() {
|
||||||
this.timerId = -1
|
this.timerId = -1
|
||||||
|
|
||||||
const newValue = this.$refs.setting.checked
|
|
||||||
if (newValue === this.value) {
|
|
||||||
this.statusUpdate = ''
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const option = {
|
const option = {
|
||||||
category: this.category.name,
|
category: this.category_name,
|
||||||
name: this.option_name,
|
name: this.option_name,
|
||||||
value: newValue
|
value: this.option.value
|
||||||
}
|
}
|
||||||
webapi
|
webapi
|
||||||
.settings_update(this.category.name, option)
|
.settings_update(this.category_name, option)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$store.commit(types.UPDATE_SETTINGS_OPTION, option)
|
this.$store.commit(types.UPDATE_SETTINGS_OPTION, option)
|
||||||
this.statusUpdate = 'success'
|
this.statusUpdate = 'success'
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.statusUpdate = 'error'
|
this.statusUpdate = 'error'
|
||||||
this.$refs.setting.checked = this.value
|
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.timerId = window.setTimeout(this.clear_status, this.timerDelay)
|
this.timerId = window.setTimeout(this.clear_status, this.timerDelay)
|
||||||
@ -119,6 +94,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
clear_status() {
|
clear_status() {
|
||||||
|
if (this.is_error) {
|
||||||
|
this.option.value = !this.option.value
|
||||||
|
}
|
||||||
this.statusUpdate = ''
|
this.statusUpdate = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,15 +53,14 @@
|
|||||||
<div v-for="output in outputs" :key="output.id">
|
<div v-for="output in outputs" :key="output.id">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<label class="checkbox">
|
<input
|
||||||
<input
|
:id="output.id"
|
||||||
v-model="output.selected"
|
v-model="output.selected"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
class="mr-2"
|
class="switch is-rounded mr-2"
|
||||||
@change="output_toggle(output.id)"
|
@change="output_toggle(output.id)"
|
||||||
/>
|
/>
|
||||||
<span v-text="output.name" />
|
<label :for="output.id" class="checkbox" v-text="output.name" />
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form
|
<form
|
||||||
|
Loading…
x
Reference in New Issue
Block a user