aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/helpers
diff options
context:
space:
mode:
authorHJ <30-hj@users.noreply.git.pleroma.social>2024-07-24 18:51:17 +0000
committerHJ <30-hj@users.noreply.git.pleroma.social>2024-07-24 18:51:17 +0000
commit0c9893c8a07426d3e41046663d4072de50eb267c (patch)
treedce14332df570a757bf78e769ac6cfd5fb189f58 /src/components/settings_modal/helpers
parent7a7d80270d1ae041f06c1fd9017135cb5b8c34d6 (diff)
parentaa7bdbae2173fdb921dd241683c3e0f9bd3aaa82 (diff)
Merge branch 'appearance-tab' into 'develop'
Themes 3: Intermission: Appearance Tab and fixes See merge request pleroma/pleroma-fe!1920
Diffstat (limited to 'src/components/settings_modal/helpers')
-rw-r--r--src/components/settings_modal/helpers/number_setting.vue1
-rw-r--r--src/components/settings_modal/helpers/setting.js10
-rw-r--r--src/components/settings_modal/helpers/unit_setting.js24
-rw-r--r--src/components/settings_modal/helpers/unit_setting.vue3
4 files changed, 32 insertions, 6 deletions
diff --git a/src/components/settings_modal/helpers/number_setting.vue b/src/components/settings_modal/helpers/number_setting.vue
index 23c1a5dd..32dc6f83 100644
--- a/src/components/settings_modal/helpers/number_setting.vue
+++ b/src/components/settings_modal/helpers/number_setting.vue
@@ -15,6 +15,7 @@
</template>
<slot v-else />
</label>
+ {{ ' ' }}
<input
:id="path"
class="input number-input"
diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js
index abf9cfdf..3b3e6268 100644
--- a/src/components/settings_modal/helpers/setting.js
+++ b/src/components/settings_modal/helpers/setting.js
@@ -48,6 +48,10 @@ export default {
draftMode: {
type: Boolean,
default: undefined
+ },
+ timedApplyMode: {
+ type: Boolean,
+ default: false
}
},
inject: {
@@ -161,7 +165,11 @@ export default {
case 'admin':
return (k, v) => this.$store.dispatch('pushAdminSetting', { path: k, value: v })
default:
- return (k, v) => this.$store.dispatch('setOption', { name: k, value: v })
+ if (this.timedApplyMode) {
+ return (k, v) => this.$store.dispatch('setOptionTemporarily', { name: k, value: v })
+ } else {
+ return (k, v) => this.$store.dispatch('setOption', { name: k, value: v })
+ }
}
},
defaultState () {
diff --git a/src/components/settings_modal/helpers/unit_setting.js b/src/components/settings_modal/helpers/unit_setting.js
index c9c23cb0..daeddd81 100644
--- a/src/components/settings_modal/helpers/unit_setting.js
+++ b/src/components/settings_modal/helpers/unit_setting.js
@@ -21,15 +21,23 @@ export default {
unitSet: {
type: String,
default: 'none'
+ },
+ step: {
+ type: Number,
+ default: 1
+ },
+ resetDefault: {
+ type: Object,
+ default: null
}
},
computed: {
...Setting.computed,
stateUnit () {
- return this.state.replace(/\d+/, '')
+ return typeof this.state === 'string' ? this.state.replace(/[0-9,.]+/, '') : ''
},
stateValue () {
- return this.state.replace(/\D+/, '')
+ return typeof this.state === 'string' ? this.state.replace(/[^0-9,.]+/, '') : ''
}
},
methods: {
@@ -39,10 +47,18 @@ export default {
return this.$t(['settings', 'units', this.unitSet, value].join('.'))
},
updateValue (e) {
- this.configSink(this.path, parseInt(e.target.value) + this.stateUnit)
+ this.configSink(this.path, parseFloat(e.target.value) + this.stateUnit)
},
updateUnit (e) {
- this.configSink(this.path, this.stateValue + e.target.value)
+ let value = this.stateValue
+ const newUnit = e.target.value
+ if (this.resetDefault) {
+ const replaceValue = this.resetDefault[newUnit]
+ if (replaceValue != null) {
+ value = replaceValue
+ }
+ }
+ this.configSink(this.path, value + newUnit)
}
}
}
diff --git a/src/components/settings_modal/helpers/unit_setting.vue b/src/components/settings_modal/helpers/unit_setting.vue
index 68f52b1c..40ab6880 100644
--- a/src/components/settings_modal/helpers/unit_setting.vue
+++ b/src/components/settings_modal/helpers/unit_setting.vue
@@ -9,11 +9,12 @@
>
<slot />
</label>
+ {{ ' ' }}
<input
:id="path"
class="input number-input"
type="number"
- step="1"
+ :step="step"
:disabled="disabled"
:min="min || 0"
:value="stateValue"