From aa33235da0baa913089b882689689b86cdc2b158 Mon Sep 17 00:00:00 2001 From: Matt Jones Date: Tue, 20 Sep 2011 20:17:49 -0400 Subject: [PATCH] [#771] fix in-place editing and broken integer-select-editor --- hobo/lib/generators/hobo/rapid/templates/hobo-rapid.js | 4 +++- hobo/lib/hobo/helper.rb | 4 ++++ hobo/lib/hobo/rapid/helper.rb | 5 +++-- hobo/lib/hobo/rapid/taglibs/rapid_editing.dryml | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hobo/lib/generators/hobo/rapid/templates/hobo-rapid.js b/hobo/lib/generators/hobo/rapid/templates/hobo-rapid.js index 9f3c92355..fab2e922a 100755 --- a/hobo/lib/generators/hobo/rapid/templates/hobo-rapid.js +++ b/hobo/lib/generators/hobo/rapid/templates/hobo-rapid.js @@ -34,6 +34,7 @@ var Hobo = { var params = Hobo.fieldSetParam(el, val) var p = el.getAttribute("hobo-ajax-params") if (p) params = params + "&" + p + params = params + '&_method=PUT' var opts = Object.merge(options || {}, { params: params, message: el.getAttribute("hobo-ajax-message")}) Hobo.ajaxRequest(Hobo.putUrl(el), updates, opts) @@ -257,8 +258,9 @@ var Hobo = { putUrl: function(el) { + /* we used to append _method=put here, but it doesn't work in Rails 3 */ var spec = Hobo.modelSpecForElement(el) - return urlBase + "/" + Hobo.pluralise(spec.name) + "/" + spec.id + "?_method=PUT" + return urlBase + "/" + Hobo.pluralise(spec.name) + "/" + spec.id }, diff --git a/hobo/lib/hobo/helper.rb b/hobo/lib/hobo/helper.rb index bf5b5559b..4a7fdaf29 100644 --- a/hobo/lib/hobo/helper.rb +++ b/hobo/lib/hobo/helper.rb @@ -179,6 +179,10 @@ def model_id_class(object=this, attribute=nil) object.respond_to?(:typed_id) ? "model::#{typed_id(object, attribute).to_s.dasherize}" : "" end + def update_elements_class(updates) + 'update::'+comma_split(updates).join(':') unless updates.blank? + end + def can_create?(object=this) if object.is_a?(Class) and object < ActiveRecord::Base object = object.new diff --git a/hobo/lib/hobo/rapid/helper.rb b/hobo/lib/hobo/rapid/helper.rb index 363e215ca..58ca75e57 100644 --- a/hobo/lib/hobo/rapid/helper.rb +++ b/hobo/lib/hobo/rapid/helper.rb @@ -120,8 +120,9 @@ def in_place_editor(attributes, this=nil) edit_text = this._?.to_s attributes.update(:hobo_edit_text => edit_text) unless edit_text.nil? - update = attributes.delete(:update) - attributes[:hobo_update] = update if update + if update = attributes.delete(:update) + attributes = add_classes(attributes, update_elements_class(update)) + end view(attributes) end diff --git a/hobo/lib/hobo/rapid/taglibs/rapid_editing.dryml b/hobo/lib/hobo/rapid/taglibs/rapid_editing.dryml index 2ec25f58f..c3b0d4a0f 100644 --- a/hobo/lib/hobo/rapid/taglibs/rapid_editing.dryml +++ b/hobo/lib/hobo/rapid/taglibs/rapid_editing.dryml @@ -218,7 +218,7 @@ This tag does not sanitize HTML; this is provided by HtmlString before saving to --> <% options ||= (min.to_i..max.to_i).to_a %> -