recordselect 3.3.6 → 3.3.7
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/stylesheets/record_select.css.erb +5 -0
- data/app/views/record_select/_list.html.erb +3 -3
- data/lib/record_select/actions.rb +7 -3
- data/lib/record_select/conditions.rb +0 -1
- data/lib/record_select/config.rb +5 -7
- data/lib/record_select/helpers/record_select_helper.rb +2 -25
- data/lib/record_select/version.rb +1 -1
- metadata +47 -17
- checksums.yaml +0 -7
- data/CHANGELOG +0 -25
@@ -5,7 +5,7 @@ pagination_url_params = params.merge(:controller => controller, :action => :brow
|
|
5
5
|
prev_url = url_for(pagination_url_params.merge(:page => page.prev.number)) if page.prev?
|
6
6
|
next_url = url_for(pagination_url_params.merge(:page => page.next.number)) if page.next?
|
7
7
|
-%>
|
8
|
-
|
8
|
+
<%= content_tag :ol, :class => ('scrollable' unless record_select_config.pagination?) do %>
|
9
9
|
<li class="found"><%= rs_(:records_found, :count => page.pager.count,
|
10
10
|
:model => record_select_config.model.model_name.human(:count => page.pager.count).downcase) %></li>
|
11
11
|
<% if page.prev? -%>
|
@@ -21,11 +21,11 @@ next_url = url_for(pagination_url_params.merge(:page => page.next.number)) if pa
|
|
21
21
|
<%= render_record_from_config(record) %>
|
22
22
|
</li>
|
23
23
|
<% end -%>
|
24
|
-
<% if page.next? -%>
|
24
|
+
<% if record_select_config.pagination? && page.next? -%>
|
25
25
|
<li class="pagination next">
|
26
26
|
<%= link_to (rs_(:next_items, :count => page.pager.per_page) + " " + image_tag('record_select/next.gif', :alt => rs_(:next))).html_safe,
|
27
27
|
{:url => next_url},
|
28
28
|
{:href => next_url, :method => :get, :remote => true} %>
|
29
29
|
</li>
|
30
30
|
<% end -%>
|
31
|
-
|
31
|
+
<% end %>
|
@@ -4,11 +4,15 @@ module RecordSelect
|
|
4
4
|
# params => [:page, :search]
|
5
5
|
def browse
|
6
6
|
conditions = record_select_conditions
|
7
|
-
|
8
|
-
|
7
|
+
user_includes = record_select_includes
|
8
|
+
klass = record_select_model.where(conditions).includes(user_includes)
|
9
|
+
klass = klass.references(user_includes) if Rails::VERSION::MAJOR >= 4 && user_includes.present?
|
10
|
+
@count = klass.count if record_select_config.pagination?
|
9
11
|
@count = @count.length if @count.is_a? ActiveSupport::OrderedHash
|
10
12
|
pager = ::Paginator.new(@count, record_select_config.per_page) do |offset, per_page|
|
11
|
-
klass.select(record_select_select)
|
13
|
+
search = record_select_select ? klass.select(record_select_select) : klass
|
14
|
+
search = search.limit(per_page).offset(offset) if record_select_config.pagination?
|
15
|
+
search.includes(record_select_config.include).order(record_select_config.order_by).to_a
|
12
16
|
end
|
13
17
|
@page = pager.page(params[:page] || 1)
|
14
18
|
|
data/lib/record_select/config.rb
CHANGED
@@ -3,20 +3,14 @@ module RecordSelect
|
|
3
3
|
class Config
|
4
4
|
def initialize(klass, options = {})
|
5
5
|
@klass = klass
|
6
|
-
|
7
6
|
@notify = block_given? ? proc : options[:notify]
|
8
|
-
|
9
7
|
@per_page = options[:per_page]
|
10
|
-
|
11
8
|
@search_on = [options[:search_on]].flatten unless options[:search_on].nil?
|
12
|
-
|
13
9
|
@order_by = options[:order_by]
|
14
|
-
|
15
10
|
@full_text_search = options[:full_text_search]
|
16
|
-
|
17
11
|
@label = options[:label]
|
18
|
-
|
19
12
|
@include = options[:include]
|
13
|
+
@pagination = options.include?(:pagination) ? options[:pagination] : true
|
20
14
|
end
|
21
15
|
|
22
16
|
def self.js_framework=(framework)
|
@@ -31,6 +25,10 @@ module RecordSelect
|
|
31
25
|
end
|
32
26
|
end
|
33
27
|
|
28
|
+
def pagination?
|
29
|
+
@pagination
|
30
|
+
end
|
31
|
+
|
34
32
|
# The model object we're browsing
|
35
33
|
def model
|
36
34
|
@model ||= klass.to_s.camelcase.constantize
|
@@ -13,7 +13,7 @@ module RecordSelectHelper
|
|
13
13
|
|
14
14
|
assert_controller_responds(options[:params][:controller])
|
15
15
|
|
16
|
-
html =
|
16
|
+
html = link_to(name, '#', options[:html])
|
17
17
|
html << javascript_tag("new RecordSelect.Dialog(#{options[:html][:id].to_json}, #{url_for(options[:params]).to_json}, {onselect: #{options[:onselect] || ''}})")
|
18
18
|
|
19
19
|
return html
|
@@ -37,8 +37,6 @@ module RecordSelectHelper
|
|
37
37
|
options[:class] ||= ''
|
38
38
|
options[:class] << ' recordselect'
|
39
39
|
|
40
|
-
ActiveSupport::Deprecation.warn 'onchange option is deprecated. Bind recordselect:change event instead.' if options[:onchange]
|
41
|
-
|
42
40
|
controller = assert_controller_responds(options.delete(:controller))
|
43
41
|
params = options.delete(:params)
|
44
42
|
record_select_options = {}
|
@@ -72,8 +70,6 @@ module RecordSelectHelper
|
|
72
70
|
options[:class] ||= ''
|
73
71
|
options[:class] << ' recordselect'
|
74
72
|
|
75
|
-
ActiveSupport::Deprecation.warn 'onchange option is deprecated. Bind recordselect:change event instead.' if options[:onchange]
|
76
|
-
|
77
73
|
controller = assert_controller_responds(options.delete(:controller))
|
78
74
|
params = options.delete(:params)
|
79
75
|
record_select_options = {}
|
@@ -88,23 +84,6 @@ module RecordSelectHelper
|
|
88
84
|
return html
|
89
85
|
end
|
90
86
|
|
91
|
-
# Assists with the creation of an observer for the :onchange option of the record_select_field method.
|
92
|
-
# Currently only supports building an Ajax.Request based on the id of the selected record.
|
93
|
-
#
|
94
|
-
# options[:url] should be a hash with all the necessary options *except* :id. that parameter
|
95
|
-
# will be provided based on the selected record.
|
96
|
-
#
|
97
|
-
# Question: if selecting users, what's more likely?
|
98
|
-
# /users/5/categories
|
99
|
-
# /categories?user_id=5
|
100
|
-
def record_select_observer(options = {})
|
101
|
-
fn = ""
|
102
|
-
fn << "function(id, value) {"
|
103
|
-
fn << "var url = #{url_for(options[:url].merge(:id => ":id:")).to_json}.replace(/:id:/, id);"
|
104
|
-
fn << "new Ajax.Request(url);"
|
105
|
-
fn << "}"
|
106
|
-
end
|
107
|
-
|
108
87
|
# Adds a RecordSelect-based form field for multiple selections. The values submit using a list of hidden inputs.
|
109
88
|
#
|
110
89
|
# *Arguments*
|
@@ -132,10 +111,8 @@ module RecordSelectHelper
|
|
132
111
|
html << hidden_field_tag("#{name}[]", '', :id => nil)
|
133
112
|
html << content_tag('ul', '', :class => 'record-select-list');
|
134
113
|
|
135
|
-
# js identifier so we can talk to it.
|
136
|
-
widget = "rs_%s" % name.gsub(/[\[\]]/, '_').chomp('_')
|
137
114
|
url = url_for({:action => :browse, :controller => controller.controller_path}.merge(params))
|
138
|
-
html << javascript_tag("
|
115
|
+
html << javascript_tag("new RecordSelect.Multiple(#{options[:id].to_json}, #{url.to_json}, #{record_select_options.to_json});")
|
139
116
|
|
140
117
|
return html
|
141
118
|
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recordselect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 5
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 3
|
8
|
+
- 3
|
9
|
+
- 7
|
10
|
+
version: 3.3.7
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Sergio Cambra
|
@@ -11,39 +17,54 @@ autorequire:
|
|
11
17
|
bindir: bin
|
12
18
|
cert_chain: []
|
13
19
|
|
14
|
-
date: 2014-
|
20
|
+
date: 2014-09-25 00:00:00 Z
|
15
21
|
dependencies:
|
16
22
|
- !ruby/object:Gem::Dependency
|
23
|
+
type: :development
|
17
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
18
26
|
requirements:
|
19
|
-
-
|
20
|
-
- ">="
|
27
|
+
- - ">="
|
21
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
22
32
|
version: "0"
|
23
33
|
version_requirements: *id001
|
24
|
-
prerelease: false
|
25
|
-
type: :development
|
26
34
|
name: shoulda
|
35
|
+
prerelease: false
|
27
36
|
- !ruby/object:Gem::Dependency
|
37
|
+
type: :development
|
28
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
29
40
|
requirements:
|
30
41
|
- - ~>
|
31
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 23
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 0
|
47
|
+
- 0
|
32
48
|
version: 1.0.0
|
33
49
|
version_requirements: *id002
|
34
|
-
prerelease: false
|
35
|
-
type: :development
|
36
50
|
name: bundler
|
51
|
+
prerelease: false
|
37
52
|
- !ruby/object:Gem::Dependency
|
53
|
+
type: :runtime
|
38
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
39
56
|
requirements:
|
40
57
|
- - ">="
|
41
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 5
|
60
|
+
segments:
|
61
|
+
- 3
|
62
|
+
- 1
|
63
|
+
- 3
|
42
64
|
version: 3.1.3
|
43
65
|
version_requirements: *id003
|
44
|
-
prerelease: false
|
45
|
-
type: :runtime
|
46
66
|
name: rails
|
67
|
+
prerelease: false
|
47
68
|
description: RecordSelect is a Rails widget to help you pick one record out of many. I designed it as a more usable and performant alternative to generating a massive dropdown list
|
48
69
|
email: activescaffold@googlegroups.com
|
49
70
|
executables: []
|
@@ -80,31 +101,40 @@ files:
|
|
80
101
|
- lib/recordselect.rb
|
81
102
|
- vendor/assets/javascripts/jquery.visible.min.js
|
82
103
|
- MIT-LICENSE
|
83
|
-
- CHANGELOG
|
84
104
|
- README
|
85
105
|
- test/recordselect_test.rb
|
86
106
|
homepage: http://github.com/scambra/recordselect
|
87
107
|
licenses:
|
88
108
|
- MIT
|
89
|
-
metadata: {}
|
90
|
-
|
91
109
|
post_install_message:
|
92
110
|
rdoc_options: []
|
93
111
|
|
94
112
|
require_paths:
|
95
113
|
- lib
|
96
114
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
97
116
|
requirements:
|
98
|
-
-
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
99
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
100
125
|
requirements:
|
101
|
-
-
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
hash: 3
|
129
|
+
segments:
|
130
|
+
- 0
|
131
|
+
version: "0"
|
102
132
|
requirements: []
|
103
133
|
|
104
134
|
rubyforge_project:
|
105
|
-
rubygems_version:
|
135
|
+
rubygems_version: 1.8.29
|
106
136
|
signing_key:
|
107
|
-
specification_version:
|
137
|
+
specification_version: 3
|
108
138
|
summary: RecordSelect widget as a replacement for massive drop down lists
|
109
139
|
test_files:
|
110
140
|
- test/recordselect_test.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA512:
|
3
|
-
metadata.gz: 96e935c1dd9b5a9d862c2ce81b5de91cf93e049579cc44bf86b0c1eccfa3837ff0ac255993179c51c46e406f31ff6a8c568c074a9434c743a630b7089ef19c55
|
4
|
-
data.tar.gz: 2ff6e3c2b1616188c9ce3cf30972b51d909bc0d94e13e7094e9ebbdf30368d3690c3fc1286cefd94c1e8e8592459588822e6911ad4c729465eea37e2a108e919
|
5
|
-
SHA1:
|
6
|
-
metadata.gz: c3f0107ec456816f71388d623c3ed258c0876601
|
7
|
-
data.tar.gz: efeca11a9905d60ffe6ef1420aa3aaed394dc9ba
|
data/CHANGELOG
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
1.0
|
2
|
-
* record_select_field always searches on the latest string
|
3
|
-
* R.S. dialog closes on mousedown instead of click (because sometimes clicks are intercepted)
|
4
|
-
* R.S. layers over <select> boxes in IE 6
|
5
|
-
* record_select_field now opens R.S. even when the field loads with focus
|
6
|
-
* new :onchange option for record_select_field, to observe selection events
|
7
|
-
|
8
|
-
1.0rc1
|
9
|
-
* helpers complain if the controller they're configured for doesn't use recordselect
|
10
|
-
* when using keyboard navigation, hitting "enter" to select a record no longer submits the form
|
11
|
-
* if text field is empty when dialog is closed, then recordselect will empty the hidden field as well (lets you deselect)
|
12
|
-
* support for multiple selections (record_multi_select_helper)
|
13
|
-
* param-based search conditions are smarter - can search numeric fields as well
|
14
|
-
* using record_select_conditions_from_controller instead of conditions_for_collection. also added a new record_select_includes override method.
|
15
|
-
* helpers now accept a :class option
|
16
|
-
* fixed bug with url escaping when helpers were configured with multiple parameters
|
17
|
-
* new :label configuration option. it's a proc - the default one calls record.to_label (for backwards compatibility).
|
18
|
-
* cleaned up merge_conditions to use activerecord's sanitize_sql.
|
19
|
-
* div.record-select-container now has a high z-index so it will by default be visible above other absolutely positioned elements.
|
20
|
-
|
21
|
-
0.9
|
22
|
-
stuff
|
23
|
-
|
24
|
-
0.1
|
25
|
-
stuff
|