active_scaffold_vho 3.0.11 → 3.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/active_scaffold_vho.gemspec +2 -2
- data/frontends/default/javascripts/jquery/active_scaffold.js +30 -14
- data/frontends/default/javascripts/prototype/active_scaffold.js +23 -7
- data/frontends/default/views/_horizontal_subform_record.html.erb +1 -1
- data/frontends/default/views/_render_field.js.rjs +2 -5
- data/frontends/default/views/_vertical_subform_record.html.erb +1 -1
- data/lib/active_scaffold/actions/core.rb +2 -1
- data/lib/active_scaffold/bridges/date_picker/bridge.rb +4 -2
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +13 -9
- data/lib/active_scaffold/finder.rb +4 -1
- data/lib/active_scaffold/version.rb +1 -1
- metadata +4 -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.12"
|
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-02-
|
12
|
+
s.date = %q{2011-02-11}
|
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 = [
|
@@ -214,16 +214,15 @@ $(document).ready(function() {
|
|
214
214
|
var as_form = element.closest('form.as_form');
|
215
215
|
$.ajax({
|
216
216
|
url: element.attr('data-update_url'),
|
217
|
-
data: {value: element.val()
|
217
|
+
data: {value: element.val(),
|
218
|
+
source_id: element.attr('id')},
|
218
219
|
beforeSend: function(event) {
|
219
220
|
element.nextAll('img.loading-indicator').css('visibility','visible');
|
220
|
-
|
221
|
-
$("input:enabled,select:enabled", as_form).attr('disabled', 'disabled');
|
221
|
+
ActiveScaffold.disable_form(as_form)
|
222
222
|
},
|
223
223
|
complete: function(event) {
|
224
224
|
element.nextAll('img.loading-indicator').css('visibility','hidden');
|
225
|
-
|
226
|
-
$("input:disabled,select:disabled", as_form).attr('disabled', '');
|
225
|
+
ActiveScaffold.enable_form(as_form)
|
227
226
|
},
|
228
227
|
error: function (xhr, status, error) {
|
229
228
|
var as_div = element.closest("div.active-scaffold");
|
@@ -504,7 +503,7 @@ var ActiveScaffold = {
|
|
504
503
|
var loading_indicator = $('#' + as_form.attr('id').replace(/-form$/, '-loading-indicator'));
|
505
504
|
if (loading_indicator) loading_indicator.css('visibility','visible');
|
506
505
|
$('input[type=submit]', as_form).attr('disabled', 'disabled');
|
507
|
-
$("input:enabled,select:enabled", as_form).attr('disabled', 'disabled');
|
506
|
+
$("input:enabled,select:enabled,textarea:enabled", as_form).attr('disabled', 'disabled');
|
508
507
|
},
|
509
508
|
|
510
509
|
enable_form: function(as_form) {
|
@@ -513,7 +512,7 @@ var ActiveScaffold = {
|
|
513
512
|
var loading_indicator = $('#' + as_form.attr('id').replace(/-form$/, '-loading-indicator'));
|
514
513
|
if (loading_indicator) loading_indicator.css('visibility','hidden');
|
515
514
|
$('input[type=submit]', as_form).attr('disabled', '');
|
516
|
-
$("input:disabled,select:disabled", as_form).attr('disabled', '');
|
515
|
+
$("input:disabled,select:disabled,textarea:disabled", as_form).attr('disabled', '');
|
517
516
|
},
|
518
517
|
|
519
518
|
focus_first_element_of_form: function(form_element) {
|
@@ -562,6 +561,15 @@ var ActiveScaffold = {
|
|
562
561
|
this.reload_if_empty(tbody, page_reload_url);
|
563
562
|
},
|
564
563
|
|
564
|
+
delete_subform_record: function(record) {
|
565
|
+
if (typeof(record) == 'string') record = '#' + record;
|
566
|
+
var errors = $(record).prev();
|
567
|
+
if (errors.hasClass('association-record-errors')) {
|
568
|
+
this.replace_html(errors, '');
|
569
|
+
}
|
570
|
+
this.remove(record);
|
571
|
+
},
|
572
|
+
|
565
573
|
report_500_response: function(active_scaffold_id) {
|
566
574
|
server_error = $(active_scaffold_id).find('td.messages-container p.server-error');
|
567
575
|
if (!$(server_error).is(':visible')) {
|
@@ -653,13 +661,21 @@ var ActiveScaffold = {
|
|
653
661
|
}
|
654
662
|
},
|
655
663
|
|
656
|
-
render_form_field: function(
|
657
|
-
if (typeof(
|
658
|
-
var
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
664
|
+
render_form_field: function(source, content, options) {
|
665
|
+
if (typeof(source) == 'string') source = '#' + source;
|
666
|
+
var source = $(source);
|
667
|
+
var element = source.closest('.association-record');
|
668
|
+
if (element.length == 0) {
|
669
|
+
element = source.closest('ol.form');
|
670
|
+
}
|
671
|
+
element = element.find('.' + options.field_class);
|
672
|
+
|
673
|
+
if (element) {
|
674
|
+
if (options.is_subform == false) {
|
675
|
+
this.replace(element.closest('dl'), content);
|
676
|
+
} else {
|
677
|
+
this.replace_html(element, content);
|
678
|
+
}
|
663
679
|
}
|
664
680
|
},
|
665
681
|
|
@@ -238,7 +238,7 @@ document.observe("dom:loaded", function() {
|
|
238
238
|
|
239
239
|
new Ajax.Request(element.readAttribute('data-update_url'), {
|
240
240
|
method: 'get',
|
241
|
-
parameters: {value: element.getValue()},
|
241
|
+
parameters: {value: element.getValue(), source_id: element.readAttribute('id')},
|
242
242
|
onLoading: function(response) {
|
243
243
|
element.next('img.loading-indicator').style.visibility = 'visible';
|
244
244
|
as_form.disable();
|
@@ -451,6 +451,14 @@ var ActiveScaffold = {
|
|
451
451
|
this.reload_if_empty(tbody, page_reload_url);
|
452
452
|
},
|
453
453
|
|
454
|
+
delete_subform_record: function(record) {
|
455
|
+
var errors = $(record).previous();
|
456
|
+
if (errors.hasClassName('association-record-errors')) {
|
457
|
+
this.replace_html(errors, '');
|
458
|
+
}
|
459
|
+
this.remove(record);
|
460
|
+
},
|
461
|
+
|
454
462
|
report_500_response: function(active_scaffold_id) {
|
455
463
|
server_error = $(active_scaffold_id).down('td.messages-container p.server-error');
|
456
464
|
if (server_error.visible()) {
|
@@ -533,12 +541,20 @@ var ActiveScaffold = {
|
|
533
541
|
}
|
534
542
|
},
|
535
543
|
|
536
|
-
render_form_field: function(
|
537
|
-
var
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
544
|
+
render_form_field: function(source, content, options) {
|
545
|
+
var source = $(source);
|
546
|
+
var element = source.up('.association-record');
|
547
|
+
if (typeof(element) === 'undefined') {
|
548
|
+
element = source.up('ol.form');
|
549
|
+
}
|
550
|
+
element = element.down('.' + options.field_class);
|
551
|
+
|
552
|
+
if (element) {
|
553
|
+
if (options.is_subform == false) {
|
554
|
+
this.replace(element.up('dl'), content);
|
555
|
+
} else {
|
556
|
+
this.replace_html(element, content);
|
557
|
+
}
|
542
558
|
}
|
543
559
|
},
|
544
560
|
|
@@ -26,7 +26,7 @@
|
|
26
26
|
<td class="actions">
|
27
27
|
<% if record_column.plural_association? and (@record.authorized_for?(:crud_type => :delete) or not [:destroy, :delete_all].include?(record_column.association.options[:dependent])) %>
|
28
28
|
<% destroy_id = "#{options[:id]}-destroy" %>
|
29
|
-
<%= link_to as_(:remove), '#', :class => 'destroy', :id => destroy_id , :onclick => "ActiveScaffold.
|
29
|
+
<%= link_to as_(:remove), '#', :class => 'destroy', :id => destroy_id , :onclick => "ActiveScaffold.delete_subform_record(\"#{tr_id}\"); return false;", :style=> "display: none;" %>
|
30
30
|
<%= javascript_tag("ActiveScaffold.show('#{destroy_id}');") if !locked %>
|
31
31
|
<% end %>
|
32
32
|
<% unless @record.new_record? %>
|
@@ -1,12 +1,9 @@
|
|
1
1
|
column = active_scaffold_config.columns[render_field.to_sym]
|
2
|
-
options = {:is_subform => false}
|
2
|
+
options = {:is_subform => false, :field_class => "#{column.name}-input"}
|
3
3
|
if column_renders_as(column) == :subform
|
4
4
|
options[:is_subform] = true
|
5
|
-
field_id = sub_form_id(:association => column.name)
|
6
|
-
else
|
7
|
-
field_id = active_scaffold_input_options(column, params[:scope])[:id]
|
8
5
|
end
|
9
|
-
page.call 'ActiveScaffold.render_form_field',
|
6
|
+
page.call 'ActiveScaffold.render_form_field', source_id, render(:partial => form_partial_for_column(column), :locals => { :column => column, :scope => params[:scope] }), options
|
10
7
|
render(:partial => "render_field", :collection => column.update_columns) if column.update_columns && !column.update_columns.empty?
|
11
8
|
|
12
9
|
|
@@ -27,7 +27,7 @@
|
|
27
27
|
<li class="actions">
|
28
28
|
<% if record_column.plural_association? and (@record.authorized_for?(:crud_type => :delete) or not [:destroy, :delete_all].include?(record_column.association.options[:dependent])) %>
|
29
29
|
<% destroy_id = "#{options[:id]}-destroy" %>
|
30
|
-
<%= link_to as_(:remove), '#', :class => 'destroy', :id => destroy_id , :onclick => "ActiveScaffold.
|
30
|
+
<%= link_to as_(:remove), '#', :class => 'destroy', :id => destroy_id , :onclick => "ActiveScaffold.delete_subform_record(\"#{tr_id}\"); return false;", :style=> "display: none;" %>
|
31
31
|
<%= javascript_tag("ActiveScaffold.show('#{destroy_id}');") if !locked %>
|
32
32
|
<% end %>
|
33
33
|
<% unless @record.new_record? %>
|
@@ -34,7 +34,8 @@ module ActiveScaffold::Actions
|
|
34
34
|
value = column_value_from_param_value(@record, column, params[:value])
|
35
35
|
@record.send "#{column.name}=", value
|
36
36
|
after_render_field(@record, column)
|
37
|
-
|
37
|
+
source_id = params.delete(:source_id)
|
38
|
+
render :partial => "render_field", :collection => Array(params[:update_columns]), :content_type => 'text/javascript', :locals => {:source_id => source_id}
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
@@ -8,8 +8,10 @@ ActiveScaffold::Bridges.bridge "DatePicker" do
|
|
8
8
|
|
9
9
|
if ActiveScaffold.js_framework == :jquery
|
10
10
|
require File.join(directory, "lib/datepicker_bridge.rb")
|
11
|
-
|
12
|
-
|
11
|
+
unless defined?(ACTIVE_SCAFFOLD_INSTALL_ASSETS) && ACTIVE_SCAFFOLD_INSTALL_ASSETS == false
|
12
|
+
FileUtils.cp(source, destination)
|
13
|
+
ActiveScaffold::Bridges::DatePickerBridge.localization(File.join(destination, 'date_picker_bridge.js'))
|
14
|
+
end
|
13
15
|
else
|
14
16
|
# make sure that jquery files are removed
|
15
17
|
FileUtils.rm(File.join(destination, 'date_picker_bridge.js')) if File.exist?(File.join(destination, 'date_picker_bridge.js'))
|
@@ -43,7 +43,7 @@ module ActiveScaffold
|
|
43
43
|
def active_scaffold_date_bridge_trend_tag(column, options, trend_options)
|
44
44
|
trend_controls = text_field_tag("#{trend_options[:name_prefix]}[#{column.name}][number]", trend_options[:number_value], :class => 'text-input', :size => 10, :autocomplete => 'off') << " " <<
|
45
45
|
select_tag("#{trend_options[:name_prefix]}[#{column.name}][unit]",
|
46
|
-
options_for_select(active_scaffold_search_date_bridge_trend_units(column), trend_options[:
|
46
|
+
options_for_select(active_scaffold_search_date_bridge_trend_units(column), trend_options[:unit_value]),
|
47
47
|
:class => 'text-input')
|
48
48
|
content_tag("span", trend_controls.html_safe, :id => "#{options[:id]}_trend", :style => "display:#{trend_options[:show] ? '' : 'none'}")
|
49
49
|
end
|
@@ -108,12 +108,16 @@ module ActiveScaffold
|
|
108
108
|
['from', 'to'].collect { |field| condition_value_for_datetime(value[field], conversion)}
|
109
109
|
end
|
110
110
|
end
|
111
|
+
|
112
|
+
def date_bridge_now
|
113
|
+
Time.zone.now
|
114
|
+
end
|
111
115
|
|
112
116
|
def date_bridge_from_to_for_trend(column, value)
|
113
117
|
case value['opt']
|
114
118
|
when "PAST"
|
115
119
|
trend_number = [value['number'].to_i, 1].max
|
116
|
-
now =
|
120
|
+
now = date_bridge_now
|
117
121
|
if date_bridge_column_date?(column)
|
118
122
|
from = now.beginning_of_day.ago((trend_number).send(value['unit'].downcase.singularize.to_sym))
|
119
123
|
to = now.end_of_day
|
@@ -124,7 +128,7 @@ module ActiveScaffold
|
|
124
128
|
return from, to
|
125
129
|
when "FUTURE"
|
126
130
|
trend_number = [value['number'].to_i, 1].max
|
127
|
-
now =
|
131
|
+
now = date_bridge_now
|
128
132
|
if date_bridge_column_date?(column)
|
129
133
|
from = now.beginning_of_day
|
130
134
|
to = now.end_of_day.in((trend_number).send(value['unit'].downcase.singularize.to_sym))
|
@@ -139,21 +143,21 @@ module ActiveScaffold
|
|
139
143
|
def date_bridge_from_to_for_range(column, value)
|
140
144
|
case value[:range]
|
141
145
|
when 'TODAY'
|
142
|
-
return
|
146
|
+
return date_bridge_now.beginning_of_day, date_bridge_now.end_of_day
|
143
147
|
when 'YESTERDAY'
|
144
|
-
return
|
148
|
+
return date_bridge_now.ago(1.day).beginning_of_day, date_bridge_now.ago(1.day).end_of_day
|
145
149
|
when 'TOMMORROW'
|
146
|
-
return
|
150
|
+
return date_bridge_now.in(1.day).beginning_of_day, date_bridge_now.in(1.day).end_of_day
|
147
151
|
else
|
148
152
|
range_type, range = value[:range].downcase.split('_')
|
149
153
|
raise ArgumentError unless ['week', 'month', 'year'].include?(range)
|
150
154
|
case range_type
|
151
155
|
when 'this'
|
152
|
-
return
|
156
|
+
return date_bridge_now.send("beginning_of_#{range}".to_sym), date_bridge_now.send("end_of_#{range}")
|
153
157
|
when 'prev'
|
154
|
-
return
|
158
|
+
return date_bridge_now.ago(1.send(range.to_sym)).send("beginning_of_#{range}".to_sym), date_bridge_now.ago(1.send(range.to_sym)).send("end_of_#{range}".to_sym)
|
155
159
|
when 'next'
|
156
|
-
return
|
160
|
+
return date_bridge_now.in(1.send(range.to_sym)).send("beginning_of_#{range}".to_sym), date_bridge_now.in(1.send(range.to_sym)).send("end_of_#{range}".to_sym)
|
157
161
|
else
|
158
162
|
return nil, nil
|
159
163
|
end
|
@@ -292,7 +292,10 @@ module ActiveScaffold
|
|
292
292
|
def append_to_query(query, options)
|
293
293
|
options.assert_valid_keys :where, :select, :group, :order, :limit, :offset, :joins, :includes, :lock, :readonly, :from
|
294
294
|
options.reject{|k, v| v.blank?}.inject(query) do |query, (k, v)|
|
295
|
-
|
295
|
+
# default ordering of model has a higher priority than current queries ordering
|
296
|
+
# fix this by removing existing ordering from arel
|
297
|
+
# will not work if order part is first one which is iterated
|
298
|
+
query = query.except(:order) if k.to_sym == :order && query.is_a?(ActiveRecord::Relation)
|
296
299
|
query.send((k.to_sym), v)
|
297
300
|
end
|
298
301
|
end
|
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: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 3.0.
|
9
|
+
- 12
|
10
|
+
version: 3.0.12
|
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-02-
|
18
|
+
date: 2011-02-11 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|