Mailinglist Archive: yast-devel (77 mails)

< Previous Next >
Re: [yast-devel] a few notes on autocompletion
  • From: Josef Reidinger <jreidinger@xxxxxxx>
  • Date: Fri, 11 Dec 2009 09:49:00 +0100
  • Message-id: <200912110949.00385.jreidinger@xxxxxxx>
Duncan Mac-Vicar Prett write:
After playing some days with forms and the users module in order to achieve
the following goals:

- autocompletion of form data
- examples for fields
- browser side validation

I want to share some results of those experiments and how they affect our
design

The first limitation I found is mostly likely present in various models.

Users.find(:all) returns less data than Users.find(id), only the username
and something else. If you want to autocomplete/suggest all known login
shells ( something like Users.find(:all).map { |x| x.login_shell } ) you
need a way on the client side to get all login shells. I ended modifying
the /users service to
- accept ?attributes[]=attr1&attributes[]=attr2... so that the caller could
chose which attributes to insert
- be sure that it was able to return json

Once you have that, doing autocompletion is trivial, but very
repeat-yourself prone. Biggest problem is that you can't call from the
browser the rest- service unless:

- you set the url of the resource in the view
- you use JSON-P, using $.getJSON and setting a jsonp callback (
http://en.wikipedia.org/wiki/JSON#JSONP )

Or you can create an action in the controller which calls the service and
returns the result. I can't get the jsonp call to actually process the
data.

Then you need to set the right autocomplete data in the javascript
document.ready callback inlined in the view (at least until we solve the
problem I mentioned in opensuse-ruby mailing list ), by using
jquery.autocomplete calls on the right form fields, giving the autocomplete
data you got from the service or the controller action

We can avoid duplication of Javascript by emulating what rails implements
with protoype, so that you specify the autocompletions in the model class.
For that we would need to swtich from find_proxy to a real User class
using the class Martin Kudlvasr and Martin Vidner where working on. Once
you have a model we could use something like:

http://github.com/grosser/simple_auto_complete

combined with the jquery.autocomplete plugin to achieve a more or less
standard to apply validation to our forms.

Any ideas?


I think, that you can use for calling rest-service AJAX call. See my email
http://lists.opensuse.org/yast-devel/2009-05/msg00026.html hot to do it. AJAX
have advantage, that it doesn't block user if it take too much time.
Josef

--
Josef Reidinger
YaST team
maintainer of perl-Bootloader, YaST2-Repair, webyast
(language,time,basesystem,ntp)
--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >