mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-22 08:37:43 +00:00
transformValue to payload, body and method
This commit is contained in:
parent
132f11298e
commit
21cc0007fb
@ -55,13 +55,36 @@ export default {
|
||||
})).catch(error => this.$store.commit('catchError', error));
|
||||
},
|
||||
updateSocialIssues(value) {
|
||||
console.log('@@@ CHANGE value', value);
|
||||
console.log('@@@ CHANGED value');
|
||||
this.$store.dispatch('updateSocialIssues', this.transformValue(value));
|
||||
},
|
||||
transformValue(value) {
|
||||
let payload = value;
|
||||
let body = {}; //{ type: "social_issue", id: 5 };
|
||||
let method = ''; //'POST' : 'DELETE';
|
||||
transformValue(updated) {
|
||||
let stored = this.value;
|
||||
//console.log('updated', updated, updated.length);
|
||||
//console.log('stored', stored, stored.length);
|
||||
|
||||
let added = updated.filter(x => stored.indexOf(x) === -1).shift();
|
||||
//console.log('added', added);
|
||||
|
||||
let removed = stored.filter(x => updated.indexOf(x) === -1).shift();
|
||||
//console.log('removed', removed);
|
||||
|
||||
let method = (typeof removed === 'undefined') ? 'POST' : 'DELETE';
|
||||
console.log('method', method);
|
||||
|
||||
//let concat = (...arrays) => [].concat(...arrays.filter(Array.isArray));
|
||||
//let changed = concat(added, removed);
|
||||
//let changed = [...new Set([...added, ...removed ])];
|
||||
|
||||
let changed = (typeof removed === 'undefined') ? added : removed;
|
||||
//console.log('changed', changed);
|
||||
|
||||
let body = { type: "social_issue", id: changed.id };
|
||||
|
||||
console.log('body', body);
|
||||
console.log(changed.text);
|
||||
|
||||
let payload = updated;
|
||||
return { payload, body, method };
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ let initPromise = getAccompanyingCourse(id)
|
||||
})).catch((error) => { commit('catchError', error) });
|
||||
},
|
||||
updateSocialIssues({ commit }, { payload, body, method }) {
|
||||
console.log('## action: payload', { payload, body, method });
|
||||
//console.log('## action: payload', { payload, body, method });
|
||||
|
||||
//postSocialIssue(id, body, method)
|
||||
//.then(response => new Promise((resolve, reject) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user