[Refactor] Cleanup agent store and actions (#373)
* Cleanup agent store and actions * Move set/create/update/destroy to helpers * Update mutation specs * Add specs for API helper * Fix edit/delete action visibility * Add actions specs * Remove unused API helpers * Remove duplicates * Remove duplicates * Fix duplicate
This commit is contained in:
parent
a92e3817f8
commit
2ce7438c79
26 changed files with 613 additions and 576 deletions
19
app/javascript/shared/helpers/vuex/mutationHelpers.js
Normal file
19
app/javascript/shared/helpers/vuex/mutationHelpers.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
export const set = (state, data) => {
|
||||
state.records = data;
|
||||
};
|
||||
|
||||
export const create = (state, data) => {
|
||||
state.records.push(data);
|
||||
};
|
||||
|
||||
export const update = (state, data) => {
|
||||
state.records.forEach((element, index) => {
|
||||
if (element.id === data.id) {
|
||||
state.records[index] = data;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const destroy = (state, id) => {
|
||||
state.records = state.records.filter(record => record.id !== id);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue