hobo 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/bin/hobo +1 -1
  2. data/hobo_files/plugin/CHANGES.txt +302 -0
  3. data/hobo_files/plugin/generators/hobo_front_controller/templates/index.dryml +2 -9
  4. data/hobo_files/plugin/generators/hobo_model/templates/model.rb +1 -1
  5. data/hobo_files/plugin/generators/hobo_model_resource/hobo_model_resource_generator.rb +0 -2
  6. data/hobo_files/plugin/generators/hobo_rapid/templates/hobo-rapid.js +76 -46
  7. data/hobo_files/plugin/generators/hobo_rapid/templates/lowpro.js +25 -18
  8. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/stylesheets/application.css +29 -11
  9. data/hobo_files/plugin/generators/hobo_user_model/templates/model.rb +2 -2
  10. data/hobo_files/plugin/init.rb +0 -1
  11. data/hobo_files/plugin/lib/active_record/has_many_association.rb +3 -0
  12. data/hobo_files/plugin/lib/hobo.rb +12 -8
  13. data/hobo_files/plugin/lib/hobo/bundle.rb +1 -1
  14. data/hobo_files/plugin/lib/hobo/dryml/dryml_builder.rb +1 -1
  15. data/hobo_files/plugin/lib/hobo/dryml/parser/attribute.rb +41 -0
  16. data/hobo_files/plugin/lib/hobo/dryml/parser/base_parser.rb +253 -0
  17. data/hobo_files/plugin/lib/hobo/dryml/parser/document.rb +26 -0
  18. data/hobo_files/plugin/lib/hobo/dryml/parser/element.rb +27 -0
  19. data/hobo_files/plugin/lib/hobo/dryml/parser/elements.rb +45 -0
  20. data/hobo_files/plugin/lib/hobo/dryml/parser/source.rb +58 -0
  21. data/hobo_files/plugin/lib/hobo/dryml/parser/text.rb +13 -0
  22. data/hobo_files/plugin/lib/hobo/dryml/parser/tree_parser.rb +67 -0
  23. data/hobo_files/plugin/lib/hobo/dryml/scoped_variables.rb +10 -5
  24. data/hobo_files/plugin/lib/hobo/dryml/template.rb +48 -27
  25. data/hobo_files/plugin/lib/hobo/dryml/template_environment.rb +28 -13
  26. data/hobo_files/plugin/lib/hobo/hobo_helper.rb +3 -1
  27. data/hobo_files/plugin/lib/hobo/model.rb +70 -10
  28. data/hobo_files/plugin/lib/hobo/model_controller.rb +49 -34
  29. data/hobo_files/plugin/lib/hobo/model_router.rb +10 -2
  30. data/hobo_files/plugin/lib/hobo/rapid_helper.rb +1 -0
  31. data/hobo_files/plugin/lib/hobo/scopes.rb +15 -0
  32. data/hobo_files/plugin/lib/hobo/scopes/apply_scopes.rb +23 -0
  33. data/hobo_files/plugin/lib/hobo/scopes/association_proxy_extensions.rb +4 -2
  34. data/hobo_files/plugin/lib/hobo/scopes/automatic_scopes.rb +34 -7
  35. data/hobo_files/plugin/lib/hobo/scopes/defined_scope_proxy_extender.rb +3 -1
  36. data/hobo_files/plugin/lib/hobo/scopes/scoped_proxy.rb +1 -5
  37. data/hobo_files/plugin/taglibs/rapid.dryml +33 -24
  38. data/hobo_files/plugin/taglibs/rapid_editing.dryml +6 -5
  39. data/hobo_files/plugin/taglibs/rapid_forms.dryml +37 -31
  40. data/hobo_files/plugin/taglibs/rapid_generics.dryml +68 -27
  41. data/hobo_files/plugin/taglibs/rapid_navigation.dryml +5 -8
  42. data/hobo_files/plugin/taglibs/rapid_pages.dryml +71 -47
  43. data/hobo_files/plugin/taglibs/rapid_plus.dryml +4 -5
  44. data/hobo_files/plugin/taglibs/rapid_support.dryml +11 -4
  45. metadata +23 -6
  46. data/hobo_files/plugin/lib/rexml.rb +0 -443
data/bin/hobo CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- HOBO_VERSION = "0.7.3"
3
+ HOBO_VERSION = "0.7.4"
4
4
 
5
5
  require 'fileutils'
6
6
  Signal.trap("INT") { puts; exit }
@@ -1,3 +1,305 @@
1
+ == Hobo 0.7.4 ===
2
+
3
+ Switching to a new style for the changelog. Now that we're using git
4
+ the commit logs are a lot better, so this file is just going to
5
+ contain edited highlights of the commit log.
6
+
7
+ Rapid: making <view> make more use of the to_html API from
8
+ HoboFields
9
+
10
+ Reworked REXML extensions. Now compatible with REXML 3.7.1.1
11
+ through 3.7.1.3
12
+
13
+ ModelController -- fix to chosing whether or not to paginate
14
+
15
+ Various IE Javascript fixes
16
+
17
+ Rapid, <select-many>: Additional params, and IE fix
18
+
19
+ Moving the part-contexts javascripts from the very end of the
20
+ output, to the end of <body>
21
+
22
+ The script tag must now be output by the <page>, instead of
23
+ being appended automatically by DRYML. This is done in
24
+ <simple-layout/>
25
+
26
+ Rapid -- removing <view for='percentage'>
27
+
28
+ DRYML -- improved error reporting
29
+
30
+ Hobo::Model: fix -- we were breaking inheritence of validations
31
+
32
+ Model generators -- adding some helpful comments
33
+
34
+ Rapid: Fix to permission check for adding to primary collection on
35
+ <show-page>
36
+
37
+ Rapid: removing empty message from <index-page>
38
+
39
+ Rapid: Fix to enum-string editor
40
+
41
+ Rapid: Fix to auto-label in <count>
42
+
43
+ User model generator -- change create permission to allow admin to
44
+ create another admin
45
+
46
+ New lowpro version
47
+
48
+ New automatic css class 'with-owner' on default <card/>
49
+
50
+ Hobo::ModelController -- fix to automatic inclusion of reorder
51
+ action for models that act as list
52
+
53
+ Improvements to default <card>
54
+
55
+ Rapid javascript: try to automatically bring back the
56
+ empty-message on removing the last item from a collection
57
+
58
+ Scopes: fix to apply_scopes
59
+
60
+ Fix to <name-for-collection>
61
+
62
+ Rapid tags: Support for the empty-message on a collection
63
+ re-appearing automatically if all the items are removed by the
64
+ user
65
+
66
+ DRYML: scoped variables -- assigning to a variable now modifies
67
+ it's value in a parent scope if it's present in one
68
+
69
+ <delete-button> fix -- was incorrectly guessing 'in-place' during
70
+ ajax update
71
+
72
+ New tag <name-for-collection>
73
+
74
+ Fix to <view for='text'/>
75
+
76
+ Improvements to <table-plus>
77
+
78
+ Ability to sort by name of 'this' when 'this' is one of the
79
+ fields
80
+
81
+ Keep table headings in when the table is empty
82
+
83
+ Don't include page nav if the collection doesn't support it
84
+
85
+ Improvements to rapid pages
86
+
87
+ Allowing has_many associations in forms
88
+
89
+ Allowing the primary collection on a show page to be provided by
90
+ an instance variable (so that filtering/searching/pagination are
91
+ supported)
92
+
93
+ Tidy of <show-page>
94
+
95
+ <index-page> -- improved wording
96
+
97
+ Fixes to <index-page>
98
+
99
+ <account-nav> make 'logged in as bob' a link to current_user
100
+
101
+ Factored out default <collection> into <base-collection>, and
102
+ fixes to <collection-preview>
103
+
104
+ <base-card> -- add 'edit' link
105
+
106
+ <base-card> change 'title' param to 'heading' and make it easier
107
+ to provide your own
108
+
109
+ <creation-details> use a div rather than a span
110
+
111
+ Fix to <select-many>
112
+
113
+ Fix to <select-menu>
114
+
115
+ Fix to <input for='datetime'>
116
+
117
+ Rapid forms: switching to <select-one> and <select-many> naming
118
+
119
+ <form> -- don't include auth token on GET forms
120
+
121
+ Rapid: <belongs-to-menu-editor> -- don't show 'View' link if the
122
+ thing is not linkable
123
+
124
+ Rapid: adding sort attribute to <belongs-to-menu-editor>
125
+
126
+ Rapid: default 'no-filter' option for filter-menu
127
+
128
+ Rapid: Fix to extraneous whitespace in <you>
129
+
130
+ Rapid: better guess of label on <count>
131
+
132
+ Rapid: Use association name rather than class name in css classes
133
+ on <a> tags (when available)
134
+
135
+ Rapid: Fix to use of <else> with <a>
136
+
137
+ Removed 'all' method from ScopedProxy - delegates to the model
138
+ class instead
139
+
140
+ Fix to origin_attribute on scoped associations
141
+
142
+ Fix to with_abc automatic scopes
143
+
144
+ New automatic scopes 'include' and 'search', and improvements to
145
+ order_by scope
146
+
147
+ Scopes: fix to parameterised scopes on associations
148
+
149
+ Scopes: new apply_scopes method for models and has_many
150
+ associations
151
+
152
+ Pass a hash of scope-name => scope-arguments (single valur or
153
+ array), the result will be scoped accordingly, but only if the
154
+ first argument to the scope is not blank. It's designed to be
155
+ used from controllers: if a param (e.g. a search or filter) is
156
+ not included in the request, the scope is not applied
157
+
158
+ Hobo::ModelController -- fix to permission denied response for
159
+ ajax actions
160
+
161
+ Hobo::ModelController -- Fix to flash message after update
162
+
163
+ Hobo::ModelController -- fix to redirection after submitting a
164
+ form
165
+
166
+ Hobo::ModelController -- cleaning up sorting and filtering
167
+
168
+ Hobo::ModelController -- make reorder one of the automatic
169
+ :write_only actions if the model has the position_column method
170
+
171
+ <with-fields> better error reporting
172
+
173
+ Hobo::ModelController -- adding automatic reorder action
174
+
175
+ Works with acts_as_list and scriptaculous drag and drop
176
+ re-ordering
177
+
178
+ Hobo::Model adding :managed => true option to has_many
179
+
180
+ Only valid with the :through option. Records of the joining
181
+ model will be created and destroyed as required when this record
182
+ is saved, in order to honour the contents of the association at
183
+ save time.
184
+
185
+ Hobo::Model -- adding .user_update
186
+
187
+ Hobo::Model -- fix to user_find
188
+
189
+ Hobo::HoboHelper -- #map_this (used by repeat) will set this_key
190
+ when iterating over a hash
191
+
192
+ DRYML: made this_field_reflection do a better job of figuring out
193
+ the current reflection
194
+
195
+ DRYML: adding this_key -- gives you the current key when
196
+ <repeat>ing on a hash
197
+
198
+ DRYML: Error message for invalid attributes on parameter tags,
199
+ e.g. <foo: if-'...'>
200
+
201
+ Hobo module - fix to permission checks on unexpected objects
202
+
203
+ Hobo module -- always return false for can_create? on has_many
204
+ associations that are not 'simple'
205
+
206
+ (i.e. they have conditions)
207
+
208
+ DRYML: Fix for replacing an overridden tag parameter
209
+
210
+ Rapid pages: new submit label on show page (add to collection)
211
+
212
+ Rapid pages: Add param to <show-page>
213
+
214
+ Rapid pages: by default, append app-name to every title, override
215
+ with full-title attribute (<base-page>)
216
+
217
+ Rapid pages: <show-page> -- update primary collection count when
218
+ an item is deleted
219
+
220
+ Rapid pages: fix on <show-page>
221
+
222
+ Rapid pages: make edit link on show-page check if the edit action
223
+ is linkable
224
+
225
+ Rapid forms: adding inputs (just textareas) for textile and
226
+ markdown
227
+
228
+ front_controller generator -- use <collection-preview> in
229
+ index.dryml
230
+
231
+ Rapid generics: adding support for <collection with='&MyModel'/>
232
+
233
+ Rapid tags: switching to <main-nav> tag, called from simple-layout
234
+
235
+ hobo_model_resource generator -- removing creating of (rails
236
+ style) resource route
237
+
238
+ Improvements to rapid pages
239
+
240
+ Allowing has_many associations in forms
241
+
242
+ Allowing the primary collection on a show page to be provided by
243
+ an instance variable (so that filtering/searching/pagination are
244
+ supported)
245
+
246
+ Rapid: Fix to use of <else> with <a>
247
+
248
+ Removed 'all' method from ScopedProxy - delegates to the model
249
+ class instead
250
+
251
+ Fix to origin_attribute on scoped associations
252
+
253
+ Rapid tags: disabled <belongs-to-view>, new <view
254
+ for='ActiveRecord::Base'> is used now
255
+
256
+ Hobo::Model -- fix to reverse_refelction
257
+
258
+ Rapid tags: Adding <head:> and <foot:> params to <ul>
259
+
260
+ Rapid tags: Adding params to <select-many>
261
+
262
+ Rapid tags: adding support for <ul empty> (force the <ul> to
263
+ appear even if empty)
264
+
265
+ Fix: automatic scopes not_ and "association name" were not being
266
+ created
267
+
268
+ Rapid forms: Renaming <name-array-input> to <select-many> (and
269
+ improvements)
270
+
271
+ Hobo::Model -- adding assigment by arrays of names to has_many
272
+ associations
273
+
274
+ Hobo::Model -- adding Model.manage_join_records
275
+
276
+ Routing: fix -- don't try to load assemble.rb if
277
+ ApplicationController not defined
278
+
279
+ Rapid pages: Fix to body class on <new-page>
280
+
281
+ Rapid pages: fix to show page
282
+
283
+ Rapid pages -- fixing pluralisation of <index-page> title
284
+
285
+ Adding support for 'this' psuedo-field to <with-fields> and
286
+ <with-fields-names>
287
+
288
+ In particular, this makes it possible to include the object
289
+ itself in a table plus column
290
+
291
+ Adding a general <view> for ActiveRecord objects (just <a/>)
292
+
293
+ Allowing lookup of polymorphic tags to include ActiveRecord::Base
294
+ or Object as a catch-all
295
+
296
+ Rapid generics: make collection preview hide the show-all link if
297
+ there are none
298
+
299
+ <page-nav> now uses will_paginate's helper to provide much better
300
+ page navigation than before.
301
+
302
+
1
303
  === Release 0.7.3 ===
2
304
 
3
305
  hobo command -- options are now:
@@ -15,15 +15,8 @@
15
15
  <content-body:>
16
16
  <ul with="&front_models">
17
17
  <li:>
18
- <header><h2><a/></h2></header>
19
- <section>
20
- <p if="&this.count == 0">There are no <type-name plural/></p>
21
- <else>
22
- <card repeat="&select_viewable(this.recent.all)"/>
23
- <p><a>More</a> (<count/>)</p>
24
- </else>
25
- <p if="&can_create? && linkable?(:new)">Create a <a to="&this" action="new"/>.</p>
26
- </section>
18
+ <collection-preview/>
19
+ <p if="&can_create? && linkable?(:new)">Create a <a to="&this" action="new"/>.</p>
27
20
  </li:>
28
21
  </ul>
29
22
  </content-body>
@@ -1,6 +1,6 @@
1
1
  class <%= class_name %> < ActiveRecord::Base
2
2
 
3
- hobo_model
3
+ hobo_model # Don't put anything above this
4
4
 
5
5
  fields do
6
6
  <% for attribute in attributes -%>
@@ -50,8 +50,6 @@ class HoboModelResourceGenerator < Rails::Generator::NamedBase
50
50
 
51
51
  m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb"))
52
52
  m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
53
-
54
- m.route_resources controller_file_name
55
53
  end
56
54
  end
57
55
 
@@ -49,8 +49,7 @@ var Hobo = {
49
49
  updates.each(function(id_or_el) {
50
50
  var el = $(id_or_el)
51
51
  if (el) { // ignore update of parts that do not exist
52
- var partDomId
53
- partDomId = el.id
52
+ var partDomId = el.id
54
53
  if (!hoboParts[partDomId]) { throw "Update of dom-id that is not a part: " + partDomId }
55
54
  params.push("render["+i+"][part_context]=" + encodeURIComponent(hoboParts[partDomId]))
56
55
  params.push("render["+i+"][id]=" + partDomId)
@@ -113,6 +112,7 @@ var Hobo = {
113
112
  if (options.onComplete)
114
113
  options.onComplete.apply(this, arguments)
115
114
  if (form && options.refocusForm) Form.focusFirstElement(form)
115
+ Event.addBehavior.reload()
116
116
  }
117
117
  if (options.method && options.method.toLowerCase() == "put") {
118
118
  delete options.method
@@ -185,30 +185,30 @@ var Hobo = {
185
185
  var updateParams = Hobo.ajaxUpdateParams(updates, [{id: id,
186
186
  result: 'new_field_value',
187
187
  func: "Hobo.onFieldEditComplete"}])
188
- opts = {okButton: false,
189
- cancelLink: false,
190
- submitOnBlur: true,
191
- evalScripts: true,
192
- htmlResponse: false,
193
- ajaxOptions: { method: "put" },
194
- onEnterHover: null,
195
- onLeaveHover: null,
196
- callback: function(form, val) {
197
- old = val
198
- return (Hobo.fieldSetParam(el, val) + "&" + updateParams)
199
- },
200
- onFailure: function(resp) {
201
- alert(resp.responseText); el.innerHTML = old
202
- },
203
- onEnterEditMode: function() {
204
- var blank_message = el.getAttribute("hobo-blank-message")
205
- if (el.innerHTML.gsub("&nbsp;", " ") == blank_message) {
206
- el.innerHTML = ""
207
- } else {
208
- Hobo.ipeOldValues[el.id] = el.innerHTML
188
+ var opts = {okButton: false,
189
+ cancelLink: false,
190
+ submitOnBlur: true,
191
+ evalScripts: true,
192
+ htmlResponse: false,
193
+ ajaxOptions: { method: "put" },
194
+ onEnterHover: null,
195
+ onLeaveHover: null,
196
+ callback: function(form, val) {
197
+ old = val
198
+ return (Hobo.fieldSetParam(el, val) + "&" + updateParams)
199
+ },
200
+ onFailure: function(resp) {
201
+ alert(resp.responseText); el.innerHTML = old
202
+ },
203
+ onEnterEditMode: function() {
204
+ var blank_message = el.getAttribute("hobo-blank-message")
205
+ if (el.innerHTML.gsub("&nbsp;", " ") == blank_message) {
206
+ el.innerHTML = ""
207
+ } else {
208
+ Hobo.ipeOldValues[el.id] = el.innerHTML
209
+ }
209
210
  }
210
- }
211
- }
211
+ }
212
212
  Object.extend(opts, options)
213
213
  return new Ajax.InPlaceEditor(el, Hobo.putUrl(el), opts)
214
214
  },
@@ -220,14 +220,14 @@ var Hobo = {
220
220
  }
221
221
 
222
222
  select(".in-place-textfield-bhv").each(function (el) {
223
- ipe = Hobo._makeInPlaceEditor(el)
223
+ var ipe = Hobo._makeInPlaceEditor(el)
224
224
  ipe.getText = function() {
225
225
  return this.element.innerHTML.gsub(/<br\s*\/?>/, "\n").unescapeHTML()
226
226
  }
227
227
  })
228
228
 
229
229
  select(".in-place-textarea-bhv").each(function (el) {
230
- ipe = Hobo._makeInPlaceEditor(el, {rows: 2})
230
+ var ipe = Hobo._makeInPlaceEditor(el, {rows: 2})
231
231
  ipe.getText = function() {
232
232
  return this.element.innerHTML.gsub(/<br\s*\/?>/, "\n").unescapeHTML()
233
233
  }
@@ -259,12 +259,12 @@ var Hobo = {
259
259
 
260
260
  select("select.number-editor-bhv").each(function(el) {
261
261
  el.onchange = function() {
262
- Hobo.ajaxSetFieldForElement(el, el.value)
262
+ Hobo.ajaxSetFieldForElement(el, $F(el))
263
263
  }
264
264
  })
265
265
 
266
266
  select(".autocomplete-bhv").each(function (el) {
267
- options = {paramName: "query", minChars: 3, method: 'get' }
267
+ var options = {paramName: "query", minChars: 3, method: 'get' }
268
268
  if (el.hasClassName("autosubmit")) {
269
269
  options.afterUpdateElement = function(el, item) { el.form.onsubmit(); }
270
270
  }
@@ -325,34 +325,50 @@ var Hobo = {
325
325
  return res
326
326
  },
327
327
 
328
+
328
329
  fadeObjectElement: function(el) {
329
- new Effect.Fade(Hobo.objectElementFor(el),
330
- { duration: 0.5,
331
- afterFinish: function (ef) { ef.element.remove() } });
330
+ var fadeEl = Hobo.objectElementFor(el)
331
+ new Effect.Fade(fadeEl, { duration: 0.5, afterFinish: function (ef) {
332
+ ef.element.remove()
333
+ } });
334
+ Hobo.showEmptyMessageAfterLastRemove(fadeEl)
332
335
  },
333
336
 
337
+
334
338
  removeButton: function(el, url, updates, options) {
335
339
  if (options.fade == null) { options.fade = true; }
336
340
  if (options.confirm == null) { options.fade = "Are you sure?"; }
337
341
 
338
342
  if (options.confirm == false || confirm(options.confirm)) {
339
- objEl = Hobo.objectElementFor(el)
343
+ var objEl = Hobo.objectElementFor(el)
340
344
  Hobo.showSpinner('Removing');
341
345
  function complete() {
342
346
  if (options.fade) { Hobo.fadeObjectElement(el) }
343
347
  Hobo.hideSpinner()
344
348
  }
345
349
  if (updates && updates.length > 0) {
346
- new Hobo.ajaxRequest(url, "Removing", updates, { method:'delete',
347
- onComplete: complete});
350
+ new Hobo.ajaxRequest(url, updates, { method:'delete', message: "Removing...", onComplete: complete});
348
351
  } else {
349
- new Ajax.Request(url, {asynchronous:true, evalScripts:true, method:'delete',
350
- onComplete: complete});
352
+ var ajaxOptions = {asynchronous:true, evalScripts:true, method:'delete', onComplete: complete}
353
+ if (typeof(formAuthToken) != "undefined") {
354
+ ajaxOptions.parameters = formAuthToken.name + "=" + formAuthToken.value
355
+ }
356
+ new Ajax.Request(url, ajaxOptions);
351
357
  }
352
358
  }
353
359
  },
354
360
 
355
361
 
362
+ showEmptyMessageAfterLastRemove: function(el) {
363
+ var empty
364
+ var container = el.parentNode
365
+ if (container.getElementsByTagName(el.nodeName).length == 1 &&
366
+ (empty = container.next('.empty-collection-message'))) {
367
+ new Effect.Appear(empty, {delay:0.3})
368
+ }
369
+ },
370
+
371
+
356
372
  parseFieldId: function(el) {
357
373
  id = el.getAttribute("hobo-model-id")
358
374
  if (!id) return
@@ -360,6 +376,7 @@ var Hobo = {
360
376
  if (m) return { name: m[1], id: m[2], field: m[3] }
361
377
  },
362
378
 
379
+
363
380
  appendRow: function(el, rowSrc) {
364
381
  // IE friendly method to add a <tr> (from html source) to a table
365
382
  // el should be an element that contains *only* a table
@@ -368,6 +385,7 @@ var Hobo = {
368
385
  Hobo.applyEvents(el)
369
386
  },
370
387
 
388
+
371
389
  objectElementFor: function(el) {
372
390
  var m
373
391
  while(el.getAttribute) {
@@ -492,7 +510,7 @@ Element.Methods.$$ = function(e, css) {
492
510
 
493
511
  // --- has_many_through_input --- //
494
512
 
495
- HasManyThroughInput = Behavior.create({
513
+ SelectManyInput = Behavior.create({
496
514
 
497
515
  initialize : function() {
498
516
  // onchange doesn't bubble in IE6 so...
@@ -500,15 +518,16 @@ HasManyThroughInput = Behavior.create({
500
518
  },
501
519
 
502
520
  addOne : function() {
503
- var select = this.element.down('select')
521
+ var select = this.element.down('select')
504
522
  var selected = select.options[select.selectedIndex]
505
- if (selected.style.display != "none" & selected.value != "") {
506
- var newItem = DOM.Builder.fromHTML(this.element.down('.item-proto').innerHTML.strip())
523
+ if (selected.style.display != "none" & selected.text != "") {
524
+ var newItem = $(DOM.Builder.fromHTML(this.element.down('.item-proto').innerHTML.strip()))
507
525
  this.element.down('.items').appendChild(newItem);
508
526
  newItem.down('span').innerHTML = selected.innerHTML
509
- newItem.down('input[type=hidden]').value = selected.innerHTML
527
+ this.itemAdded(newItem, selected)
510
528
  selected.style.display = 'none'
511
529
  select.value = ""
530
+ Event.addBehavior.reload()
512
531
  }
513
532
  },
514
533
 
@@ -525,12 +544,23 @@ HasManyThroughInput = Behavior.create({
525
544
  var label = el.down('span').innerHTML
526
545
  var option = $A(this.element.getElementsByTagName('option')).find(function(o) { return o.innerHTML == label })
527
546
  option.style.display = 'block'
547
+ },
548
+
549
+ itemAdded: function(item, option) {
550
+ this.hiddenField(item).value = option.innerHTML
551
+ },
552
+
553
+ hiddenField: function(item) {
554
+ return item.down('input[type=hidden]')
555
+ //return item.getElementsByClassName("hidden-field")[0]
528
556
  }
529
557
 
558
+
530
559
  })
531
560
 
532
561
  Event.addBehavior({
533
- 'div.has-many-through.input' : HasManyThroughInput(),
562
+ 'div.select-many.input' : SelectManyInput(),
563
+
534
564
  '.association-count:click' : function(e) {
535
565
  new Effect.ScrollTo('primary-collection', {duration: 1.0, offset: -20, transition: Effect.Transitions.sinoidal});
536
566
  Event.stop(e);
@@ -538,11 +568,11 @@ Event.addBehavior({
538
568
  'form.filter-menu select:change': function(event) {
539
569
  var paramName = this.up('form').down('input[type=hidden]').value.gsub("-", "_")
540
570
  var params = {}
541
- remove = [ 'page' ]
542
- if (this.value == '') {
571
+ var remove = [ 'page' ]
572
+ if ($F(this) == '') {
543
573
  remove.push(paramName)
544
574
  } else {
545
- params[paramName] = this.value
575
+ params[paramName] = $F(this)
546
576
  }
547
577
  location.href = Hobo.addUrlParams(params, {remove: remove})
548
578
  }