diff options
| author | HJ <30-hj@users.noreply.git.pleroma.social> | 2023-05-24 18:55:20 +0000 |
|---|---|---|
| committer | HJ <30-hj@users.noreply.git.pleroma.social> | 2023-05-24 18:55:20 +0000 |
| commit | c730c9b6d0fac2b79e0fa5900117c66d073e4a9d (patch) | |
| tree | b33e33e9da2225c05cce2f47f87c5bc54d01cdc1 /src/components/settings_modal/helpers/choice_setting.js | |
| parent | 4bf085b8feb81ad52bad6cb8979786df22baba9e (diff) | |
| parent | cbd22d52b8d0cacf01f71edcb799294b93754f60 (diff) | |
Merge branch 'improve_settings_reusability' into 'develop'
AdminFE functionality in PleromaFE
See merge request pleroma/pleroma-fe!1800
Diffstat (limited to 'src/components/settings_modal/helpers/choice_setting.js')
| -rw-r--r-- | src/components/settings_modal/helpers/choice_setting.js | 68 |
1 files changed, 29 insertions, 39 deletions
diff --git a/src/components/settings_modal/helpers/choice_setting.js b/src/components/settings_modal/helpers/choice_setting.js index 3da559fe..bdeece76 100644 --- a/src/components/settings_modal/helpers/choice_setting.js +++ b/src/components/settings_modal/helpers/choice_setting.js @@ -1,51 +1,41 @@ -import { get, set } from 'lodash' import Select from 'src/components/select/select.vue' -import ModifiedIndicator from './modified_indicator.vue' -import ServerSideIndicator from './server_side_indicator.vue' +import Setting from './setting.js' + export default { + ...Setting, components: { - Select, - ModifiedIndicator, - ServerSideIndicator + ...Setting.components, + Select }, - props: [ - 'path', - 'disabled', - 'options', - 'expert' - ], - computed: { - pathDefault () { - const [firstSegment, ...rest] = this.path.split('.') - return [firstSegment + 'DefaultValue', ...rest].join('.') + props: { + ...Setting.props, + options: { + type: Array, + required: false }, - state () { - const value = get(this.$parent, this.path) - if (value === undefined) { - return this.defaultState - } else { - return value + optionLabelMap: { + type: Object, + required: false, + default: {} + } + }, + computed: { + ...Setting.computed, + realOptions () { + if (this.realSource === 'admin') { + return this.backendDescriptionSuggestions.map(x => ({ + key: x, + value: x, + label: this.optionLabelMap[x] || x + })) } - }, - defaultState () { - return get(this.$parent, this.pathDefault) - }, - isServerSide () { - return this.path.startsWith('serverSide_') - }, - isChanged () { - return !this.path.startsWith('serverSide_') && this.state !== this.defaultState - }, - matchesExpertLevel () { - return (this.expert || 0) <= this.$parent.expertLevel + return this.options } }, methods: { - update (e) { - set(this.$parent, this.path, e) - }, - reset () { - set(this.$parent, this.path, this.defaultState) + ...Setting.methods, + getValue (e) { + return e } } } |
