recordselect 3.6.2 → 3.7.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ac1e9e5a4f739a43f8a4be495630f808787f7b5
|
4
|
+
data.tar.gz: c95307b6061af403a3e4a6996e47043bfbc66f3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a17a0f13b7d5c1708934d1cfd5425b3eeb27e01471befcc4fcb0befc5eba403ad2d5cbb71518e3dbbef5c788804d53f6157da420da94535919314c104ee2cd63
|
7
|
+
data.tar.gz: 4ec482ddf60812a49c5226f8bd9263fbd8bcee453f9991d017297e04e31c99b129d839c538558692867666bc21dc45e429136377600c153b7d39fc558106bfb6
|
@@ -140,9 +140,10 @@ RecordSelect.select_item = function(item) {
|
|
140
140
|
}
|
141
141
|
}
|
142
142
|
|
143
|
-
RecordSelect.observe = function(
|
144
|
-
|
145
|
-
|
143
|
+
RecordSelect.observe = function(form) {
|
144
|
+
if (typeof(form) == 'string') form = '#' + form;
|
145
|
+
form = jQuery(form);
|
146
|
+
var min_length = 0, rs = form.closest('.record-select-container').data('recordselect');
|
146
147
|
if (rs) min_length = rs.min_length;
|
147
148
|
form.find('input.text-input').delayedObserver(function() {
|
148
149
|
if (form.closest('body').length) form.trigger("submit");
|
@@ -206,7 +207,7 @@ RecordSelect.Abstract = Class.extend({
|
|
206
207
|
if (this.is_open()) return;
|
207
208
|
var _this = this;
|
208
209
|
jQuery.rails.fire(_this.obj, 'recordselect:before');
|
209
|
-
_this.
|
210
|
+
_this.create_form();
|
210
211
|
_this.container.show();
|
211
212
|
var params = _this.obj.data('params'), text = _this.obj.val();
|
212
213
|
|
@@ -214,19 +215,17 @@ RecordSelect.Abstract = Class.extend({
|
|
214
215
|
params = params ? [params, search_params].join("&") : search_params;
|
215
216
|
this.current_xhr = jQuery.ajax({
|
216
217
|
url: this.url,
|
217
|
-
//type: "POST",
|
218
218
|
data: params,
|
219
|
-
|
220
|
-
|
219
|
+
success: function(data, status, xhr) {
|
220
|
+
if (_this.current_xhr != xhr) return;
|
221
221
|
if (status != 'abort') _this.current_xhr = null;
|
222
222
|
_this.container.html(data);
|
223
223
|
if (!_this.container.is(':visible')) _this.close();
|
224
224
|
else {
|
225
225
|
_this.container.find('.text-input').val(_this.obj.val());
|
226
|
-
RecordSelect.observe(_this.container.find('form')
|
226
|
+
RecordSelect.observe(_this.container.find('form'));
|
227
227
|
_this.container.hide(); // needed to get right document height to position first time
|
228
228
|
if (text.length >= _this.min_length) _this.show();
|
229
|
-
jQuery(document.body).mousedown(jQuery.proxy(_this, "onbodyclick"));
|
230
229
|
}
|
231
230
|
}
|
232
231
|
});
|
@@ -292,7 +291,7 @@ RecordSelect.Abstract = Class.extend({
|
|
292
291
|
* returns true/false for whether the recordselect is open
|
293
292
|
*/
|
294
293
|
is_open: function() {
|
295
|
-
|
294
|
+
return jQuery.trim(this.container.html()).length != 0;
|
296
295
|
},
|
297
296
|
|
298
297
|
/**
|
@@ -322,11 +321,23 @@ RecordSelect.Abstract = Class.extend({
|
|
322
321
|
}
|
323
322
|
});
|
324
323
|
jQuery(document.body).append(e);
|
324
|
+
jQuery(document.body).mousedown(jQuery.proxy(this, "onbodyclick"));
|
325
325
|
if (!rs.fixed && e.offsetParent().css('position') == 'static') rs.body_static = true;
|
326
326
|
e.get(0).onselect = jQuery.proxy(this, "onselect")
|
327
327
|
return e;
|
328
328
|
},
|
329
329
|
|
330
|
+
create_form: function() {
|
331
|
+
var div = jQuery('<div>').addClass('record-select').attr('id', this.options.id);
|
332
|
+
var form = jQuery('<form>').attr('action', this.url).attr('data-remote', true).attr('method', 'get');
|
333
|
+
form.append(jQuery('<input type="text" name="search" class="text-input">'));
|
334
|
+
form.append(jQuery('<input type="hidden" name="page" value="1">'));
|
335
|
+
form.append(jQuery('<input type="hidden" name="update" value="1">'));
|
336
|
+
div.append(form).append(jQuery('<ol>'));
|
337
|
+
this.container.html(div);
|
338
|
+
RecordSelect.observe(form);
|
339
|
+
},
|
340
|
+
|
330
341
|
onkeyup: function(event) {
|
331
342
|
if (!this.is_open()) return;
|
332
343
|
this.container.find('.text-input').val(this.obj.val()).trigger(event);
|
@@ -19,7 +19,7 @@ module RecordSelectHelper
|
|
19
19
|
options[:html][:id] ||= "rs_#{rand(9999)}"
|
20
20
|
|
21
21
|
assert_controller_responds(options[:params][:controller])
|
22
|
-
record_select_options = {:onselect
|
22
|
+
record_select_options = {id: record_select_id(controller.controller_path), onselect: options[:onselect] || ''}
|
23
23
|
record_select_options.merge! options[:rs] if options[:rs]
|
24
24
|
|
25
25
|
html = link_to(name, '#', options[:html])
|
@@ -49,7 +49,7 @@ module RecordSelectHelper
|
|
49
49
|
|
50
50
|
controller = assert_controller_responds(options.delete(:controller))
|
51
51
|
params = options.delete(:params)
|
52
|
-
record_select_options = {}
|
52
|
+
record_select_options = {id: record_select_id(controller.controller_path)}
|
53
53
|
record_select_options[:field_name] = options.delete(:field_name) if options[:field_name]
|
54
54
|
if current and not current.new_record?
|
55
55
|
record_select_options[:id] = current.id
|
@@ -84,7 +84,7 @@ module RecordSelectHelper
|
|
84
84
|
|
85
85
|
controller = assert_controller_responds(options.delete(:controller))
|
86
86
|
params = options.delete(:params)
|
87
|
-
record_select_options = {:label
|
87
|
+
record_select_options = {id: record_select_id(controller.controller_path), label: options.delete(:label)}
|
88
88
|
if current
|
89
89
|
record_select_options[:label] ||= label_for_field(current, controller)
|
90
90
|
end
|
@@ -118,7 +118,7 @@ module RecordSelectHelper
|
|
118
118
|
|
119
119
|
controller = assert_controller_responds(options.delete(:controller))
|
120
120
|
params = options.delete(:params)
|
121
|
-
record_select_options = {}
|
121
|
+
record_select_options = {id: record_select_id(controller.controller_path)}
|
122
122
|
record_select_options[:current] = current.inject([]) { |memo, record| memo.push({:id => record.id, :label => label_for_field(record, controller)}) }
|
123
123
|
record_select_options.merge! options[:rs] if options[:rs]
|
124
124
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recordselect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Cambra
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-06-
|
13
|
+
date: 2017-06-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|