diff --git a/app/assets/javascripts/locomotive/views/pages/new_view.js.coffee b/app/assets/javascripts/locomotive/views/pages/new_view.js.coffee index a2f5f61d..b2359a6c 100644 --- a/app/assets/javascripts/locomotive/views/pages/new_view.js.coffee +++ b/app/assets/javascripts/locomotive/views/pages/new_view.js.coffee @@ -3,4 +3,6 @@ Locomotive.Views.Pages ||= {} class Locomotive.Views.Pages.NewView extends Locomotive.Views.Pages.FormView save: (event) -> - # TODO \ No newline at end of file + @save_in_ajax event, + on_success: (response, xhr) -> + window.location.href = xhr.getResponseHeader('location') \ No newline at end of file diff --git a/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee b/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee index 57ad7aff..85a6da46 100644 --- a/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +++ b/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee @@ -29,14 +29,13 @@ class Locomotive.Views.Shared.FormView extends Backbone.View @model.save {}, success: (model, response, xhr) => - console.log(response) - console.log(xhr) + window.response = xhr - $.growl('success', xhr.getResponseHeader('X-Message')) + $.growl('success', xhr.getResponseHeader('X-Message')) if xhr.getResponseHeader('X-Message')? model.attributes = previous_attributes - options.on_success(response) if options.on_success + options.on_success(response, xhr) if options.on_success error: (model, xhr) => $.growl('error', xhr.getResponseHeader('X-Message')) @@ -89,7 +88,12 @@ class Locomotive.Views.Shared.FormView extends Backbone.View show_error: (attribute, message, html) -> input = @$("##{@model.paramRoot}_#{attribute}") - input.after(html) if input.size() > 0 + + return unless input.size() > 0 + + anchor = input.parent().find('.error-anchor') + anchor = input if anchor.size() == 0 + anchor.after(html) _enable_checkbox: (name, options) -> @$('li#page_' + name + '_input input[type=checkbox]').checkToggle diff --git a/app/assets/javascripts/locomotive/views/sites/new_view.js.coffee b/app/assets/javascripts/locomotive/views/sites/new_view.js.coffee index 09c559f2..66989f5b 100644 --- a/app/assets/javascripts/locomotive/views/sites/new_view.js.coffee +++ b/app/assets/javascripts/locomotive/views/sites/new_view.js.coffee @@ -28,7 +28,9 @@ class Locomotive.Views.Sites.NewView extends Locomotive.Views.Shared.FormView @$('#site_domains_input label').after(@domains_view.render().el) save: (event) -> - @save_in_ajax(event) + @save_in_ajax event, + on_success: (response, xhr) -> + window.location.href = xhr.getResponseHeader('location') show_error: (attribute, message, html) -> if attribute == 'domains' diff --git a/app/assets/stylesheets/locomotive/formtastic_changes.scss b/app/assets/stylesheets/locomotive/formtastic_changes.scss index 9b9693a7..00d37657 100644 --- a/app/assets/stylesheets/locomotive/formtastic_changes.scss +++ b/app/assets/stylesheets/locomotive/formtastic_changes.scss @@ -219,12 +219,16 @@ form.formtastic { p { display: inline-block; width: auto; + line-height: 14px; margin: 0px; - padding: 3px 12px 4px 30px; + padding: 3px 12px 4px 27px; - background: #cd0f19 image-url("locomotive//form/icons/error.png") no-repeat 10px 6px; + @include box-shadow(rgba(0, 0, 0, 0.4) 2px 2px 2px 0); + @include border-radius(3px); + background: #cd0f19 image-url("locomotive/form/icons/error.png") no-repeat 7px center; color: #fff !important; + font-size: 12px; @include single-text-shadow(#000, 0px, 1px, 1px); } } // div.inline-errors diff --git a/app/inputs/locomotive/subdomain_input.rb b/app/inputs/locomotive/subdomain_input.rb index bb7d32d5..ca34336c 100644 --- a/app/inputs/locomotive/subdomain_input.rb +++ b/app/inputs/locomotive/subdomain_input.rb @@ -14,7 +14,7 @@ module Locomotive label_html << template.content_tag(:em, "http://") << builder.text_field(method, input_html_options) << - template.content_tag(:em, ".#{domain}") + template.content_tag(:em, ".#{domain}", :class => 'error-anchor') end end diff --git a/app/models/locomotive/page.rb b/app/models/locomotive/page.rb index 9d74a45f..0fe7dffa 100644 --- a/app/models/locomotive/page.rb +++ b/app/models/locomotive/page.rb @@ -72,7 +72,7 @@ module Locomotive else slugs = self.self_and_ancestors.sort_by(&:depth).map(&:slug) slugs.shift unless slugs.size == 1 - File.join slugs + File.join slugs.compact end end diff --git a/lib/locomotive/responder.rb b/lib/locomotive/responder.rb index 976f8b52..a6824755 100644 --- a/lib/locomotive/responder.rb +++ b/lib/locomotive/responder.rb @@ -9,7 +9,6 @@ module Locomotive end def to_json - Rails.logger.debug "TO JSON !!!!" if get? display resource elsif has_errors? @@ -18,9 +17,8 @@ module Locomotive display resource.errors, :status => :unprocessable_entity end elsif post? - with_flash_message do |message| - display resource, :location => api_location - end + set_flash_message! + display resource, :location => api_location elsif put? with_flash_message do |message| display resource, :status => :ok, :location => api_location diff --git a/vendor/assets/javascripts/backbone.sync.js b/vendor/assets/javascripts/backbone.sync.js index b49edcf8..ae23c8b0 100644 --- a/vendor/assets/javascripts/backbone.sync.js +++ b/vendor/assets/javascripts/backbone.sync.js @@ -47,6 +47,8 @@ if (typeof(FormData) != 'undefined') { // XHR2 var formData = new FormData(); + formData.append('xhr', true); // fix a bug with POW which happens to not like empty form + var _buildParams = function(prefix, obj, fn) { // code grabbed from jquery if (jQuery.isArray(obj)) { jQuery.each(obj, function(i, v) {