muck-engine 0.4.21 → 0.4.23
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/helpers/muck_custom_form_builder.rb +30 -13
- data/app/views/forms/_base_field.erb +2 -0
- data/app/views/forms/_color_picker_field.erb +1 -1
- data/app/views/forms/_field.erb +1 -1
- data/app/views/forms/_menu_field.erb +1 -1
- data/lib/action_controller/muck_application.rb +21 -7
- data/locales/en.yml +11 -10
- data/muck-engine.gemspec +2 -2
- data/public/javascripts/muck-src.js +1 -1
- data/public/javascripts/muck.js +1 -1
- data/test/rails_root/test/functional/default_controller_test.rb +10 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.23
|
@@ -23,8 +23,14 @@ class MuckCustomFormBuilder < ActionView::Helpers::FormBuilder
|
|
23
23
|
# tip_key The id of the div that contains the tip text.
|
24
24
|
# tip_position Position for tip text. Valid values are 'top', 'right', 'bottom', 'left'. Default is 'right'
|
25
25
|
# wrapper_id Alternate id for the container. Each field is typically wrapper in a div. This is the id of that div.
|
26
|
+
# wrapper_class Css class for the container. All containers have the class form-row. This value will be in addition to that class.
|
27
|
+
# label_class Css class for the label
|
28
|
+
# hide_label Prevents a label from being output
|
26
29
|
# hide_required Do not show 'required' label even though field is required
|
27
30
|
# hide_control_error Hide errors that show up next to the field
|
31
|
+
# required_text_mark By default '(required)' is used to show required fields. Override this by setting required_text_mark to something else - ie '*'
|
32
|
+
# Alternatively override 'muck.engine.required_text_mark' in your app's en.yml or the appropriate localization file. You can also
|
33
|
+
# specify a value in global_config.yml with required_text_mark: *
|
28
34
|
def render_field_template(name, field, options)
|
29
35
|
|
30
36
|
tippable = !options[:tip].nil?
|
@@ -33,22 +39,26 @@ class MuckCustomFormBuilder < ActionView::Helpers::FormBuilder
|
|
33
39
|
field_id = options[:field_id]
|
34
40
|
|
35
41
|
local_options = {
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
42
|
+
:pre_html => options.delete(:pre_html),
|
43
|
+
:after_label_html => options.delete(:after_label_html),
|
44
|
+
:extra_html => options.delete(:extra_html),
|
45
|
+
:tip => options.delete(:tip),
|
46
|
+
:tip_title => options.delete(:tip_title),
|
47
|
+
:tip_key => options.delete(:tip_key),
|
48
|
+
:tip_position => options.delete(:tip_position) || 'right',
|
49
|
+
:wrapper_id => options.delete(:wrapper_id),
|
50
|
+
:wrapper_class => options.delete(:wrapper_class),
|
51
|
+
:hide_required => options.delete(:hide_required),
|
44
52
|
:hide_control_error => options.delete(:hide_control_error),
|
45
|
-
:css_class
|
53
|
+
:css_class => options.delete(:css_class)
|
46
54
|
}
|
47
55
|
# TODO css_class does not appear to be used. Can just use the standard :class in html options to set the class
|
48
56
|
|
49
57
|
is_checkbox = false
|
50
58
|
is_checkbox = true if %w(check_box).include?(name)
|
51
59
|
|
60
|
+
required_text_mark = options.delete(:required_text_mark)
|
61
|
+
|
52
62
|
type = options.delete(:type)
|
53
63
|
type ||= :tippable if tippable
|
54
64
|
|
@@ -67,7 +77,7 @@ class MuckCustomFormBuilder < ActionView::Helpers::FormBuilder
|
|
67
77
|
else
|
68
78
|
required = required_field?(field)
|
69
79
|
label_text = (options[:label] || field.to_s.camelize)
|
70
|
-
label_text = label_text + required_mark(field) if required
|
80
|
+
label_text = label_text + required_mark(field, required_text_mark) if required
|
71
81
|
end
|
72
82
|
label_name = options.delete(:label)
|
73
83
|
|
@@ -79,11 +89,17 @@ class MuckCustomFormBuilder < ActionView::Helpers::FormBuilder
|
|
79
89
|
options[:label_class] = 'desc'
|
80
90
|
end
|
81
91
|
|
92
|
+
if options.delete(:hide_label)
|
93
|
+
label_element = ''
|
94
|
+
else
|
95
|
+
label_element = label(field, label_text, label_options)
|
96
|
+
end
|
97
|
+
|
82
98
|
locals = {
|
83
99
|
:field_element => yield,
|
84
100
|
:field_name => field_id || field_name(field),
|
85
101
|
:label_name => options.delete(:required_label) || label_name || '',
|
86
|
-
:label_element =>
|
102
|
+
:label_element => label_element,
|
87
103
|
:is_checkbox => is_checkbox,
|
88
104
|
:required => required
|
89
105
|
}.merge(local_options)
|
@@ -197,8 +213,9 @@ class MuckCustomFormBuilder < ActionView::Helpers::FormBuilder
|
|
197
213
|
"#{@object_name.to_s}_#{field.to_s}"
|
198
214
|
end
|
199
215
|
|
200
|
-
def required_mark(field)
|
201
|
-
|
216
|
+
def required_mark(field, required_text_mark = nil)
|
217
|
+
required_text_mark ||= GlobalConfig.required_text_mark || I18n.translate('muck.engine.required_text_mark')
|
218
|
+
required_field?(field) ? " <em id=\"#{field_name(field)}-label-required\">#{required_text_mark}</em>" : ''
|
202
219
|
end
|
203
220
|
|
204
221
|
def required_field?(field)
|
@@ -2,8 +2,10 @@
|
|
2
2
|
<% if is_checkbox -%>
|
3
3
|
<%= field_element %>
|
4
4
|
<%= label_element %>
|
5
|
+
<%= after_label_html %>
|
5
6
|
<% else -%>
|
6
7
|
<%= label_element %>
|
8
|
+
<%= after_label_html %>
|
7
9
|
<%= field_element %>
|
8
10
|
<% end -%>
|
9
11
|
<% if required -%><div id="<%= field_name %>_required" class="required-tip" style="display:none;"><em><%= I18n.t('muck.forms.please_enter_a_value', :label => label_name) %></em></div><% end -%>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% color = value
|
2
2
|
html_id = '_' + id.to_s + '_' + field_name %>
|
3
|
-
<div <%= wrapper_id.nil? ? '' : "id=\"#{wrapper_id}\"" -%> class="form-row color-selector-container">
|
3
|
+
<div <%= wrapper_id.nil? ? '' : "id=\"#{wrapper_id}\"" -%> class="form-row color-selector-container <%= wrapper_class %>">
|
4
4
|
<%= render :partial => 'forms/base_field', :locals => local_assigns %>
|
5
5
|
<div id="colorSelector<%=html_id%>" class="color-selector">
|
6
6
|
<div id="colorSelectorDisplay<%=html_id%>" style="background-color:#<%=color%>;"></div>
|
data/app/views/forms/_field.erb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
<div <%= wrapper_id.nil? ? '' : "id=\"#{wrapper_id}\"" -%> class="chooseMenu">
|
1
|
+
<div <%= wrapper_id.nil? ? '' : "id=\"#{wrapper_id}\"" -%> class="chooseMenu <%= wrapper_class %>">
|
2
2
|
<%= render :partial => 'forms/base_field', :locals => local_assigns %>
|
3
3
|
<%= render :partial => 'forms/tips', :locals => local_assigns %>
|
4
4
|
</div>
|
@@ -141,8 +141,11 @@ module ActionController
|
|
141
141
|
|
142
142
|
# Attempts to create an @parent object using params
|
143
143
|
# or the url.
|
144
|
-
|
145
|
-
|
144
|
+
# scope: Friendly id can require a scope to find the object. Pass the scope as needed.
|
145
|
+
# ignore: Names to ignore. For example if the url is /foo/1/bar?thing_id=1
|
146
|
+
# you might want to ignore thing_id so pass :thing.
|
147
|
+
def setup_parent(args = {})
|
148
|
+
@parent = get_parent(args)
|
146
149
|
if @parent.blank?
|
147
150
|
render :text => t('muck.engine.missing_parent_error')
|
148
151
|
return false
|
@@ -152,28 +155,39 @@ module ActionController
|
|
152
155
|
# Tries to get parent using parent_type and parent_id from the url.
|
153
156
|
# If that fails and attempt is then made using find_parent
|
154
157
|
# parameters:
|
158
|
+
# scope: Friendly id can require a scope to find the object. Pass the scope as needed.
|
155
159
|
# ignore: Names to ignore. For example if the url is /foo/1/bar?thing_id=1
|
156
160
|
# you might want to ignore thing_id so pass :thing.
|
157
|
-
def get_parent(
|
161
|
+
def get_parent(args = {})
|
158
162
|
if params[:parent_type].blank? || params[:parent_id].blank?
|
159
|
-
find_parent(
|
163
|
+
find_parent(args)
|
160
164
|
else
|
161
165
|
klass = params[:parent_type].to_s.constantize
|
162
|
-
|
166
|
+
if args.has_key?(:scope)
|
167
|
+
klass.find(params[:parent_id], :scope => args[:scope])
|
168
|
+
else
|
169
|
+
klass.find(params[:parent_id])
|
170
|
+
end
|
163
171
|
end
|
164
172
|
end
|
165
173
|
|
166
174
|
# Searches the params to try and find an entry ending with _id
|
167
175
|
# ie article_id, user_id, etc. Will return the first value found.
|
168
176
|
# parameters:
|
177
|
+
# scope: Friendly id can require a scope to find the object. Pass the scope as needed.
|
169
178
|
# ignore: Names to ignore. For example if the url is /foo/1/bar?thing_id=1
|
170
179
|
# you might want to ignore thing_id so pass 'thing' to be ignored.
|
171
|
-
def find_parent(
|
180
|
+
def find_parent(args = {})
|
181
|
+
ignore = args.delete(:ignore) || []
|
172
182
|
ignore.flatten!
|
173
183
|
params.each do |name, value|
|
174
184
|
if name =~ /(.+)_id$/
|
175
185
|
if !ignore.include?($1)
|
176
|
-
|
186
|
+
if args.has_key?(:scope)
|
187
|
+
return $1.classify.constantize.find(value, :scope => args[:scope])
|
188
|
+
else
|
189
|
+
return $1.classify.constantize.find(value)
|
190
|
+
end
|
177
191
|
end
|
178
192
|
end
|
179
193
|
end
|
data/locales/en.yml
CHANGED
@@ -4,6 +4,7 @@ en:
|
|
4
4
|
forms:
|
5
5
|
please_enter_a_value: Please enter a value for {{label}}
|
6
6
|
engine:
|
7
|
+
required_text_mark: (required)
|
7
8
|
choose_state: Choose State
|
8
9
|
select_state_prompt: Please select a state
|
9
10
|
choose_language: Choose Language
|
@@ -12,29 +13,29 @@ en:
|
|
12
13
|
select_country_prompt: Please select a country
|
13
14
|
missing_parent_error: Please specify a parent object
|
14
15
|
admin_logout: Logout
|
15
|
-
admin_home: Home
|
16
16
|
admin_roles: Roles
|
17
17
|
admin_access_codes: Access Codes
|
18
|
+
admin_home: Home
|
18
19
|
admin_welcome: Welcome back {{user}}
|
19
20
|
admin_home_title: Admin Home
|
20
21
|
select_language_prompt: Please select a language
|
21
22
|
general:
|
22
|
-
no_text: "No"
|
23
23
|
deactivate: Deactivate
|
24
|
-
|
24
|
+
no_text: "No"
|
25
25
|
previous: "« Previous"
|
26
|
-
|
26
|
+
help: Help
|
27
27
|
delete: Delete
|
28
|
+
settings_saved: Settings have been saved.
|
28
29
|
time_ago: "{{time_in_words}} ago"
|
29
|
-
yes_text: "Yes"
|
30
|
-
enable: Disable
|
31
30
|
enabled: Enabled?
|
31
|
+
enable: Disable
|
32
|
+
yes_text: "Yes"
|
32
33
|
loading: Loading...
|
33
34
|
save: Save
|
34
|
-
disable: Enable
|
35
|
-
activate: Activate
|
36
35
|
next: Next »
|
37
|
-
|
36
|
+
activate: Activate
|
37
|
+
disable: Enable
|
38
38
|
update: Update
|
39
|
-
|
39
|
+
general_info: General info
|
40
40
|
deleting: Deleting...
|
41
|
+
read_more: read more
|
data/muck-engine.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{muck-engine}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.23"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Ball", "Joel Duffin"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-16}
|
13
13
|
s.description = %q{The base engine for the muck system. Contains common tables, custom for, css and javascript.}
|
14
14
|
s.email = %q{justin@tatemae.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -125,7 +125,7 @@ function split_list(items_string){
|
|
125
125
|
}
|
126
126
|
var cleaned = [];
|
127
127
|
for(i=0;i<items.length;i++){
|
128
|
-
var cleaned_item = items[i]
|
128
|
+
var cleaned_item = jQuery.trim(items[i]);
|
129
129
|
if(cleaned_item.length > 0){
|
130
130
|
cleaned.push(cleaned_item);
|
131
131
|
}
|
data/public/javascripts/muck.js
CHANGED
@@ -3,4 +3,4 @@ function add_headers(a){a.setRequestHeader("Accept","text/javascript");a.setRequ
|
|
3
3
|
jQuery(document).ready(function(){jQuery("a.ajax-delete").live("click",function(){var a=jQuery(this).attr("title"),b=true;if(a.length>0)b=confirm(a);b&&jQuery.post(this.href,{_method:"delete",format:"js"},null,"script");return false});jQuery("a.ajax-update").live("click",function(){jQuery.post(this.href,{_method:"put",format:"js"},null,"script");return false});jQuery(".submit-form").click(function(){jQuery(this).parent("form").submit()});apply_ajax_forms();jQuery("a.dialog-pop").live("click",function(){var a=
|
4
4
|
jQuery('<div class="dialog"></div>').appendTo("body");a.dialog({modal:true,autoOpen:false,width:"auto",title:jQuery(this).attr("title")});a.load(jQuery(this).attr("href"),"",function(){a.dialog("open");apply_ajax_forms()});return false});jQuery(".submit-delete").live("click",function(){jQuery(this).parents(".delete-container").fadeOut();var a=jQuery(this).parents("form");jQuery.post(a.attr("action")+".json",a.serialize(),function(b){b=eval("("+b+")");b.success||jQuery.jGrowl.info(b.message)});return false});
|
5
5
|
jQuery(".submit-delete-js").live("click",function(){jQuery(this).parents(".delete-container").fadeOut();var a=jQuery(this).parents("form");jQuery.post(a.attr("action")+".js",a.serialize(),function(){});return false});jQuery(document).ready(function(){jQuery(".waiting").hide();jQuery(".wait-button").live("click",function(){jQuery(this).siblings(".waiting").show();jQuery(this).hide()})})});
|
6
|
-
function add_to_list(a,b){a=split_list(a);var c=true;for(i=0;i<a.length;i++)if(a[i]==b)c=false;c&&a.push(b);return a.join(", ")}function remove_from_list(a,b){a=split_list(a);var c=[];for(i=0;i<a.length;i++)a[i]!=b&&c.push(a[i]);return c.join(", ")}function split_list(a){a=undefined!=a&&a.length>0?a.split(","):[];var b=[];for(i=0;i<a.length;i++){var c=a[i]
|
6
|
+
function add_to_list(a,b){a=split_list(a);var c=true;for(i=0;i<a.length;i++)if(a[i]==b)c=false;c&&a.push(b);return a.join(", ")}function remove_from_list(a,b){a=split_list(a);var c=[];for(i=0;i<a.length;i++)a[i]!=b&&c.push(a[i]);return c.join(", ")}function split_list(a){a=undefined!=a&&a.length>0?a.split(","):[];var b=[];for(i=0;i<a.length;i++){var c=jQuery.trim(a[i]);c.length>0&&b.push(c)}return b};
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 23
|
9
|
+
version: 0.4.23
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Justin Ball
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-04-
|
18
|
+
date: 2010-04-16 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|