-
Notifications
You must be signed in to change notification settings - Fork 90
'Canvas View': pfCanvas & pfCanvasEditor - Contribution from MiQ/SUI #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jeff-phillips-18
merged 2 commits into
patternfly:branch-4.0-dev
from
dtaylor113:CFUX-308-pfCanvas
Feb 17, 2017
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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
166 changes: 166 additions & 0 deletions
166
src/canvas-view/canvas-editor/canvas-editor.component.js
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,166 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
angular.module('patternfly.canvas').component('pfCanvasEditor', { | ||
|
||
bindings: { | ||
chartDataModel: "=", | ||
chartViewModel: "=?", | ||
toolboxTabs: "=", | ||
readOnly: '<?' | ||
}, | ||
transclude: true, | ||
templateUrl: "canvas-view/canvas-editor/canvas-editor.html", | ||
controller: function ($timeout) { | ||
var ctrl = this; | ||
var newNodeCount = 0; | ||
var prevClickedOnChart, prevInConnectingMode; | ||
|
||
ctrl.$onInit = function () { | ||
ctrl.toolboxVisible = false; | ||
ctrl.hideConnectors = false; | ||
ctrl.draggedItem = null; | ||
}; | ||
|
||
// need to get these in next digest cycle, after pfCanvas sets chartViewModel | ||
$timeout(function () { | ||
prevClickedOnChart = ctrl.chartViewModel.clickedOnChart; | ||
prevInConnectingMode = ctrl.chartViewModel.inConnectingMode; | ||
}); | ||
|
||
ctrl.$doCheck = function () { | ||
if (angular.isDefined(prevClickedOnChart) && angular.isDefined(prevInConnectingMode)) { | ||
if (!angular.equals(ctrl.chartViewModel.clickedOnChart, prevClickedOnChart)) { | ||
if (ctrl.chartViewModel.clickedOnChart) { | ||
ctrl.chartViewModel.clickedOnChart = false; | ||
ctrl.hideToolbox(); | ||
} | ||
prevClickedOnChart = ctrl.chartViewModel.clickedOnChart; | ||
} | ||
if (!angular.equals(ctrl.chartViewModel.inConnectingMode, prevInConnectingMode)) { | ||
if (ctrl.chartViewModel.inConnectingMode) { | ||
ctrl.hideConnectors = false; | ||
ctrl.hideToolbox(); | ||
} | ||
prevInConnectingMode = ctrl.chartViewModel.inConnectingMode; | ||
} | ||
} | ||
}; | ||
|
||
ctrl.addNodeToCanvas = function (newNode) { | ||
ctrl.chartViewModel.addNode(newNode); | ||
}; | ||
|
||
/*** Toolbox Methods ***/ | ||
|
||
ctrl.showToolbox = function () { | ||
ctrl.toolboxVisible = true; | ||
// add class to subtabs to apply PF style and | ||
// focus to filter input box | ||
|
||
$timeout(function () { | ||
angular.element(".subtabs>ul").addClass('nav-tabs-pf'); | ||
angular.element("#filterFld").focus(); | ||
}); | ||
}; | ||
|
||
ctrl.hideToolbox = function () { | ||
ctrl.toolboxVisible = false; | ||
}; | ||
|
||
ctrl.toggleToolbox = function () { | ||
if (!ctrl.readOnly && !ctrl.chartViewModel.inConnectingMode) { | ||
if (ctrl.toolboxVisible === true) { | ||
ctrl.hideToolbox(); | ||
} else { | ||
ctrl.showToolbox(); | ||
} | ||
} | ||
}; | ||
|
||
ctrl.tabClicked = function () { | ||
angular.element("#filterFld").focus(); | ||
}; | ||
|
||
/*** Toolbox ***/ | ||
|
||
ctrl.startCallback = function (event, ui, item) { | ||
ctrl.draggedItem = item; | ||
}; | ||
|
||
ctrl.dropCallback = function (event, ui) { | ||
var newNode = angular.copy(ctrl.draggedItem); | ||
newNodeCount++; | ||
newNode.x = event.clientX - 600; | ||
newNode.y = event.clientY - 200; | ||
newNode.backgroundColor = newNode.backgroundColor ? newNode.backgroundColor : '#fff'; | ||
|
||
ctrl.chartViewModel.addNode(newNode); | ||
}; | ||
|
||
ctrl.addNodeByClick = function (item) { | ||
var newNode = angular.copy(item); | ||
newNodeCount++; | ||
newNode.x = 250 + (newNodeCount * 4 + 160); | ||
newNode.y = 200 + (newNodeCount * 4 + 160); | ||
newNode.backgroundColor = newNode.backgroundColor ? newNode.backgroundColor : '#fff'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use pfUtils.colorPalette.white |
||
|
||
ctrl.chartViewModel.addNode(newNode); | ||
}; | ||
|
||
ctrl.tabClicked = function () { | ||
angular.element("#filterFld").focus(); | ||
}; | ||
|
||
ctrl.activeTab = function () { | ||
return ctrl.toolboxTabs.filter(function (tab) { | ||
return tab.active; | ||
})[0]; | ||
}; | ||
|
||
ctrl.activeSubTab = function () { | ||
var activeTab = ctrl.activeTab(); | ||
if (activeTab && activeTab.subtabs) { | ||
return activeTab.subtabs.filter(function (subtab) { | ||
return subtab.active; | ||
})[0]; | ||
} | ||
}; | ||
|
||
ctrl.activeSubSubTab = function () { | ||
var activeSubTab = ctrl.activeSubTab(); | ||
if (activeSubTab && activeSubTab.subtabs) { | ||
return activeSubTab.subtabs.filter(function (subsubtab) { | ||
return subsubtab.active; | ||
})[0]; | ||
} | ||
}; | ||
|
||
/*** Zoom ***/ | ||
|
||
ctrl.maxZoom = function () { | ||
if (ctrl.chartViewModel && ctrl.chartViewModel.zoom) { | ||
return ctrl.chartViewModel.zoom.isMax(); | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
ctrl.minZoom = function () { | ||
if (ctrl.chartViewModel && ctrl.chartViewModel.zoom) { | ||
return ctrl.chartViewModel.zoom.isMin(); | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
ctrl.zoomIn = function () { | ||
ctrl.chartViewModel.zoom.in(); | ||
}; | ||
|
||
ctrl.zoomOut = function () { | ||
ctrl.chartViewModel.zoom.out(); | ||
}; | ||
} // controller | ||
}); // module | ||
})(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use pfUtils.colorPalette.white
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, but there isn't a 'white' in patternfly.pfPaletteColors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that is silly...