recordselect 4.0.2 → 4.0.4
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 +4 -4
- data/README +0 -4
- data/app/views/record_select/_search.html.erb +1 -1
- data/lib/record_select/actions.rb +10 -6
- data/lib/record_select/conditions.rb +0 -2
- data/lib/record_select/config.rb +4 -4
- data/lib/record_select/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 362f542dfd84f4252b0a550c0f9200f3aa956c6ca43a1b939636decae08a805d
|
4
|
+
data.tar.gz: 84e8d713f19e301b23193bd7fb103bcb639f9155d6262c8057658abb88d2e8b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdba6822301d47fe4976bbf65c0c361c459a750914d477ed16cd4609a4eed2997a4e8c1c01058fd3580a977b1cd7b8ae3cb090069ac489618f8152f3ea4d17bc
|
7
|
+
data.tar.gz: 2993c28d98c8da784d9646dd55b29f1c43cb1e698d2c3481a465adeb7c6f990327cf04cdde489dcbcc9e30e3fbe66366e94d34f3431a79b3a3529d06c41c4e0f
|
data/README
CHANGED
@@ -45,7 +45,3 @@ Either using assets pipeline or importmap, it will be loaded when requiring or i
|
|
45
45
|
|
46
46
|
= DEPENDENCIES
|
47
47
|
This depends on the excellent Paginator gem by Bruce Williams. This simple gem is available at paginator.rubyforge.org.
|
48
|
-
|
49
|
-
It should autoselect js framework, but you can select :jquery or :prototype framework with config/initializer file:
|
50
|
-
RecordSelect::Config.js_framework = :jquery
|
51
|
-
RecordSelect::Config.js_framework = :prototype
|
@@ -4,6 +4,6 @@ url_options = params.permit(*permit_fields).merge(controller: controller, action
|
|
4
4
|
-%>
|
5
5
|
<%= form_tag url_options, {method: :get, remote: true, id: record_select_search_id} -%>
|
6
6
|
<%= text_field_tag 'search', params[:search], autocomplete: 'off', class: 'text-input' %>
|
7
|
-
<%= hidden_field_tag 'rs_mode', params[:rs_mode] %>
|
7
|
+
<%= hidden_field_tag 'rs_mode', params[:rs_mode] if record_select_config.toggle_search_mode? %>
|
8
8
|
<%= submit_tag 'search', class: "search_submit" %>
|
9
9
|
</form>
|
@@ -3,12 +3,7 @@ module RecordSelect
|
|
3
3
|
# :method => :get
|
4
4
|
# params => [:page, :search]
|
5
5
|
def browse
|
6
|
-
|
7
|
-
user_includes = record_select_includes
|
8
|
-
query = conditions.inject(record_select_model.includes(user_includes)) do |query, cond|
|
9
|
-
query.where(cond)
|
10
|
-
end
|
11
|
-
query = query.references(user_includes) if Rails::VERSION::MAJOR >= 4 && user_includes.present?
|
6
|
+
query = record_select_query
|
12
7
|
@count = query.count if record_select_config.pagination?
|
13
8
|
@count = @count.length if @count.is_a? Hash
|
14
9
|
pager = ::Paginator.new(@count, record_select_config.per_page) do |offset, per_page|
|
@@ -67,6 +62,15 @@ module RecordSelect
|
|
67
62
|
|
68
63
|
private
|
69
64
|
|
65
|
+
def record_select_query
|
66
|
+
query = record_select_model
|
67
|
+
user_includes = record_select_includes
|
68
|
+
query = query.includes(user_includes).references(user_includes) if user_includes.present?
|
69
|
+
query = query.joins(record_select_config.joins).distinct if record_select_config.joins.present?
|
70
|
+
query = query.left_joins(record_select_config.left_joins) if record_select_config.left_joins.present?
|
71
|
+
record_select_conditions.inject(query) { |query, cond| query.where(cond) }
|
72
|
+
end
|
73
|
+
|
70
74
|
def record_select_views_path
|
71
75
|
"record_select"
|
72
76
|
end
|
@@ -7,8 +7,6 @@ module RecordSelect
|
|
7
7
|
# * intelligent url params (e.g. params[:first_name] if first_name is a model column)
|
8
8
|
# * specific conditions supplied by the developer
|
9
9
|
def record_select_conditions
|
10
|
-
conditions = []
|
11
|
-
|
12
10
|
[
|
13
11
|
record_select_conditions_from_search,
|
14
12
|
*record_select_conditions_from_params,
|
data/lib/record_select/config.rb
CHANGED
@@ -9,11 +9,15 @@ module RecordSelect
|
|
9
9
|
@order_by = options[:order_by]
|
10
10
|
@full_text_search = options[:full_text_search]
|
11
11
|
@label = options[:label]
|
12
|
+
@joins = options[:joins]
|
13
|
+
@left_joins = options[:left_joins]
|
12
14
|
@include = options[:include]
|
13
15
|
@pagination = options.include?(:pagination) ? options[:pagination] : true
|
14
16
|
@toggle_search_mode = options[:toggle_search_mode]
|
15
17
|
end
|
16
18
|
|
19
|
+
attr_reader :include, :joins, :left_joins
|
20
|
+
|
17
21
|
def pagination?
|
18
22
|
@pagination
|
19
23
|
end
|
@@ -52,10 +56,6 @@ module RecordSelect
|
|
52
56
|
@toggle_search_mode ? true : false
|
53
57
|
end
|
54
58
|
|
55
|
-
def include
|
56
|
-
@include
|
57
|
-
end
|
58
|
-
|
59
59
|
# If a proc, must accept the record as an argument and return a descriptive string.
|
60
60
|
#
|
61
61
|
# If a symbol or string, must name a partial that renders a representation of the
|
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: 4.0.
|
4
|
+
version: 4.0.4
|
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: 2025-
|
13
|
+
date: 2025-02-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|