Skip to content

Commit

Permalink
Fix oppia#3027 Updates Add Vertex functionality in GraphInput, when v…
Browse files Browse the repository at this point in the history
…ertex is added mode is changed to "MOVE". (oppia#3115)

* Fix oppia#3027 Updates Add Vertex functionality in GraphInput, when vertex is added mode is changed to "MOVE".

* Adds Helper function setMode0

* Updates onClickGraphSVG function

* Change two function name in GraphInput

* setMode to onClickModeButton

* setMode0 to setMode

* Removed comment
  • Loading branch information
95adityajain authored and seanlip committed Feb 28, 2017
1 parent 33a1441 commit b68eb12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion extensions/interactions/GraphInput/GraphInput.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
ng-attr-y="<[10 + 50 * $index]>"
rx="5"
ry="5"
ng-click="setMode(button.mode, $event)"
ng-click="onClickModeButton(button.mode, $event)"
ng-mouseenter="state.hoveredModeButton = button.mode"
ng-mouseleave="state.hoveredModeButton = (state.hoveredModeButton == button.mode) ? null : state.hoveredModeButton"
ng-attr-style="fill: white; stroke: black; stroke-width: <[(state.currentMode == button.mode) ? 3 : 1]>;">
Expand Down
12 changes: 8 additions & 4 deletions extensions/interactions/GraphInput/GraphInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ oppia.directive('graphViz', function() {
y: $scope.state.mouseY,
label: ''
});
setMode(_MODES.MOVE);
}
if ($scope.state.hoveredVertex === null) {
$scope.state.selectedVertex = null;
Expand Down Expand Up @@ -334,15 +335,18 @@ oppia.directive('graphViz', function() {
}
$scope.graph[option] = !$scope.graph[option];
};
$scope.setMode = function(mode, $event) {
// Prevents new vertex from being added in add edge mode
$event.preventDefault();
$event.stopPropagation();

var setMode = function(mode) {
$scope.state.currentMode = mode;
$scope.state.addEdgeVertex = null;
$scope.state.selectedVertex = null;
$scope.state.selectedEdge = null;
};
$scope.onClickModeButton = function(mode, $event) {
$event.preventDefault();
$event.stopPropagation();
setMode(mode);
};

// TODO(czx): Consider if there's a neat way to write a reset()
// function to clear bits of $scope.state
Expand Down

0 comments on commit b68eb12

Please sign in to comment.