diff --git a/.gitignore b/.gitignore index 9627e8fd..bc648353 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,6 @@ Capfile config/deploy.rb perf/*.rb gem_graph.png -./sites/ permanent doc/bushido *.swp diff --git a/app/controllers/locomotive/my_account_controller.rb b/app/controllers/locomotive/my_account_controller.rb index 328fb4b7..56ece5e9 100644 --- a/app/controllers/locomotive/my_account_controller.rb +++ b/app/controllers/locomotive/my_account_controller.rb @@ -17,7 +17,7 @@ module Locomotive def update @account = current_locomotive_account @account.update_attributes(params[:account]) - respond_with @account, edit_my_account_url + respond_with @account, :location => edit_my_account_url end end diff --git a/app/inputs/locomotive/locale_input.rb b/app/inputs/locomotive/locale_input.rb new file mode 100644 index 00000000..9054a430 --- /dev/null +++ b/app/inputs/locomotive/locale_input.rb @@ -0,0 +1,28 @@ +module Locomotive + class LocaleInput < Formtastic::Inputs::TextInput + + def to_html + input_wrapping do + label_html << + self.available_locales_to_html + end + end + + def available_locales_to_html + template.content_tag(:div, + Locomotive.config.locales.map do |locale| + template.content_tag(:div, locale_to_html(locale).html_safe, :class => 'entry') + end.join.html_safe, :class => 'list') + end + + def locale_to_html(locale) + text = I18n.t("locomotive.my_account.edit.#{locale}") + + builder.radio_button(:locale, locale) + + template.content_tag(:label, + template.image_tag("locomotive/icons/flags/#{locale}.png", :alt => text) + + text) + end + + end +end \ No newline at end of file diff --git a/app/views/locomotive/my_account/edit.html.haml b/app/views/locomotive/my_account/edit.html.haml index fb2e6df3..809d14d6 100644 --- a/app/views/locomotive/my_account/edit.html.haml +++ b/app/views/locomotive/my_account/edit.html.haml @@ -1,7 +1,8 @@ - title link_to(@account.name.blank? ? @account.name_was : @account.name, '#', :rel => 'my_account_name', :title => t('.ask_for_name'), :class => 'editable') -- content_for :head do - / = include_javascripts :account +- content_for :backbone_view_data do + :plain + { account: #{@account.to_json} } - content_for :submenu do = render_cell 'locomotive/settings_menu', :show @@ -12,35 +13,28 @@ %p= t('.help') -= semantic_form_for @account, :as => :my_account, :url => my_account_url, :html => { :class => 'save-with-shortcut' } do |f| += semantic_form_for @account, :url => my_account_url do |f| = f.inputs :name => :information do = f.input :name + = f.input :locale, :as => '::Locomotive::Locale' - = f.inputs :name => :credentials do + = f.inputs :name => :credentials, :class => "inputs foldable folded" do = f.input :email - = f.input :password, :input_html => { :autocomplete => "off" } - = f.input :password_confirmation, :input_html => { :autocomplete => "off" } + = f.input :password, :input_html => { :autocomplete => 'off' } + = f.input :password_confirmation, :input_html => { :autocomplete => 'off' } - if multi_sites? - = f.inputs :name => :sites, :class => 'sites' do - %ul.list - - @account.sites.each do |site| - %li - %strong= link_to site.name, site_url(site) - %em= site.domains.join(', ') + = f.inputs :name => :sites, :class => "sites inputs foldable #{'folded' if inputs_folded?(@account)}" do + %li.input.empty.no-label.last + .list + - @account.sites.each do |site| + .entry + %strong= link_to site.name, site_url(site) + %em= site.domains.join(', ') - - if admin_on?(site) && site != current_site - %span{ :class => 'actions' } - = link_to 'x', site_url(site), :class => 'remove first', :confirm => t('locomotive.messages.confirm'), :method => :delete - - = f.inputs :name => :language, :class => 'language' do - - Locomotive.config.locales.each do |locale| - %span - = f.radio_button :locale, locale - %label{ :for => "my_account_locale_#{locale.downcase}" } - = image_tag "admin/icons/flags/#{locale}.png" - = t(".#{locale}") - /   + - if admin_on?(site) && site != current_site + %span{ :class => 'actions' } + = link_to 'x', site_url(site), :class => 'remove first', :confirm => t('locomotive.messages.confirm'), :method => :delete = render 'locomotive/shared/form_actions', :button_label => :update