diff options
| author | Henry Jameson <me@hjkos.com> | 2023-03-22 12:43:53 +0200 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2023-03-22 12:43:53 +0200 |
| commit | c7a16bdfe2cebe51c232ae3fe3101d35c4f877a2 (patch) | |
| tree | 270b734d561770e31f927b44c6b2df18ba5c4f47 /src/components/settings_modal/helpers/setting.js | |
| parent | 6992439c92c247bf5b48155a76ff4e39a57b0ec7 (diff) | |
grouped settings/managed drafts support added
Diffstat (limited to 'src/components/settings_modal/helpers/setting.js')
| -rw-r--r-- | src/components/settings_modal/helpers/setting.js | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js index d42ae763..d2e1a6f4 100644 --- a/src/components/settings_modal/helpers/setting.js +++ b/src/components/settings_modal/helpers/setting.js @@ -48,15 +48,32 @@ export default { }, data () { return { - draft: null + localDraft: null } }, created () { - if (this.realDraftMode) { + if (this.realDraftMode && this.realSource !== 'admin') { this.draft = this.state } }, computed: { + draft: { + // TODO allow passing shared draft object? + get () { + if (this.realSource === 'admin') { + return get(this.$store.state.adminSettings.draft, this.path) + } else { + return this.localDraft + } + }, + set (value) { + if (this.realSource === 'admin') { + this.$store.commit('updateAdminDraft', { path: this.canonPath, value }) + } else { + this.localDraft = value + } + } + }, state () { const value = get(this.configSource, this.path) if (value === undefined) { @@ -130,11 +147,18 @@ export default { return this.state !== this.defaultState } }, + canonPath () { + return Array.isArray(this.path) ? this.path : this.path.split('.') + }, isDirty () { - return this.realDraftMode && this.draft !== this.state + if (this.realSource === 'admin' && this.canonPath.length > 3) { + return false // should not show draft buttons for "grouped" values + } else { + return this.realDraftMode && this.draft !== this.state + } }, canHardReset () { - return this.realSource === 'admin' && this.$store.state.adminSettings.modifiedPaths.has(this.path) + return this.realSource === 'admin' && this.$store.state.adminSettings.modifiedPaths.has(this.canonPath.join(' -> ')) }, matchesExpertLevel () { return (this.expert || 0) <= this.$store.state.config.expertLevel > 0 |
