From 551b8f3690bab1f53ec22ccf6963009a30fa45d0 Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Mon, 7 Mar 2022 20:02:53 -0500 Subject: [PATCH] Fix "max depth in thread" setting --- .../settings_modal/helpers/integer_setting.js | 37 +++++++++++++++++++ .../helpers/integer_setting.vue | 20 ++++++++++ .../settings_modal/tabs/filtering_tab.js | 4 +- .../settings_modal/tabs/filtering_tab.vue | 15 +++----- .../settings_modal/tabs/general_tab.js | 2 + .../settings_modal/tabs/general_tab.vue | 15 +++----- 6 files changed, 72 insertions(+), 21 deletions(-) create mode 100644 src/components/settings_modal/helpers/integer_setting.js create mode 100644 src/components/settings_modal/helpers/integer_setting.vue diff --git a/src/components/settings_modal/helpers/integer_setting.js b/src/components/settings_modal/helpers/integer_setting.js new file mode 100644 index 00000000..fa6569ab --- /dev/null +++ b/src/components/settings_modal/helpers/integer_setting.js @@ -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)) + } + } +} diff --git a/src/components/settings_modal/helpers/integer_setting.vue b/src/components/settings_modal/helpers/integer_setting.vue new file mode 100644 index 00000000..8284abcc --- /dev/null +++ b/src/components/settings_modal/helpers/integer_setting.vue @@ -0,0 +1,20 @@ + + + diff --git a/src/components/settings_modal/tabs/filtering_tab.js b/src/components/settings_modal/tabs/filtering_tab.js index 4eaf4217..73413b48 100644 --- a/src/components/settings_modal/tabs/filtering_tab.js +++ b/src/components/settings_modal/tabs/filtering_tab.js @@ -1,6 +1,7 @@ import { filter, trim } from 'lodash' import BooleanSetting from '../helpers/boolean_setting.vue' import ChoiceSetting from '../helpers/choice_setting.vue' +import IntegerSetting from '../helpers/integer_setting.vue' import SharedComputedObject from '../helpers/shared_computed_object.js' @@ -17,7 +18,8 @@ const FilteringTab = { }, components: { BooleanSetting, - ChoiceSetting + ChoiceSetting, + IntegerSetting }, computed: { ...SharedComputedObject(), diff --git a/src/components/settings_modal/tabs/filtering_tab.vue b/src/components/settings_modal/tabs/filtering_tab.vue index 50ee20e0..eb1705e7 100644 --- a/src/components/settings_modal/tabs/filtering_tab.vue +++ b/src/components/settings_modal/tabs/filtering_tab.vue @@ -60,17 +60,12 @@

{{ $t('settings.attachments') }}

  • - - + {{ $t('settings.max_thumbnails') }} +
  • diff --git a/src/components/settings_modal/tabs/general_tab.js b/src/components/settings_modal/tabs/general_tab.js index 8ae0021c..03ca99fa 100644 --- a/src/components/settings_modal/tabs/general_tab.js +++ b/src/components/settings_modal/tabs/general_tab.js @@ -1,5 +1,6 @@ import BooleanSetting from '../helpers/boolean_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 SharedComputedObject from '../helpers/shared_computed_object.js' @@ -47,6 +48,7 @@ const GeneralTab = { components: { BooleanSetting, ChoiceSetting, + IntegerSetting, InterfaceLanguageSwitcher }, computed: { diff --git a/src/components/settings_modal/tabs/general_tab.vue b/src/components/settings_modal/tabs/general_tab.vue index 6c108292..ba01fdeb 100644 --- a/src/components/settings_modal/tabs/general_tab.vue +++ b/src/components/settings_modal/tabs/general_tab.vue @@ -176,17 +176,12 @@
  • - - + {{ $t('settings.max_depth_in_thread') }} +