Skip to content

Edge Entry Prototype #7

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
merged 20 commits into from
May 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
95acb76
edge-entry: NodeSelectors can set graph highlight color for selected …
benloh May 4, 2018
bcb038f
edge-entry: NodeSelector: Only select nodes that have not already bee…
benloh May 7, 2018
6455060
edge-entry: First pass at working edge entry with a revised D3SimpleN…
benloh May 7, 2018
fe4c12a
edge-entry: Pull out UpdateForces into separate function to enable UI…
benloh May 7, 2018
a4caa90
edge-entry: Add node click handler to respond to user mouse clicks on…
benloh May 7, 2018
0aa5cc5
edge-entry: Merge branch 'dev-bl/node-entry' into dev-bl/edge-entry
benloh May 7, 2018
2c69753
edge-entry: AutoCompleteDemo now can handle node click and select the…
benloh May 7, 2018
3e546ce
edge-entry: Disable text selection.
benloh May 8, 2018
30daa91
edge-entry: Refactor NodeSelector to move data management into AutoCo…
benloh May 8, 2018
9931bc3
edge-entry: Refactor EdgeEntry to move data management into AutoCompl…
benloh May 8, 2018
2516140
edge-entry: Fix controlled input error for EdgeEntry's Selected Sourc…
benloh May 8, 2018
34f57ec
edge-entry: Make sure "Add New Node" is shown when a selectedNode is …
benloh May 9, 2018
a7302ac
edge-entry: Disable EdgeEntry submit button so the form isn't submitt…
benloh May 9, 2018
5f1735a
edge-entry: HIghlights and selections now only match when there is an…
benloh May 9, 2018
abf6ff3
edge-entry: Add basic click handler for edge selection.
benloh May 9, 2018
d5c1b79
edge-entry: Select and deselect edges based on clicks, selected sourc…
benloh May 9, 2018
bb8513a
edge-entry: Don't allow saving an edge entry if either the source or …
benloh May 9, 2018
5913ff8
edge-entry: Data and D3SimpleNetGraph hack to emphasize edge changes.…
benloh May 9, 2018
8f4a657
Add documentation for components.
benloh May 17, 2018
fc45322
Add documentation for EdgeEntry.
benloh May 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,500 changes: 2,500 additions & 0 deletions build/app/assets/htmldemos/d3forcedemo/data.reducedlinks.json

Large diffs are not rendered by default.

513 changes: 501 additions & 12 deletions build/app/view/autocompletedemo/AutoCompleteDemo.jsx

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions build/app/view/autocompletedemo/components/AutoComplete.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,17 @@ svg {
flex-basis: 100%;
min-width: 200px;
}
/* D3SimpleNetGraph redo removes links group...
svg .links line {
stroke: #aaa;
}
... and replaces with .edge */
svg .edge {
stroke: #aaa;
}
svg .edge.selected {
stroke: #f00;
stroke-width: 5px;
}
svg .nodes circle {
pointer-events: all;
Expand All @@ -86,3 +95,6 @@ svg .nodes text {
stroke: #666;
stroke-width: 0px;
}
.noselect {
user-select: none;
}
38 changes: 34 additions & 4 deletions build/app/view/autocompletedemo/components/AutoComplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,40 @@ const Autosuggest = require('react-autosuggest');
/******************************************************************************/
/*/

AutoComplete is the text input field for entering node labels to:
* search for nodes,
* edit existing nodes,
* and add new nodes.

Main features:

* It interactively provides a list of suggestions that match the current
input, e.g. typing "ah" will display a list of suggestions including "Ah
Long", "Ah Seung", and "Oahu Railroad Station".

* Users can highlight suggestions (via mouseover or with keyboard arrows)

* Users can select a suggestion (via clicking or hitting return)

AutoComplete is a wrapper class for the open source AutoSuggest component,
which handles the actual rendering of the suggestions list. AutoComplete
provides an interface to NodeSelector and EdgeEntry. AutoComplete also
provides the handler routines for generating the suggestions list and
handling highlights and selections.



This relies on the react-autosuggest component.
See documentation: https://github.com/moroshko/react-autosuggest


To Use:
<AutoComplete

data={this.state.data}
value={label}
disableSuggestions={this.state.canEdit}

onInputChange={this.handleInputChange}
onSelection={this.handleNodeSelection}
onHighlight={this.handleSuggestionHighlight}
Expand All @@ -26,8 +52,8 @@ const Autosuggest = require('react-autosuggest');
data is mapped to this.props.data
This is how graph data is passed to the AutoComplete component.

requestClearValue is mapped to this.props.clearValue
Parent component can call this to clear the input field.
value is mapped to this.props.setValue
Use this to set the autocomplete value externally.

disableSuggesions is mapped to this.props.disabled
Set to true to stop making suggestions
Expand Down Expand Up @@ -171,7 +197,7 @@ class AutoComplete extends React.Component {
onSuggestionSelected (event, { suggestion }) {
// call parent handler
if (suggestion.isAddNew) {
console.log('Add new:', this.state.value, 'suggestion',suggestion);
// console.log('Add new:', this.state.value, 'suggestion',suggestion);
this.props.onSelection( this.state.value )
} else {
this.props.onSelection( suggestion )
Expand All @@ -186,13 +212,17 @@ class AutoComplete extends React.Component {
return this.props.disableSuggestions
}

setValue ( value ) {
// console.log('...AutoComplete.setValue to',value)
this.setState({value: value})
}
clearValue () {
this.setState({value:''})
}

componentWillReceiveProps (nextProps) {
// console.log('AutoComplete: componentWillReceiveProps',nextProps)
if (nextProps.requestClearValue) this.clearValue()
if (nextProps.value!==undefined) this.setValue( nextProps.value )
}

render() {
Expand Down
13 changes: 11 additions & 2 deletions build/app/view/autocompletedemo/components/D3NetGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
NetGraph calls SetData whenever it receives an updated data object.
This triggers D3NetGraph to redraw itself.

DEPRECATED
This implementation was problematic because newly-added links would not be
properly updated. The problem likely had to do with:
* Not using a proper link id based on source.id + target.id
* Using saved references to objects that could get outdated with
data joins/merges/updates.
Use `D3SimpleNetGraph.js` instead.

\*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ * //////////////////////////////////////*/


Expand Down Expand Up @@ -152,12 +160,13 @@ class D3NetGraph {
.on("end", (d) => { this._Dragended(d, this) }))

// UPDATE SELECTION
// If a node is not selected, its d.selected value is ''.
this.node.merge(nodeRoot).selectAll("circle")
.attr("stroke", function(d) { if (d.selected) return '#000'; })
.attr("stroke", function(d) { if (d.selected) return d.selected; })
.attr("stroke-width", function(d) { if (d.selected) return '5px'; })
this.node.merge(nodeRoot).selectAll("text")
.attr("color", function(d) { if (d.selected) return d.selected; })
.attr("font-weight", function(d) { if (d.selected) return 'bold'; })
.attr("color", function(d) { if (d.selected) return '#000'; })

// ENTER Add Group Items
this.node.append("circle")
Expand Down
Loading