[web] Rename confusing variable name option

This commit is contained in:
Alain Nussbaumer 2024-04-26 18:15:35 +02:00
parent 0401fb9616
commit 8fe6cba6ef
5 changed files with 62 additions and 83 deletions

View File

@ -1,13 +1,13 @@
<template> <template>
<div class="field"> <div class="field">
<input <input
:id="option.name" :id="setting.name"
v-model="option.value" v-model="setting.value"
type="checkbox" type="checkbox"
class="switch is-rounded mr-2" class="switch is-rounded mr-2"
@change="update_setting" @change="update_setting"
/> />
<label class="pt-0" :for="option.name"> <label class="pt-0" :for="setting.name">
<slot name="label" /> <slot name="label" />
</label> </label>
<i <i
@ -27,8 +27,8 @@ import webapi from '@/webapi'
export default { export default {
name: 'SettingsCheckbox', name: 'SettingsCheckbox',
props: { props: {
category_name: { required: true, type: String }, category: { required: true, type: String },
option_name: { required: true, type: String } name: { required: true, type: String }
}, },
data() { data() {
@ -54,40 +54,37 @@ export default {
is_success() { is_success() {
return this.statusUpdate === 'success' return this.statusUpdate === 'success'
}, },
option() { setting() {
const option = this.$store.getters.setting( const setting = this.$store.getters.setting(this.category, this.name)
this.category_name, if (!setting) {
this.option_name
)
if (!option) {
return { return {
category: this.category_name, category: this.category,
name: this.option_name, name: this.name,
value: false value: false
} }
} }
return option return setting
} }
}, },
methods: { methods: {
clear_status() { clear_status() {
if (this.is_error) { if (this.is_error) {
this.option.value = !this.option.value this.setting.value = !this.setting.value
} }
this.statusUpdate = '' this.statusUpdate = ''
}, },
update_setting() { update_setting() {
this.timerId = -1 this.timerId = -1
const option = { const setting = {
category: this.category_name, category: this.category,
name: this.option_name, name: this.name,
value: this.option.value value: this.setting.value
} }
webapi webapi
.settings_update(this.category_name, option) .settings_update(this.category, setting)
.then(() => { .then(() => {
this.$store.dispatch('update_setting', option) this.$store.dispatch('update_setting', setting)
this.statusUpdate = 'success' this.statusUpdate = 'success'
}) })
.catch(() => { .catch(() => {

View File

@ -16,7 +16,7 @@
inputmode="numeric" inputmode="numeric"
min="0" min="0"
:placeholder="placeholder" :placeholder="placeholder"
:value="option.value" :value="setting.value"
@input="set_update_timer" @input="set_update_timer"
/> />
</div> </div>
@ -33,9 +33,9 @@ import webapi from '@/webapi'
export default { export default {
name: 'SettingsIntfield', name: 'SettingsIntfield',
props: { props: {
category_name: { required: true, type: String }, category: { required: true, type: String },
disabled: Boolean, disabled: Boolean,
option_name: { required: true, type: String }, name: { required: true, type: String },
placeholder: { default: '', type: String } placeholder: { default: '', type: String }
}, },
@ -62,8 +62,8 @@ export default {
is_success() { is_success() {
return this.statusUpdate === 'success' return this.statusUpdate === 'success'
}, },
option() { setting() {
return this.$store.getters.setting(this.category_name, this.option_name) return this.$store.getters.setting(this.category, this.name)
} }
}, },
@ -87,15 +87,15 @@ export default {
this.statusUpdate = '' this.statusUpdate = ''
return return
} }
const option = { const setting = {
category: this.category_name, category: this.category,
name: this.option_name, name: this.name,
value: newValue value: newValue
} }
webapi webapi
.settings_update(this.category_name, option) .settings_update(this.category, setting)
.then(() => { .then(() => {
this.$store.dispatch('update_setting', option) this.$store.dispatch('update_setting', setting)
this.statusUpdate = 'success' this.statusUpdate = 'success'
}) })
.catch(() => { .catch(() => {

View File

@ -15,7 +15,7 @@
class="input" class="input"
type="text" type="text"
:placeholder="placeholder" :placeholder="placeholder"
:value="option.value" :value="setting.value"
@input="set_update_timer" @input="set_update_timer"
/> />
</div> </div>
@ -32,9 +32,9 @@ import webapi from '@/webapi'
export default { export default {
name: 'SettingsTextfield', name: 'SettingsTextfield',
props: { props: {
category_name: { required: true, type: String }, category: { required: true, type: String },
disabled: Boolean, disabled: Boolean,
option_name: { required: true, type: String }, name: { required: true, type: String },
placeholder: { default: '', type: String } placeholder: { default: '', type: String }
}, },
@ -61,8 +61,8 @@ export default {
is_success() { is_success() {
return this.statusUpdate === 'success' return this.statusUpdate === 'success'
}, },
option() { setting() {
return this.$store.getters.setting(this.category_name, this.option_name) return this.$store.getters.setting(this.category, this.name)
} }
}, },
@ -88,15 +88,15 @@ export default {
this.statusUpdate = '' this.statusUpdate = ''
return return
} }
const option = { const setting = {
category: this.category_name, category: this.category,
name: this.option_name, name: this.name,
value: newValue value: newValue
} }
webapi webapi
.settings_update(this.category_name, option) .settings_update(this.category, setting)
.then(() => { .then(() => {
this.$store.dispatch('update_setting', option) this.$store.dispatch('update_setting', setting)
this.statusUpdate = 'success' this.statusUpdate = 'success'
}) })
.catch(() => { .catch(() => {

View File

@ -16,8 +16,8 @@
/> />
<settings-checkbox <settings-checkbox
v-if="spotify.spotify_logged_in" v-if="spotify.spotify_logged_in"
category_name="artwork" category="artwork"
option_name="use_artwork_source_spotify" name="use_artwork_source_spotify"
> >
<template #label> <template #label>
<span v-text="$t('page.settings.artwork.spotify')" /> <span v-text="$t('page.settings.artwork.spotify')" />
@ -26,10 +26,7 @@
</a> </a>
</template> </template>
</settings-checkbox> </settings-checkbox>
<settings-checkbox <settings-checkbox category="artwork" name="use_artwork_source_discogs">
category_name="artwork"
option_name="use_artwork_source_discogs"
>
<template #label> <template #label>
<span v-text="$t('page.settings.artwork.discogs')" /> <span v-text="$t('page.settings.artwork.discogs')" />
<a href="https://www.discogs.com/" target="_blank"> <a href="https://www.discogs.com/" target="_blank">
@ -38,8 +35,8 @@
</template> </template>
</settings-checkbox> </settings-checkbox>
<settings-checkbox <settings-checkbox
category_name="artwork" category="artwork"
option_name="use_artwork_source_coverartarchive" name="use_artwork_source_coverartarchive"
> >
<template #label> <template #label>
<span v-text="$t('page.settings.artwork.coverartarchive')" /> <span v-text="$t('page.settings.artwork.coverartarchive')" />

View File

@ -26,57 +26,45 @@
v-text="$t('page.settings.general.navigation-item-selection-info')" v-text="$t('page.settings.general.navigation-item-selection-info')"
/> />
<settings-checkbox <settings-checkbox
category_name="webinterface" category="webinterface"
option_name="show_menu_item_playlists" name="show_menu_item_playlists"
> >
<template #label> <template #label>
<span v-text="$t('page.settings.general.playlists')" /> <span v-text="$t('page.settings.general.playlists')" />
</template> </template>
</settings-checkbox> </settings-checkbox>
<settings-checkbox <settings-checkbox category="webinterface" name="show_menu_item_music">
category_name="webinterface"
option_name="show_menu_item_music"
>
<template #label> <template #label>
<span v-text="$t('page.settings.general.music')" /> <span v-text="$t('page.settings.general.music')" />
</template> </template>
</settings-checkbox> </settings-checkbox>
<settings-checkbox <settings-checkbox
category_name="webinterface" category="webinterface"
option_name="show_menu_item_podcasts" name="show_menu_item_podcasts"
> >
<template #label> <template #label>
<span v-text="$t('page.settings.general.podcasts')" /> <span v-text="$t('page.settings.general.podcasts')" />
</template> </template>
</settings-checkbox> </settings-checkbox>
<settings-checkbox <settings-checkbox
category_name="webinterface" category="webinterface"
option_name="show_menu_item_audiobooks" name="show_menu_item_audiobooks"
> >
<template #label> <template #label>
<span v-text="$t('page.settings.general.audiobooks')" /> <span v-text="$t('page.settings.general.audiobooks')" />
</template> </template>
</settings-checkbox> </settings-checkbox>
<settings-checkbox <settings-checkbox category="webinterface" name="show_menu_item_radio">
category_name="webinterface"
option_name="show_menu_item_radio"
>
<template #label> <template #label>
<span v-text="$t('page.settings.general.radio')" /> <span v-text="$t('page.settings.general.radio')" />
</template> </template>
</settings-checkbox> </settings-checkbox>
<settings-checkbox <settings-checkbox category="webinterface" name="show_menu_item_files">
category_name="webinterface"
option_name="show_menu_item_files"
>
<template #label> <template #label>
<span v-text="$t('page.settings.general.files')" /> <span v-text="$t('page.settings.general.files')" />
</template> </template>
</settings-checkbox> </settings-checkbox>
<settings-checkbox <settings-checkbox category="webinterface" name="show_menu_item_search">
category_name="webinterface"
option_name="show_menu_item_search"
>
<template #label> <template #label>
<span v-text="$t('page.settings.general.search')" /> <span v-text="$t('page.settings.general.search')" />
</template> </template>
@ -92,8 +80,8 @@
</template> </template>
<template #content> <template #content>
<settings-checkbox <settings-checkbox
category_name="webinterface" category="webinterface"
option_name="show_cover_artwork_in_album_lists" name="show_cover_artwork_in_album_lists"
> >
<template #label> <template #label>
<span v-text="$t('page.settings.general.show-coverart')" /> <span v-text="$t('page.settings.general.show-coverart')" />
@ -110,8 +98,8 @@
</template> </template>
<template #content> <template #content>
<settings-checkbox <settings-checkbox
category_name="webinterface" category="webinterface"
option_name="show_composer_now_playing" name="show_composer_now_playing"
> >
<template #label> <template #label>
<span v-text="$t('page.settings.general.show-composer')" /> <span v-text="$t('page.settings.general.show-composer')" />
@ -121,8 +109,8 @@
</template> </template>
</settings-checkbox> </settings-checkbox>
<settings-textfield <settings-textfield
category_name="webinterface" category="webinterface"
option_name="show_composer_for_genre" name="show_composer_for_genre"
:disabled="!setting_show_composer_now_playing" :disabled="!setting_show_composer_now_playing"
:placeholder="$t('page.settings.general.genres')" :placeholder="$t('page.settings.general.genres')"
> >
@ -145,8 +133,8 @@
</template> </template>
</settings-textfield> </settings-textfield>
<settings-checkbox <settings-checkbox
category_name="webinterface" category="webinterface"
option_name="show_filepath_now_playing" name="show_filepath_now_playing"
> >
<template #label> <template #label>
<span v-text="$t('page.settings.general.show-path')" /> <span v-text="$t('page.settings.general.show-path')" />
@ -162,10 +150,7 @@
/> />
</template> </template>
<template #content> <template #content>
<settings-intfield <settings-intfield category="webinterface" name="recently_added_limit">
category_name="webinterface"
option_name="recently_added_limit"
>
<template #label> <template #label>
<span <span
v-text="$t('page.settings.general.recently-added-page-info')" v-text="$t('page.settings.general.recently-added-page-info')"