all files / src/vuex/ mutations.js

100% Statements 29/29
100% Branches 14/14
100% Functions 7/7
100% Lines 10/10
7 statements, 5 branches 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                              
import * as types from './mutation_types'
import getters from './getters'
import _ from 'underscore'
 
export default {
  [types.CHANGE_TITLE] (state, data) {
    getters.getListById(state, data.id).title = data.title
  },
  [types.POPULATE_SHOPPING_LISTS] (state, lists) {
    state.shoppinglists = lists
  },
  [types.ADD_SHOPPING_LIST] (state, newList) {
    if (_.isObject(newList)) {
      state.shoppinglists.push(newList)
    }
  },
  [types.DELETE_SHOPPING_LIST] (state, id) {
    state.shoppinglists = _.reject(state.shoppinglists, (list) => {
      return list.id === id
    })
  }
}