Commit 700b21aa authored by Themousaillon's avatar Themousaillon

fix node suppression

parent f64d3e61
......@@ -310,7 +310,6 @@
"fieldNames": {
"dateFields": ["isoStartDate", "isoEndDate"],
"geoLocalisation": "latLong"
},
"nodeTypes2": {
......
......@@ -26,7 +26,7 @@ export class Node2d {
})
getEdgesId = () => {
const targets = this.targets.ids() .map(targetId => `${this.id} ${targetId}`)
const targets = this.targets.ids().map(targetId => `${this.id} ${targetId}`)
const parents = this.parents.ids().map(parentId => `${parentId} ${this.id}`)
return targets.concat(parents)
}
......@@ -37,13 +37,13 @@ export class Node2d {
getRelated= (relationType="all") => [...this.getParents(relationType), ...this.getTargets(relationType)]
addTarget = targetId => {this.targets.addOne(targetId)}
addTarget = targetObj => this.targets.addOne(targetObj)
addParent = parentId => {this.parents.addOne(parentId)}
addParent = parentObj => this.parents.addOne(parentObj)
removeTarget = targetId => {this.targets.removeOne(targetId)}
removeTargets = targetIds => this.targets.removeByIds(targetIds)
removeParent = parentId => {this.parents.removeOne(parentId)}
removeParents = parentIds => this.parents.removeByIds(parentIds)
childrenSummary = (nodes, excludeHidden=false) => {
let valueCounts = {nodes: {}, links: {}}
......
......@@ -317,24 +317,25 @@ export class Graph2d {
edges.filter(edge => edge && !this.isEdgeHidden(edge)).forEach(edge => f("edge", edge))
}
removeComponents = idList => f => this._pending.push(() => new Promise(
resolve => {
const nodes = this._nodes.collectFromKeys(idList)
const edgesIds = nodes.map(n => n.getEdgesId()).flat()
const targetsToRemove = nodes.map(node => [node.id, node.getParents().map(link => link.id)])
const parentsToRemove = nodes.map(node =>[node.id, node.getTargets().map(link => link.id)])
targetsToRemove.forEach(([id, targets]) => this._nodes.collectFromKeys(targets).forEach(t => t.removeTarget(id)))
parentsToRemove.forEach(([id, parents]) => this._nodes.collectFromKeys(parents).forEach(p => p.removeParent(id)))
this._nodes.removeByIds(idList)
this._edges.removeByIds(edgesIds)
idList.forEach(id => {
this._currentNodes.delete(id)
f("node", id)
})
edgesIds.forEach(id => f("edge", id))
resolve()
removeComponents = idList => f => {
const nodes = this._nodes.collectFromKeys(idList)
const edgesIds = nodes.map(n => n.getEdgesId()).flat()
const targetsToRemove = nodes.map(node => [node.id, node.targets.ids()])
const parentsToRemove = nodes.map(node =>[node.id, node.parents.ids()])
targetsToRemove.forEach(
([id, targets]) => this._nodes.collectFromKeys(targets).forEach(t => t.removeParents([id]))
)
parentsToRemove.forEach(
([id, parents]) => this._nodes.collectFromKeys(parents).forEach(p => p.removeTargets([id]))
)
this._nodes.removeByIds(idList)
this._edges.removeByIds(edgesIds)
idList.forEach(id => {
this._currentNodes.delete(id)
f("node", id)
})
)
edgesIds.forEach(id => f("edge", id))
}
filter = (keywords, startDate, endDate) => this._filters.filterAll(keywords, startDate, endDate)(this._nodes)
......
......@@ -429,6 +429,8 @@ module.exports = {
settingsList.forEach((s, i) => {
options[i] = s.database.name;
});
// setTimeout(() => $(".swal2-confirm").click(), 100)
// setTimeout(() => $(".swal2-confirm").click(), 150)
return alert.select('Choose a database : ', null, options).then((choice) => {
let settings = settingsList[choice];
return alert.credentials('Connexion', settings.database.login, !!settings.database.password ? settings.database.password : "").then((credentials) => {
......@@ -437,5 +439,6 @@ module.exports = {
return app;
});
});
}
};
\ No newline at end of file
......@@ -8,15 +8,22 @@
export default class IdSet {
constructor(iterable){
this._entries = {}
if (iterable)
iterable.forEach(obj => {this._entries[obj.id] = obj})
this._keys = new Set()
if (iterable){
iterable.forEach(obj => {
this._entries[obj.id] = obj
this._keys.add(obj.id)
})
}
}
ids = () => Object.keys(this._entries)
ids = () => [...this._keys]
addOne = obj => {
if (obj && !this._entries[obj.id])
if (obj && !this._keys.has(obj.id)){
this._entries[obj.id] = obj
this._keys.add(obj.id)
}
}
get = (id, condFn=null) => {
......@@ -28,6 +35,7 @@ export default class IdSet {
return elem
}
removeOne = obj => {
this._keys.delete(obj.id)
delete this._entries[obj.id]
}
......@@ -57,6 +65,7 @@ export default class IdSet {
removeByIds = idList => {
idList.forEach(id => {
this._keys.delete(id)
delete this._entries[id]
})
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment