orma / openroads-iD

Fork of iD to power Open Roads
Other
0 stars 0 forks source link

Carrying an ID through an iD session #75

Open dereklieu opened 8 years ago

dereklieu commented 8 years ago

@danielfdsilva I didn't get to this last week, but wanted to do a write-up of how I would try to approach this.

First I would attach a function on window.context which iD uses to preserve state, in id.js:

    var taskIDs = {};
    context.taskIDs = function(_) {
        if (!arguments.length) return taskIDs;
        taskIDs = _;
        return context;
    };

Up to you whether the data structure is be an array or an object, an object seems convenient to do like {TASK_1: true, TASK_2: false} corresponding to whether the task is marked finished, but it could just as easily be [{id: TASK_1, completed: true}, {id: TASK_2, completed: false}]

Then I would check for a task id in the url query around the same place where the bounds query is in #67. This would populate the initial task ids.

The third step is a little harder because it involves rendering the UI. In commit.js I would generate some HTML form elements by attaching context.taskIDs() to d3.data(), with event handlers to listen for user validation that the task is finished.

Finally, I would post the appropriate task IDs to the API concurrent with the changeset upload in connection.js

@danielfdsilva let me know if you have questions or thoughts here, as we're still not in that different a time zone, just going the other way now :)

danielfdsilva commented 8 years ago

This looks solid. Although the object may be more convenient, I'd go with the array. If we need to attach more info it can handle it, or you think this won't be necessary? Where would you query the server for the task details?

dereklieu commented 8 years ago

Ah, yeah, I would put that function on the context object as well and trigger it from the hash step, similar to how iD handles loadEntity - see here and here.