refinerycms-settings 1.0.11 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.rspec +3 -0
- data/.travis.yml +16 -0
- data/Gemfile +74 -0
- data/Rakefile +19 -0
- data/app/controllers/refinery/admin/settings_controller.rb +55 -0
- data/app/decorators/controllers/refinery/.gitkeep +0 -0
- data/app/decorators/models/refinery/.gitkeep +0 -0
- data/app/helpers/refinery/admin/settings_helper.rb +29 -0
- data/app/models/refinery/setting.rb +204 -0
- data/app/views/refinery/admin/settings/_actions.html.erb +8 -0
- data/app/views/refinery/admin/settings/_form.html.erb +54 -0
- data/app/views/refinery/admin/settings/_records.html.erb +21 -0
- data/app/views/refinery/admin/settings/_setting.html.erb +23 -0
- data/app/views/refinery/admin/settings/_settings.html.erb +4 -0
- data/app/views/refinery/admin/settings/edit.html.erb +1 -0
- data/app/views/{admin/refinery_settings → refinery/admin/settings}/index.html.erb +2 -2
- data/app/views/refinery/admin/settings/new.html.erb +1 -0
- data/config/locales/bg.yml +22 -40
- data/config/locales/cs.yml +22 -39
- data/config/locales/da.yml +22 -40
- data/config/locales/de.yml +26 -43
- data/config/locales/el.yml +22 -40
- data/config/locales/en.yml +22 -35
- data/config/locales/es.yml +31 -63
- data/config/locales/fi.yml +22 -40
- data/config/locales/fr.yml +22 -38
- data/config/locales/it.yml +20 -36
- data/config/locales/ja.yml +30 -0
- data/config/locales/ko.yml +29 -0
- data/config/locales/lolcat.yml +21 -37
- data/config/locales/lt.yml +23 -40
- data/config/locales/lv.yml +22 -40
- data/config/locales/nb.yml +22 -40
- data/config/locales/nl.yml +22 -40
- data/config/locales/pl.yml +23 -40
- data/config/locales/pt-BR.yml +22 -38
- data/config/locales/rs.yml +22 -40
- data/config/locales/ru.yml +22 -37
- data/config/locales/sk.yml +22 -40
- data/config/locales/sl.yml +21 -20
- data/config/locales/sv.yml +22 -39
- data/config/locales/vi.yml +23 -42
- data/config/locales/zh-CN.yml +22 -40
- data/config/locales/zh-TW.yml +22 -40
- data/config/routes.rb +3 -6
- data/db/migrate/20100913234710_create_refinerycms_settings_schema.rb +11 -19
- data/lib/refinery/generators/refinery/settings/settings_generator.rb +20 -0
- data/lib/refinery/settings/engine.rb +26 -0
- data/lib/refinery/settings.rb +22 -0
- data/lib/refinerycms-settings.rb +1 -32
- data/readme.md +46 -0
- data/refinerycms-settings.gemspec +7 -79
- data/script/rails +6 -0
- data/spec/factories/settings.rb +5 -0
- data/spec/models/refinery/setting_spec.rb +103 -0
- data/spec/requests/refinery/admin/settings_spec.rb +57 -0
- data/spec/spec_helper.rb +56 -0
- data/tasks/rspec.rake +4 -0
- metadata +87 -75
- data/app/controllers/admin/refinery_settings_controller.rb +0 -71
- data/app/helpers/refinery_settings_helper.rb +0 -25
- data/app/models/refinery_setting.rb +0 -206
- data/app/views/admin/refinery_settings/_actions.html.erb +0 -15
- data/app/views/admin/refinery_settings/_form.html.erb +0 -62
- data/app/views/admin/refinery_settings/_records.html.erb +0 -21
- data/app/views/admin/refinery_settings/_refinery_setting.html.erb +0 -23
- data/app/views/admin/refinery_settings/_refinery_settings.html.erb +0 -5
- data/app/views/admin/refinery_settings/edit.html.erb +0 -1
- data/app/views/admin/refinery_settings/new.html.erb +0 -1
- data/config/locales/jp.yml +0 -47
- data/db/migrate/20100926142529_add_value_type_to_refinery_settings.rb +0 -9
- data/features/manage_refinery_settings.feature +0 -5
- data/features/step_definitions/setting_steps.rb +0 -9
- data/features/support/paths.rb +0 -14
- data/lib/gemspec.rb +0 -37
- data/lib/generators/refinerycms_settings_generator.rb +0 -8
- data/spec/models/refinery_setting_spec.rb +0 -101
metadata
CHANGED
@@ -1,70 +1,66 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-settings
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
- Resolve Digital
|
12
|
+
authors:
|
9
13
|
- Philip Arndt
|
10
|
-
-
|
11
|
-
- Steven Heidel
|
12
|
-
- Uģis Ozols
|
14
|
+
- "U\xC4\xA3is Ozols"
|
13
15
|
autorequire:
|
14
16
|
bindir: bin
|
15
17
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
none: false
|
22
|
-
requirements:
|
23
|
-
- - ~>
|
24
|
-
- !ruby/object:Gem::Version
|
25
|
-
version: 3.0.10
|
26
|
-
type: :runtime
|
18
|
+
|
19
|
+
date: 2012-03-01 00:00:00 Z
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: refinerycms-core
|
27
23
|
prerelease: false
|
28
|
-
|
29
|
-
none: false
|
30
|
-
requirements:
|
31
|
-
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 3.0.10
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: refinerycms-base
|
36
|
-
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
37
25
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
26
|
+
requirements:
|
27
|
+
- - "="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 15
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 0
|
33
|
+
- 0
|
34
|
+
version: 2.0.0
|
42
35
|
type: :runtime
|
43
|
-
|
44
|
-
|
45
|
-
none: false
|
46
|
-
requirements:
|
47
|
-
- - '='
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: 1.0.11
|
50
|
-
description: The default settings engine that is required by Refinery CMS core. Adds
|
51
|
-
programmer creatable, user editable settings for each engine.
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Adds programmer creatable, user editable settings.
|
52
38
|
email: info@refinerycms.com
|
53
39
|
executables: []
|
40
|
+
|
54
41
|
extensions: []
|
42
|
+
|
55
43
|
extra_rdoc_files: []
|
56
|
-
|
57
|
-
|
58
|
-
-
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
- app/
|
64
|
-
- app/
|
65
|
-
- app/
|
66
|
-
- app/
|
67
|
-
- app/
|
44
|
+
|
45
|
+
files:
|
46
|
+
- .gitignore
|
47
|
+
- .rspec
|
48
|
+
- .travis.yml
|
49
|
+
- Gemfile
|
50
|
+
- Rakefile
|
51
|
+
- app/controllers/refinery/admin/settings_controller.rb
|
52
|
+
- app/decorators/controllers/refinery/.gitkeep
|
53
|
+
- app/decorators/models/refinery/.gitkeep
|
54
|
+
- app/helpers/refinery/admin/settings_helper.rb
|
55
|
+
- app/models/refinery/setting.rb
|
56
|
+
- app/views/refinery/admin/settings/_actions.html.erb
|
57
|
+
- app/views/refinery/admin/settings/_form.html.erb
|
58
|
+
- app/views/refinery/admin/settings/_records.html.erb
|
59
|
+
- app/views/refinery/admin/settings/_setting.html.erb
|
60
|
+
- app/views/refinery/admin/settings/_settings.html.erb
|
61
|
+
- app/views/refinery/admin/settings/edit.html.erb
|
62
|
+
- app/views/refinery/admin/settings/index.html.erb
|
63
|
+
- app/views/refinery/admin/settings/new.html.erb
|
68
64
|
- config/locales/bg.yml
|
69
65
|
- config/locales/cs.yml
|
70
66
|
- config/locales/da.yml
|
@@ -75,7 +71,8 @@ files:
|
|
75
71
|
- config/locales/fi.yml
|
76
72
|
- config/locales/fr.yml
|
77
73
|
- config/locales/it.yml
|
78
|
-
- config/locales/
|
74
|
+
- config/locales/ja.yml
|
75
|
+
- config/locales/ko.yml
|
79
76
|
- config/locales/lolcat.yml
|
80
77
|
- config/locales/lt.yml
|
81
78
|
- config/locales/lv.yml
|
@@ -93,40 +90,55 @@ files:
|
|
93
90
|
- config/locales/zh-TW.yml
|
94
91
|
- config/routes.rb
|
95
92
|
- db/migrate/20100913234710_create_refinerycms_settings_schema.rb
|
96
|
-
-
|
97
|
-
-
|
98
|
-
-
|
99
|
-
- features/support/paths.rb
|
100
|
-
- lib/gemspec.rb
|
101
|
-
- lib/generators/refinerycms_settings_generator.rb
|
93
|
+
- lib/refinery/generators/refinery/settings/settings_generator.rb
|
94
|
+
- lib/refinery/settings.rb
|
95
|
+
- lib/refinery/settings/engine.rb
|
102
96
|
- lib/refinerycms-settings.rb
|
103
97
|
- license.md
|
98
|
+
- readme.md
|
104
99
|
- refinerycms-settings.gemspec
|
105
|
-
-
|
100
|
+
- script/rails
|
101
|
+
- spec/factories/settings.rb
|
102
|
+
- spec/models/refinery/setting_spec.rb
|
103
|
+
- spec/requests/refinery/admin/settings_spec.rb
|
104
|
+
- spec/spec_helper.rb
|
105
|
+
- tasks/rspec.rake
|
106
106
|
homepage: http://refinerycms.com
|
107
|
-
licenses:
|
107
|
+
licenses:
|
108
108
|
- MIT
|
109
109
|
post_install_message:
|
110
110
|
rdoc_options: []
|
111
|
-
|
111
|
+
|
112
|
+
require_paths:
|
112
113
|
- lib
|
113
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
115
|
none: false
|
115
|
-
requirements:
|
116
|
-
- -
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
|
119
|
-
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
124
|
none: false
|
121
|
-
requirements:
|
122
|
-
- -
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
hash: 3
|
129
|
+
segments:
|
130
|
+
- 0
|
131
|
+
version: "0"
|
125
132
|
requirements: []
|
133
|
+
|
126
134
|
rubyforge_project: refinerycms
|
127
|
-
rubygems_version: 1.8.
|
135
|
+
rubygems_version: 1.8.17
|
128
136
|
signing_key:
|
129
137
|
specification_version: 3
|
130
138
|
summary: Settings engine for Refinery CMS
|
131
|
-
test_files:
|
139
|
+
test_files:
|
140
|
+
- spec/factories/settings.rb
|
141
|
+
- spec/models/refinery/setting_spec.rb
|
142
|
+
- spec/requests/refinery/admin/settings_spec.rb
|
143
|
+
- spec/spec_helper.rb
|
132
144
|
has_rdoc:
|
@@ -1,71 +0,0 @@
|
|
1
|
-
module Admin
|
2
|
-
class RefinerySettingsController < Admin::BaseController
|
3
|
-
|
4
|
-
helper :refinery_settings
|
5
|
-
|
6
|
-
crudify :refinery_setting,
|
7
|
-
:title_attribute => :title,
|
8
|
-
:order => "name ASC",
|
9
|
-
:redirect_to_url => :redirect_to_where?,
|
10
|
-
:xhr_paging => true
|
11
|
-
|
12
|
-
before_filter :sanitise_params, :only => [:create, :update]
|
13
|
-
after_filter :fire_setting_callback, :only => [:update]
|
14
|
-
|
15
|
-
def new
|
16
|
-
if current_user.has_role?(:superuser) and params[:form_value_type].present?
|
17
|
-
@refinery_setting = RefinerySetting.new(:form_value_type => params[:form_value_type])
|
18
|
-
else
|
19
|
-
@refinery_setting = RefinerySetting.new(:form_value_type => 'text_area')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def edit
|
24
|
-
@refinery_setting = RefinerySetting.find(params[:id])
|
25
|
-
|
26
|
-
render :layout => false if request.xhr?
|
27
|
-
end
|
28
|
-
|
29
|
-
protected
|
30
|
-
def find_all_refinery_settings
|
31
|
-
@refinery_settings = RefinerySetting.order('name ASC')
|
32
|
-
|
33
|
-
unless current_user.has_role?(:superuser)
|
34
|
-
@refinery_settings = @refinery_settings.where("restricted <> ? ", true)
|
35
|
-
end
|
36
|
-
|
37
|
-
@refinery_settings
|
38
|
-
end
|
39
|
-
|
40
|
-
def search_all_refinery_settings
|
41
|
-
# search for settings that begin with keyword
|
42
|
-
term = "^" + params[:search].to_s.downcase.gsub(' ', '_')
|
43
|
-
|
44
|
-
# First find normal results, then weight them with the query.
|
45
|
-
@refinery_settings = find_all_refinery_settings.with_query(term)
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
def redirect_to_where?
|
50
|
-
(from_dialog? && session[:return_to].present?) ? session[:return_to] : admin_refinery_settings_url
|
51
|
-
end
|
52
|
-
|
53
|
-
# this fires before an update or create to remove any attempts to pass sensitive arguments.
|
54
|
-
def sanitise_params
|
55
|
-
params.delete(:callback_proc_as_string)
|
56
|
-
params.delete(:scoping)
|
57
|
-
end
|
58
|
-
|
59
|
-
def fire_setting_callback
|
60
|
-
begin
|
61
|
-
@refinery_setting.callback_proc.call
|
62
|
-
rescue
|
63
|
-
logger.warn('Could not fire callback proc. Details:')
|
64
|
-
logger.warn(@refinery_setting.inspect)
|
65
|
-
logger.warn($!.message)
|
66
|
-
logger.warn($!.backtrace)
|
67
|
-
end unless @refinery_setting.callback_proc.nil?
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module RefinerySettingsHelper
|
2
|
-
def form_value_type
|
3
|
-
@refinery_setting.form_value_type.presence || 'text_area'
|
4
|
-
end
|
5
|
-
|
6
|
-
def refinery_setting_title(f)
|
7
|
-
if @refinery_setting.form_value_type == 'check_box'
|
8
|
-
raw "<h3>#{@refinery_setting.name.to_s.titleize}?</h3>"
|
9
|
-
else
|
10
|
-
f.label :value
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def refinery_setting_field(f, help)
|
15
|
-
case form_value_type
|
16
|
-
when 'check_box'
|
17
|
-
raw "#{f.check_box :value, :value => @refinery_setting.form_value}
|
18
|
-
#{f.label :value, help.presence || t('enabled', :scope => 'admin.refinery_settings.form'),
|
19
|
-
:class => 'stripped'}"
|
20
|
-
else
|
21
|
-
f.text_area :value, :value => @refinery_setting.form_value,
|
22
|
-
:class => 'widest', :rows => 5
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,206 +0,0 @@
|
|
1
|
-
class RefinerySetting < ActiveRecord::Base
|
2
|
-
|
3
|
-
FORM_VALUE_TYPES = [
|
4
|
-
['Multi-line', 'text_area'],
|
5
|
-
['Checkbox', 'check_box']
|
6
|
-
]
|
7
|
-
|
8
|
-
validates :name, :presence => true
|
9
|
-
|
10
|
-
serialize :value # stores into YAML format
|
11
|
-
serialize :callback_proc_as_string
|
12
|
-
|
13
|
-
# Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
|
14
|
-
acts_as_indexed :fields => [:name]
|
15
|
-
|
16
|
-
attr_accessible :name, :value, :destroyable,
|
17
|
-
:scoping, :restricted, :callback_proc_as_string,
|
18
|
-
:form_value_type
|
19
|
-
|
20
|
-
before_save do |setting|
|
21
|
-
setting.restricted = false if setting.restricted.nil?
|
22
|
-
end
|
23
|
-
|
24
|
-
after_save do |setting|
|
25
|
-
setting.class.rewrite_cache
|
26
|
-
end
|
27
|
-
|
28
|
-
class << self
|
29
|
-
# Number of settings to show per page when using will_paginate
|
30
|
-
def per_page
|
31
|
-
12
|
32
|
-
end
|
33
|
-
|
34
|
-
def ensure_cache_exists!
|
35
|
-
if (result = Rails.cache.read(cache_key, :multithread => true)).nil?
|
36
|
-
result = rewrite_cache
|
37
|
-
end
|
38
|
-
|
39
|
-
result
|
40
|
-
end
|
41
|
-
protected :ensure_cache_exists!
|
42
|
-
|
43
|
-
def cache_read(name = nil, scoping = nil)
|
44
|
-
result = ensure_cache_exists!
|
45
|
-
|
46
|
-
if name.present?
|
47
|
-
scoping = scoping.to_s if scoping.is_a?(Symbol)
|
48
|
-
result = result.detect do |rs|
|
49
|
-
rs[:name] == name.to_s.downcase.to_sym and rs[:scoping] == scoping
|
50
|
-
end
|
51
|
-
result = result[:value] if !result.nil? and result.keys.include?(:value)
|
52
|
-
end
|
53
|
-
|
54
|
-
result
|
55
|
-
end
|
56
|
-
|
57
|
-
def to_cache(settings)
|
58
|
-
settings.collect do |rs|
|
59
|
-
{
|
60
|
-
:name => rs.name.to_s.downcase.to_sym,
|
61
|
-
:value => rs.value,
|
62
|
-
:scoping => rs.scoping,
|
63
|
-
:destroyable => rs.destroyable
|
64
|
-
}
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def rewrite_cache
|
69
|
-
# delete cache
|
70
|
-
Rails.cache.delete(cache_key, :multithread => true)
|
71
|
-
|
72
|
-
# generate new cache
|
73
|
-
result = (to_cache(all) if (table_exists? rescue false))
|
74
|
-
|
75
|
-
# write cache
|
76
|
-
Rails.cache.write(cache_key, result, :multithread => true)
|
77
|
-
|
78
|
-
# return cache, or lack thereof.
|
79
|
-
result ||= []
|
80
|
-
end
|
81
|
-
|
82
|
-
def cache_key
|
83
|
-
[Refinery.base_cache_key, 'refinery_settings_cache'].join('_')
|
84
|
-
end
|
85
|
-
|
86
|
-
# find_or_set offers a convenient way to
|
87
|
-
def find_or_set(name, the_value, options={})
|
88
|
-
# Merge default options with supplied options.
|
89
|
-
options = {
|
90
|
-
:scoping => nil, :restricted => false,
|
91
|
-
:callback_proc_as_string => nil, :form_value_type => 'text_area'
|
92
|
-
}.merge(options)
|
93
|
-
|
94
|
-
# try to find the setting first
|
95
|
-
value = get(name, :scoping => options[:scoping])
|
96
|
-
|
97
|
-
# if the setting's value is nil, store a new one using the existing functionality.
|
98
|
-
value = set(name, options.merge({:value => the_value})) if value.nil?
|
99
|
-
|
100
|
-
# Return what we found.
|
101
|
-
value
|
102
|
-
end
|
103
|
-
|
104
|
-
alias :get_or_set :find_or_set
|
105
|
-
|
106
|
-
# Retrieve the current value for the setting whose name is supplied.
|
107
|
-
def get(name, options = {})
|
108
|
-
options = {:scoping => nil}.update(options)
|
109
|
-
cache_read(name, options[:scoping])
|
110
|
-
end
|
111
|
-
|
112
|
-
alias :[] :get
|
113
|
-
|
114
|
-
def set(name, value)
|
115
|
-
return (value.is_a?(Hash) ? value[:value] : value) unless (table_exists? rescue false)
|
116
|
-
|
117
|
-
scoping = (value[:scoping] if value.is_a?(Hash) and value.has_key?(:scoping))
|
118
|
-
setting = find_or_initialize_by_name_and_scoping(:name => name.to_s, :scoping => scoping)
|
119
|
-
|
120
|
-
# you could also pass in {:value => 'something', :scoping => 'somewhere'}
|
121
|
-
unless value.is_a?(Hash) and value.has_key?(:value)
|
122
|
-
setting.value = value
|
123
|
-
else
|
124
|
-
# set the value last, so that the other attributes can transform it if required.
|
125
|
-
setting.form_value_type = value[:form_value_type] || 'text_area' if setting.respond_to?(:form_value_type)
|
126
|
-
setting.scoping = value[:scoping] if value.has_key?(:scoping)
|
127
|
-
setting.callback_proc_as_string = value[:callback_proc_as_string] if value.has_key?(:callback_proc_as_string)
|
128
|
-
setting.destroyable = value[:destroyable] if value.has_key?(:destroyable)
|
129
|
-
setting.value = value[:value]
|
130
|
-
end
|
131
|
-
|
132
|
-
# Save because we're in a setter method.
|
133
|
-
setting.save
|
134
|
-
|
135
|
-
# Return the value
|
136
|
-
setting.value
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
# prettier version of the name.
|
141
|
-
# site_name becomes Site Name
|
142
|
-
def title
|
143
|
-
result = name.to_s.titleize
|
144
|
-
result += ' (' + scoping.titleize + ')' if scoping.is_a?(String)
|
145
|
-
result
|
146
|
-
end
|
147
|
-
|
148
|
-
# form_value is so that on the web interface we can display a sane value.
|
149
|
-
def form_value
|
150
|
-
unless self[:value].blank? or self[:value].is_a?(String)
|
151
|
-
YAML::dump(self[:value])
|
152
|
-
else
|
153
|
-
self[:value]
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def value
|
158
|
-
replacements!(self[:value])
|
159
|
-
end
|
160
|
-
|
161
|
-
def value=(new_value)
|
162
|
-
# must convert "1" to true and "0" to false when supplied using 'check_box', unfortunately.
|
163
|
-
if ["1", "0"].include?(new_value) and form_value_type == 'check_box'
|
164
|
-
new_value = new_value == "1" ? true : false
|
165
|
-
end
|
166
|
-
|
167
|
-
# must convert to string if true or false supplied otherwise it becomes 0 or 1, unfortunately.
|
168
|
-
if [true, false].include?(new_value)
|
169
|
-
new_value = new_value.to_s
|
170
|
-
end
|
171
|
-
|
172
|
-
super
|
173
|
-
end
|
174
|
-
|
175
|
-
def callback_proc
|
176
|
-
eval("Proc.new{#{callback_proc_as_string} }") if callback_proc_as_string.present?
|
177
|
-
end
|
178
|
-
|
179
|
-
private
|
180
|
-
# Below is not very nice, but seems to be required. The problem is when Rails
|
181
|
-
# serialises a fields like booleans it doesn't retrieve it back out as a boolean
|
182
|
-
# it just returns a string. This code maps the two boolean values
|
183
|
-
# correctly so that a boolean is returned instead of a string.
|
184
|
-
REPLACEMENTS = {"true" => true, "false" => false}
|
185
|
-
|
186
|
-
def replacements!(current_value)
|
187
|
-
# This bit handles true and false so that true and false are actually returned
|
188
|
-
# not "0" and "1"
|
189
|
-
REPLACEMENTS.each do |current, new_value|
|
190
|
-
current_value = new_value if current_value == current
|
191
|
-
end
|
192
|
-
|
193
|
-
# converts the serialised value back to an integer
|
194
|
-
# if the value is an integer
|
195
|
-
begin
|
196
|
-
if current_value.to_i.to_s == current_value
|
197
|
-
current_value = current_value.to_i
|
198
|
-
end
|
199
|
-
rescue
|
200
|
-
current_value
|
201
|
-
end
|
202
|
-
|
203
|
-
current_value
|
204
|
-
end
|
205
|
-
|
206
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<ul>
|
2
|
-
<li>
|
3
|
-
<%= render :partial => "/shared/admin/search",
|
4
|
-
:locals => {
|
5
|
-
:url => admin_refinery_settings_url
|
6
|
-
} %>
|
7
|
-
</li>
|
8
|
-
<li>
|
9
|
-
<%= link_to t('.new'), new_admin_refinery_setting_path({
|
10
|
-
:dialog => true,
|
11
|
-
:width => 725,
|
12
|
-
:height => 475
|
13
|
-
}), :class => "add_icon" %>
|
14
|
-
</li>
|
15
|
-
</ul>
|
@@ -1,62 +0,0 @@
|
|
1
|
-
<%= form_for [:admin, @refinery_setting] do |f| %>
|
2
|
-
|
3
|
-
<%= render :partial => "/shared/admin/error_messages",
|
4
|
-
:locals => {
|
5
|
-
:object => @refinery_setting,
|
6
|
-
:include_object_name => true
|
7
|
-
} %>
|
8
|
-
|
9
|
-
<div class='field'>
|
10
|
-
<%= f.label :name %>
|
11
|
-
<% if action_name =~ /(new)|(create)/ %>
|
12
|
-
<%= f.text_field :name, :class => "larger widest" %>
|
13
|
-
<% else %>
|
14
|
-
<label class='stripped' for='refinery_setting_value'>
|
15
|
-
<%= @refinery_setting.title %>
|
16
|
-
</label>
|
17
|
-
<span class="preview">- (<%= @refinery_setting.name %>)</span>
|
18
|
-
<% end %>
|
19
|
-
<% if current_user.has_role?(:superuser) and !@refinery_setting.persisted? %>
|
20
|
-
<div class='field'>
|
21
|
-
<%= f.label :form_value_type %>
|
22
|
-
<%= f.select :form_value_type, RefinerySetting::FORM_VALUE_TYPES -%>
|
23
|
-
</div>
|
24
|
-
<% end %>
|
25
|
-
<% unless action_name =~ /(new)|(create)/ or (help = t(@refinery_setting.name, :scope => 'admin.refinery_settings.form.help', :default => '')).blank? or @refinery_setting.form_value_type == 'check_box' %>
|
26
|
-
<p>
|
27
|
-
<span><%= help %></span>
|
28
|
-
</p>
|
29
|
-
<% end %>
|
30
|
-
<% if current_user.has_role?(:superuser) %>
|
31
|
-
<span class='label_with_help'>
|
32
|
-
<%= f.label :restricted %>
|
33
|
-
<%= refinery_help_tag t('restricted', :scope => 'admin.refinery_settings.form.help') %>
|
34
|
-
</span>
|
35
|
-
<%= f.check_box :restricted %>
|
36
|
-
<%= f.label :restricted, t('.yes_make_this_setting_restricted'), :class => 'stripped' %>
|
37
|
-
<% end %>
|
38
|
-
</div>
|
39
|
-
<div class='field'>
|
40
|
-
<%= refinery_setting_title(f) %>
|
41
|
-
<%= refinery_setting_field(f, help) %>
|
42
|
-
</div>
|
43
|
-
|
44
|
-
<%= render :partial => "/shared/admin/form_actions",
|
45
|
-
:locals => {
|
46
|
-
:f => f,
|
47
|
-
:continue_editing => false,
|
48
|
-
:hide_cancel => from_dialog?,
|
49
|
-
:submit_button_title => t('.restart_may_be_in_order_html'),
|
50
|
-
:delete_title => t('delete', :scope => 'admin.refinery_settings'),
|
51
|
-
:delete_confirmation => t('message', :scope => 'shared.admin.delete',
|
52
|
-
:title => @refinery_setting.title),
|
53
|
-
:hide_delete => (!@refinery_setting.persisted? or !@refinery_setting.destroyable or from_dialog?)
|
54
|
-
} %>
|
55
|
-
<% end -%>
|
56
|
-
<% content_for :javascripts do %>
|
57
|
-
<script>
|
58
|
-
$('#refinery_setting_form_value_type').change(function(e) {
|
59
|
-
window.location = location_url + ((location_url.indexOf("?") > -1 ? "&" : "?") + "form_value_type=" + $(this).val());
|
60
|
-
});
|
61
|
-
</script>
|
62
|
-
<% end if current_user.has_role?(:superuser) %>
|
@@ -1,21 +0,0 @@
|
|
1
|
-
<% if searching? %>
|
2
|
-
<h2>
|
3
|
-
<%= t('results_for', :scope => 'shared.admin.search', :query => params[:search]) %>
|
4
|
-
</h2>
|
5
|
-
<% end %>
|
6
|
-
<% if @refinery_settings.any? %>
|
7
|
-
<div class='pagination_container'>
|
8
|
-
<%= render :partial => 'refinery_settings' %>
|
9
|
-
</div>
|
10
|
-
<% else %>
|
11
|
-
<p>
|
12
|
-
<% if searching? %>
|
13
|
-
<%= t('no_results', :scope => 'shared.admin.search') %>
|
14
|
-
<% else %>
|
15
|
-
<strong>
|
16
|
-
<%= t('.empty_set') %>
|
17
|
-
<%= t('.create_first', :link => t('new', :scope => 'admin.refinery_settings.actions')) %>
|
18
|
-
</strong>
|
19
|
-
<% end %>
|
20
|
-
</p>
|
21
|
-
<% end %>
|
@@ -1,23 +0,0 @@
|
|
1
|
-
<li class='clearfix record <%= cycle("on", "on-hover") %>'>
|
2
|
-
<span class='title'>
|
3
|
-
<%= t(refinery_setting.name, :scope => 'admin.refinery_settings.form.title', :default => refinery_setting.title) %>
|
4
|
-
<span class="preview">- <%= truncate(refinery_setting.value.to_s, :length => 40) %></span>
|
5
|
-
</span>
|
6
|
-
<span class='actions'>
|
7
|
-
<%= link_to refinery_icon_tag('application_edit.png'),
|
8
|
-
edit_admin_refinery_setting_path(refinery_setting, :dialog => true, :width => 725, :height => 525),
|
9
|
-
:title => t('edit', :scope => 'admin.refinery_settings') %>
|
10
|
-
<%= link_to refinery_icon_tag('delete.png'),
|
11
|
-
admin_refinery_setting_path(refinery_setting),
|
12
|
-
:class => 'cancel confirm-delete',
|
13
|
-
:title => t('delete', :scope => 'admin.refinery_settings'),
|
14
|
-
:confirm => t('message', :scope => 'shared.admin.delete', :title => refinery_setting.title),
|
15
|
-
:method => :delete if refinery_setting.destroyable %>
|
16
|
-
|
17
|
-
<% unless (help = t(refinery_setting.name, :scope => 'admin.refinery_settings.form.help', :default => '')).blank? %>
|
18
|
-
<%= link_to refinery_icon_tag('information.png'), '#',
|
19
|
-
:tooltip => help,
|
20
|
-
:class => 'information suppress' %>
|
21
|
-
<% end %>
|
22
|
-
</span>
|
23
|
-
</li>
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= render :partial => "form" %>
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= render :partial => "form" %>
|