pleroma-fe/src/components/settings_modal/helpers/boolean_setting.js

31 lines
759 B
JavaScript
Raw Normal View History

2021-04-07 20:53:58 +03:00
import Checkbox from 'src/components/checkbox/checkbox.vue'
import Setting from './setting.js'
2021-04-07 20:53:58 +03:00
export default {
...Setting,
props: {
...Setting.props,
2026-01-06 16:22:52 +02:00
indeterminateState: [String, Object],
},
2021-04-07 20:53:58 +03:00
components: {
...Setting.components,
2026-01-06 16:22:52 +02:00
Checkbox,
2021-04-07 20:53:58 +03:00
},
computed: {
...Setting.computed,
2026-01-06 16:22:52 +02:00
isIndeterminate() {
return this.visibleState === this.indeterminateState
2026-01-06 16:22:52 +02:00
},
},
methods: {
...Setting.methods,
2026-01-06 16:22:52 +02:00
getValue(e) {
// Basic tri-state toggle implementation
2026-09-04 01:05:52 +03:00
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
2026-01-06 16:22:52 +02:00
},
},
2021-04-07 20:53:58 +03:00
}