From 1332185d856e0d57ef19a8928831a08de132d631 Mon Sep 17 00:00:00 2001 From: Didier Lafforgue Date: Fri, 10 Feb 2012 01:42:06 +0100 Subject: [PATCH] the locale was missing when saving an editable element by the inline editor --- .../locomotive/views/inline_editor/toolbar_view.js.coffee | 2 ++ app/controllers/locomotive/public/pages_controller.rb | 6 +++--- app/views/locomotive/public/pages/show_toolbar.html.haml | 3 ++- app/views/locomotive/shared/_head.html.haml | 3 ++- vendor/assets/javascripts/locomotive/backbone.sync.js | 2 ++ 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/locomotive/views/inline_editor/toolbar_view.js.coffee b/app/assets/javascripts/locomotive/views/inline_editor/toolbar_view.js.coffee index 479da066..f156e552 100644 --- a/app/assets/javascripts/locomotive/views/inline_editor/toolbar_view.js.coffee +++ b/app/assets/javascripts/locomotive/views/inline_editor/toolbar_view.js.coffee @@ -113,6 +113,8 @@ class Locomotive.Views.InlinEditor.ToolbarView extends Backbone.View picker.toggle() + window.content_locale = selected[1] + _window.location.href = '/' + @model.get('localized_fullpaths')[selected[1]] + '/_edit' get_locale_attributes: (context) -> diff --git a/app/controllers/locomotive/public/pages_controller.rb b/app/controllers/locomotive/public/pages_controller.rb index 4f5210da..06ee60ae 100644 --- a/app/controllers/locomotive/public/pages_controller.rb +++ b/app/controllers/locomotive/public/pages_controller.rb @@ -12,7 +12,7 @@ module Locomotive before_filter :validate_site_membership, :only => [:show_toolbar] - before_filter :set_ui_locale, :only => :show_toolbar + before_filter :set_toolbar_locale, :only => :show_toolbar before_filter :set_locale, :only => [:show, :edit] @@ -31,9 +31,9 @@ module Locomotive protected - def set_ui_locale + def set_toolbar_locale ::I18n.locale = current_locomotive_account.locale rescue Locomotive.config.default_locale - ::Mongoid::Fields::I18n.locale = params[:locale] || current_site.default_locale + ::Mongoid::Fields::I18n.locale = session[:content_locale] || current_site.default_locale end def set_locale diff --git a/app/views/locomotive/public/pages/show_toolbar.html.haml b/app/views/locomotive/public/pages/show_toolbar.html.haml index f5ef4cb6..6bc1857e 100644 --- a/app/views/locomotive/public/pages/show_toolbar.html.haml +++ b/app/views/locomotive/public/pages/show_toolbar.html.haml @@ -16,7 +16,8 @@ %script{ :type => 'text/javascript' } :plain - window.locale = '#{I18n.locale}'; + window.locale = '#{I18n.locale}'; + window.content_locale = '#{::Mongoid::Fields::I18n.locale}'; Locomotive.mounted_on = '#{Locomotive.mounted_on}'; Locomotive.current_site = new Locomotive.Models.Site(#{current_site.to_json}); diff --git a/app/views/locomotive/shared/_head.html.haml b/app/views/locomotive/shared/_head.html.haml index fe9ea09c..89f25515 100644 --- a/app/views/locomotive/shared/_head.html.haml +++ b/app/views/locomotive/shared/_head.html.haml @@ -12,7 +12,8 @@ %script{ :type => 'text/javascript' } :plain - window.locale = '#{I18n.locale}'; + window.locale = '#{I18n.locale}'; + window.content_locale = '#{::Mongoid::Fields::I18n.locale}'; Locomotive.mounted_on = '#{Locomotive.mounted_on}'; Locomotive.current_site = new Locomotive.Models.Site(#{current_site.to_json}); diff --git a/vendor/assets/javascripts/locomotive/backbone.sync.js b/vendor/assets/javascripts/locomotive/backbone.sync.js index db79c0f8..677a8138 100644 --- a/vendor/assets/javascripts/locomotive/backbone.sync.js +++ b/vendor/assets/javascripts/locomotive/backbone.sync.js @@ -48,6 +48,8 @@ var formData = new FormData(); formData.append('xhr', true); // fix a bug with POW which happens to not like empty form + if (window.content_locale) + formData.append('content_locale', window.content_locale); var _buildParams = function(prefix, obj, fn) { // code grabbed from jquery if (jQuery.isArray(obj)) {