aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/helpers/boolean_setting.js
blob: 199d3d0f020e380ab554eef31ae24bd68e057be3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import Checkbox from 'src/components/checkbox/checkbox.vue'
import Setting from './setting.js'

export default {
  ...Setting,
  props: {
    ...Setting.props,
    indeterminateState: [String, Object]
  },
  components: {
    ...Setting.components,
    Checkbox
  },
  computed: {
    ...Setting.computed,
    isIndeterminate () {
      return this.visibleState === this.indeterminateState
    }
  },
  methods: {
    ...Setting.methods,
    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
    }
  }
}