2020-05-08 18:02:18 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
namespaced: true,
|
|
|
|
strict: true,
|
|
|
|
state: {
|
2020-05-30 12:54:05 +02:00
|
|
|
connections: []
|
2020-05-12 18:27:31 +02:00
|
|
|
},
|
|
|
|
getters: {
|
2020-05-30 12:54:05 +02:00
|
|
|
getConnections: state => state.connections
|
2020-05-08 18:02:18 +02:00
|
|
|
},
|
|
|
|
mutations: {
|
2020-05-12 18:27:31 +02:00
|
|
|
ADD_CONNECTION (state, connection) {
|
|
|
|
state.connections.push(connection);
|
|
|
|
},
|
2020-05-23 13:32:14 +02:00
|
|
|
DELETE_CONNECTION (state, connection) {
|
|
|
|
state.connections = state.connections.filter(el => el.uid !== connection.uid);
|
|
|
|
},
|
2020-05-23 22:02:09 +02:00
|
|
|
EDIT_CONNECTION (state, connection) {
|
|
|
|
const editedConnections = state.connections.map(conn => {
|
|
|
|
if (conn.uid === connection.uid) return connection;
|
|
|
|
return conn;
|
|
|
|
});
|
|
|
|
state.connections = editedConnections;
|
|
|
|
state.selected_conection = {};
|
|
|
|
},
|
2020-05-22 19:32:55 +02:00
|
|
|
UPDATE_CONNECTIONS (state, connections) {
|
|
|
|
state.connections = connections;
|
2020-05-08 18:02:18 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
actions: {
|
2020-05-12 18:27:31 +02:00
|
|
|
addConnection ({ commit }, connection) {
|
|
|
|
commit('ADD_CONNECTION', connection);
|
|
|
|
},
|
2020-05-23 13:32:14 +02:00
|
|
|
deleteConnection ({ commit }, connection) {
|
|
|
|
commit('DELETE_CONNECTION', connection);
|
|
|
|
},
|
|
|
|
editConnection ({ commit }, connection) {
|
|
|
|
commit('EDIT_CONNECTION', connection);
|
|
|
|
},
|
2020-05-22 19:32:55 +02:00
|
|
|
updateConnections ({ commit }, connections) {
|
|
|
|
commit('UPDATE_CONNECTIONS', connections);
|
2020-05-08 18:02:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|