I have an invoice application that requires the user to select a user object named "creator" from a list of over 100k users. Since there are so many users a traditional select box with 100k options is out of the question. An AJAX enabled select box is out of the question too due to the types of clients that will use this application. I think it should work something like this... -User creates invoice and fills out some fields (e.g. description) -User clicks "select creator" link that takes them to a user select page -On the user select page they can type in a partial name, click submit, and the matches are returned. When they find the one they want they click a "select user" link. This link returns them to the invoice page, populates the "creator" field and keeps all of their previous edits (e.g. description). Ideally I would like to construct this "choose user" functionality so that it could be reused for other applications (e.g. purchase order has a "creator" field as well). Any thoughts on how to pattern this?
Kyle Maxwell
2005-Aug-31 18:20 UTC
Re: Help with pattern for reusable large chooser / select
I think that the primary pattern 95% of us use for this type of situation is text_field_with_auto_complete, so I wouldn''t worry to much about making it available for global use. Anyhow, in the popup: 1. Start from a standard scaffold-style paginated list. 2. Add :conditions => ["user LIKE ?", "%#{@params[:search]}%"] 3. Add a search form: <form method=post><input name=search value="<%=h @params[:search]%>"></form> 4. Add a link to each row with javascript:opener.formElement.value=<%=row.value%>;window.close() Kyle Maxwell On 8/31/05, J T <future429-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have an invoice application that requires the user to select a user object > named "creator" from a list of over 100k users. Since there are so many users a > traditional select box with 100k options is out of the question. An AJAX enabled > select box is out of the question too due to the types of clients that will use > this application. I think it should work something like this... > > -User creates invoice and fills out some fields (e.g. description) > -User clicks "select creator" link that takes them to a user select page > -On the user select page they can type in a partial name, click submit, and the > matches are returned. When they find the one they want they click a "select > user" link. This link returns them to the invoice page, populates the "creator" > field and keeps all of their previous edits (e.g. description). > > Ideally I would like to construct this "choose user" functionality so that it > could be reused for other applications (e.g. purchase order has a "creator" > field as well). > > Any thoughts on how to pattern this? > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Andrew Otwell
2005-Aug-31 21:09 UTC
re: Help with pattern for reusable large chooser / select
> -User creates invoice and fills out some fields (e.g. description) > -User clicks "select creator" link that takes them to a user select > page > -On the user select page they can type in a partial name, click > submit, and the matches are returned. When they find the one they > want they click a "select user" link. This link returns them to the > invoice page, populates the "creator" field and keeps all of their > previous edits (e.g. description).Why the extra step? 1. create invoice 2. On the invoice, the user enters a name in the "creator" field. 3. On submit, if the name doesn''t match one from the db (it might), show nearest matches and ask them to choose. No point in even asking them to choose unless you know there''s a failure. If you book airline reservations online, you see this a lot: I type "Austin" as an airport and it asks if I mean "Austin, TX" or "Austin, OR", or "Austin, NY". But consider using Ajax, even an <iframe>-based solution. There aren''t as many client limitations as you might think.