all files / src/vuex/ store.js

63.16% Statements 12/19
66.67% Branches 4/6
16.67% Functions 1/6
50% Lines 7/14
1 branch Ignored     
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                                                                                        
import Vue from 'vue'
import Vuex from 'vuex'
 
Vue.use(Vuex)
Vue.config.debug = true
 
const state = {
  selected: null,
  placeholder: 'Select a Country',
  multiple: true,
  maxHeight: '400px',
  options: {
    advanced: require('../countries/advanced.js'),
    simple: require('../countries/simple.js'),
  },
  optionType: 'advanced'
}
 
const mutations = {
  SET_SELECTED (state, selected) {
    state.selected = selected
  },
 
  TOGGLE_OPTION_TYPE (state) {
    if( state.optionType === 'advanced' ) {
      state.optionType = 'simple'
    } else {
      state.optionType = 'advanced'
    }
  },
 
  SET_PLACEHOLDER (state, placeholder) {
    state.placeholder = placeholder
  },
 
  TOGGLE_MULTIPLE (state) {
    state.multiple = ! state.multiple
  },
 
  SET_MAX_HEIGHT (state, maxHeight) {
    state.maxHeight = maxHeight
  }
}
 
export default new Vuex.Store({
  state,
  mutations
})