codeforboston/finda — pull request #127 by rst (2014-10-22 02:33:30+00:00)
Title: Edits

I'm actually requesting review of some code for editing the map within finda. This does not yet close #84 (or shouldn't!), but there's enough here, I think, to demonstrate proof of concept, and it's probably time for someone else to give the code a good hard look for maintainability and functionality.

Here's what works: if you put '"edit_mode": true' in the config, you get an "Export Data" button in the navbar, and when you select a point, you can reposition it (by dragging the marker), and edit the properties (using Jeremy Dorn's JSON Editor, which replaces the contents of the info pane). The "Export Data" button puts the edited GeoJSON in a separate browser window, from where you can "Save As" and stick it where you like; this may be more convenient than asking users to paste it out of a text box.

Here's what's not there yet: First off, the JSON Editor control really doesn't have enough room in the info box. It needs more width, shrunk fonts, or both. There is not yet a way to create a new point (scratch plan: double-click on the map) or delete one. There's also no form of undo; actually releasing an editor without this is against my religion. (Scratch plan: on first change, record initial position and properties of the point; after that, offer a "revert" button. Also, "delete" would just set a "deleted" flag and leave the point visible, with the marker's opacity set to 0.5, and available for "undelete"; points with the "deleted" flag set would be skipped on an export. All subject to change, but I don't think this is all that much code.)

A few more details: most of the new code is guarded by "if (editMode)" hooks of one kind or another, so display behavior with edit mode off should be unchanged.

There's a demo at http://www.panix.com/~rst/finda/ if you'd like to see it in action.

Have fun, and hope this is useful.