Merge branch 'improve_settings_reusability' into shigusegubu-vue3
* improve_settings_reusability: fixes for diabled state, tri-state boolean and access control made draft-mode and source inject-able fixes
This commit is contained in:
commit
bd97a2dc00
10 changed files with 178 additions and 109 deletions
|
@ -14,7 +14,12 @@ library.add(
|
||||||
)
|
)
|
||||||
|
|
||||||
const InstanceTab = {
|
const InstanceTab = {
|
||||||
data () {},
|
provide () {
|
||||||
|
return {
|
||||||
|
defaultDraftMode: true,
|
||||||
|
defaultSource: 'admin'
|
||||||
|
}
|
||||||
|
},
|
||||||
components: {
|
components: {
|
||||||
BooleanSetting,
|
BooleanSetting,
|
||||||
ChoiceSetting,
|
ChoiceSetting,
|
||||||
|
|
|
@ -4,66 +4,108 @@
|
||||||
<h2>{{ $t('admin_dash.instance.instance') }}</h2>
|
<h2>{{ $t('admin_dash.instance.instance') }}</h2>
|
||||||
<ul class="setting-list">
|
<ul class="setting-list">
|
||||||
<li>
|
<li>
|
||||||
<StringSetting
|
<StringSetting path=":pleroma.:instance.:name">
|
||||||
source="admin"
|
|
||||||
path=":pleroma.:instance.:name"
|
|
||||||
draft-mode
|
|
||||||
>
|
|
||||||
NAME
|
NAME
|
||||||
</StringSetting>
|
</StringSetting>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<StringSetting
|
<StringSetting path=":pleroma.:instance.:email">
|
||||||
source="admin"
|
|
||||||
path=":pleroma.:instance.:email"
|
|
||||||
draft-mode
|
|
||||||
>
|
|
||||||
ADMIN EMAIL
|
ADMIN EMAIL
|
||||||
</StringSetting>
|
</StringSetting>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<StringSetting
|
<StringSetting path=":pleroma.:instance.:description">
|
||||||
source="admin"
|
|
||||||
path=":pleroma.:instance.:description"
|
|
||||||
draft-mode
|
|
||||||
>
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
</StringSetting>
|
</StringSetting>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<StringSetting
|
<StringSetting path=":pleroma.:instance.:short_description">
|
||||||
source="admin"
|
|
||||||
path=":pleroma.:instance.:short_description"
|
|
||||||
draft-mode
|
|
||||||
>
|
|
||||||
SHORT DESCRIPTION
|
SHORT DESCRIPTION
|
||||||
</StringSetting>
|
</StringSetting>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<StringSetting
|
<StringSetting path=":pleroma.:instance.:instance_thumbnail">
|
||||||
source="admin"
|
|
||||||
path=":pleroma.:instance.:instance_thumbnail"
|
|
||||||
draft-mode
|
|
||||||
>
|
|
||||||
INSTANCE THUMBNAIL
|
INSTANCE THUMBNAIL
|
||||||
</StringSetting>
|
</StringSetting>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<StringSetting
|
<StringSetting path=":pleroma.:instance.:background_image">
|
||||||
source="admin"
|
|
||||||
path=":pleroma.:instance.:background_image"
|
|
||||||
draft-mode
|
|
||||||
>
|
|
||||||
BACKGROUND IMAGE
|
BACKGROUND IMAGE
|
||||||
</StringSetting>
|
</StringSetting>
|
||||||
</li>
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="setting-item">
|
||||||
|
<h2>{{ $t('admin_dash.instance.access') }}</h2>
|
||||||
|
<ul class="setting-list">
|
||||||
|
<li>
|
||||||
|
<BooleanSetting path=":pleroma.:instance.:public">
|
||||||
|
PUBLIC
|
||||||
|
</BooleanSetting>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<h3>{{ $t('admin_dash.instance.restrict.header') }}</h3>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<ChoiceSetting path=":pleroma.:instance.:limit_to_local_content">
|
||||||
|
SEARCH RESTRICTION
|
||||||
|
</ChoiceSetting>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<h4>{{ $t('admin_dash.instance.restrict.timelines') }}</h4>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<BooleanSetting
|
<BooleanSetting
|
||||||
source="admin"
|
path=":pleroma.:restrict_unauthenticated.:timelines.:local"
|
||||||
path=":pleroma.:instance.:public"
|
indeterminate-state=":if_instance_is_private"
|
||||||
draft-mode
|
|
||||||
>
|
>
|
||||||
PUBLIC
|
LOCAL TIMELINES
|
||||||
|
</BooleanSetting>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<BooleanSetting
|
||||||
|
path=":pleroma.:restrict_unauthenticated.:timelines.:federated"
|
||||||
|
indeterminate-state=":if_instance_is_private"
|
||||||
|
>
|
||||||
|
FED TIMELINES
|
||||||
|
</BooleanSetting>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<h4>{{ $t('admin_dash.instance.restrict.profiles') }}</h4>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<BooleanSetting
|
||||||
|
path=":pleroma.:restrict_unauthenticated.:profiles.:local"
|
||||||
|
indeterminate-state=":if_instance_is_private"
|
||||||
|
>
|
||||||
|
LOCAL PROFILES
|
||||||
|
</BooleanSetting>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<BooleanSetting
|
||||||
|
path=":pleroma.:restrict_unauthenticated.:profiles.:remote"
|
||||||
|
indeterminate-state=":if_instance_is_private"
|
||||||
|
>
|
||||||
|
FED PROFILES
|
||||||
|
</BooleanSetting>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<h4>{{ $t('admin_dash.instance.restrict.activities') }}</h4>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<BooleanSetting
|
||||||
|
path=":pleroma.:restrict_unauthenticated.:activities.:local"
|
||||||
|
indeterminate-state=":if_instance_is_private"
|
||||||
|
>
|
||||||
|
LOCAL STATUSES
|
||||||
|
</BooleanSetting>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<BooleanSetting
|
||||||
|
path=":pleroma.:restrict_unauthenticated.:activities.:remote"
|
||||||
|
indeterminate-state=":if_instance_is_private"
|
||||||
|
>
|
||||||
|
FED STATUSES
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -72,21 +114,15 @@
|
||||||
<h2>{{ $t('admin_dash.instance.registrations') }}</h2>
|
<h2>{{ $t('admin_dash.instance.registrations') }}</h2>
|
||||||
<ul class="setting-list">
|
<ul class="setting-list">
|
||||||
<li>
|
<li>
|
||||||
<BooleanSetting
|
<BooleanSetting path=":pleroma.:instance.:registrations_open">
|
||||||
source="admin"
|
|
||||||
path=":pleroma.:instance.:registrations_open"
|
|
||||||
draft-mode
|
|
||||||
>
|
|
||||||
REGISTRATIONS OPEN
|
REGISTRATIONS OPEN
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
<ul class="setting-list suboptions">
|
<ul class="setting-list suboptions">
|
||||||
<li>
|
<li>
|
||||||
<BooleanSetting
|
<BooleanSetting
|
||||||
source="admin"
|
|
||||||
path=":pleroma.:instance.:invites_enabled"
|
path=":pleroma.:instance.:invites_enabled"
|
||||||
parent-path=":pleroma.:instance.:registrations_open"
|
parent-path=":pleroma.:instance.:registrations_open"
|
||||||
:parent-invert="true"
|
parent-invert
|
||||||
draft-mode
|
|
||||||
>
|
>
|
||||||
INVITES ENABLED
|
INVITES ENABLED
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
|
@ -94,20 +130,27 @@
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<BooleanSetting
|
<BooleanSetting path=":pleroma.:instance.:birthday_required">
|
||||||
source="admin"
|
BDEY REQUIRED
|
||||||
path=":pleroma.:instance.:account_activation_required"
|
</BooleanSetting>
|
||||||
draft-mode
|
<ul class="setting-list suboptions">
|
||||||
>
|
<li>
|
||||||
|
<IntegerSetting
|
||||||
|
path=":pleroma.:instance.:birthday_min_age"
|
||||||
|
parent-path=":pleroma.:instance.:birthday_required"
|
||||||
|
>
|
||||||
|
BDEY age of consent
|
||||||
|
</IntegerSetting>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<BooleanSetting path=":pleroma.:instance.:account_activation_required">
|
||||||
ACTIVATION REQUIRED
|
ACTIVATION REQUIRED
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<BooleanSetting
|
<BooleanSetting path=":pleroma.:instance.:account_approval_required">
|
||||||
source="admin"
|
|
||||||
path=":pleroma.:instance.:account_approval_required"
|
|
||||||
draft-mode
|
|
||||||
>
|
|
||||||
APPROVAL REQUIRED
|
APPROVAL REQUIRED
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
</li>
|
</li>
|
||||||
|
@ -115,32 +158,24 @@
|
||||||
<h3>{{ $t('admin_dash.instance.captcha_header') }}</h3>
|
<h3>{{ $t('admin_dash.instance.captcha_header') }}</h3>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<BooleanSetting
|
<BooleanSetting :path="[':pleroma', 'Pleroma.Captcha', ':enabled']">
|
||||||
source="admin"
|
|
||||||
:path="[':pleroma', 'Pleroma.Captcha', ':enabled']"
|
|
||||||
draft-mode
|
|
||||||
>
|
|
||||||
CAPTCHA
|
CAPTCHA
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
<ul class="setting-list suboptions">
|
<ul class="setting-list suboptions">
|
||||||
<li>
|
<li>
|
||||||
<ChoiceSetting
|
<ChoiceSetting
|
||||||
source="admin"
|
|
||||||
:path="[':pleroma', 'Pleroma.Captcha', ':method']"
|
:path="[':pleroma', 'Pleroma.Captcha', ':method']"
|
||||||
:parent-path="[':pleroma', 'Pleroma.Captcha', ':enabled']"
|
:parent-path="[':pleroma', 'Pleroma.Captcha', ':enabled']"
|
||||||
:option-label-map="{
|
:option-label-map="{
|
||||||
'Pleroma.Captcha.Native': $t('admin_dash.captcha.native'),
|
'Pleroma.Captcha.Native': $t('admin_dash.captcha.native'),
|
||||||
'Pleroma.Captcha.Kocaptcha': $t('admin_dash.captcha.kocaptcha')
|
'Pleroma.Captcha.Kocaptcha': $t('admin_dash.captcha.kocaptcha')
|
||||||
}"
|
}"
|
||||||
draft-mode
|
|
||||||
>
|
>
|
||||||
CAPTCHA TYPE
|
CAPTCHA TYPE
|
||||||
</ChoiceSetting>
|
</ChoiceSetting>
|
||||||
<IntegerSetting
|
<IntegerSetting
|
||||||
source="admin"
|
|
||||||
:path="[':pleroma', 'Pleroma.Captcha', ':seconds_valid']"
|
:path="[':pleroma', 'Pleroma.Captcha', ':seconds_valid']"
|
||||||
:parent-path="[':pleroma', 'Pleroma.Captcha', ':enabled']"
|
:parent-path="[':pleroma', 'Pleroma.Captcha', ':enabled']"
|
||||||
draft-mode
|
|
||||||
>
|
>
|
||||||
VALID
|
VALID
|
||||||
</IntegerSetting>
|
</IntegerSetting>
|
||||||
|
@ -152,11 +187,7 @@
|
||||||
>
|
>
|
||||||
<h4>{{ $t('admin_dash.instance.kocaptcha') }}</h4>
|
<h4>{{ $t('admin_dash.instance.kocaptcha') }}</h4>
|
||||||
<li>
|
<li>
|
||||||
<StringSetting
|
<StringSetting :path="[':pleroma', 'Pleroma.Captcha.Kocaptcha', ':endpoint']">
|
||||||
source="admin"
|
|
||||||
:path="[':pleroma', 'Pleroma.Captcha.Kocaptcha', ':endpoint']"
|
|
||||||
draft-mode
|
|
||||||
>
|
|
||||||
cockAPTCHA ENDPOINT
|
cockAPTCHA ENDPOINT
|
||||||
</StringSetting>
|
</StringSetting>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -3,13 +3,28 @@ import Setting from './setting.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
...Setting,
|
...Setting,
|
||||||
|
props: {
|
||||||
|
...Setting.props,
|
||||||
|
indeterminateState: [String, Object]
|
||||||
|
},
|
||||||
components: {
|
components: {
|
||||||
...Setting.components,
|
...Setting.components,
|
||||||
Checkbox
|
Checkbox
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...Setting.computed,
|
||||||
|
isIndeterminate () {
|
||||||
|
return this.visibleState === this.indeterminateState
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...Setting.methods,
|
...Setting.methods,
|
||||||
getValue (e) {
|
getValue (e) {
|
||||||
|
// Basic tri-state toggle implementation
|
||||||
|
if (!!this.indeterminateState && !e && this.visibleState === true) {
|
||||||
|
// If we have indeterminate state, switching from true to false first goes through indeterminate
|
||||||
|
return this.indeterminateState
|
||||||
|
}
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,35 +4,37 @@
|
||||||
class="BooleanSetting"
|
class="BooleanSetting"
|
||||||
>
|
>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:model-value="draftMode ? draft :state"
|
:model-value="visibleState"
|
||||||
:disabled="shouldBeDisabled"
|
:disabled="shouldBeDisabled"
|
||||||
|
:indeterminate="isIndeterminate"
|
||||||
@update:modelValue="update"
|
@update:modelValue="update"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
v-if="!!$slots.default"
|
v-if="!!$slots.default"
|
||||||
class="label"
|
class="label"
|
||||||
|
:class="{ 'faint': shouldBeDisabled }"
|
||||||
>
|
>
|
||||||
<template v-if="backendDescription">
|
<template v-if="backendDescription">
|
||||||
{{ backendDescriptionLabel + ' ' }}
|
{{ backendDescriptionLabel }}
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<slot />
|
<slot />
|
||||||
</template>
|
</template>
|
||||||
</span>
|
</span>
|
||||||
{{ ' ' }}
|
|
||||||
<ModifiedIndicator
|
|
||||||
:changed="isChanged"
|
|
||||||
:onclick="reset"
|
|
||||||
/>
|
|
||||||
<ProfileSettingIndicator :is-profile="isProfileSetting" />
|
|
||||||
<DraftButtons />
|
|
||||||
<p
|
|
||||||
v-if="backendDescriptionDescription"
|
|
||||||
class="setting-description"
|
|
||||||
>
|
|
||||||
{{ backendDescriptionDescription + ' ' }}
|
|
||||||
</p>
|
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
|
<ModifiedIndicator
|
||||||
|
:changed="isChanged"
|
||||||
|
:onclick="reset"
|
||||||
|
/>
|
||||||
|
<ProfileSettingIndicator :is-profile="isProfileSetting" />
|
||||||
|
<DraftButtons />
|
||||||
|
<p
|
||||||
|
v-if="backendDescriptionDescription"
|
||||||
|
class="setting-description"
|
||||||
|
:class="{ 'faint': shouldBeDisabled }"
|
||||||
|
>
|
||||||
|
{{ backendDescriptionDescription + ' ' }}
|
||||||
|
</p>
|
||||||
</label>
|
</label>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,7 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
...Setting.computed,
|
...Setting.computed,
|
||||||
realOptions () {
|
realOptions () {
|
||||||
if (this.source === 'admin') {
|
if (this.realSource === 'admin') {
|
||||||
console.log(this.backendDescriptionSuggestions)
|
|
||||||
return this.backendDescriptionSuggestions.map(x => ({
|
return this.backendDescriptionSuggestions.map(x => ({
|
||||||
key: x,
|
key: x,
|
||||||
value: x,
|
value: x,
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
</template>
|
</template>
|
||||||
{{ ' ' }}
|
{{ ' ' }}
|
||||||
<Select
|
<Select
|
||||||
:model-value="draftMode ? draft :state"
|
:model-value="realDraftMode ? draft :state"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
@update:modelValue="update"
|
@update:modelValue="update"
|
||||||
>
|
>
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
class="DraftButtons"
|
class="DraftButtons"
|
||||||
>
|
>
|
||||||
<Popover
|
<Popover
|
||||||
|
v-if="$parent.isDirty"
|
||||||
trigger="hover"
|
trigger="hover"
|
||||||
:trigger-attrs="{ 'aria-label': $t('settings.commit_value_tooltip') }"
|
:trigger-attrs="{ 'aria-label': $t('settings.commit_value_tooltip') }"
|
||||||
>
|
>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
v-if="$parent.isDirty"
|
|
||||||
class="button button-default btn"
|
class="button button-default btn"
|
||||||
type="button"
|
type="button"
|
||||||
:title="$t('settings.commit_value')"
|
:title="$t('settings.commit_value')"
|
||||||
|
@ -27,13 +27,13 @@
|
||||||
</template>
|
</template>
|
||||||
</Popover>
|
</Popover>
|
||||||
<Popover
|
<Popover
|
||||||
|
v-if="$parent.isDirty"
|
||||||
trigger="hover"
|
trigger="hover"
|
||||||
:trigger-attrs="{ 'aria-label': $t('settings.reset_value_tooltip') }"
|
:trigger-attrs="{ 'aria-label': $t('settings.reset_value_tooltip') }"
|
||||||
>
|
>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
v-if="$parent.isDirty"
|
|
||||||
class="button button-default btn"
|
class="button button-default btn"
|
||||||
type="button"
|
type="button"
|
||||||
:title="$t('settings.reset_value')"
|
:title="$t('settings.reset_value')"
|
||||||
|
@ -49,13 +49,13 @@
|
||||||
</template>
|
</template>
|
||||||
</Popover>
|
</Popover>
|
||||||
<Popover
|
<Popover
|
||||||
|
v-if="$parent.canHardReset"
|
||||||
trigger="hover"
|
trigger="hover"
|
||||||
:trigger-attrs="{ 'aria-label': $t('settings.hard_reset_value_tooltip') }"
|
:trigger-attrs="{ 'aria-label': $t('settings.hard_reset_value_tooltip') }"
|
||||||
>
|
>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
v-if="$parent.canHardReset"
|
|
||||||
class="button button-default btn"
|
class="button button-default btn"
|
||||||
type="button"
|
type="button"
|
||||||
:title="$t('settings.hard_reset_value')"
|
:title="$t('settings.hard_reset_value')"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
v-if="matchesExpertLevel"
|
v-if="matchesExpertLevel"
|
||||||
class="NumberSetting"
|
class="NumberSetting"
|
||||||
>
|
>
|
||||||
<label :for="path">
|
<label :for="path" :class="{ 'faint': shouldBeDisabled }">
|
||||||
<template v-if="backendDescription">
|
<template v-if="backendDescription">
|
||||||
{{ backendDescriptionLabel + ' ' }}
|
{{ backendDescriptionLabel + ' ' }}
|
||||||
</template>
|
</template>
|
||||||
|
@ -16,9 +16,9 @@
|
||||||
class="number-input"
|
class="number-input"
|
||||||
type="number"
|
type="number"
|
||||||
:step="step || 1"
|
:step="step || 1"
|
||||||
:disabled="disabled"
|
:disabled="shouldBeDisabled"
|
||||||
:min="min || 0"
|
:min="min || 0"
|
||||||
:value="draftMode ? draft :state"
|
:value="realDraftMode ? draft :state"
|
||||||
@change="update"
|
@change="update"
|
||||||
>
|
>
|
||||||
{{ ' ' }}
|
{{ ' ' }}
|
||||||
|
@ -31,6 +31,7 @@
|
||||||
<p
|
<p
|
||||||
v-if="backendDescriptionDescription"
|
v-if="backendDescriptionDescription"
|
||||||
class="setting-description"
|
class="setting-description"
|
||||||
|
:class="{ 'faint': shouldBeDisabled }"
|
||||||
>
|
>
|
||||||
{{ backendDescriptionDescription + ' ' }}
|
{{ backendDescriptionDescription + ' ' }}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import Checkbox from 'src/components/checkbox/checkbox.vue'
|
|
||||||
import ModifiedIndicator from './modified_indicator.vue'
|
import ModifiedIndicator from './modified_indicator.vue'
|
||||||
import ProfileSettingIndicator from './profile_setting_indicator.vue'
|
import ProfileSettingIndicator from './profile_setting_indicator.vue'
|
||||||
import DraftButtons from './draft_buttons.vue'
|
import DraftButtons from './draft_buttons.vue'
|
||||||
|
@ -6,7 +5,6 @@ import { get, set } from 'lodash'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Checkbox,
|
|
||||||
ModifiedIndicator,
|
ModifiedIndicator,
|
||||||
DraftButtons,
|
DraftButtons,
|
||||||
ProfileSettingIndicator
|
ProfileSettingIndicator
|
||||||
|
@ -33,10 +31,18 @@ export default {
|
||||||
},
|
},
|
||||||
source: {
|
source: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'default'
|
default: undefined
|
||||||
},
|
},
|
||||||
draftMode: {
|
draftMode: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
default: undefined
|
||||||
|
}
|
||||||
|
},
|
||||||
|
inject: {
|
||||||
|
defaultSource: {
|
||||||
|
default: 'default'
|
||||||
|
},
|
||||||
|
defaultDraftMode: {
|
||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -46,7 +52,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
if (this.draftMode) {
|
if (this.realDraftMode) {
|
||||||
this.draft = this.state
|
this.draft = this.state
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -59,6 +65,15 @@ export default {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
visibleState () {
|
||||||
|
return this.realDraftMode ? this.draft : this.state
|
||||||
|
},
|
||||||
|
realSource () {
|
||||||
|
return this.source || this.defaultSource
|
||||||
|
},
|
||||||
|
realDraftMode () {
|
||||||
|
return typeof this.draftMode === 'undefined' ? this.defaultDraftMode : this.draftMode
|
||||||
|
},
|
||||||
backendDescription () {
|
backendDescription () {
|
||||||
return get(this.$store.state.adminSettings.descriptions, this.path)
|
return get(this.$store.state.adminSettings.descriptions, this.path)
|
||||||
},
|
},
|
||||||
|
@ -76,7 +91,7 @@ export default {
|
||||||
return this.disabled || (parentValue !== null ? (this.parentInvert ? parentValue : !parentValue) : false)
|
return this.disabled || (parentValue !== null ? (this.parentInvert ? parentValue : !parentValue) : false)
|
||||||
},
|
},
|
||||||
configSource () {
|
configSource () {
|
||||||
switch (this.source) {
|
switch (this.realSource) {
|
||||||
case 'profile':
|
case 'profile':
|
||||||
return this.$store.state.profileConfig
|
return this.$store.state.profileConfig
|
||||||
case 'admin':
|
case 'admin':
|
||||||
|
@ -86,7 +101,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
configSink () {
|
configSink () {
|
||||||
switch (this.source) {
|
switch (this.realSource) {
|
||||||
case 'profile':
|
case 'profile':
|
||||||
return (k, v) => this.$store.dispatch('setProfileOption', { name: k, value: v })
|
return (k, v) => this.$store.dispatch('setProfileOption', { name: k, value: v })
|
||||||
case 'admin':
|
case 'admin':
|
||||||
|
@ -96,7 +111,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
defaultState () {
|
defaultState () {
|
||||||
switch (this.source) {
|
switch (this.realSource) {
|
||||||
case 'profile':
|
case 'profile':
|
||||||
return {}
|
return {}
|
||||||
default:
|
default:
|
||||||
|
@ -104,10 +119,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isProfileSetting () {
|
isProfileSetting () {
|
||||||
return this.source === 'profile'
|
return this.realSource === 'profile'
|
||||||
},
|
},
|
||||||
isChanged () {
|
isChanged () {
|
||||||
switch (this.source) {
|
switch (this.realSource) {
|
||||||
case 'profile':
|
case 'profile':
|
||||||
case 'admin':
|
case 'admin':
|
||||||
return false
|
return false
|
||||||
|
@ -116,10 +131,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isDirty () {
|
isDirty () {
|
||||||
return this.draftMode && this.draft !== this.state
|
return this.realDraftMode && this.draft !== this.state
|
||||||
},
|
},
|
||||||
canHardReset () {
|
canHardReset () {
|
||||||
return this.source === 'admin' && this.$store.state.adminSettings.modifiedPaths.has(this.path)
|
return this.realSource === 'admin' && this.$store.state.adminSettings.modifiedPaths.has(this.path)
|
||||||
},
|
},
|
||||||
matchesExpertLevel () {
|
matchesExpertLevel () {
|
||||||
return (this.expert || 0) <= this.$store.state.config.expertLevel > 0
|
return (this.expert || 0) <= this.$store.state.config.expertLevel > 0
|
||||||
|
@ -130,20 +145,20 @@ export default {
|
||||||
return e.target.value
|
return e.target.value
|
||||||
},
|
},
|
||||||
update (e) {
|
update (e) {
|
||||||
if (this.draftMode) {
|
if (this.realDraftMode) {
|
||||||
this.draft = this.getValue(e)
|
this.draft = this.getValue(e)
|
||||||
} else {
|
} else {
|
||||||
this.configSink(this.path, this.getValue(e))
|
this.configSink(this.path, this.getValue(e))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
commitDraft () {
|
commitDraft () {
|
||||||
if (this.draftMode) {
|
if (this.realDraftMode) {
|
||||||
this.configSink(this.path, this.draft)
|
this.configSink(this.path, this.draft)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reset () {
|
reset () {
|
||||||
console.log('reset')
|
console.log('reset')
|
||||||
if (this.draftMode) {
|
if (this.realDraftMode) {
|
||||||
console.log(this.draft)
|
console.log(this.draft)
|
||||||
console.log(this.state)
|
console.log(this.state)
|
||||||
this.draft = this.state
|
this.draft = this.state
|
||||||
|
@ -152,7 +167,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hardReset () {
|
hardReset () {
|
||||||
switch (this.source) {
|
switch (this.realSource) {
|
||||||
case 'admin':
|
case 'admin':
|
||||||
return this.$store.dispatch('resetAdminSetting', { path: this.path })
|
return this.$store.dispatch('resetAdminSetting', { path: this.path })
|
||||||
.then(() => { this.draft = this.state })
|
.then(() => { this.draft = this.state })
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
v-if="matchesExpertLevel"
|
v-if="matchesExpertLevel"
|
||||||
class="StringSetting"
|
class="StringSetting"
|
||||||
>
|
>
|
||||||
<label :for="path">
|
<label :for="path" :class="{ 'faint': shouldBeDisabled }">
|
||||||
<template v-if="backendDescription">
|
<template v-if="backendDescription">
|
||||||
{{ backendDescriptionLabel + ' ' }}
|
{{ backendDescriptionLabel + ' ' }}
|
||||||
</template>
|
</template>
|
||||||
|
@ -15,8 +15,8 @@
|
||||||
:id="path"
|
:id="path"
|
||||||
class="string-input"
|
class="string-input"
|
||||||
step="1"
|
step="1"
|
||||||
:disabled="disabled"
|
:disabled="shouldBeDisabled"
|
||||||
:value="draftMode ? draft :state"
|
:value="realDraftMode ? draft : state"
|
||||||
@change="update"
|
@change="update"
|
||||||
>
|
>
|
||||||
{{ ' ' }}
|
{{ ' ' }}
|
||||||
|
@ -29,6 +29,7 @@
|
||||||
<p
|
<p
|
||||||
v-if="backendDescriptionDescription"
|
v-if="backendDescriptionDescription"
|
||||||
class="setting-description"
|
class="setting-description"
|
||||||
|
:class="{ 'faint': shouldBeDisabled }"
|
||||||
>
|
>
|
||||||
{{ backendDescriptionDescription + ' ' }}
|
{{ backendDescriptionDescription + ' ' }}
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Add table
Reference in a new issue