admin_assistant 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/README +3 -28
  2. data/Rakefile +18 -10
  3. data/init.rb +1 -0
  4. data/install.rb +5 -1
  5. data/lib/admin_assistant/active_record_column.rb +211 -0
  6. data/lib/admin_assistant/association_target.rb +35 -0
  7. data/lib/admin_assistant/belongs_to_column.rb +186 -0
  8. data/lib/admin_assistant/builder.rb +222 -35
  9. data/lib/admin_assistant/column.rb +266 -297
  10. data/lib/admin_assistant/default_search_column.rb +41 -0
  11. data/lib/admin_assistant/file_column_column.rb +73 -0
  12. data/lib/admin_assistant/form_view.rb +7 -68
  13. data/lib/admin_assistant/helper.rb +4 -2
  14. data/lib/admin_assistant/index.rb +101 -81
  15. data/lib/admin_assistant/paperclip_column.rb +45 -0
  16. data/lib/admin_assistant/polymorphic_belongs_to_column.rb +102 -0
  17. data/lib/admin_assistant/request/autocomplete.rb +47 -0
  18. data/lib/admin_assistant/request/base.rb +176 -0
  19. data/lib/admin_assistant/request/create.rb +27 -0
  20. data/lib/admin_assistant/request/destroy.rb +15 -0
  21. data/lib/admin_assistant/request/edit.rb +11 -0
  22. data/lib/admin_assistant/request/index.rb +26 -0
  23. data/lib/admin_assistant/request/new.rb +19 -0
  24. data/lib/admin_assistant/request/show.rb +24 -0
  25. data/lib/admin_assistant/request/update.rb +44 -0
  26. data/lib/admin_assistant/search.rb +82 -0
  27. data/lib/admin_assistant/show_view.rb +20 -0
  28. data/lib/admin_assistant/virtual_column.rb +61 -0
  29. data/lib/admin_assistant.rb +190 -85
  30. data/lib/javascripts/admin_assistant.js +253 -0
  31. data/lib/stylesheets/activescaffold.css +219 -0
  32. data/lib/stylesheets/default.css +119 -0
  33. data/lib/views/_polymorphic_field_search.html.erb +89 -0
  34. data/lib/views/_restricted_autocompleter.html.erb +53 -0
  35. data/lib/views/autocomplete.html.erb +11 -0
  36. data/lib/views/form.html.erb +6 -3
  37. data/lib/views/index.html.erb +53 -46
  38. data/lib/views/show.html.erb +19 -0
  39. data/vendor/ar_query/MIT-LICENSE +20 -0
  40. data/vendor/ar_query/README +0 -0
  41. data/vendor/ar_query/init.rb +1 -0
  42. data/vendor/ar_query/install.rb +1 -0
  43. data/vendor/ar_query/lib/ar_query.rb +137 -0
  44. data/vendor/ar_query/spec/ar_query_spec.rb +253 -0
  45. data/vendor/ar_query/tasks/ar_query_tasks.rake +0 -0
  46. data/vendor/ar_query/uninstall.rb +1 -0
  47. metadata +39 -16
  48. data/lib/admin_assistant/request.rb +0 -183
  49. data/lib/stylesheets/admin_assistant.css +0 -75
@@ -0,0 +1,219 @@
1
+ /******************************************************************************
2
+ Don't edit this file: It gets re-copied every time the server starts.
3
+ ******************************************************************************/
4
+
5
+ .admin_assistant {
6
+ font-family: "Arial", sans-serif;
7
+ margin: 9px 0
8
+ }
9
+ .admin_assistant .aa_header {
10
+ position: relative;
11
+ padding-bottom: 5px;
12
+ }
13
+ .admin_assistant .aa_header h2 {
14
+ font-size: 160%;
15
+ font-weight: bold;
16
+ color: #555;
17
+ padding: 2px 0;
18
+ margin: 0;
19
+ }
20
+ .admin_assistant .aa_header .actions {
21
+ position: absolute;
22
+ right: 5px;
23
+ top: 5px;
24
+ text-align: right;
25
+ font-size: 14px;
26
+ letter-spacing: -1px;
27
+ font-weight: bold;
28
+ }
29
+ .admin_assistant .aa_header .actions a {
30
+ color: #0066CC
31
+ }
32
+ .admin_assistant a {
33
+ text-decoration: none;
34
+ }
35
+
36
+ /***** Index stuff ***********************************************************/
37
+
38
+ .admin_assistant.index table {
39
+ font-family: "Verdana", "Arial", sans-serif;
40
+ font-size: 11px;
41
+ width: 100%; margin: 0px 0px 3px 0px; padding: 0px
42
+ }
43
+ .admin_assistant.index th {
44
+ background: #555;
45
+ color: white;
46
+ padding: 2px 15px 5px 4px;
47
+ text-align: left;
48
+ font-weight: bold;
49
+ font-family: Arial, sans-serif;
50
+ }
51
+ .admin_assistant.index th a {
52
+ color: white;
53
+ text-decoration: none;
54
+ }
55
+ .admin_assistant.index th.sort.asc {
56
+ background: #333 url(../../images/admin_assistant/sort-asc.png) no-repeat right
57
+ }
58
+ .admin_assistant.index th.sort.desc {
59
+ background: #333 url(../../images/admin_assistant/sort-desc.png) no-repeat right
60
+ }
61
+ .admin_assistant.index td {
62
+ background: #E6F2FF;
63
+ color: #333;
64
+ border-bottom: 1px solid #ccc;
65
+ border-right: 1px solid #ccc;
66
+ padding: 5px
67
+ }
68
+ .admin_assistant td.actions {
69
+ position: relative;
70
+ text-align: left;
71
+ font-weight: bold;
72
+ letter-spacing: -1px;
73
+ }
74
+ .admin_assistant.index tbody tr td:first-child {
75
+ border-left: 1px solid #ccc;
76
+ }
77
+ .admin_assistant.index tbody tr.even td {
78
+ background: #fff;
79
+ }
80
+
81
+ .admin_assistant.index tbody tr td.sort {
82
+ background: #B9DCFF
83
+ }
84
+ .admin_assistant.index tbody tr.even td.sort {
85
+ background: #E6F2FF
86
+ }
87
+ .admin_assistant.index .aa_footer {
88
+ font-family: arial, sans-serif;
89
+ font-size: 12px;
90
+ font-weight: bold;
91
+ }
92
+ .admin_assistant.index .aa_footer .pagination {
93
+ float: right;
94
+ }
95
+ .admin_assistant.index .aa_footer .pagination .links {
96
+ float: left;
97
+ }
98
+ .admin_assistant.index .aa_footer .pagination form {
99
+ margin-left: 5px;
100
+ float: left;
101
+ }
102
+ .admin_assistant.index #search_form {
103
+ background-color: #DAFFCD;
104
+ border: 1px solid #7FCF00;
105
+ padding: 4px;
106
+ font-family: verdana, sans-serif;
107
+ font-size: 11px;
108
+ margin-bottom: 0px;
109
+ }
110
+
111
+ /***** Form stuff ************************************************************/
112
+
113
+ .admin_assistant.form {
114
+ background: #DAFFCD;
115
+ border: 1px solid #7FCF00;
116
+ padding: 4px;
117
+ }
118
+
119
+ .admin_assistant.form .aa_header h2 {
120
+ color: #1F7F00;
121
+ font-size: 16px;
122
+ letter-spacing: -1px;
123
+ padding: 2px;
124
+ }
125
+
126
+ .admin_assistant.form form {
127
+ margin-top: 20px;
128
+ padding: 0px 5px;
129
+ }
130
+
131
+ .admin_assistant.form .column {
132
+ margin-bottom: 10px;
133
+ }
134
+
135
+ .admin_assistant.form label {
136
+ font-size: 11px;
137
+ }
138
+
139
+ .admin_assistant.form input[type=text] {
140
+ width: 100%
141
+ }
142
+
143
+ .admin_assistant.form input[type=text].integer {
144
+ width: 50px
145
+ }
146
+
147
+ .admin_assistant.form input, .admin_assistant.form select, .admin_assistant.form textarea {
148
+ font-size: 16px;
149
+ font-weight: bold;
150
+ letter-spacing: -1px;
151
+ }
152
+
153
+ .admin_assistant.form textarea {
154
+ width: 100%;
155
+ }
156
+
157
+ .admin_assistant.form .errorExplanation {
158
+ background: #FFCCCC;
159
+ border: 1px solid #FF6666;
160
+ margin: 2px 0;
161
+ }
162
+
163
+ .admin_assistant.form .errorExplanation h2 {
164
+ background: #FF6666;
165
+ color: #333333;
166
+ font-family: Verdana;
167
+ font-size: 11px;
168
+ padding: 2px 5px;
169
+ margin: 0;
170
+ }
171
+
172
+ .admin_assistant.form .errorExplanation p {
173
+ font-family: Verdana;
174
+ font-size: 11px;
175
+ margin: 0;
176
+ padding: 2px 5px;
177
+ }
178
+
179
+ .admin_assistant.form .errorExplanation ul {
180
+ list-style: none outside disc;
181
+ margin: 0;
182
+ padding: 0 2px 4px 25px;
183
+ }
184
+
185
+ .admin_assistant.form .errorExplanation ul li {
186
+ font-family: Verdana;
187
+ font-size: 11px;
188
+ letter-spacing: -1px;
189
+ margin: 0;
190
+ padding: 0;
191
+ font-weight: bold;
192
+ }
193
+
194
+ .admin_assistant .autocomplete_palette {
195
+ background: white;
196
+ color: #000;
197
+ border: 1px solid #2b303d;
198
+ }
199
+
200
+ .admin_assistant .autocomplete_palette ul li {
201
+ padding: 1px 5px;
202
+ }
203
+
204
+ .admin_assistant .autocomplete_palette ul li:hover,
205
+ .admin_assistant .autocomplete_palette ul li.selected {
206
+ background: #66aaff;
207
+ }
208
+
209
+
210
+ /***** Show stuff ************************************************************/
211
+ .admin_assistant.show .column {
212
+ margin-bottom: 10px;
213
+ }
214
+
215
+ .admin_assistant.show label {
216
+ font-size: small;
217
+ }
218
+
219
+
@@ -0,0 +1,119 @@
1
+ /******************************************************************************
2
+ Don't edit this file: It gets re-copied every time the server starts.
3
+ ******************************************************************************/
4
+
5
+ .admin_assistant { font-family: "Verdana","Arial", sans-serif }
6
+ .admin_assistant h2 { font-size: large; font-weight: bold }
7
+ .admin_assistant .actions {
8
+ position: absolute; right: 5px; top: 5px; text-align: right
9
+ }
10
+ .admin_assistant .aa_header { position: relative }
11
+
12
+ /***** Index stuff ***********************************************************/
13
+
14
+ .admin_assistant.index table {
15
+ width: 100%; margin: 0px 0px 10px 0px; padding: 0px
16
+ }
17
+ .admin_assistant.index th {
18
+ background: #666; color: white; padding: 5px 20px 5px 5px
19
+ }
20
+ .admin_assistant.index th a {
21
+ color: white
22
+ }
23
+ .admin_assistant.index th.sort.asc {
24
+ background: #000 url(../../images/admin_assistant/sort-asc.png) no-repeat right
25
+ }
26
+ .admin_assistant.index th.sort.desc {
27
+ background: #000 url(../../images/admin_assistant/sort-desc.png) no-repeat right
28
+ }
29
+ .admin_assistant.index td {
30
+ background: white;
31
+ border-bottom: 1px solid #ccc;
32
+ border-right: 1px solid #ccc;
33
+ padding: 5px
34
+ }
35
+ .admin_assistant td.actions {
36
+ position: relative; text-align: left
37
+ }
38
+ .admin_assistant.index tbody tr td:first-child {
39
+ border-left: 1px solid #ccc;
40
+ }
41
+ .admin_assistant.index tbody tr.even td {
42
+ background: #eee;
43
+ }
44
+
45
+ .admin_assistant.index tbody tr td.sort {
46
+ background: #ddd
47
+ }
48
+ .admin_assistant.index tbody tr.even td.sort {
49
+ background: #ccc
50
+ }
51
+
52
+ /***** Search stuff ***********************************************************/
53
+ .admin_assistant.index #search_form .autocomplete_palette {
54
+ width: 500px
55
+ }
56
+
57
+ .admin_assistant.index #search_form .polymorphic .polymorphic_type {
58
+ float: left;
59
+ padding-right: 5px;
60
+ }
61
+
62
+ /***** Form stuff ************************************************************/
63
+
64
+ .admin_assistant.form .column {
65
+ margin-bottom: 10px;
66
+ }
67
+
68
+ .admin_assistant.form .column .description {
69
+ font-size: small;
70
+ }
71
+
72
+ .admin_assistant.form input {
73
+ font-size: large
74
+ }
75
+
76
+ .admin_assistant.form input[type=text] {
77
+ width: 100%
78
+ }
79
+
80
+ .admin_assistant.form input[type=text].integer {
81
+ width: 50px
82
+ }
83
+
84
+ .admin_assistant.form select {
85
+ font-size: large
86
+ }
87
+
88
+ .admin_assistant.form textarea {
89
+ width: 100%;
90
+ font-size: large
91
+ }
92
+
93
+
94
+ .admin_assistant .autocomplete_palette {
95
+ background: white;
96
+ color: #000;
97
+ border: 1px solid #2b303d;
98
+ }
99
+
100
+ .admin_assistant .autocomplete_palette ul li {
101
+ padding: 1px 5px;
102
+ }
103
+
104
+ .admin_assistant .autocomplete_palette ul li:hover,
105
+ .admin_assistant .autocomplete_palette ul li.selected {
106
+ background: #66aaff;
107
+ }
108
+
109
+
110
+ /***** Show stuff ************************************************************/
111
+ .admin_assistant.show .column {
112
+ margin-bottom: 10px;
113
+ }
114
+
115
+ .admin_assistant.show label {
116
+ font-size: small;
117
+ }
118
+
119
+
@@ -0,0 +1,89 @@
1
+ <div class="polymorphic">
2
+ <%
3
+ hidden_field_id = "search_#{column.association_foreign_key}"
4
+ hidden_type_field_id = "search_#{column.foreign_type_field}"
5
+ associated = record.send(column.name)
6
+ if associated
7
+ associated_id = associated.id
8
+ associated_type = associated.class.name
9
+ else
10
+ associated_id = nil
11
+ associated_type = nil
12
+ end
13
+ auth_token = if protect_against_forgery?
14
+ form_authenticity_token
15
+ else
16
+ ''
17
+ end
18
+ js_args = {:autocompleteTypes => [], :idTypes => [], :selectTypes => []}
19
+ %>
20
+ <%= hidden_field_tag(
21
+ "search[#{column.association_foreign_key}]", associated_id,
22
+ :id => "search_#{column.association_foreign_key}"
23
+ ) %>
24
+ <%= hidden_field_tag(
25
+ "search[#{column.foreign_type_field}]", associated_type,
26
+ :id => hidden_type_field_id
27
+ ) %>
28
+ <%
29
+ polymorphic_types.each do |polymorphic_type|
30
+ name = polymorphic_type.name.underscore.downcase
31
+ association_target = AdminAssistant::AssociationTarget.new polymorphic_type
32
+ %>
33
+ <div class="polymorphic_type">
34
+ <% if association_target.default_name_method %>
35
+ <label><%= association_target.name.capitalize %></label>
36
+ <br />
37
+ <%
38
+ if polymorphic_type.count > 15
39
+ clear_link_id = "clear_#{column.name}_#{name}_link"
40
+ text_field_id = "#{column.name}_#{name}_autocomplete_input"
41
+ palette_id = "#{column.name}_#{name}_autocomplete_palette"
42
+ js_args[:autocompleteTypes] << {
43
+ :clearLink => clear_link_id, :name => name, :palette => palette_id,
44
+ :parameters => "authenticity_token=#{auth_token}",
45
+ :textField => text_field_id, :type => polymorphic_type.name,
46
+ :url => "/#{controller.controller_path}/autocomplete_#{name}"
47
+ }
48
+ text_field_value = if associated.class == polymorphic_type
49
+ association_target.assoc_value(associated)
50
+ end
51
+ %>
52
+ <%= text_field_tag(text_field_id, text_field_value, :id => text_field_id) %>
53
+ <div id="<%= palette_id %>" class="autocomplete_palette" style="display:none"></div>
54
+ <div id="<%= clear_link_id %>" style="display:none; padding: 5px">
55
+ <%= link_to_function("Clear #{name}", "") %>
56
+ </div>
57
+ <%
58
+ else
59
+ js_args[:selectTypes] << {:name => name, :type => polymorphic_type.name}
60
+ option_tags = "<option value=''></option>"
61
+ option_tags << options_for_select(
62
+ association_target.options_for_select,
63
+ (associated.id if associated.class == polymorphic_type)
64
+ )
65
+ %>
66
+ <%= select_tag("#{column.name}_#{name}_id", option_tags) %>
67
+ <%
68
+ end
69
+ else
70
+ js_args[:idTypes] << {:name => name, :type => polymorphic_type.name}
71
+ %>
72
+ <label><%= association_target.name.capitalize %> ID</label>
73
+ <br />
74
+ <%= text_field_tag(
75
+ "#{column.name}_#{name}_id",
76
+ (associated.id if associated.class == polymorphic_type)
77
+ ) %>
78
+ <%
79
+ end
80
+ %>
81
+ </div>
82
+ <% end %>
83
+ <br style="clear:both" />
84
+ </div>
85
+ <script type="text/javascript">
86
+ new AdminAssistant.PolymorphicFieldSearch(
87
+ '<%= column.name %>', <%= js_args.to_json %>
88
+ );
89
+ </script>
@@ -0,0 +1,53 @@
1
+ <%
2
+ record = form.object
3
+ unless defined?(palette_clones_input_width) && !palette_clones_input_width.nil?
4
+ palette_clones_input_width = true
5
+ end
6
+ class_name = record.class.name.gsub(/.*::/, '').underscore.downcase
7
+ associated_class_name = column.associated_class.name.underscore
8
+ text_field_id = "#{associated_class_name}_autocomplete_input"
9
+ palette_id = "#{associated_class_name}_autocomplete_palette"
10
+ hidden_field_id = "#{class_name}_#{column.association_foreign_key}"
11
+ associated = record.send(column.name)
12
+ if associated
13
+ associated_id = associated.id
14
+ else
15
+ associated_id = nil
16
+ end
17
+ autocompleter_js_var = "#{associated_class_name}_autocompleter"
18
+ target = AdminAssistant::AssociationTarget.new column.associated_class
19
+ %>
20
+ <%= text_field_tag(
21
+ text_field_id, target.assoc_value(record.send(column.name)),
22
+ :id => text_field_id
23
+ ) %>
24
+ <%=
25
+ form.hidden_field(column.association_foreign_key, :id => hidden_field_id)
26
+ %>
27
+ <div id="<%= palette_id %>" class="autocomplete_palette" style="display:none"></div>
28
+
29
+ <div id="clear_<%= associated_class_name %>_link" style="display:none; padding: 5px">
30
+ <%= link_to_function("Clear #{associated_class_name}", "") %>
31
+ </div>
32
+
33
+ <%
34
+ auth_token = if protect_against_forgery?
35
+ form_authenticity_token
36
+ else
37
+ ''
38
+ end
39
+ options = {
40
+ :includeBlank => select_options[:include_blank],
41
+ :paletteClonesInputWidth => palette_clones_input_width,
42
+ :parameters => "authenticity_token=#{auth_token}"
43
+ }
44
+ %>
45
+ <script type="text/javascript">
46
+ new AdminAssistant.RestrictedAutocompleter(
47
+ "<%= associated_class_name %>",
48
+ "<%= hidden_field_id %>",
49
+ "/<%= controller.controller_path %>/autocomplete_<%= associated_class_name %>",
50
+ <%= options.to_json %>
51
+ );
52
+ </script>
53
+
@@ -0,0 +1,11 @@
1
+ <%
2
+ association_target = AdminAssistant::AssociationTarget.new(associated_class)
3
+ %>
4
+ <ul>
5
+ <% records.each do |record| %>
6
+ <li id="<%= prefix %><%= record.id %>"><%=
7
+ association_target.assoc_value(record)
8
+ %></li>
9
+ <% end %>
10
+ </ul>
11
+
@@ -1,11 +1,11 @@
1
1
  <%
2
2
  form_view = AdminAssistant::FormView.new(@record, @admin_assistant, self)
3
3
  %>
4
- <div id="admin_assistant" class="form <%=
4
+ <div class="admin_assistant form <%=
5
5
  @admin_assistant.controller_css_class(controller)
6
6
  %>">
7
7
  <% id = nil unless defined?(id) %>
8
- <div id="header">
8
+ <div class="aa_header">
9
9
  <h2><%= h(form_view.title) %></h2>
10
10
  <div class="actions">
11
11
  <%= link_to('Back to index', :action => 'index') %>
@@ -18,7 +18,10 @@ form_view = AdminAssistant::FormView.new(@record, @admin_assistant, self)
18
18
  <% form_view.columns.each do |column| %>
19
19
  <div class="column">
20
20
  <label><%= h(column.label) %></label>
21
- <br /><%= form_view.column_html(column, rails_form) %>
21
+ <% if column.description %>
22
+ <p class="description"><%= h(column.description) %></p>
23
+ <% end %>
24
+ <br /><%= column.html(rails_form) %>
22
25
  </div>
23
26
  <% end %>
24
27
  <div>
@@ -1,92 +1,99 @@
1
- <div id="admin_assistant" class="index <%=
1
+ <% index_view = @index.view(self) %>
2
+ <div class="admin_assistant index <%=
2
3
  @admin_assistant.controller_css_class(controller)
3
4
  %>">
4
- <script type="text/javascript">
5
- function show_search_form() { $('search_form').show(); }
6
- </script>
7
-
8
- <div id="header">
5
+ <div class="aa_header">
9
6
  <div class="actions">
10
- <%= link_to_function('Search', 'show_search_form()') %>
7
+ <%= link_to_function('Search', 'AdminAssistant.show_search_form()') %>
11
8
  <%= link_to(
12
9
  "New #{@admin_assistant.model_class_name}", @admin_assistant.url_params(:new)
13
- ) %>
10
+ ) if @admin_assistant.new? %>
14
11
  <% @admin_assistant.index_settings.actions.each do |action, params| %>
15
12
  <%= link_to_unless_current(action, params) %>
16
13
  <% end %>
17
14
  </div>
18
- <h2><%= h(
19
- @admin_assistant.model_class.name.pluralize.gsub(/([A-Z])/, ' \1')[1..-1]
20
- ) %></h2>
15
+ <h2><%= h(index_view.header) %></h2>
21
16
  </div>
22
17
 
23
- <% @search = @index.search %>
24
18
  <% form_for(
25
- :search,
19
+ :search, @index.search,
26
20
  :url => {:action => 'index'},
27
21
  :html => {:id => 'search_form', :style => 'display:none', :method => 'get'}
28
22
  ) do |form| %>
29
- <% @search.column_views(self).each do |column_view| %>
30
- <%= column_view.search_html %>
23
+ <% column_views = @index.search.column_views self %>
24
+ <% if column_views.size > 1 %>
25
+ Match all conditions <%= radio_button_tag(
26
+ "search[(all_or_any)]", "all", @index.search.match_all_conditions?
27
+ ) %>
28
+ &nbsp;&nbsp;&nbsp;
29
+ Match any condition <%= radio_button_tag(
30
+ "search[(all_or_any)]", "any", @index.search.match_any_conditions?
31
+ ) %>
32
+ <% end %>
33
+ <% column_views.each do |column_view| %>
34
+ <%= column_view.html(form) %>
31
35
  <% end %>
32
36
  <%= submit_tag('Search') %>
33
- <%= link_to('Back to index', :action => 'index') if @index.search_terms %>
37
+ <%=
38
+ link_to('Back to index', :action => 'index') if @index.search_requested?
39
+ %>
34
40
  <% end %>
35
41
 
36
- <% if @index.search_terms %>
37
- <script type="text/javascript">
38
- show_search_form();
39
- </script>
42
+ <% if @index.search_requested? %>
43
+ <script type="text/javascript">AdminAssistant.show_search_form();</script>
40
44
  <% end %>
41
45
 
42
46
  <% if !@index.records.empty? %>
43
47
  <table cellspacing="0" cellpadding="0">
44
48
  <thead>
45
49
  <tr>
46
- <% @index.view(self).columns.each do |column| %>
47
- <% th_class = column.index_header_css_class %>
50
+ <% index_view.columns.each do |column| %>
51
+ <% th_class = column.header_css_class %>
48
52
  <th<%= " class=\"#{th_class}\"" if th_class %>><%=
49
- if column.sort_possible?
53
+ if column.sort_possible?(@index.records.total_entries)
50
54
  link_to(h(column.label), column.next_sort_params)
51
55
  else
52
56
  h(column.label)
53
57
  end
54
58
  %></th>
55
59
  <% end %>
56
- <% if @admin_assistant.update? || @admin_assistant.destroy? %>
57
- <th></th>
58
- <% end %>
60
+ <% if index_view.right_column? %><th></th><% end %>
59
61
  </tr>
60
62
  </thead>
61
- <tbody>
63
+ <tbody id="<%= @admin_assistant.model_class.name.underscore.pluralize %>_index_tbody">
62
64
  <% @index.records.each do |record| %>
63
- <tr class="<%= cycle('odd', 'even') %>" id="record_<%= record.id %>">
65
+ <tr class="<%= cycle('odd', 'even') %>" id="<%=
66
+ @admin_assistant.model_class.name.underscore
67
+ %>_<%= record.id %>">
64
68
  <% @index.view(self).columns.each do |column| %>
65
- <% td_class = column.index_td_css_class %>
69
+ <% td_class = column.td_css_class %>
66
70
  <td<%= " class=\"#{td_class}\"" if td_class %>><%=
67
- column.index_html(record)
71
+ column.html(record)
68
72
  %></td>
69
73
  <% end %>
70
- <% if @admin_assistant.update? || @admin_assistant.destroy? %>
71
- <td>
72
- <% if @admin_assistant.update? %>
73
- <%= link_to 'Edit', :action => 'edit', :id => record.id %>
74
- <% end %>
75
- <% if @admin_assistant.destroy? %>
76
- <%= link_to_remote(
77
- 'Delete',
78
- :url => {:action => 'destroy', :id => record.id},
79
- :confirm => 'Are you sure?',
80
- :success => "Effect.Fade('record_#{record.id}')"
81
- ) %>
82
- <% end %>
83
- </td>
74
+ <% if index_view.right_column? %>
75
+ <td class="actions"><%= index_view.right_column_links(record) %></td>
84
76
  <% end %>
85
77
  </tr>
86
78
  <% end %>
87
79
  </tbody>
88
80
  </table>
89
- <%= will_paginate @index.records %>
90
81
  <% end %>
91
- <%= @index.records.empty? ? 'No' : @index.records.total_entries %> <%= @admin_assistant.model_class_name %><%= 's' unless @index.records.total_entries == 1 %> found
82
+ <div class="aa_footer">
83
+ <div class="pagination">
84
+ <div class="links">
85
+ <%= will_paginate @index.records, :container => false %>
86
+ </div>
87
+ <% if @index.records.total_pages > 10 %>
88
+ <% form_tag({:action => 'index'}, :method => 'get') do %>
89
+ <%= text_field_tag('page', nil, :size => 2) %>
90
+ <%= submit_tag('Jump') %>
91
+ <% end %>
92
+ <% end %>
93
+ </div>
94
+ <%= @index.records.empty? ? 'No' : @index.records.total_entries %> <%=
95
+ name = @admin_assistant.model_class_name
96
+ @index.records.total_entries == 1 ? name : name.pluralize
97
+ %> found
98
+ </div>
92
99
  </div>
@@ -0,0 +1,19 @@
1
+ <div class="admin_assistant show <%=
2
+ @admin_assistant.controller_css_class(controller)
3
+ %>">
4
+ <div class="aa_header">
5
+ <h2><%=
6
+ h("#{request.model_class_name(@record).capitalize} #{@record.id}")
7
+ %></h2>
8
+ <%= link_to 'Edit', :action => 'edit', :id => @record.id %>
9
+ </div>
10
+ <%
11
+ show_view = AdminAssistant::ShowView.new(@record, @admin_assistant, self)
12
+ %>
13
+ <% show_view.columns.each do |column| %>
14
+ <div class="column">
15
+ <label><%= h(column.label) %></label>
16
+ <br /><%= show_view.column_html(column) %>
17
+ </div>
18
+ <% end %>
19
+ </div>