Commit 2047d47c authored by unknown's avatar unknown

Date + keyword filter ok + beginning of box selection

parent 297fd0a9
......@@ -34,7 +34,6 @@ export class Graph2D {
container: document.getElementById('cy'),
wheelSensitivity: 0.1,
autounselectify: true,
style: [
{
selector: 'node',
......@@ -81,7 +80,7 @@ export class Graph2D {
layout.run();
this.filterByDate([document.getElementById('filter-date-start'), document.getElementById('filter-date-end')].map(this.toIso));
this.filterGraph();
this.applyFilterToGraph();
this.cy.on('cxttap', this.displayGraphMenu);
......@@ -89,6 +88,13 @@ export class Graph2D {
this.cy.on('cxttap', 'node', this.displayContextMenu);
this.cy.on('mouseover', 'node', this.highlightNode);
this.cy.on('mouseout', 'node', this.deEmphasizeNode);
this.cy.on('boxselect', 'node', this.selectNode);
}
selectNode = (e) => {
const nodeId = e.target._private.data.id;
this.cy.getElementById(nodeId).style("backgroundColor", 'red');
}
showTooltip = () => {
......@@ -150,7 +156,17 @@ export class Graph2D {
});
}
displayNewElements = (type, element) => {
postProc = filterFn => node => {
if (filterFn(node)) {
return true;
}
else {
node.hide = true;
return false;
}
}
displayNewElements = postProc => (type, element) => {
if (this.cy.getElementById(element.id).length === 0) {
if (type === "node") {
const cX = this.cy.getElementById(this.selectedNodeId)._private.position.x;
......@@ -159,7 +175,11 @@ export class Graph2D {
this.cy.add({
group: 'nodes',
data: element,
position: { x: cX + 200 * Math.cos(a), y: cY + 200 * Math.sin(a) }
position: { x: cX + 200 * Math.cos(a), y: cY + 200 * Math.sin(a) },
style:
{
display: postProc(element) ? 'element' : 'none'
}
});
} else {
this.cy.add({
......@@ -172,11 +192,13 @@ export class Graph2D {
expandNodes = (id, nodeType='all', relationType="all") => {
this.hideContextMenu();
this.graph2d.getRelated([id], nodeType, relationType)(this.displayNewElements);
this.graph2d.mutate().then(() => {
this.filterByDate([document.getElementById('filter-date-start'), document.getElementById('filter-date-end')].map(this.toIso));
this.applyFilterToGraph();
});
const keywords = $("#filter-content").val().split(" ");
const startDate = this.toIso(document.getElementById('filter-date-start'));
const endDate = this.toIso(document.getElementById('filter-date-end'));
const filterFn = this.graph2d._filters.filterAllByNode(keywords, startDate, endDate);
this.graph2d.getRelated([id], nodeType, relationType)(this.displayNewElements(this.postProc(filterFn)));
this.graph2d.mutate();
}
collapseNodes = (id, nodeType='all', relationType="all") => {
......@@ -279,9 +301,10 @@ export class Graph2D {
this.graph2d.forEachCurrentNode(node => this.cy.getElementById(node.id).style("display", node.hide ? "none": "element"));
}
filterByDate = (dateValues) => {
const [startDate, endDate] = dateValues;
this.graph2d.filter([], startDate, endDate);
this.applyFilterToGraph();
filterGraph = () => {
const keywords = $("#filter-content").val().split(" ");
const startDate = this.toIso(document.getElementById('filter-date-start'));
const endDate = this.toIso(document.getElementById('filter-date-end'));
this.graph2d.filter(keywords, startDate, endDate);
}
}
\ No newline at end of file
......@@ -80,7 +80,8 @@ function setupDateFilter(app, newGraph, id, start, end) {
dateValues[handle].innerHTML = values[handle];
app.updateFilter();
newGraph.filterByDate(dateValues.map(toIso));
newGraph.filterGraph();
newGraph.applyFilterToGraph();
});
}
......@@ -428,8 +429,8 @@ function start(settings, login, password) {
$("#filter-content").on("input", () => {
const keywords = $("#filter-content").val().split(" ")
graph2D.graph2d.filterByKeywords(keywords)
graph2D.applyFilterToGraph()
graph2D.filterGraph();
graph2D.applyFilterToGraph();
})
return app;
}
......
module.exports = { version: '185' }
module.exports = { version: '192' }
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