[Swimlanes] Check for valid swimlane

Issue #599. Also switches class toggle from scope based to element
based.
This commit is contained in:
David Hudson 2016-09-20 17:59:25 +09:00 committed by Victor Woeltjen
parent 6c5d5f3d00
commit 471adde923
2 changed files with 18 additions and 6 deletions

View File

@ -77,7 +77,8 @@
<mct-splitter></mct-splitter> <mct-splitter></mct-splitter>
<!-- BOTTOM PANE RESOURCE LEGEND --> <!-- BOTTOM PANE RESOURCE LEGEND -->
<div mct-resource-graph-drop class="split-pane-component abs l-timeline-pane t-pane-h l-pane-btm s-timeline-resource-legend l-timeline-resource-legend" ng-class="{'drop-over': resourceGraphLegendropOver }"> <div mct-resource-graph-drop
class="split-pane-component abs l-timeline-pane t-pane-h l-pane-btm s-timeline-resource-legend l-timeline-resource-legend">
<div class="l-title s-title">{{ngModel.title}}Resource Graph Legend</div> <div class="l-title s-title">{{ngModel.title}}Resource Graph Legend</div>
<div class="l-legend-items legend"> <div class="l-legend-items legend">
<mct-include key="'timeline-legend-item'" <mct-include key="'timeline-legend-item'"

View File

@ -36,8 +36,15 @@ define(
function link(scope, element, attrs) { function link(scope, element, attrs) {
// Handle dragover // Handle dragover
element.on('dragover', function (e) { element.on('dragover', function (e) {
scope.resourceGraphLegendropOver = true; var swimlane = dndService.getData(
SwimlaneDragConstants.TIMELINE_SWIMLANE_DRAG_TYPE
);
if (typeof swimlane !== "undefined" && !swimlane.graph()) {
element.addClass('drop-over');
scope.$apply(); scope.$apply();
e.preventDefault();
}
}); });
// Handle drops // Handle drops
element.on('drop', function (e) { element.on('drop', function (e) {
@ -45,15 +52,19 @@ define(
SwimlaneDragConstants.TIMELINE_SWIMLANE_DRAG_TYPE SwimlaneDragConstants.TIMELINE_SWIMLANE_DRAG_TYPE
); );
element.removeClass('drop-over');
// Only toggle if the graph isn't already set // Only toggle if the graph isn't already set
if (!swimlane.graph()) { if (typeof swimlane !== "undefined" && !swimlane.graph()) {
swimlane.toggleGraph(); swimlane.toggleGraph();
e.preventDefault();
} }
}); });
// Clear highlights when drag leaves this swimlane // Clear highlights when drag leaves this swimlane
element.on('dragleave', function () { element.on('dragleave', function (e) {
scope.resourceGraphLegendropOver = false; element.removeClass('drop-over');
scope.$apply(); scope.$apply();
e.preventDefault();
}); });
} }