mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 22:04:23 +00:00
visgraph: prepare PATCH relationship when submitting (wip)
This commit is contained in:
parent
2099edefc5
commit
adac384279
@ -305,19 +305,43 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
submitRelationship() {
|
submitRelationship() {
|
||||||
console.log('submitRelationship')
|
console.log('submitRelationship with action', this.modal.action)
|
||||||
if (this.modal.action !== 'delete') {
|
switch (this.modal.action) {
|
||||||
return postRelationship(
|
|
||||||
this.getPerson(this.modal.data.from), this.getPerson(this.modal.data.to), this.relation, this.reverse
|
case 'create':
|
||||||
)
|
return postRelationship(
|
||||||
.then(relationship => new Promise(resolve => {
|
this.getPerson(this.modal.data.from), this.getPerson(this.modal.data.to), this.relation, this.reverse
|
||||||
console.log('post response', relationship)
|
)
|
||||||
this.$store.dispatch('addLinkFromRelationship', adapt2vis(relationship))
|
.then(relationship => new Promise(resolve => {
|
||||||
this.modal.showModal = false
|
console.log('post response', relationship)
|
||||||
this.resetForm()
|
this.$store.dispatch('addLinkFromRelationship', adapt2vis(relationship))
|
||||||
resolve()
|
this.modal.showModal = false
|
||||||
}))
|
this.resetForm()
|
||||||
.catch()
|
resolve()
|
||||||
|
}))
|
||||||
|
.catch()
|
||||||
|
|
||||||
|
case 'edit':
|
||||||
|
/// TODO
|
||||||
|
// récupérer la relationship,
|
||||||
|
// la modifier,
|
||||||
|
// patcher en reconstruisant le body,
|
||||||
|
// récupérer la réponse,
|
||||||
|
// mettre le link (edge) à jour
|
||||||
|
return patchRelationship(relationship)
|
||||||
|
.then(response => new Promise(resolve => {
|
||||||
|
console.log('patch response', response)
|
||||||
|
this.$store.dispatch('updateLinkFromRelationship', adapt2vis(response))
|
||||||
|
this.modal.showModal = false
|
||||||
|
this.resetForm()
|
||||||
|
resolve()
|
||||||
|
}))
|
||||||
|
.catch()
|
||||||
|
|
||||||
|
case 'delete':
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
throw "undefined action"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,10 +139,35 @@ const postRelationship = (fromPerson, toPerson, relation, reverse) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function patchRelationship
|
||||||
|
* @param relationship
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
const patchRelationship = (relationship) => {
|
||||||
|
return patchFetch(
|
||||||
|
`/api/1.0/relations/relationship/${relationship._id}.json`,
|
||||||
|
{
|
||||||
|
type: 'relationship',
|
||||||
|
fromPerson: { type: 'person',
|
||||||
|
id: fromPerson._id
|
||||||
|
},
|
||||||
|
toPerson: { type: 'person',
|
||||||
|
id: toPerson._id
|
||||||
|
},
|
||||||
|
relation: { type: 'relation',
|
||||||
|
id: relation.id
|
||||||
|
},
|
||||||
|
reverse: reverse
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getHouseholdByPerson,
|
getHouseholdByPerson,
|
||||||
getCoursesByPerson,
|
getCoursesByPerson,
|
||||||
getRelationshipsByPerson,
|
getRelationshipsByPerson,
|
||||||
getRelationsList,
|
getRelationsList,
|
||||||
postRelationship,
|
postRelationship,
|
||||||
|
patchRelationship
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user