active_scaffold_vho 3.0.13 → 3.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/active_scaffold_vho.gemspec +3 -2
- data/frontends/default/javascripts/jquery/active_scaffold.js +5 -1
- data/frontends/default/javascripts/prototype/active_scaffold.js +4 -0
- data/frontends/default/stylesheets/stylesheet.css +4 -1
- data/frontends/default/views/_base_form.html.erb +11 -5
- data/frontends/default/views/_form.html.erb +2 -2
- data/frontends/default/views/_form_association.html.erb +7 -2
- data/frontends/default/views/_form_attribute.html.erb +1 -1
- data/frontends/default/views/_horizontal_subform.html.erb +7 -1
- data/frontends/default/views/_horizontal_subform_record.html.erb +1 -1
- data/frontends/default/views/_list_messages.html.erb +1 -1
- data/frontends/default/views/_vertical_subform_record.html.erb +1 -1
- data/lib/active_scaffold/actions/core.rb +10 -1
- data/lib/active_scaffold/actions/field_search.rb +1 -1
- data/lib/active_scaffold/actions/list.rb +1 -1
- data/lib/active_scaffold/actions/subform.rb +14 -4
- data/lib/active_scaffold/actions/update.rb +5 -1
- data/lib/active_scaffold/bridges/cancan/lib/cancan_bridge.rb +7 -3
- data/lib/active_scaffold/bridges/carrierwave/lib/form_ui.rb +12 -8
- data/lib/active_scaffold/bridges/tiny_mce/lib/tiny_mce_bridge.rb +19 -3
- data/lib/active_scaffold/config/mark.rb +1 -1
- data/lib/active_scaffold/data_structures/action_columns.rb +4 -0
- data/lib/active_scaffold/finder.rb +8 -4
- data/lib/active_scaffold/helpers/list_column_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/search_column_helpers.rb +10 -5
- data/lib/active_scaffold/locale/fr.rb +36 -30
- data/lib/active_scaffold/version.rb +1 -1
- data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +1 -0
- data/lib/generators/active_scaffold_controller/templates/helper.rb +2 -0
- data/test/misc/finder_test.rb +2 -2
- data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +4 -1
- metadata +5 -4
data/active_scaffold_vho.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{active_scaffold_vho}
|
8
|
-
s.version = "3.0.
|
8
|
+
s.version = "3.0.14"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Many, see README"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-03-05}
|
13
13
|
s.description = %q{Save time and headaches, and create a more easily maintainable set of pages, with ActiveScaffold. ActiveScaffold handles all your CRUD (create, read, update, delete) user interface needs, leaving you more time to focus on more challenging (and interesting!) problems.}
|
14
14
|
s.email = %q{activescaffold@googlegroups.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -225,6 +225,7 @@ Gem::Specification.new do |s|
|
|
225
225
|
"lib/generators/active_scaffold_controller/USAGE",
|
226
226
|
"lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb",
|
227
227
|
"lib/generators/active_scaffold_controller/templates/controller.rb",
|
228
|
+
"lib/generators/active_scaffold_controller/templates/helper.rb",
|
228
229
|
"lib/generators/active_scaffold_setup/USAGE",
|
229
230
|
"lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb",
|
230
231
|
"public/blank.html",
|
@@ -140,7 +140,11 @@ $(document).ready(function() {
|
|
140
140
|
csrf_token = $('meta[name=csrf-token]').first(),
|
141
141
|
my_parent = span.parent(),
|
142
142
|
column_heading = null;
|
143
|
-
|
143
|
+
|
144
|
+
if(!(my_parent.is('td') || my_parent.is('th'))){
|
145
|
+
my_parent = span.parents('td').eq(0);
|
146
|
+
}
|
147
|
+
|
144
148
|
if (my_parent.is('td')) {
|
145
149
|
var column_no = my_parent.prevAll('td').length;
|
146
150
|
column_heading = my_parent.closest('.active-scaffold').find('th:eq(' + column_no + ')');
|
@@ -155,6 +155,10 @@ document.observe("dom:loaded", function() {
|
|
155
155
|
csrf_token = $$('meta[name=csrf-token]')[0],
|
156
156
|
my_parent = span.up(),
|
157
157
|
column_heading = null;
|
158
|
+
|
159
|
+
if(!(my_parent.nodeName.toLowerCase() === 'td' || my_parent.nodeName.toLowerCase() === 'th')){
|
160
|
+
my_parent = span.up('td');
|
161
|
+
}
|
158
162
|
|
159
163
|
if (my_parent.nodeName.toLowerCase() === 'td') {
|
160
164
|
var heading_selector = '.' + span.up().readAttribute('class').split(' ')[0] + '_heading';
|
@@ -793,8 +793,11 @@ padding: 2px;
|
|
793
793
|
}
|
794
794
|
|
795
795
|
.active-scaffold .fieldWithErrors input,
|
796
|
+
.active-scaffold .field_with_errors input,
|
796
797
|
.active-scaffold .fieldWithErrors textarea,
|
797
|
-
.active-scaffold .
|
798
|
+
.active-scaffold .field_with_errors textarea,
|
799
|
+
.active-scaffold .fieldWithErrors select,
|
800
|
+
.active-scaffold .field_with_errors select {
|
798
801
|
border: solid 1px #f00;
|
799
802
|
}
|
800
803
|
|
@@ -1,21 +1,27 @@
|
|
1
1
|
<% url_options ||= params_for(:action => form_action)
|
2
2
|
xhr = request.xhr? if xhr.nil?
|
3
|
-
|
3
|
+
if active_scaffold_config.actions.include? form_action
|
4
|
+
multipart ||= active_scaffold_config.send(form_action).multipart?
|
5
|
+
columns ||= active_scaffold_config.send(form_action).columns
|
6
|
+
else
|
7
|
+
multipart ||= false
|
8
|
+
columns ||= nil
|
9
|
+
end
|
4
10
|
body_partial ||= 'form' %>
|
5
11
|
<%=
|
6
12
|
options = {:onsubmit => onsubmit,
|
7
13
|
:id => element_form_id(:action => form_action),
|
8
|
-
:multipart =>
|
14
|
+
:multipart => multipart,
|
9
15
|
:class => "as_form #{form_action.to_s}",
|
10
16
|
:method => method,
|
11
17
|
'data-loading' => true}
|
12
18
|
cancel_options = {:class => 'as_cancel', 'data-refresh' => false}
|
13
19
|
|
14
20
|
cancel_options[:remote] = true if xhr #cancel link does nt have to care about multipart forms
|
15
|
-
if xhr &&
|
21
|
+
if xhr && multipart # file_uploads
|
16
22
|
form_remote_upload_tag url_options.merge({:iframe => true}), options
|
17
23
|
else
|
18
|
-
options[:remote] = true if xhr && !
|
24
|
+
options[:remote] = true if xhr && !multipart
|
19
25
|
form_tag url_options, options
|
20
26
|
end
|
21
27
|
-%>
|
@@ -33,7 +39,7 @@ end
|
|
33
39
|
<% end -%>
|
34
40
|
</div>
|
35
41
|
|
36
|
-
<%= render :partial => body_partial, :locals => { :columns =>
|
42
|
+
<%= render :partial => body_partial, :locals => { :columns => columns } %>
|
37
43
|
|
38
44
|
<p class="form-footer">
|
39
45
|
<%= submit_tag as_(form_action), :class => "submit" %>
|
@@ -13,11 +13,11 @@
|
|
13
13
|
next %>
|
14
14
|
<% elsif renders_as == :subform and !override_form_field?(column) -%>
|
15
15
|
<li class="sub-form <%= active_scaffold_config_for(column.association.klass).subform.layout %>-sub-form <%= column.css_class unless column.css_class.nil? || column.css_class.is_a?(Proc) %>" id="<%= sub_form_id(:association => column.name) %>">
|
16
|
-
<%= render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column } -%>
|
16
|
+
<%=raw render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column } -%>
|
17
17
|
</li>
|
18
18
|
<% else -%>
|
19
19
|
<li class="form-element <%= 'required' if column.required? %> <%= column.css_class unless column.css_class.nil? || column.css_class.is_a?(Proc) %>">
|
20
|
-
<%= render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column } -%>
|
20
|
+
<%=raw render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column } -%>
|
21
21
|
</li>
|
22
22
|
<% end -%>
|
23
23
|
<% end -%>
|
@@ -2,8 +2,13 @@
|
|
2
2
|
parent_record = @record
|
3
3
|
associated = column.singular_association? ? [parent_record.send(column.name)].compact : parent_record.send(column.name).to_a
|
4
4
|
associated = associated.sort_by {|r| r.new_record? ? 99999999999 : r.id} unless column.association.options.has_key?(:order)
|
5
|
-
|
6
|
-
associated <<
|
5
|
+
if column.show_blank_record? associated
|
6
|
+
associated << if column.singular_association?
|
7
|
+
parent_record.send("build_#{column.name}".to_sym)
|
8
|
+
else
|
9
|
+
parent_record.send(column.name).build
|
10
|
+
end
|
11
|
+
end
|
7
12
|
subform_div_id = "#{sub_form_id({:association => column.name, :id => parent_record.id || 99999999999})}-div"
|
8
13
|
-%>
|
9
14
|
<h5><%= column.label -%></h5>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<label for="<%= active_scaffold_input_options(column, scope)[:id] %>"><%= column.label %></label>
|
5
5
|
</dt>
|
6
6
|
<dd>
|
7
|
-
<%= active_scaffold_input_for column, scope %>
|
7
|
+
<%=raw active_scaffold_input_for column, scope %>
|
8
8
|
<% if column.update_columns -%>
|
9
9
|
<%= loading_indicator_tag(:action => :render_field, :id => params[:id]) %>
|
10
10
|
<% end -%>
|
@@ -1,5 +1,11 @@
|
|
1
1
|
<table cellpadding="0" cellspacing="0">
|
2
|
-
<%
|
2
|
+
<%
|
3
|
+
@record = if column.singular_association?
|
4
|
+
parent_record.send("build_#{column.name}".to_sym)
|
5
|
+
else
|
6
|
+
parent_record.send(column.name).build
|
7
|
+
end
|
8
|
+
-%>
|
3
9
|
<%= render :partial => 'horizontal_subform_header', :locals => {:parent_record => parent_record} %>
|
4
10
|
|
5
11
|
<tbody id="<%= sub_form_list_id(:association => column.name) %>">
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% record_column = column
|
2
2
|
readonly = (@record.readonly? or not @record.authorized_for?(:crud_type => :update))
|
3
|
-
crud_type = @record.new_record? ? :create : (readonly ? :read :
|
3
|
+
crud_type = @record.new_record? ? :create : (readonly ? :read : :update)
|
4
4
|
show_actions = false
|
5
5
|
config = active_scaffold_config_for(@record.class)
|
6
6
|
options = active_scaffold_input_options(config.columns[@record.class.primary_key], scope)
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<% if active_scaffold_config.list.show_search_reset && @filtered -%>
|
19
19
|
<% search_link = ActiveScaffold::DataStructures::ActionLink.new('index', :label => :click_to_reset, :type => :member, :position => false)
|
20
20
|
action_links = ActiveScaffold::DataStructures::ActionLinks.new
|
21
|
-
record =
|
21
|
+
record = new_model
|
22
22
|
record.id = 0
|
23
23
|
action_links.add(search_link) -%>
|
24
24
|
<%= render :partial => 'list_actions', :locals => {:record => record, :url_options => params_for(:escape => false, :search => ''), :action_links => action_links.member} %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%
|
2
2
|
record_column = column
|
3
3
|
readonly = (@record.readonly? or not @record.authorized_for?(:crud_type => :update))
|
4
|
-
crud_type = @record.new_record? ? :create : (readonly ? :read :
|
4
|
+
crud_type = @record.new_record? ? :create : (readonly ? :read : :update)
|
5
5
|
show_actions = false
|
6
6
|
config = active_scaffold_config_for(@record.class)
|
7
7
|
options = active_scaffold_input_options(config.columns[@record.class.primary_key], scope)
|
@@ -6,6 +6,7 @@ module ActiveScaffold::Actions
|
|
6
6
|
end
|
7
7
|
base.helper_method :nested?
|
8
8
|
base.helper_method :beginning_of_chain
|
9
|
+
base.helper_method :new_model
|
9
10
|
end
|
10
11
|
def render_field
|
11
12
|
if params[:in_place_editing]
|
@@ -151,12 +152,20 @@ module ActiveScaffold::Actions
|
|
151
152
|
private
|
152
153
|
def respond_to_action(action)
|
153
154
|
respond_to do |type|
|
154
|
-
|
155
|
+
action_formats.each do |format|
|
155
156
|
type.send(format){ send("#{action}_respond_to_#{format}") }
|
156
157
|
end
|
157
158
|
end
|
158
159
|
end
|
159
160
|
|
161
|
+
def action_formats
|
162
|
+
@action_formats ||= if respond_to? "#{action_name}_formats"
|
163
|
+
send("#{action_name}_formats")
|
164
|
+
else
|
165
|
+
(default_formats + active_scaffold_config.formats).uniq
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
160
169
|
def response_code_for_rescue(exception)
|
161
170
|
case exception
|
162
171
|
when ActiveScaffold::RecordNotAllowed
|
@@ -11,7 +11,7 @@ module ActiveScaffold::Actions
|
|
11
11
|
# FieldSearch uses params[:search] and not @record because search conditions do not always pass the Model's validations.
|
12
12
|
# This facilitates for example, textual searches against associations via .search_sql
|
13
13
|
def show_search
|
14
|
-
@record =
|
14
|
+
@record = new_model
|
15
15
|
respond_to_action(:field_search)
|
16
16
|
end
|
17
17
|
|
@@ -18,7 +18,7 @@ module ActiveScaffold::Actions
|
|
18
18
|
def list
|
19
19
|
do_list
|
20
20
|
do_new if active_scaffold_config.list.always_show_create
|
21
|
-
@record ||=
|
21
|
+
@record ||= new_model if active_scaffold_config.list.always_show_search
|
22
22
|
@nested_auto_open = active_scaffold_config.list.nested_auto_open
|
23
23
|
respond_to_action(:list)
|
24
24
|
end
|
@@ -1,17 +1,27 @@
|
|
1
1
|
module ActiveScaffold::Actions
|
2
2
|
module Subform
|
3
3
|
def edit_associated
|
4
|
-
|
4
|
+
do_edit_associated
|
5
|
+
render :action => 'edit_associated'
|
6
|
+
end
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
def do_edit_associated
|
11
|
+
@parent_record = params[:id].nil? ? new_model : find_if_allowed(params[:id], :update)
|
5
12
|
@column = active_scaffold_config.columns[params[:association]]
|
6
13
|
|
7
14
|
# NOTE: we don't check whether the user is allowed to update this record, because if not, we'll still let them associate the record. we'll just refuse to do more than associate, is all.
|
8
15
|
@record = @column.association.klass.find(params[:associated_id]) if params[:associated_id]
|
9
|
-
@record ||= @column.
|
16
|
+
@record ||= if @column.singular_association?
|
17
|
+
@parent_record.send("build_#{@column.name}".to_sym)
|
18
|
+
else
|
19
|
+
@parent_record.send(@column.name).build
|
20
|
+
end
|
10
21
|
|
11
22
|
@scope = "[#{@column.name}]"
|
12
23
|
@scope += (@record.new_record?) ? "[#{(Time.now.to_f*1000).to_i.to_s}]" : "[#{@record.id}]" if @column.plural_association?
|
13
|
-
|
14
|
-
render :action => 'edit_associated'
|
15
24
|
end
|
25
|
+
|
16
26
|
end
|
17
27
|
end
|
@@ -75,18 +75,22 @@ module ActiveScaffold::Actions
|
|
75
75
|
# If you want to customize this algorithm, consider using the +before_update_save+ callback
|
76
76
|
def do_update
|
77
77
|
do_edit
|
78
|
-
@record = update_record_from_params(@record, active_scaffold_config.update.columns, params[:record])
|
79
78
|
update_save
|
80
79
|
end
|
81
80
|
|
82
81
|
def update_save
|
83
82
|
begin
|
84
83
|
active_scaffold_config.model.transaction do
|
84
|
+
@record = update_record_from_params(@record, active_scaffold_config.update.columns, params[:record]) unless options[:no_record_param_update]
|
85
85
|
before_update_save(@record)
|
86
86
|
self.successful = [@record.valid?, @record.associated_valid?].all? {|v| v == true} # this syntax avoids a short-circuit
|
87
87
|
if successful?
|
88
88
|
@record.save! and @record.save_associated!
|
89
89
|
after_update_save(@record)
|
90
|
+
else
|
91
|
+
# some associations such as habtm are saved before saved is called on parent object
|
92
|
+
# we have to revert these changes if validation fails
|
93
|
+
raise ActiveRecord::Rollback, "don't save habtm associations unless record is valid"
|
90
94
|
end
|
91
95
|
end
|
92
96
|
rescue ActiveRecord::RecordInvalid
|
@@ -68,10 +68,14 @@ module ActiveScaffold
|
|
68
68
|
# if cancan says "no", it delegates to default AS behavior
|
69
69
|
def authorized_for_with_cancan?(options = {})
|
70
70
|
raise InvalidArgument if options[:crud_type].blank? and options[:action].blank?
|
71
|
-
|
72
|
-
|
71
|
+
if current_ability.present?
|
72
|
+
crud_type_result = options[:crud_type].nil? ? true : current_ability.can?(options[:crud_type], self)
|
73
|
+
action_result = options[:action].nil? ? true : current_ability.can?(options[:action].to_sym, self)
|
74
|
+
else
|
75
|
+
crud_type_result, action_result = false, false
|
76
|
+
end
|
73
77
|
default_result = authorized_for_without_cancan?(options)
|
74
|
-
result = (crud_type_result
|
78
|
+
result = (crud_type_result && action_result) || default_result
|
75
79
|
return result
|
76
80
|
end
|
77
81
|
end
|
@@ -3,14 +3,8 @@ module ActiveScaffold
|
|
3
3
|
module FormColumnHelpers
|
4
4
|
def active_scaffold_input_carrierwave(column, options)
|
5
5
|
options = active_scaffold_input_text_options(options)
|
6
|
-
input = file_field(:record, column.name, options)
|
7
6
|
carrierwave = @record.send("#{column.name}")
|
8
7
|
if carrierwave.file.present? && !carrierwave.file.empty?
|
9
|
-
if ActiveScaffold.js_framework == :jquery
|
10
|
-
js_remove_file_code = "$(this).prev().val('true'); $(this).parent().hide().next().show(); return false;";
|
11
|
-
else
|
12
|
-
js_remove_file_code = "$(this).previous().value='true'; $(this).up().hide().next().show(); return false;";
|
13
|
-
end
|
14
8
|
|
15
9
|
remove_field_options = {
|
16
10
|
:name => options[:name].gsub(/\[#{column.name}\]$/, "[remove_#{column.name}]"),
|
@@ -23,6 +17,15 @@ module ActiveScaffold
|
|
23
17
|
:id => options[:id] + '_cache'
|
24
18
|
}
|
25
19
|
|
20
|
+
if ActiveScaffold.js_framework == :jquery
|
21
|
+
js_remove_file_code = "$(this).prev('input#remove_#{options[:id]}').val('true'); $(this).parent().hide().next().show(); return false;";
|
22
|
+
js_dont_remove_file_code = "$(this).parents('div.carrierwave_controls').find('input#remove_#{options[:id]}').val('false'); return false;";
|
23
|
+
else
|
24
|
+
js_remove_file_code = "$(this).previous('input#remove_#{options[:id]}').value='true'; $(this).up().hide().next().show(); return false;";
|
25
|
+
js_dont_remove_file_code = "$(this).up('div.carrierwave_controls').down('input#remove_#{options[:id]}').value='false'; return false;";
|
26
|
+
end
|
27
|
+
|
28
|
+
input = file_field(:record, column.name, options.merge(:onchange => js_dont_remove_file_code))
|
26
29
|
content_tag( :div,
|
27
30
|
content_tag(:div, (
|
28
31
|
get_column_value(@record, column) + " | " +
|
@@ -30,10 +33,11 @@ module ActiveScaffold
|
|
30
33
|
hidden_field(:record, "remove_#{column.name}", remove_field_options) +
|
31
34
|
content_tag(:a, as_(:remove_file), {:href => '#', :onclick => js_remove_file_code})
|
32
35
|
).html_safe
|
33
|
-
) + content_tag(:div, input, :style => "display: none")
|
36
|
+
) + content_tag(:div, input, :style => "display: none"),
|
37
|
+
:class => 'carrierwave_controls'
|
34
38
|
)
|
35
39
|
else
|
36
|
-
|
40
|
+
file_field(:record, column.name, options)
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
@@ -2,7 +2,18 @@ module ActiveScaffold
|
|
2
2
|
module TinyMceBridge
|
3
3
|
module ViewHelpers
|
4
4
|
def active_scaffold_includes(*args)
|
5
|
-
|
5
|
+
if ActiveScaffold.js_framework == :jquery
|
6
|
+
tiny_mce_js = javascript_tag(%|
|
7
|
+
var action_link_close = ActiveScaffold.ActionLink.Abstract.prototype.close;
|
8
|
+
ActiveScaffold.ActionLink.Abstract.prototype.close = function() {
|
9
|
+
$(this.adapter).find('textarea.mceEditor').each(function(index, elem) {
|
10
|
+
tinyMCE.execCommand('mceRemoveControl', false, $(elem).attr('id'));
|
11
|
+
});
|
12
|
+
action_link_close.apply(this);
|
13
|
+
};
|
14
|
+
|) if using_tiny_mce?
|
15
|
+
else
|
16
|
+
tiny_mce_js = javascript_tag(%|
|
6
17
|
var action_link_close = ActiveScaffold.ActionLink.Abstract.prototype.close;
|
7
18
|
ActiveScaffold.ActionLink.Abstract.prototype.close = function() {
|
8
19
|
this.adapter.select('textarea.mceEditor').each(function(elem) {
|
@@ -10,7 +21,8 @@ ActiveScaffold.ActionLink.Abstract.prototype.close = function() {
|
|
10
21
|
});
|
11
22
|
action_link_close.apply(this);
|
12
23
|
};
|
13
|
-
|
24
|
+
|) if using_tiny_mce?
|
25
|
+
end
|
14
26
|
super(*args) + (include_tiny_mce_if_needed || '') + (tiny_mce_js || '')
|
15
27
|
end
|
16
28
|
end
|
@@ -25,7 +37,11 @@ ActiveScaffold.ActionLink.Abstract.prototype.close = function() {
|
|
25
37
|
end
|
26
38
|
|
27
39
|
def onsubmit
|
28
|
-
|
40
|
+
if ActiveScaffold.js_framework == :jquery
|
41
|
+
submit_js = 'tinyMCE.triggerSave();$(\'textarea.mceEditor\').each(function(index, elem) { tinyMCE.execCommand(\'mceRemoveControl\', false, $(elem).attr(\'id\')); });' if using_tiny_mce?
|
42
|
+
else
|
43
|
+
submit_js = 'tinyMCE.triggerSave();this.select(\'textarea.mceEditor\').each(function(elem) { tinyMCE.execCommand(\'mceRemoveControl\', false, elem.id); });' if using_tiny_mce?
|
44
|
+
end
|
29
45
|
[super, submit_js].compact.join ';'
|
30
46
|
end
|
31
47
|
end
|
@@ -16,7 +16,7 @@ module ActiveScaffold::Config
|
|
16
16
|
@core.columns[:marked].form_ui = :checkbox
|
17
17
|
@core.columns[:marked].inplace_edit = true
|
18
18
|
@core.columns[:marked].sort = false
|
19
|
-
@core.list.columns = [:marked] + @core.list.columns.
|
19
|
+
@core.list.columns = [:marked] + @core.list.columns.names_without_auth_check unless @core.list.columns.include? :marked
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -1,5 +1,9 @@
|
|
1
1
|
module ActiveScaffold
|
2
2
|
module Finder
|
3
|
+
def self.like_operator
|
4
|
+
@@like_operator ||= ::ActiveRecord::Base.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE"
|
5
|
+
end
|
6
|
+
|
3
7
|
module ClassMethods
|
4
8
|
# Takes a collection of search terms (the tokens) and creates SQL that
|
5
9
|
# searches all specified ActiveScaffold columns. A row will match if each
|
@@ -13,13 +17,13 @@ module ActiveScaffold
|
|
13
17
|
|
14
18
|
where_clauses = []
|
15
19
|
columns.each do |column|
|
16
|
-
where_clauses << ((column.column.nil? || column.column.text?) ? "
|
20
|
+
where_clauses << ((column.column.nil? || column.column.text?) ? "#{column.search_sql} #{ActiveScaffold::Finder.like_operator} ?" : "#{column.search_sql} = ?")
|
17
21
|
end
|
18
22
|
phrase = "(#{where_clauses.join(' OR ')})"
|
19
23
|
|
20
24
|
sql = ([phrase] * tokens.length).join(' AND ')
|
21
25
|
tokens = tokens.collect do |value|
|
22
|
-
columns.collect {|column| (column.column.nil? || column.column.text?) ? like_pattern.sub('?', value
|
26
|
+
columns.collect {|column| (column.column.nil? || column.column.text?) ? like_pattern.sub('?', value) : column.column.type_cast(value)}
|
23
27
|
end.flatten
|
24
28
|
|
25
29
|
[sql, *tokens]
|
@@ -52,7 +56,7 @@ module ActiveScaffold
|
|
52
56
|
["#{column.search_sql} in (?)", Array(value)]
|
53
57
|
else
|
54
58
|
if column.column.nil? || column.column.text?
|
55
|
-
["
|
59
|
+
["#{column.search_sql} #{ActiveScaffold::Finder.like_operator} ?", like_pattern.sub('?', value)]
|
56
60
|
else
|
57
61
|
["#{column.search_sql} = ?", column.column.type_cast(value)]
|
58
62
|
end
|
@@ -82,7 +86,7 @@ module ActiveScaffold
|
|
82
86
|
def condition_for_range(column, value, like_pattern = nil)
|
83
87
|
if !value.is_a?(Hash)
|
84
88
|
if column.column.nil? || column.column.text?
|
85
|
-
["
|
89
|
+
["#{column.search_sql} #{ActiveScaffold::Finder.like_operator} ?", like_pattern.sub('?', value)]
|
86
90
|
else
|
87
91
|
["#{column.search_sql} = ?", column.column.type_cast(value)]
|
88
92
|
end
|
@@ -275,7 +275,7 @@ module ActiveScaffold
|
|
275
275
|
|
276
276
|
def inplace_edit_control(column)
|
277
277
|
if inplace_edit?(active_scaffold_config.model, column) and inplace_edit_cloning?(column)
|
278
|
-
@record =
|
278
|
+
@record = new_model
|
279
279
|
column = column.clone
|
280
280
|
column.options = column.options.clone
|
281
281
|
column.form_ui = :select if (column.association && column.form_ui.nil?)
|
@@ -121,15 +121,20 @@ module ActiveScaffold
|
|
121
121
|
return values[:opt], values[:from], values[:to]
|
122
122
|
end
|
123
123
|
|
124
|
-
def
|
125
|
-
opt_value, from_value, to_value = field_search_params_range_values(column)
|
126
|
-
|
127
|
-
text_field_size = 10
|
124
|
+
def active_scaffold_search_range_comparator_options(column)
|
128
125
|
select_options = ActiveScaffold::Finder::NumericComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
|
129
126
|
if column.column && column.column.text?
|
130
127
|
select_options.unshift *ActiveScaffold::Finder::StringComparators.collect {|title, comp| [as_(title), comp]}
|
131
|
-
text_field_size = 15
|
132
128
|
end
|
129
|
+
select_options
|
130
|
+
end
|
131
|
+
|
132
|
+
def active_scaffold_search_range(column, options)
|
133
|
+
opt_value, from_value, to_value = field_search_params_range_values(column)
|
134
|
+
|
135
|
+
select_options = active_scaffold_search_range_comparator_options(column)
|
136
|
+
text_field_size = ((column.column && column.column.text?) ? 15 : 10)
|
137
|
+
|
133
138
|
from_value = controller.class.condition_value_for_numeric(column, from_value)
|
134
139
|
to_value = controller.class.condition_value_for_numeric(column, to_value)
|
135
140
|
from_value = format_number_value(from_value, column.options) if from_value.is_a?(Numeric)
|
@@ -7,6 +7,7 @@
|
|
7
7
|
:are_you_sure_to_delete => 'Êtes vous sûr?',
|
8
8
|
:cancel => 'Annuler',
|
9
9
|
:click_to_edit => 'Cliquer pour éditer',
|
10
|
+
:click_to_reset => 'Cliquer pour ré-initialiser',
|
10
11
|
:close => 'Fermer',
|
11
12
|
:config_list => 'Configure',
|
12
13
|
:config_list_model => 'Configure Columns for %{model}',
|
@@ -24,6 +25,7 @@
|
|
24
25
|
:export => 'Exporter',
|
25
26
|
:nested_for_model => '%{nested_model} pour %{parent_model}',
|
26
27
|
:nested_of_model => '%{nested_model} de %{parent_model}',
|
28
|
+
:false => 'Faux',
|
27
29
|
:filtered => '(Filtré)',
|
28
30
|
:found => 'Trouvé',
|
29
31
|
:hide => 'Cacher',
|
@@ -50,6 +52,7 @@
|
|
50
52
|
:show => 'Montrer',
|
51
53
|
:show_model => 'Montrer %{model}',
|
52
54
|
:_to_ => ' à ',
|
55
|
+
:true => 'Vrai',
|
53
56
|
:update => 'Mettre à jour',
|
54
57
|
:update_model => 'Mettre à jour le(/la) %{model}',
|
55
58
|
:updated_model => 'Mis à jour de %{model}',
|
@@ -60,31 +63,34 @@
|
|
60
63
|
:'<' => '<',
|
61
64
|
:'!=' => '!=',
|
62
65
|
:between => 'Entre',
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
72
|
-
:
|
73
|
-
:
|
74
|
-
:
|
75
|
-
:
|
76
|
-
:
|
77
|
-
:
|
78
|
-
:
|
66
|
+
:contains => 'Contient',
|
67
|
+
:begins_with => 'Commençant par',
|
68
|
+
:ends_with => 'Se terminant par',
|
69
|
+
:today => "Aujourd'hui",
|
70
|
+
:yesterday => 'Hier',
|
71
|
+
:tomorrow => 'Demain',
|
72
|
+
:this_week => 'Cette Semaine',
|
73
|
+
:prev_week => 'Semaine dernière',
|
74
|
+
:next_week => 'Semaine prochaine',
|
75
|
+
:this_month => 'Ce Mois',
|
76
|
+
:prev_month => 'Mois dernier',
|
77
|
+
:next_month => 'Mois prochain',
|
78
|
+
:this_year => 'Cette Année',
|
79
|
+
:prev_year => 'Année dernière',
|
80
|
+
:next_year => 'Année prochaine',
|
81
|
+
:past => 'Passé',
|
82
|
+
:future => 'Futur',
|
83
|
+
:range => 'Intervale',
|
84
|
+
:seconds => 'Secondes',
|
79
85
|
:minutes => 'Minutes',
|
80
|
-
:hours => '
|
81
|
-
:days => '
|
82
|
-
:weeks => '
|
83
|
-
:months => '
|
84
|
-
:years => '
|
85
|
-
:optional_attributes => '
|
86
|
-
:null => '
|
87
|
-
:not_null => '
|
86
|
+
:hours => 'Heures',
|
87
|
+
:days => 'Jours',
|
88
|
+
:weeks => 'Semaines',
|
89
|
+
:months => 'Mois',
|
90
|
+
:years => 'Années',
|
91
|
+
:optional_attributes => 'Options additionnelles',
|
92
|
+
:null => 'Nulle',
|
93
|
+
:not_null => 'Non Nulle',
|
88
94
|
:date_picker_options => {
|
89
95
|
:weekHeader => 'Sm',
|
90
96
|
:firstDay => 1,
|
@@ -99,18 +105,18 @@
|
|
99
105
|
:errors => {
|
100
106
|
:template => {
|
101
107
|
:header => {
|
102
|
-
:one => "1
|
103
|
-
:other => "%{count}
|
108
|
+
:one => "1 erreur interdit ce(tte) %{model} d'être sauvegardé.",
|
109
|
+
:other => "%{count} erreurs interdit ce(tte) %{model} d'être sauvegardé"
|
104
110
|
},
|
105
|
-
:body => "
|
111
|
+
:body => "Il y avait des problèmes avec les champs suivants :"
|
106
112
|
}
|
107
113
|
},
|
108
114
|
# error_messages
|
109
|
-
:cant_destroy_record => "%{record}
|
115
|
+
:cant_destroy_record => "%{record} ne peut être supprimé",
|
110
116
|
:internal_error => 'Erreur de la requête (code 500, Erreur interne)',
|
111
117
|
:version_inconsistency => "Version incomplète - Cet enregistrement a été modifié depuis que vous avez commencé à l'éditer.",
|
112
|
-
:record_not_saved => '
|
113
|
-
:no_authorization_for_action => "
|
118
|
+
:record_not_saved => "Impossible d'enregistrer l'enregistrement à cause d'une erreur inconnue",
|
119
|
+
:no_authorization_for_action => "Aucune autorisation pour l'action %{action}"
|
114
120
|
}
|
115
121
|
}
|
116
122
|
}
|
@@ -16,6 +16,7 @@ module Rails
|
|
16
16
|
|
17
17
|
def create_controller_files
|
18
18
|
template 'controller.rb', File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
|
19
|
+
template 'helper.rb', File.join('app/helpers', class_path, "#{controller_file_name}_helper.rb")
|
19
20
|
end
|
20
21
|
|
21
22
|
hook_for :test_framework, :as => :scaffold
|
data/test/misc/finder_test.rb
CHANGED
@@ -33,13 +33,13 @@ class FinderTest < Test::Unit::TestCase
|
|
33
33
|
]
|
34
34
|
|
35
35
|
expected_conditions = [
|
36
|
-
'(
|
36
|
+
'("model_stubs"."a" LIKE ? OR "model_stubs"."b" LIKE ?) AND ("model_stubs"."a" LIKE ? OR "model_stubs"."b" LIKE ?)',
|
37
37
|
'%foo%', '%foo%', '%bar%', '%bar%'
|
38
38
|
]
|
39
39
|
assert_equal expected_conditions, ClassWithFinder.create_conditions_for_columns(tokens, columns)
|
40
40
|
|
41
41
|
expected_conditions = [
|
42
|
-
'(
|
42
|
+
'("model_stubs"."a" LIKE ? OR "model_stubs"."b" LIKE ?)',
|
43
43
|
'%foo%', '%foo%'
|
44
44
|
]
|
45
45
|
assert_equal expected_conditions, ClassWithFinder.create_conditions_for_columns('foo', columns)
|
@@ -662,8 +662,11 @@ padding: 2px;
|
|
662
662
|
}
|
663
663
|
|
664
664
|
.active-scaffold .fieldWithErrors input,
|
665
|
+
.active-scaffold .field_with_errors input,
|
665
666
|
.active-scaffold .fieldWithErrors textarea,
|
666
|
-
.active-scaffold .
|
667
|
+
.active-scaffold .field_with_errors textarea,
|
668
|
+
.active-scaffold .fieldWithErrors select,
|
669
|
+
.active-scaffold .field_with_errors select {
|
667
670
|
border: solid 1px #f00;
|
668
671
|
}
|
669
672
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_scaffold_vho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 3.0.
|
9
|
+
- 14
|
10
|
+
version: 3.0.14
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Many, see README
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-05 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -340,6 +340,7 @@ files:
|
|
340
340
|
- lib/generators/active_scaffold_controller/USAGE
|
341
341
|
- lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb
|
342
342
|
- lib/generators/active_scaffold_controller/templates/controller.rb
|
343
|
+
- lib/generators/active_scaffold_controller/templates/helper.rb
|
343
344
|
- lib/generators/active_scaffold_setup/USAGE
|
344
345
|
- lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb
|
345
346
|
- public/blank.html
|