Fix "max depth in thread" setting

This commit is contained in:
Tusooa Zhu 2022-03-07 20:02:53 -05:00
parent 48178bdc53
commit 551b8f3690
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
6 changed files with 72 additions and 21 deletions

View file

@ -0,0 +1,37 @@
import { get, set } from 'lodash'
import ModifiedIndicator from './modified_indicator.vue'
export default {
components: {
ModifiedIndicator
},
props: {
path: String,
disabled: Boolean,
min: Number
},
computed: {
pathDefault () {
const [firstSegment, ...rest] = this.path.split('.')
return [firstSegment + 'DefaultValue', ...rest].join('.')
},
state () {
const value = get(this.$parent, this.path)
if (value === undefined) {
return this.defaultState
} else {
return value
}
},
defaultState () {
return get(this.$parent, this.pathDefault)
},
isChanged () {
return this.state !== this.defaultState
}
},
methods: {
update (e) {
set(this.$parent, this.path, parseInt(e.target.value))
}
}
}

View file

@ -0,0 +1,20 @@
<template>
<span class="IntegerSetting">
<label :for="path">
<slot />
</label>
<input
:id="path"
class="number-input"
type="number"
step="1"
:disabled="disabled"
:min="min || 0"
:value="state"
@change="update"
>
<ModifiedIndicator :changed="isChanged" />
</span>
</template>
<script src="./integer_setting.js"></script>

View file

@ -1,6 +1,7 @@
import { filter, trim } from 'lodash' import { filter, trim } from 'lodash'
import BooleanSetting from '../helpers/boolean_setting.vue' import BooleanSetting from '../helpers/boolean_setting.vue'
import ChoiceSetting from '../helpers/choice_setting.vue' import ChoiceSetting from '../helpers/choice_setting.vue'
import IntegerSetting from '../helpers/integer_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js' import SharedComputedObject from '../helpers/shared_computed_object.js'
@ -17,7 +18,8 @@ const FilteringTab = {
}, },
components: { components: {
BooleanSetting, BooleanSetting,
ChoiceSetting ChoiceSetting,
IntegerSetting
}, },
computed: { computed: {
...SharedComputedObject(), ...SharedComputedObject(),

View file

@ -60,17 +60,12 @@
</li> </li>
<h3>{{ $t('settings.attachments') }}</h3> <h3>{{ $t('settings.attachments') }}</h3>
<li> <li>
<label for="maxThumbnails"> <IntegerSetting
{{ $t('settings.max_thumbnails') }} path="maxThumbnails"
</label> :min="0"
<input
id="maxThumbnails"
path.number="maxThumbnails"
class="number-input"
type="number"
min="0"
step="1"
> >
{{ $t('settings.max_thumbnails') }}
</IntegerSetting>
</li> </li>
<li> <li>
<BooleanSetting path="hideAttachments"> <BooleanSetting path="hideAttachments">

View file

@ -1,5 +1,6 @@
import BooleanSetting from '../helpers/boolean_setting.vue' import BooleanSetting from '../helpers/boolean_setting.vue'
import ChoiceSetting from '../helpers/choice_setting.vue' import ChoiceSetting from '../helpers/choice_setting.vue'
import IntegerSetting from '../helpers/integer_setting.vue'
import InterfaceLanguageSwitcher from 'src/components/interface_language_switcher/interface_language_switcher.vue' import InterfaceLanguageSwitcher from 'src/components/interface_language_switcher/interface_language_switcher.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js' import SharedComputedObject from '../helpers/shared_computed_object.js'
@ -47,6 +48,7 @@ const GeneralTab = {
components: { components: {
BooleanSetting, BooleanSetting,
ChoiceSetting, ChoiceSetting,
IntegerSetting,
InterfaceLanguageSwitcher InterfaceLanguageSwitcher
}, },
computed: { computed: {

View file

@ -176,17 +176,12 @@
</BooleanSetting> </BooleanSetting>
</li> </li>
<li> <li>
<label for="maxDepthInThread"> <IntegerSetting
{{ $t('settings.max_depth_in_thread') }} path="maxDepthInThread"
</label> :min="3"
<input
id="maxDepthInThread"
path.number="maxDepthInThread"
class="number-input"
type="number"
min="3"
step="1"
> >
{{ $t('settings.max_depth_in_thread') }}
</IntegerSetting>
</li> </li>
<li> <li>
<ChoiceSetting <ChoiceSetting