aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/helpers/setting.js
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2023-03-16 23:18:55 +0200
committerHenry Jameson <me@hjkos.com>2023-03-16 23:18:55 +0200
commitbfd802ad046886230574cf2262f9c2e5f1b03a3f (patch)
tree90f28ae9b62c5cd70c0a7fa6c170dc041dabf68e /src/components/settings_modal/helpers/setting.js
parent4d23d31fecf480abfccc4db3ac79c6640078dc3b (diff)
setting admin settings works now. also now we have draftable settings
Diffstat (limited to 'src/components/settings_modal/helpers/setting.js')
-rw-r--r--src/components/settings_modal/helpers/setting.js70
1 files changed, 63 insertions, 7 deletions
diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js
index 9195d3e9..0971b919 100644
--- a/src/components/settings_modal/helpers/setting.js
+++ b/src/components/settings_modal/helpers/setting.js
@@ -1,5 +1,16 @@
+import Checkbox from 'src/components/checkbox/checkbox.vue'
+import ModifiedIndicator from './modified_indicator.vue'
+import ProfileSettingIndicator from './profile_setting_indicator.vue'
+import DraftButtons from './draft_buttons.vue'
import { get, set } from 'lodash'
+
export default {
+ components: {
+ Checkbox,
+ ModifiedIndicator,
+ DraftButtons,
+ ProfileSettingIndicator
+ },
props: {
path: {
type: String,
@@ -23,6 +34,20 @@ export default {
source: {
type: String,
default: 'default'
+ },
+ draftMode: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data () {
+ return {
+ draft: null
+ }
+ },
+ created () {
+ if (this.draftMode) {
+ this.draft = this.state
}
},
computed: {
@@ -53,7 +78,7 @@ export default {
case 'profile':
return (k, v) => this.$store.dispatch('setProfileOption', { name: k, value: v })
case 'admin':
- return (k, v) => console.log(this.path, k, v)
+ return (k, v) => this.$store.dispatch('pushAdminSetting', { path: k, value: v })
default:
return (k, v) => this.$store.dispatch('setOption', { name: k, value: v })
}
@@ -72,25 +97,56 @@ export default {
isChanged () {
switch (this.source) {
case 'profile':
- return false
case 'admin':
- console.log(this.$store.state.adminSettings.modifiedPaths)
- return this.$store.state.adminSettings.modifiedPaths.has(this.path)
+ return false
default:
return this.state !== this.defaultState
}
},
+ isDirty () {
+ return this.draftMode && this.draft !== this.state
+ },
+ canHardReset () {
+ return this.source === 'admin' && this.$store.state.adminSettings.modifiedPaths.has(this.path)
+ },
matchesExpertLevel () {
return (this.expert || 0) <= this.$store.state.config.expertLevel > 0
}
},
methods: {
+ getValue (e) {
+ return e.target.value
+ },
update (e) {
- console.log('U', this.path, e)
- this.configSink(this.path, e)
+ if (this.draftMode) {
+ this.draft = this.getValue(e)
+ } else {
+ this.configSink(this.path, this.getValue(e))
+ }
+ },
+ commitDraft () {
+ if (this.draftMode) {
+ this.configSink(this.path, this.draft)
+ }
},
reset () {
- set(this.$store.getters.mergedConfig, this.path, this.defaultState)
+ console.log('reset')
+ if (this.draftMode) {
+ console.log(this.draft)
+ console.log(this.state)
+ this.draft = this.state
+ } else {
+ set(this.$store.getters.mergedConfig, this.path, this.defaultState)
+ }
+ },
+ hardReset () {
+ switch (this.source) {
+ case 'admin':
+ return this.$store.dispatch('resetAdminSetting', { path: this.path })
+ .then(() => { this.draft = this.state })
+ default:
+ console.warn('Hard reset not implemented yet!')
+ }
}
}
}