Skip to content

Commit 26ec6db

Browse files
committed
first attempt to 1.0.x compat
1 parent 697cd05 commit 26ec6db

File tree

12 files changed

+62
-67
lines changed

12 files changed

+62
-67
lines changed

app/controllers/admin/editor_settings_controller.rb

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Spree::Admin::EditorSettingsController < Spree::Admin::BaseController
2+
3+
def show
4+
@config = Spree::EditorConfiguration.new
5+
end
6+
7+
def edit
8+
@config = Spree::EditorConfiguration.new
9+
end
10+
11+
def update
12+
config = Spree::EditorConfiguration.new
13+
14+
params.each do |name, value|
15+
next unless config.has_preference? name
16+
config[name] = value
17+
end
18+
19+
redirect_to admin_editor_settings_path
20+
end
21+
22+
end
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
class EditorConfiguration < Configuration
1+
class Spree::EditorConfiguration < Spree::Preferences::Configuration
2+
23
preference :enabled, :boolean, :default => true
34
preference :current_editor, :string, :default => 'TinyMCE'
45
preference :ids, :text, :default => 'product_description page_body'
6+
57
end

app/overrides/add_rich_editor_link.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Deface::Override.new(:virtual_path => "admin/configurations/index",
1+
Deface::Override.new(:virtual_path => "spree/admin/configurations/index",
22
:name => "add_rich_editor_link",
33
:insert_after => "[data-hook='admin_configurations_menu'], #admin_configurations_menu[data-hook]",
44
:text => "<tr>

app/overrides/add_rich_editor_tab.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Deface::Override.new(:virtual_path => "admin/shared/_configuration_menu",
1+
Deface::Override.new(:virtual_path => "spree/admin/shared/_configuration_menu",
22
:name => "add_rich_editor_tab",
33
:insert_bottom => "[data-hook='admin_configurations_sidebar_menu'], #admin_configurations_sidebar_menu[data-hook]",
44
:text => "<li<%== ' class=\"active\"' if controller.controller_name == 'editor_settings' %>><%= link_to t(\"rich_editor\"), admin_editor_settings_path %></li>")

app/overrides/include_rich_text_js.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Deface::Override.new(:virtual_path => "layouts/admin",
1+
Deface::Override.new(:virtual_path => "spree/layouts/admin",
22
:name => "include_rich_text_js",
33
:insert_after => "[data-hook='admin_inside_head'], #admin_inside_head[data-hook]",
44
:text => "<%= render :partial => 'shared/rich_editor_javascript' %>")

app/views/admin/editor_settings/edit.html.erb

-24
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<% is_enabled = Spree::Editor::Config[:enabled] %>
2-
<% current_editor = Spree::Editor::Config[:current_editor] %>
3-
<% ids = Spree::Editor::Config[:ids].split %>
1+
<% @editor_configuration = Spree::EditorConfiguration.new %>
2+
<% is_enabled = @editor_configuration[:enabled] %>
3+
<% current_editor = @editor_configuration[:current_editor] %>
4+
<% ids = @editor_configuration[:ids].split %>
45

56
<% if is_enabled and ids.any? %>
6-
<%= render :partial => "shared/editor_engines/#{Spree::Editor::Config[:current_editor].underscore}",
7+
<%= render :partial => "shared/editor_engines/#{@editor_configuration[:current_editor].underscore}",
78
:locals => { :ids => ids } %>
89
<% end %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
2+
3+
<h1><%= t('rich_editor') %></h1>
4+
5+
<%= form_for(@config, :as => "editor_configuration", :url => admin_editor_settings_path, :method => :put) do |form| %>
6+
<fieldset id="preferences">
7+
<%= form.field_container :current_editor do %>
8+
<%= form.label(:current_editor, t('rich_editor_engine')) %>
9+
<%= select_tag :current_editor, options_for_select(SpreeEditor::EditorEngines, @config[:current_editor]) %>
10+
<% end %>
11+
<%= form.field_container :enabled do %>
12+
<%= preference_field_tag(:enabled, @config[:enabled], :type => :boolean) %>
13+
<%= form.label(:enabled, t(:enable_rich_editor)) %>
14+
<% end %>
15+
<%= form.field_container :ids do %>
16+
<%= form.label(:ids, t(:rich_editor_ids_description)+": ") + tag(:br) %>
17+
<%= preference_field_tag(:ids, @config[:ids], :type => :text) %>
18+
<% end %>
19+
</fieldset>
20+
<p class="form-buttons">
21+
<%= button t('update') %>
22+
<%= t("or") %> <%= link_to t("cancel"), admin_editor_settings_url %>
23+
</p>
24+
<% end %>

app/views/admin/editor_settings/show.html.erb app/views/spree/admin/editor_settings/show.html.erb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
<%= render :partial => 'admin/shared/configuration_menu' %>
1+
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
22

33
<h1><%= t("rich_editor") %></h1>
44

55
<table>
66
<tr>
77
<td><%= t('enable_rich_editor') %>:</td>
8-
<td><%= Spree::Editor::Config[:enabled] ? t('yes') : t('no') %></td>
8+
<td><%= @config[:enabled] ? t('yes') : t('no') %></td>
99
</tr>
1010
<tr>
1111
<td><%= t('rich_editor_engine') %>:</td>
12-
<td><%= Spree::Editor::Config[:current_editor] %></td>
12+
<td><%= @config[:current_editor] %></td>
1313
</tr>
1414
<tr>
1515
<td><%= t('rich_editor_ids') %>:</td>
16-
<td><%= Spree::Editor::Config[:ids] %></td>
16+
<td><%= @config[:ids] %></td>
1717
</tr>
1818
</table>
1919

config/routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Rails.application.routes.draw do
1+
Spree::Core::Engine.routes.draw do
22
namespace :admin do
33
resource :editor_settings, :only => ['show', 'update', 'edit']
44
end

lib/spree/editor/config.rb

-22
This file was deleted.

0 commit comments

Comments
 (0)