mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
visgraph: post, patch and delete relationship link works!
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { splitId } from './vis-network'
|
||||
|
||||
/**
|
||||
* @function makeFetch
|
||||
* @param method
|
||||
@@ -130,21 +132,19 @@ const getRelationsList = () => {
|
||||
|
||||
/**
|
||||
* @function postRelationship
|
||||
* @param fromPerson
|
||||
* @param toPerson
|
||||
* @param relation
|
||||
* @param reverse
|
||||
* @param relationship
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
const postRelationship = (fromPerson, toPerson, relation, reverse) => {
|
||||
const postRelationship = (relationship) => {
|
||||
console.log(relationship)
|
||||
return postFetch(
|
||||
`/api/1.0/relations/relationship.json`,
|
||||
{
|
||||
type: 'relationship',
|
||||
fromPerson: { type: 'person', id: fromPerson._id },
|
||||
toPerson: { type: 'person', id: toPerson._id },
|
||||
relation: { type: 'relation', id: relation.id },
|
||||
reverse: reverse
|
||||
fromPerson: { type: 'person', id: splitId(relationship.from, 'id') },
|
||||
toPerson: { type: 'person', id: splitId(relationship.to, 'id') },
|
||||
relation: { type: 'relation', id: relationship.relation.id },
|
||||
reverse: relationship.reverse
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -156,12 +156,14 @@ const postRelationship = (fromPerson, toPerson, relation, reverse) => {
|
||||
*/
|
||||
const patchRelationship = (relationship) => {
|
||||
console.log(relationship)
|
||||
let linkType = splitId(relationship.id, 'link')
|
||||
let id = splitId(linkType, 'id')
|
||||
return patchFetch(
|
||||
`/api/1.0/relations/relationship/${relationship.id}.json`,
|
||||
`/api/1.0/relations/relationship/${id}.json`,
|
||||
{
|
||||
type: 'relationship',
|
||||
fromPerson: { type: 'person', id: relationship.fromPerson.id },
|
||||
toPerson: { type: 'person', id: relationship.toPerson.id },
|
||||
fromPerson: { type: 'person', id: splitId(relationship.from, 'id') },
|
||||
toPerson: { type: 'person', id: splitId(relationship.to, 'id') },
|
||||
relation: { type: 'relation', id: relationship.relation.id },
|
||||
reverse: relationship.reverse
|
||||
}
|
||||
@@ -174,8 +176,11 @@ const patchRelationship = (relationship) => {
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
const deleteRelationship = (relationship) => {
|
||||
console.log(relationship)
|
||||
let linkType = splitId(relationship.id, 'link')
|
||||
let id = splitId(linkType, 'id')
|
||||
return deleteFetch(
|
||||
`/api/1.0/relations/relationship/${relationship.id}.json`
|
||||
`/api/1.0/relations/relationship/${id}.json`
|
||||
)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user