From b7a97b86037fdfd9f9b4d816fd00db06fbaadc0a Mon Sep 17 00:00:00 2001
From: Henry Jameson
Date: Tue, 2 Dec 2025 20:44:14 +0200
Subject: [PATCH] merge multicheckbox and list inputs
---
.../settings_modal/admin_tabs/instance_tab.js | 22 ++---
.../admin_tabs/instance_tab.vue | 3 +-
.../settings_modal/admin_tabs/links_tab.js | 6 +-
.../settings_modal/admin_tabs/links_tab.vue | 9 +-
.../settings_modal/helpers/list_setting.js | 97 +++++++++++++++----
.../settings_modal/helpers/list_setting.vue | 68 +++++++------
.../helpers/multicheckbox_setting.js | 47 ---------
.../helpers/multicheckbox_setting.vue | 48 ---------
8 files changed, 138 insertions(+), 162 deletions(-)
delete mode 100644 src/components/settings_modal/helpers/multicheckbox_setting.js
delete mode 100644 src/components/settings_modal/helpers/multicheckbox_setting.vue
diff --git a/src/components/settings_modal/admin_tabs/instance_tab.js b/src/components/settings_modal/admin_tabs/instance_tab.js
index 4c4203c60..119c7cd35 100644
--- a/src/components/settings_modal/admin_tabs/instance_tab.js
+++ b/src/components/settings_modal/admin_tabs/instance_tab.js
@@ -4,17 +4,10 @@ import IntegerSetting from '../helpers/integer_setting.vue'
import StringSetting from '../helpers/string_setting.vue'
import GroupSetting from '../helpers/group_setting.vue'
import AttachmentSetting from '../helpers/attachment_setting.vue'
-import MultiCheckboxSetting from '../helpers/multicheckbox_setting.vue'
+import ListSetting from '../helpers/list_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
-import { library } from '@fortawesome/fontawesome-svg-core'
-import {
- faGlobe
-} from '@fortawesome/free-solid-svg-icons'
-
-library.add(
- faGlobe
-)
+import { get } from 'lodash'
const InstanceTab = {
provide () {
@@ -29,11 +22,18 @@ const InstanceTab = {
IntegerSetting,
StringSetting,
AttachmentSetting,
- MultiCheckboxSetting,
+ ListSetting,
GroupSetting
},
computed: {
- ...SharedComputedObject()
+ ...SharedComputedObject(),
+ providersOptions () {
+ const desc = get(this.$store.state.adminSettings.descriptions, [':pleroma', 'Pleroma.Web.Metadata', ':providers'])
+ return new Set(desc.suggestions.map(option => ({
+ label: option.replace('Pleroma.Web.Metadata.Providers.', ''),
+ value: option
+ })))
+ },
}
}
diff --git a/src/components/settings_modal/admin_tabs/instance_tab.vue b/src/components/settings_modal/admin_tabs/instance_tab.vue
index d8d5ae889..a46686029 100644
--- a/src/components/settings_modal/admin_tabs/instance_tab.vue
+++ b/src/components/settings_modal/admin_tabs/instance_tab.vue
@@ -134,7 +134,8 @@
{{ $t('admin_dash.instance.rich_metadata') }}
-
-
diff --git a/src/components/settings_modal/admin_tabs/links_tab.js b/src/components/settings_modal/admin_tabs/links_tab.js
index 9bd58344c..1bf626643 100644
--- a/src/components/settings_modal/admin_tabs/links_tab.js
+++ b/src/components/settings_modal/admin_tabs/links_tab.js
@@ -5,7 +5,6 @@ import StringSetting from '../helpers/string_setting.vue'
import GroupSetting from '../helpers/group_setting.vue'
import AttachmentSetting from '../helpers/attachment_setting.vue'
import ListSetting from '../helpers/list_setting.vue'
-import MultiCheckboxSetting from '../helpers/multicheckbox_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
import { get } from 'lodash'
@@ -24,13 +23,12 @@ const MediaProxyTab = {
StringSetting,
AttachmentSetting,
GroupSetting,
- ListSetting,
- MultiCheckboxSetting
+ ListSetting
},
computed: {
ttlSettersOptions () {
const desc = get(this.$store.state.adminSettings.descriptions, ':pleroma.:rich_media.:ttl_setters')
- return new Set([...desc.suggestions, 'Pleroma.Web.RichMedia.Parser.TTL.Opengraph'].map(option => ({
+ return new Set(desc.suggestions.map(option => ({
label: option.replace('Pleroma.Web.RichMedia.Parser.TTL.', ''),
value: option
})))
diff --git a/src/components/settings_modal/admin_tabs/links_tab.vue b/src/components/settings_modal/admin_tabs/links_tab.vue
index 11559c61d..c4677ee63 100644
--- a/src/components/settings_modal/admin_tabs/links_tab.vue
+++ b/src/components/settings_modal/admin_tabs/links_tab.vue
@@ -7,7 +7,7 @@
-
-
@@ -18,13 +18,16 @@
/>
-
-
-
-
+
-
diff --git a/src/components/settings_modal/helpers/list_setting.js b/src/components/settings_modal/helpers/list_setting.js
index f744e925b..3ce7e5bef 100644
--- a/src/components/settings_modal/helpers/list_setting.js
+++ b/src/components/settings_modal/helpers/list_setting.js
@@ -1,41 +1,100 @@
+import Checkbox from 'src/components/checkbox/checkbox.vue'
import Setting from './setting.js'
export default {
...Setting,
data () {
return {
- newValue: ''
+ newValue: '',
}
},
components: {
- ...Setting.components
+ ...Setting.components,
+ Checkbox
},
props: {
- ...Setting.props
+ ...Setting.props,
+ ignoreSuggestions: {
+ required: false,
+ type: Boolean
+ },
+ overrideAvailableOptions: {
+ required: false,
+ type: Set
+ },
+ allowNew: {
+ required: false,
+ type: Set,
+ default: true
+ }
},
computed: {
- ...Setting.computed
+ ...Setting.computed,
+ valueSet () {
+ return new Set(this.visibleState)
+ },
+ suggestions () {
+ const suggestions = this.backendDescription?.suggestions
+ if (suggestions) {
+ return new Set(this.backendDescription.suggestions)
+ } else {
+ return new Set()
+ }
+ },
+ extraEntries () {
+ if (this.ignoreSuggestions) return [...this.valueSet.values()]
+ return [...this.valueSet.values()].filter((x) => {
+ return !this.suggestions.has(x)
+ })
+ },
+ builtinEntries () {
+ if (this.ignoreSuggestions) return []
+ if (this.overrideAvailableOptions) {
+ return [...this.overrideAvailableOptions]
+ }
+
+ const builtins = [...this.valueSet.values()].filter((x) => {
+ return this.suggestions.has(x)
+ })
+
+ return builtins.map((option) => ({
+ label: option,
+ value: option
+ }))
+ }
},
methods: {
...Setting.methods,
- addNew () {
- this.update({ newValue: this.newValue })
+ optionPresent (option) {
+ return this.valueSet.has(option)
},
- getValue ({ event, index, newValue, remove }) {
- if (newValue) {
- this.newValue = ''
- return [...this.visibleState, newValue]
- } else if (remove) {
- const pre = this.visibleState.slice(0, index)
- const post = this.visibleState.slice(index + 1)
+ getValue ({ event, index, eventType }) {
+ switch (eventType) {
+ case 'toggle': {
+ this.newValue = ''
+ return [...this.visibleState, event]
+ }
- return [...pre, ...post]
- } else {
- const pre = this.visibleState.slice(0, index)
- const post = this.visibleState.slice(index + 1)
- const string = event?.target?.value
+ case 'add': {
+ const res = [...this.visibleState, this.newValue]
+ this.newValue = ''
+ return res
+ }
- return [...pre, string, ...post]
+ case 'remove': {
+ const pre = this.visibleState.slice(0, index)
+ const post = this.visibleState.slice(index + 1)
+
+ return [...pre, ...post]
+ }
+
+ case 'edit': {
+ const pre = this.visibleState.slice(0, index)
+ const post = this.visibleState.slice(index + 1)
+ const string = event?.target?.value
+
+ return [...pre, string, ...post]
+ }
}
}
}
diff --git a/src/components/settings_modal/helpers/list_setting.vue b/src/components/settings_modal/helpers/list_setting.vue
index ef3315a14..364766e63 100644
--- a/src/components/settings_modal/helpers/list_setting.vue
+++ b/src/components/settings_modal/helpers/list_setting.vue
@@ -23,36 +23,46 @@
{{ backendDescriptionDescription + ' ' }}
.ListSetting {
- li.btn-group {
+ .btn-group {
display: flex
}
}
diff --git a/src/components/settings_modal/helpers/multicheckbox_setting.js b/src/components/settings_modal/helpers/multicheckbox_setting.js
deleted file mode 100644
index 3d64a8a56..000000000
--- a/src/components/settings_modal/helpers/multicheckbox_setting.js
+++ /dev/null
@@ -1,47 +0,0 @@
-import Checkbox from 'src/components/checkbox/checkbox.vue'
-import Setting from './setting.js'
-
-export default {
- ...Setting,
- props: {
- ...Setting.props,
- overrideAvailableOptions: {
- required: false,
- type: Set
- }
- },
- components: {
- ...Setting.components,
- Checkbox
- },
- computed: {
- ...Setting.computed,
- availableOptions () {
- if (this.overrideAvailableOptions) {
- return new Set(this.overrideAvailableOptions)
- }
- return new Set(this.backendDescription?.suggestions.map((option) => ({
- label: option,
- value: option
- })))
- },
- valueSet () {
- return new Set(this.visibleState)
- }
- },
- methods: {
- ...Setting.methods,
- optionPresent (option) {
- return this.valueSet.has(option)
- },
- getValue ({ event, option }) {
- const set = new Set(this.visibleState)
- if (event) {
- set.add(option)
- } else {
- set.delete(option)
- }
- return [...set]
- }
- }
-}
diff --git a/src/components/settings_modal/helpers/multicheckbox_setting.vue b/src/components/settings_modal/helpers/multicheckbox_setting.vue
deleted file mode 100644
index 083f568c1..000000000
--- a/src/components/settings_modal/helpers/multicheckbox_setting.vue
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-