Chatwoot/app/javascript/shared/helpers/vuex/mutationHelpers.js
Pranav Raj S 47ec7ad7c9
Feature: Ability to customise widget color (#903)
- Use Chrome style color-picker
2020-05-30 17:28:00 +05:30

30 lines
693 B
JavaScript

import Vue from 'vue';
export const set = (state, data) => {
state.records = data;
};
export const create = (state, data) => {
state.records.push(data);
};
export const setSingleRecord = (state, data) => {
const recordIndex = state.records.findIndex(record => record.id === data.id);
if (recordIndex > -1) {
state.records[recordIndex] = data;
} else {
create(state, data);
}
};
export const update = (state, data) => {
state.records.forEach((element, index) => {
if (element.id === data.id) {
Vue.set(state.records, index, data);
}
});
};
export const destroy = (state, id) => {
state.records = state.records.filter(record => record.id !== id);
};