Skip to content
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

Edits #127

Open
wants to merge 59 commits into
base: gh-pages
Choose a base branch
from
Open

Edits #127

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
59a1a1e
Add "Export Data" button, which shows the geoJSON in a new window.
rst Oct 10, 2014
1767987
Export data with half-decent indentation.
rst Oct 10, 2014
45a657a
Add "edit-mode" config flag, to enable/disable editing features.
rst Oct 12, 2014
4f585d7
Specs for the "export data" widget support code.
rst Oct 12, 2014
b1e802b
Create 'edit_state' object in data to manage, well, state of edits.
rst Oct 16, 2014
9523061
In edit mode, currently selected point is draggable.
rst Oct 16, 2014
ad2969a
Tests for altering feature location by dragging on the map.
rst Oct 17, 2014
7d147ed
Map responds to external selectedFeatureMove events, if they ever come.
rst Oct 19, 2014
607cea0
Barebones edit-state support for generic prop-change events.
rst Oct 19, 2014
7d6ceb0
Start on the property-editing UI.
rst Oct 21, 2014
a4ab9d8
Nuke tabs that crept into previous changes.
rst Oct 21, 2014
46bb3f6
Wire up JSON editor to edit state object.
rst Oct 21, 2014
0145661
Quarter-decent styling for "export data" button
rst Oct 21, 2014
cac05ff
Basic tests for editor manipulation in info box.
rst Oct 22, 2014
490babf
(Barely) usable styling for edit widgets in info pane.
rst Oct 23, 2014
d245b8d
More complete edit schema for sample data.
rst Oct 23, 2014
9eceab6
Use bootstrap's icons in JSON editor.
rst Oct 23, 2014
8efb51b
Scroll edit pane to the top when loading a new feature.
rst Oct 23, 2014
16e2749
Widen edit box, so all list widgetry shows on one row.
rst Oct 23, 2014
5695dec
Add some property names to edit schema.
rst Oct 23, 2014
9d31e82
Lop off some JSON editor widgetry that probably isn't worth the clutter.
rst Oct 23, 2014
040192e
Correctly handle editing of multi-line addresses.
rst Oct 24, 2014
0c54937
Double-clicking on the map offers to add a point.
rst Oct 24, 2014
0bc1d31
Tests for UI to add new features.
rst Oct 24, 2014
a4bad0e
Quiet complaints from jshint.
rst Oct 24, 2014
4c67344
Update TODO state, as long as it's drifted into git anwyay.
rst Oct 24, 2014
340222a
Stop blowing up names of array properties in editor pane.
rst Oct 26, 2014
412a1ef
Be more aggressive about disabling dragging on deselect.
rst Oct 27, 2014
d095733
"Delete" functionality, and tests.
rst Oct 27, 2014
1f9b4b8
Quiet complaints from jshint.
rst Oct 27, 2014
f3a7f15
More jshint lint.
rst Oct 27, 2014
6d40af1
Help text for editing features
rst Oct 27, 2014
ac5eeb2
Don't show editing help unless we are actually in edit mode.
rst Oct 27, 2014
aabb54c
Make sure we can still find a feature's marker after a position change.
rst Oct 30, 2014
918f251
Mitigate Heisenbug in map specs.
rst Oct 31, 2014
9594791
Better help text on "deletion".
rst Oct 31, 2014
6a33389
Edit help-text edits: "organization" -> "site".
rst Oct 31, 2014
6b17407
Further corrections to drag-end processing.
rst Oct 31, 2014
f92421e
Rebuild the FUSE index with changed features after edits.
rst Oct 31, 2014
1eb9f8a
Edit docs materialize as 'readme.edit_mode'.
rst Oct 31, 2014
bd3ac75
Correct jshint problems.
rst Oct 31, 2014
868183a
Update facets for changed data while in edit mode.
rst Nov 2, 2014
668e6a4
Drop default reindex timeout to 5 seconds.
rst Nov 2, 2014
ac6db01
Separate 'info' and 'infoedits' UI components.
rst Nov 2, 2014
77c599d
Correct docs. ("editedData" event is now "reindex")
rst Nov 3, 2014
b8641d8
Implement rudimentary "undo" capability.
rst Nov 3, 2014
2c67613
Deal with jshint complaints
rst Nov 3, 2014
e1a1b06
In edit mode, allow users to create a point by entering the address.
rst Nov 21, 2014
200f4c8
Merge branch 'master' into edits
rst Nov 24, 2014
8f0df7d
Belatedly add specs for the new 'add_site' widget...
rst Nov 24, 2014
a2d2231
Merge branch 'gh-pages' into edits -- quick and sloppy
rst Dec 17, 2014
2dd0be8
Fix up map-edit code so tests once again pass.
rst Dec 17, 2014
6c76170
Eliminate some more merge damage.
rst Dec 24, 2014
e72085c
Facet code shouldn't gag on undefined values.
rst Dec 24, 2014
ee0e72f
Merge branch 'gh-pages' into edits
rst Dec 24, 2014
a863c36
Make sure icon for newly added feature sticks on the map.
rst Dec 24, 2014
55e4cc7
Newly created features should show up in the list widget.
rst Dec 24, 2014
33fc81c
Deal with jshint complaints.
rst Dec 24, 2014
17def96
Export strips internally assigned 'finda-foo' IDs.
rst Dec 24, 2014
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
46 changes: 45 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"map": {
"preview_attribute": "organization_name",
"new_point_address_attribute": "address",
"center":[42.3725, -71.1266],
"zoom":13,
"maxZoom":16,
Expand Down Expand Up @@ -62,5 +63,48 @@
"hostname": "auto",
"detail_enabled": true
},
"geojson_source": "data.geojson"
"geojson_source": "data.geojson",
"edit_mode": true,
"new_feature_popup_label": "Add service provider named...",
"feature_property_json_schema": {
"title": "Organization",
"type": "object",
"id": "properties",
"properties": {
"organization_name": { "title": "Name", "type": "string" },
"address": { "title": "Address", "type": "string", "format": "textarea" },
"city": { "title": "City", "type": "string" },
"web_url": { "title": "Web URL", "type": "string", "format": "url" },
"phone_numbers": {
"title": "Phone numbers",
"type": "array", "format": "table", "items": { "type": "string" }
},
"contact_emails": {
"title": "Email addresses",
"type": "array", "format": "table", "items": { "type": "string" }
},
"contact_names": {
"title": "Contact names",
"type": "array", "format": "table", "items": { "type": "string" }
},
"target_populations": {
"title": "Target Populations",
"type": "array", "format": "table", "items": { "type": "string" }
},
"youth_category": {
"title": "Youth category",
"type": "array", "format": "table", "items": { "type": "string" }
},
"service_class_level_1": {
"title": "Service class lvl 1",
"type": "array", "format": "table", "items": { "type": "string" }
},
"service_class_level_2": {
"title": "Service class lvl 2",
"type": "array", "format": "table", "items": { "type": "string" }
},
"age_range": { "title": "Age Range", "type": "string" },
"additional_notes": { "title": "Further Notes", "type": "string" }
}
}
}
Binary file added fonts/glyphicons-halflings-regular.eot
Binary file not shown.
229 changes: 229 additions & 0 deletions fonts/glyphicons-halflings-regular.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fonts/glyphicons-halflings-regular.ttf
Binary file not shown.
Binary file added fonts/glyphicons-halflings-regular.woff
Binary file not shown.
54 changes: 54 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@
<div class="collapse navbar-collapse" id="finda-navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#" data-toggle="modal" data-target="#about">About</a></li>
<li id="editing-help-link"><a href="#" data-toggle="modal" data-target="#editing-how-to">Help</a></li>
</ul>
<form id="search" class="navbar-form dropdown" role="search">
<!-- VERY awkward to have export button as part of this form
semantically, but it's a kludge to get quarter-decent display.
-->
<button id="export" type="submit" class="btn btn-default" title="export">Export Data</button>
<div class="form-group">
<input type="text" class="address form-control" placeholder="Enter an address..." title="Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright">
</div>
Expand All @@ -42,6 +47,7 @@
<p class="suggested">Suggested results:</p>
<ul></ul>
</div>
<button id="add-site" type="submit" class="btn btn-default" title="Add Site">Add Site</button>
</form>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
Expand All @@ -54,6 +60,9 @@
<div id="info" class="control">
<button type="button" class="close">&times;</button>
</div>
<div id="infoedits" class="control">
<button type="button" class="close">&times;</button>
</div>
</div>

<div class="modal fade" id="about" tabindex="-1" role="dialog" aria-labelledby="aboutLabel" aria-hidden="true">
Expand All @@ -79,6 +88,39 @@ <h4>About Code for Boston</h4>
</div>
</div>

<div class="modal fade" id="editing-how-to" tabindex="-1" role="dialog" aria-labelledby="editing-how-to-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="editing-how-to-label">How to edit</h4>
</div>
<div class="modal-body">
<h4>How to edit</h4>
<p>
Finda is currently running in "edit mode", which allows you
to produce a changed copy of the map. If you hit "export data",
this copy will appear in a separate browser window, from where
you can save it (via browser "Save as"), and move it where you
like.
</p>
<p>To make changes to the copy in your browser:</p>
<ul>
<li>Selecting a site lets you change its properties,
in the property-edit pane that appears on the left of the map.
</li>
<li>To add a new site, double-click on the map.</li>
<li>To delete a site, select it and hit the "delete"
button. It isn't actually gone until you export (though
the map marker turns ghostly), and can be restored by
selecting it again, and hitting the button now marked
"restore".</li>
<li>To export the altered data, once again, push the "Export
Data" button</li>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<div class="modal" id="loading" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
Expand All @@ -88,6 +130,18 @@ <h4></h4>
</div>
</div>
</div>

<div id="new-feature-popup" class="hidden">
<form class="create-feature-popup-form">
<div class="form-group">
<label id="new-feature-popup-label">Creating new item named...</label>
<input name="new_feature_name"
type="text" class="form-control input-sm"/>
<button type="submit" class="btn btn-xs">Create</button>
</div>
</form>
</div>

<!--[if lt IE 9]>
<script src="lib/es5-shim.min.js"></script>
<script src="lib/es5-sham.min.js"></script>
Expand Down
1 change: 1 addition & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = function(config) {
'lib/es5-shim.min.js',
'lib/es5-sham.min.js',
'lib/jquery-1.11.1.min.js',
'lib/jsoneditor.min.js',

'test/lib/jasmine-jquery.js',
'test/lib/jasmine-flight.js',
Expand Down
10 changes: 10 additions & 0 deletions lib/jsoneditor.min.js

Large diffs are not rendered by default.

103 changes: 103 additions & 0 deletions readme.edit_mode
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
How to configure edit mode:

Editing mode is controlled by several entries in config.json.

First off is "edit_mode". If this isn't set to "true", then
all edit-related features are erased.

If "edit_mode" is set, then there are a couple of other config
entries that probably ought to be customized:

new_feature_popup_label is the prompt that the user will see
when creating a new feature, by double-clicking on the map.

feature_property_json_schema is the JSON schema describing
the properties of each feature, the data types, and display.
For more on what this ought to be like, see the documentation
for the JSON editor, which is what actually manages the 'info'
pane in edit mode:

https://github.com/jdorn/json-editor

and the official JSON schema spec:

http://json-schema.org/

Innards -- Expected protocol:

A flight component can either listen for incremental changes to
data items, or wait for the edit state to pump out an 'reindex'
event. The latter is for things that need to rebuild the world,
and we may want to put some hysteresis on it. (Current components
that do that, for the moment: the fuse index for data/typeahead,
and the facets data component.)

If you're listening for incremental changes, you need to listen
for all of 'em. So, map should be listening for selectedFeatureMoved
as well as sending it, lest something else start sending it as well
(in which case, it'll need to move the icon -- plausible case:
changes to address moving the icon as well).

Incremental changes:

selectFeature
deselectFeature

selectedFeatureMoved [carries an array of properties, as a GeoJSON
lng, lat coordinate pair]
selectedFeaturePropsChanged [carries new props;
those not mentioned to be left alone]

selectedFeatureDeleted [sets a flag; actual cull happens at export]
selectedFeatureUndeleted [clears the flag]

newFeature [carries a latlng *and* properties]

Additionally, there may be components (most notably, the typeahead
search engine with its Fuse index) which want to completely rebuild
periodically based on changed data. We don't necessarily want to be
running these large computations on every one of a quick succession
of changes, only to immediately toss the result. So, the edit-state
manager will send out a 'reindex' event, with a full copy of new data,
ten seconds after a series of local change events stops.

TODO:

+) decide what we're doing about list features. Set '"list": true' in
config for 'em to get off the dime.

For next three: jdorn/json-editor

+) alternative infotemplates that render form inputs,
with '"data-property": "foo"'

+) code to scrape property values *out* of the form inputs

+) code to add and remove list items from list-valued props

+) glue code to send and process changedProperty events

+) newFeature event support
+) double click sets preliminary marker, and pops up a form asking
for a value for the preview_attribute.
+) cancel on that form is a no-op; prelim marker goes away.
may need startCreate/cancelCreate events to mediate this
+) submit sends a newFeature event

+) delete event support
+) editState sets flag on item, and culls from export
+) map turns opacity on icon to 50%
+) "delete/undelete" button on above forms to show status & trigger changes

+) Edit help text and display, similar to current "About"

+) glue code to send the editedData events from edit_state, and
have typeahead.js update the FUSE index.

*) Undo mechanism:
items have an undo state which can be null or "revert properties"
for pre-exisiting items, edit_state caches properties at first
change

*) UI for filtering to only edited items, for quick review of current
change set. Could possibly use undo-state info.
Loading