active_scaffold_vho 3.2.8 → 3.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/jquery/active_scaffold.js +62 -39
- data/lib/active_scaffold/attribute_params.rb +1 -1
- data/lib/active_scaffold/data_structures/action_columns.rb +7 -2
- data/lib/active_scaffold/data_structures/column.rb +5 -1
- data/lib/active_scaffold/data_structures/set.rb +11 -1
- data/lib/active_scaffold/helpers/form_column_helpers.rb +7 -0
- data/lib/active_scaffold/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmNjMTRjZWFkYWM5ZWJjZDU1NGJkZGI0MWM0ZDZjNDQ3OTZmMzQ5Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDE2MGFlYmRmNWQ3ZmE1N2EwYjMwNTU2ZTc1YTlmMDVjY2E3MDIzNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDI2ODUyN2U4NTY0ZTFkYWYxZGMyZDcyMzIwNWE2N2E0ZGUyZmI5ZjdmZTJi
|
10
|
+
ODFmY2JmOTFjMmM2YmMzODU0ZDZmYzcwNzBlOTM5OGJiMTk5NjM0OTk5ZmYz
|
11
|
+
MzQ3NzNlZGZiMWM5MDBlMDMzYTQyODdmMGNjY2VmNmMxN2JmYTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTJiMTcwMTRlYzNlMDk2OWFhODFhM2RhNDhiOTY5MjMxYWJmMTEwZGY2M2Nl
|
14
|
+
NjM2YjNmZDNkYzhmMzJkZDNjMjg2N2JmYmQ2YTUxM2U4Mzc2ODY4NTIwYWEz
|
15
|
+
NGNhYjYzOTIwOTRlZjMyNzk5NzdhZjIxZGVhNGJkNDYyOTc1YTQ=
|
data/Gemfile.lock
CHANGED
@@ -201,44 +201,22 @@ $(document).ready(function() {
|
|
201
201
|
return false;
|
202
202
|
});
|
203
203
|
|
204
|
-
$(document).on('change', 'input.update_form, textarea.update_form, select.update_form', function(event) {
|
205
|
-
|
206
|
-
|
207
|
-
var params = null;
|
208
|
-
|
209
|
-
if (element.attr('data-update_send_form')) {
|
210
|
-
params = as_form.serialize();
|
211
|
-
params += '&' + $.param({source_id: element.attr('id')});
|
212
|
-
} else {
|
213
|
-
if (element.is("input:checkbox")) {
|
214
|
-
params = {value: element.is(":checked")};
|
215
|
-
} else {
|
216
|
-
params = {value: element.val()};
|
217
|
-
}
|
218
|
-
params.source_id = element.attr('id');
|
219
|
-
}
|
204
|
+
$(document).on('change', 'input.update_form:not(.recordselect), input.update_form, textarea.update_form, select.update_form', function(event) {
|
205
|
+
var form_element = $(this);
|
206
|
+
var value, additional_params;
|
220
207
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
ActiveScaffold.enable_form(as_form)
|
234
|
-
},
|
235
|
-
error: function (xhr, status, error) {
|
236
|
-
var as_div = element.closest("div.active-scaffold");
|
237
|
-
if (as_div) {
|
238
|
-
ActiveScaffold.report_500_response(as_div)
|
239
|
-
}
|
240
|
-
}
|
241
|
-
});
|
208
|
+
if (form_element.is("input:checkbox")) {
|
209
|
+
value = form_element.is(":checked");
|
210
|
+
} else {
|
211
|
+
value = form_element.val();
|
212
|
+
}
|
213
|
+
ActiveScaffold.update_column(form_element, form_element.data('update_url'), form_element.data('update_send_form'), form_element.attr('id'), value, additional_params);
|
214
|
+
return true;
|
215
|
+
});
|
216
|
+
|
217
|
+
jQuery(document).on('recordselect:change', 'input.recordselect.update_form', function(event, id, label) {
|
218
|
+
var element = jQuery(this);
|
219
|
+
ActiveScaffold.update_column(element, element.data('update_url'), element.data('update_send_form'), element.attr('id'), id);
|
242
220
|
return true;
|
243
221
|
});
|
244
222
|
|
@@ -548,6 +526,46 @@ var ActiveScaffold = {
|
|
548
526
|
if (even_row === true) replaced.addClass('even-record');
|
549
527
|
ActiveScaffold.highlight(replaced);
|
550
528
|
},
|
529
|
+
|
530
|
+
update_column: function(element, url, send_form, source_id, val, additional_params) {
|
531
|
+
if (!element) element = jQuery('#' + source_id);
|
532
|
+
var as_form = element.closest('form.as_form');
|
533
|
+
var params = null;
|
534
|
+
|
535
|
+
if (element.attr('data-update_send_form')) {
|
536
|
+
params = as_form.serialize();
|
537
|
+
params += '&' + $.param({source_id: source_id});
|
538
|
+
} else {
|
539
|
+
if (element.is("input:checkbox")) {
|
540
|
+
params = {value: element.is(":checked")};
|
541
|
+
} else {
|
542
|
+
params = {value: val};
|
543
|
+
}
|
544
|
+
params.source_id = source_id;
|
545
|
+
}
|
546
|
+
|
547
|
+
$.ajax({
|
548
|
+
url: url,
|
549
|
+
data: params,
|
550
|
+
beforeSend: function(xhr, settings) {
|
551
|
+
element.nextAll('img.loading-indicator').css('visibility','visible');
|
552
|
+
ActiveScaffold.disable_form(as_form);
|
553
|
+
if (settings.dataType === undefined || settings.dataType === 'text') {
|
554
|
+
xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
|
555
|
+
}
|
556
|
+
},
|
557
|
+
complete: function(xhr, status) {
|
558
|
+
element.nextAll('img.loading-indicator').css('visibility','hidden');
|
559
|
+
ActiveScaffold.enable_form(as_form)
|
560
|
+
},
|
561
|
+
error: function (xhr, status, error) {
|
562
|
+
var as_div = element.closest("div.active-scaffold");
|
563
|
+
if (as_div) {
|
564
|
+
ActiveScaffold.report_500_response(as_div)
|
565
|
+
}
|
566
|
+
}
|
567
|
+
});
|
568
|
+
},
|
551
569
|
|
552
570
|
replace: function(element, html, disable_event_trigger) {
|
553
571
|
if (typeof(element) == 'string') element = '#' + element;
|
@@ -767,10 +785,15 @@ var ActiveScaffold = {
|
|
767
785
|
if (typeof(source) == 'string') source = '#' + source;
|
768
786
|
var source = $(source);
|
769
787
|
var element = source.closest('.association-record');
|
788
|
+
|
789
|
+
var element = source.closest('.sub-form-record'), selector = '';
|
770
790
|
if (element.length == 0) {
|
771
|
-
element = source.closest('ol.form');
|
791
|
+
element = source.closest('form > ol.form');
|
792
|
+
selector = 'li';
|
772
793
|
}
|
773
|
-
|
794
|
+
// find without entering new subforms
|
795
|
+
selector = options.is_subform ? '' : selector + ':not(.sub-form) ';
|
796
|
+
element = element.find(selector + '.' + options.field_class).first();
|
774
797
|
|
775
798
|
if (element) {
|
776
799
|
if (options.is_subform == false) {
|
@@ -125,7 +125,7 @@ module ActiveScaffold
|
|
125
125
|
def column_value_from_param_simple_value(parent_record, column, value)
|
126
126
|
if column.singular_association?
|
127
127
|
# it's a single id
|
128
|
-
column.association.klass.
|
128
|
+
column.association.klass.where(:id=> value).first if value and not value.empty?
|
129
129
|
elsif column.plural_association?
|
130
130
|
column_plural_assocation_value_from_value(column, value)
|
131
131
|
elsif column.column && column.column.number? && [:i18n_number, :currency].include?(column.options[:format])
|
@@ -19,13 +19,18 @@ module ActiveScaffold::DataStructures
|
|
19
19
|
attr_accessor :collapsed
|
20
20
|
|
21
21
|
# nests a subgroup in the column set
|
22
|
-
def add_subgroup(label, &proc)
|
22
|
+
def add_subgroup(label, insert_index = nil, &proc)
|
23
23
|
columns = ActiveScaffold::DataStructures::ActionColumns.new
|
24
24
|
columns.label = label
|
25
25
|
columns.action = self.action
|
26
26
|
columns.configure &proc
|
27
27
|
self.exclude columns.collect_columns
|
28
|
-
|
28
|
+
if insert_index.nil?
|
29
|
+
self.add columns
|
30
|
+
else
|
31
|
+
self.add columns, insert_index
|
32
|
+
end
|
33
|
+
|
29
34
|
end
|
30
35
|
|
31
36
|
def include?(item)
|
@@ -306,7 +306,11 @@ module ActiveScaffold::DataStructures
|
|
306
306
|
|
307
307
|
# default all the configurable variables
|
308
308
|
self.css_class = ''
|
309
|
-
self.required = active_record_class.validators_on(self.name).
|
309
|
+
self.required = active_record_class.validators_on(self.name).any? do |val|
|
310
|
+
!val.options[:if] && !val.options[:unless] && (ActiveModel::Validations::PresenceValidator === val ||
|
311
|
+
(ActiveModel::Validations::InclusionValidator === val && !val.options[:allow_nil] && !val.options[:allow_blank] && !(@form_ui == :checkbox && [[true, false], [false, true]].include?(val.send(:delimiter))))
|
312
|
+
)
|
313
|
+
end
|
310
314
|
self.sort = true
|
311
315
|
self.search_sql = true
|
312
316
|
|
@@ -16,9 +16,19 @@ module ActiveScaffold::DataStructures
|
|
16
16
|
# the way to add items to the set.
|
17
17
|
def add(*args)
|
18
18
|
args.flatten! # allow [] as a param
|
19
|
+
|
20
|
+
index = args.pop if args.last().is_a? Numeric
|
21
|
+
|
19
22
|
args.each { |arg|
|
20
23
|
arg = arg.to_sym if arg.is_a? String
|
21
|
-
|
24
|
+
unless @set.include? arg # avoid duplicates
|
25
|
+
if index.nil?
|
26
|
+
@set << arg
|
27
|
+
else
|
28
|
+
@set.insert(index,arg)
|
29
|
+
index += 1
|
30
|
+
end
|
31
|
+
end
|
22
32
|
}
|
23
33
|
end
|
24
34
|
alias_method :<<, :add
|
@@ -196,6 +196,13 @@ module ActiveScaffold
|
|
196
196
|
record_select_options = {:controller => remote_controller, :id => options[:id]}
|
197
197
|
record_select_options.merge!(active_scaffold_input_text_options)
|
198
198
|
record_select_options.merge!(column.options)
|
199
|
+
record_select_options[:size] ||= ActionView::Helpers::InstanceTag::DEFAULT_FIELD_OPTIONS["size"]
|
200
|
+
|
201
|
+
unless options['data-update_url'].nil?
|
202
|
+
record_select_options['data-update_url'] = options['data-update_url']
|
203
|
+
record_select_options['data-update_send_form'] = options['data-update_send_form']
|
204
|
+
record_select_options[:class] = "#{record_select_options[:class]} #{options[:class]}".strip
|
205
|
+
end
|
199
206
|
|
200
207
|
if multiple
|
201
208
|
record_multi_select_field(options[:name], value || [], record_select_options)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_scaffold_vho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Many, see README
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|