-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unit test and add changelog entry #70
Signed-off-by: tdruez <tdruez@nexb.com>
- Loading branch information
Showing
4 changed files
with
45 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 37 additions & 4 deletions
41
organization/templates/organization/includes/owner_hierarchy.js.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,43 @@ | ||
{% extends "hierarchy_base.js.html" %} | ||
<script> | ||
function is_active_tab(id) { | ||
var active_tab_id = $('.tab-pane.active')[0].id; | ||
return (active_tab_id == id); | ||
} | ||
|
||
{% block herarchy_js_content %} | ||
{% for parent in parents %} | ||
jsPlumb.ready(function() { | ||
var jsPlumbHierarchy = jsPlumb.getInstance({ | ||
Connector: ['Straight'], | ||
PaintStyle: {strokeStyle: 'gray', lineWidth: 1}, | ||
EndpointStyle: {radius: 3, fillStyle: 'gray'}, | ||
Anchors: ['LeftMiddle', 'RightMiddle'], | ||
Container: $("#{{ tab_name }}") | ||
}); | ||
|
||
// Do not draw right away as the tab may be hidden | ||
jsPlumbHierarchy.setSuspendDrawing(true); | ||
|
||
{% for parent in parents %} | ||
jsPlumbHierarchy.connect({source: 'owner_{{ current_owner.pk }}', target: 'owner_{{ parent.pk }}'}); | ||
{% endfor %} | ||
{% for child in children %} | ||
jsPlumbHierarchy.connect({source: 'owner_{{ child.pk }}', target: 'owner_{{ current_owner.pk }}'}); | ||
{% endfor %} | ||
{% endblock %} | ||
|
||
// Draw if the related tab is active | ||
if (is_active_tab("{{ tab_name }}")) | ||
jsPlumbHierarchy.setSuspendDrawing(false, true); | ||
|
||
// Repaint on opening the tab, as when the tab content is hidden | ||
// the connectors are not painted properly | ||
$('button[data-bs-target="#{{ tab_name }}"]').on('shown.bs.tab', function (e) { | ||
// Second argument instructs jsPlumb to perform a full repaint. | ||
jsPlumbHierarchy.setSuspendDrawing(false, true); | ||
}); | ||
|
||
// Repaint on resizing the browser window if the related tab is active | ||
$(window).resize(function(){ | ||
if (is_active_tab("{{ tab_name }}")) | ||
jsPlumbHierarchy.repaintEverything(); | ||
}); | ||
}); | ||
</script> |