mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
store action add/remove id values in hidden input fields
This commit is contained in:
parent
66776eed01
commit
5822736f19
@ -143,9 +143,4 @@ div.flex-bloc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
select#chill_activitybundle_activity_persons,
|
|
||||||
select#chill_activitybundle_activity_thirdParties,
|
|
||||||
select#chill_activitybundle_activity_users {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
@ -4,6 +4,20 @@ import { createStore } from 'vuex';
|
|||||||
const debug = process.env.NODE_ENV !== 'production';
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
//console.log('window.activity', window.activity);
|
//console.log('window.activity', window.activity);
|
||||||
|
|
||||||
|
const addIdToValue = (string, id) => {
|
||||||
|
let array = string ? string.split(',') : [];
|
||||||
|
array.push(id.toString());
|
||||||
|
let str = array.join();
|
||||||
|
return str;
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeIdFromValue = (string, id) => {
|
||||||
|
let array = string.split(',');
|
||||||
|
array = array.filter(el => el !== id.toString());
|
||||||
|
let str = array.join();
|
||||||
|
return str;
|
||||||
|
};
|
||||||
|
|
||||||
const store = createStore({
|
const store = createStore({
|
||||||
strict: debug,
|
strict: debug,
|
||||||
state: {
|
state: {
|
||||||
@ -27,7 +41,7 @@ const store = createStore({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
removePersonInvolved(state, payload) {
|
removePersonInvolved(state, payload) {
|
||||||
console.log('### mutation removePersonInvolved', payload.type);
|
//console.log('### mutation removePersonInvolved', payload.type);
|
||||||
switch (payload.type) {
|
switch (payload.type) {
|
||||||
case 'person':
|
case 'person':
|
||||||
state.activity.persons = state.activity.persons.filter(person => person !== payload);
|
state.activity.persons = state.activity.persons.filter(person => person !== payload);
|
||||||
@ -43,15 +57,39 @@ const store = createStore({
|
|||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
addPersonsInvolved({ commit }, payload) {
|
addPersonsInvolved({ commit }, payload) {
|
||||||
console.log('### action addPersonsInvolved', payload);
|
console.log('### action addPersonsInvolved', payload.result.type);
|
||||||
//let el = document.getElementById('form['activity']['xxx']['xxxx']');
|
switch (payload.result.type) {
|
||||||
//let option = document.createElement('option');
|
case 'person':
|
||||||
//option.value = person.id;
|
let aPersons = document.getElementById("chill_activitybundle_activity_persons");
|
||||||
//el.appendChild(option);
|
aPersons.value = addIdToValue(aPersons.value, payload.result.id);
|
||||||
|
break;
|
||||||
|
case 'thirdparty':
|
||||||
|
let aThirdParties = document.getElementById("chill_activitybundle_activity_thirdParties");
|
||||||
|
aThirdParties.value = addIdToValue(aThirdParties.value, payload.result.id);
|
||||||
|
break;
|
||||||
|
case 'user':
|
||||||
|
let aUsers = document.getElementById("chill_activitybundle_activity_users");
|
||||||
|
aUsers.value = addIdToValue(aUsers.value, payload.result.id);
|
||||||
|
break;
|
||||||
|
};
|
||||||
commit('addPersonsInvolved', payload);
|
commit('addPersonsInvolved', payload);
|
||||||
},
|
},
|
||||||
removePersonInvolved({ commit }, payload) {
|
removePersonInvolved({ commit }, payload) {
|
||||||
console.log('### action removePersonInvolved', payload);
|
console.log('### action removePersonInvolved', payload);
|
||||||
|
switch (payload.type) {
|
||||||
|
case 'person':
|
||||||
|
let aPersons = document.getElementById("chill_activitybundle_activity_persons");
|
||||||
|
aPersons.value = removeIdFromValue(aPersons.value, payload.id);
|
||||||
|
break;
|
||||||
|
case 'thirdparty':
|
||||||
|
let aThirdParties = document.getElementById("chill_activitybundle_activity_thirdParties");
|
||||||
|
aThirdParties.value = removeIdFromValue(aThirdParties.value, payload.id);
|
||||||
|
break;
|
||||||
|
case 'user':
|
||||||
|
let aUsers = document.getElementById("chill_activitybundle_activity_users");
|
||||||
|
aUsers.value = removeIdFromValue(aUsers.value, payload.id);
|
||||||
|
break;
|
||||||
|
};
|
||||||
commit('removePersonInvolved', payload);
|
commit('removePersonInvolved', payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user