Skip to content

Commit

Permalink
Add separate admin locale page
Browse files Browse the repository at this point in the history
  • Loading branch information
jhawthorn committed Feb 8, 2017
1 parent 02e0603 commit 0bd2d42
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 32 deletions.

This file was deleted.

16 changes: 16 additions & 0 deletions app/controllers/spree/admin/locales_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Spree
module Admin
class LocalesController < Spree::Admin::BaseController
def show
end

def update
params.each do |name, value|
next unless SolidusI18n::Config.has_preference? name
SolidusI18n::Config[name] = value.map(&:to_sym)
end
redirect_to admin_locale_path
end
end
end
end

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- insert_bottom '[data-hook=admin_configurations_sidebar_menu]'-->
<%= tab :locales, url: spree.admin_locale_path %>
29 changes: 29 additions & 0 deletions app/views/spree/admin/locales/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<%= render 'spree/admin/shared/configuration_menu' %>

<% admin_breadcrumb("locales") %>

<%= form_tag admin_locale_path, method: :patch do %>
<div class="panel panel-default panel-localization">
<div class="panel-heading">
<h1 class="panel-title">
<%= Spree.t(:'i18n.localization_settings') %>
</h1>
</div>

<div class="panel-body" data-hook="localization_settings_body">
<div class="form-group">
<label for="available_locales_">
<%= Spree.t(:'i18n.available_locales') %>
</label>
<%= select_available_locales %>
<p class="help-block">
<%= Spree.t(:'i18n.locales_displayed_on_frontend_select_box') %>
</p>
</div>
</div>
</div>

<div class="form-buttons filter-actions actions" data-hook="buttons">
<%= button Spree.t('actions.update') %>
</div>
<% end %>
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
filter :locale

post '/locale/set', to: 'locale#set', defaults: { format: :json }, as: :set_locale

namespace :admin do
resource :locale, only: [:show, :update]
end
end
1 change: 1 addition & 0 deletions spec/features/admin/translations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
background do
SolidusI18n::Config.available_locales = []
visit spree.edit_admin_general_settings_path
click_on "Locales"
end

scenario 'adds german to available locales' do
Expand Down

0 comments on commit 0bd2d42

Please sign in to comment.