Permalink
Browse files

Added documentation on text_field_with_auto_complete.

:defaults javascript added to django theme's layout.

I'm not sure if it's really a good idea to load
Script.aculo.us and Prototype every time, even if they're
not needed. Perhaps I should "clone" the django theme or
provide a way to customize/control javascript loading.
  • Loading branch information...
1 parent 9713eed commit 265ac062cb0c642cb99b4c5047c83671807dcb7e @baldowl committed Dec 31, 2008
Showing with 41 additions and 0 deletions.
  1. +18 −0 README
  2. +22 −0 lib/auto_admin_simple_theme.rb
  3. +1 −0 themes/django/views/layouts/layout.html.erb
View
18 README
@@ -108,6 +108,10 @@ To use AutoAdmin with Rails 2.* you need an extra plugin,
will_paginate[git://github.com/mislav/will_paginate.git], because the
pagination mechanism has been removed from the Rails core base.
+To use the +text_field_with_auto_complete+ helper you need an extra plugin,
+auto_complete[git://github.com/rails/auto_complete.git], because the
+autocompletion mechanism has been removed from the Rails core base.
+
For the optional export mechanism you also need:
* the *faster_csv* gem for the CSV export module;
@@ -298,6 +302,20 @@ reasons.
can be used to return an hash to be merged into the options that are about
to be passed to the tag helper.
+* +text_field_with_auto_complete+ provides a simple text field with
+ autocompletion delegating all the work to the homonymous ActionView's
+ helper; there's a complication, however: there must be a separate controller
+ which provides the completion data:
+
+ b.text_field_with_auto_complete :name,
+ :completion => { :url => { :controller => 'items',
+ :action => 'auto_complete_for_item_name' }}
+
+ For information on this controller, see Rails documentation. Note that if
+ you designed your application in a REST-like way, you should tweak your
+ resources' definitios or add a specific route for the new
+ <tt>auto_complete_for_<em>model</em>_<em>field</em></tt>.
+
* None of the following actually work, but they're defined, waiting for me to
come back and write them. +html_area+ will eventually use FCKeditor by
default, and presumably the file/image fields will delegate to file_column:
@@ -259,6 +259,28 @@ def datetime_select(field, options = {})
common_option_translations! options
super(field, options)
end
+
+ # To use this helper there must be a separate controller which provides
+ # the completion data. Let's say we have the Item model, with a :name
+ # attribute for which we want autocompletion, and that there's the
+ # ItemsControler; we should add
+ #
+ # auto_complete_for :item, :name
+ #
+ # to the controller. Then, in the Item model we should add
+ #
+ # admin_fieldset do |b|
+ # b.text_field_with_auto_complete :name,
+ # :completion => {:url => {:controller => 'items',
+ # :action => 'auto_complete_for_item_name'}}
+ # # ...
+ # end
+ #
+ # If our design is REST-like, we must tweak the resources' definitions or
+ # add a specific route for this action to work:
+ #
+ # map.resources :items,
+ # :collection => {:auto_complete_for_item_name => :post}
def text_field_with_auto_complete(field, options = {})
common_option_translations! options
completion_options = options.delete(:completion) || {}
@@ -4,6 +4,7 @@
<head>
<title><%=h @title ? "#{@title} | " : '' %><%=h site.name %></title>
<%= tag("link", { "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => url_for( :action => 'asset', :path => 'stylesheets/auto_admin.css', :escape => false ) } ) %>
+ <%= javascript_include_tag :defaults %>
</head>
<body class="<%=h @body_class %>">

0 comments on commit 265ac06

Please sign in to comment.