jimguys/poemlab — pull request #19 by marclitchfield (2013-09-23 01:53:45+00:00)
Title: Add poets to poem

This feature allows the user to add poets on the new poem form. Tried out twitter typeahead because it was really small and appeared simple to use, and it ended up working very well with minimal effort. There is a new /poet?q endpoint that the typeahead calls to do the search. When a poet is selected, a hidden input field with the poetid is added to the form. When the form is submitted, an array of poet ids is submitted to the server. A new addPoets method in the poemRepository adds all poets to the poem in one shot.

There's still room for improvement. We should probably do the poem creation in a transaction, and the typeahead should probably exclude the current user and any poets that are already added to the poem. We should also add an index to the poet name. Right now it is a starts-with search, but we could probably make it a contains search, depending on the type of index we put on the name column.