fat_free_crm 0.19.0 → 0.19.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fat_free_crm might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +146 -146
- data/app/views/shared/_empty.html.haml +1 -1
- data/lib/fat_free_crm/version.rb +1 -1
- data/spec/views/accounts/create.js.haml_spec.rb +1 -1
- data/spec/views/campaigns/create.js.haml_spec.rb +1 -1
- data/spec/views/campaigns/edit.js.haml_spec.rb +2 -2
- data/spec/views/campaigns/index.js.haml_spec.rb +1 -1
- data/spec/views/campaigns/update.js.haml_spec.rb +1 -1
- data/spec/views/contacts/create.js.haml_spec.rb +1 -1
- data/spec/views/contacts/edit.js.haml_spec.rb +1 -1
- data/spec/views/contacts/index.js.html_spec.rb +1 -1
- data/spec/views/contacts/update.js.haml_spec.rb +2 -2
- metadata +3 -38
- data/vendor/gems/ransack_ui-1.3.4/.gitignore +0 -17
- data/vendor/gems/ransack_ui-1.3.4/Gemfile +0 -7
- data/vendor/gems/ransack_ui-1.3.4/LICENSE.txt +0 -22
- data/vendor/gems/ransack_ui-1.3.4/README.md +0 -57
- data/vendor/gems/ransack_ui-1.3.4/Rakefile +0 -1
- data/vendor/gems/ransack_ui-1.3.4/app/assets/images/ransack_ui/calendar.png +0 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/images/ransack_ui/delete.png +0 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack/predicates.js.coffee +0 -41
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee +0 -26
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_bootstrap/index.js.coffee +0 -2
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_jquery/index.js +0 -2
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_jquery/search_form.js.coffee.erb +0 -499
- data/vendor/gems/ransack_ui-1.3.4/app/assets/stylesheets/ransack_ui_bootstrap/index.css +0 -3
- data/vendor/gems/ransack_ui-1.3.4/app/assets/stylesheets/ransack_ui_bootstrap/search.css.scss +0 -41
- data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_condition_fields.html.erb +0 -15
- data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_grouping_fields.html.erb +0 -16
- data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_search.html.erb +0 -29
- data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_sort_fields.html.erb +0 -4
- data/vendor/gems/ransack_ui-1.3.4/config/locales/en.yml +0 -24
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui.rb +0 -9
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/adapters/active_record.rb +0 -6
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/adapters/active_record/base.rb +0 -46
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/controller_helpers.rb +0 -18
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/rails/engine.rb +0 -21
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/adapters/active_record/base.rb +0 -47
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/configuration.rb +0 -15
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/context.rb +0 -9
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/helpers/form_builder.rb +0 -262
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/attribute.rb +0 -13
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/condition.rb +0 -13
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/grouping.rb +0 -20
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/version.rb +0 -3
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/view_helpers.rb +0 -30
- data/vendor/gems/ransack_ui-1.3.4/ransack_ui.gemspec +0 -23
@@ -1,6 +1,6 @@
|
|
1
1
|
- assets = controller_name
|
2
2
|
- asset = assets.singularize
|
3
|
-
- new_asset_path =
|
3
|
+
- new_asset_path = url_for(action: :new, controller: controller_name)
|
4
4
|
#empty
|
5
5
|
- if @current_query.blank?
|
6
6
|
== #{t(:could_not_find, t(assets.downcase))} #{link_to_inline(:"create_#{asset}", new_asset_path, plain: true, text: "#{t(:create_a_new)} #{t(asset + '_small')}")}.
|
data/lib/fat_free_crm/version.rb
CHANGED
@@ -25,7 +25,7 @@ describe "/accounts/create" do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should hide [Create Account] form and insert account partial" do
|
28
|
-
expect(rendered).to include("$('#accounts').prepend('<li class=\\'account
|
28
|
+
expect(rendered).to include("$('#accounts').prepend('<li class=\\'highlight account\\' id=\\'account_#{@account.id}\\'")
|
29
29
|
expect(rendered).to include(%/$('#account_#{@account.id}').effect("highlight"/)
|
30
30
|
end
|
31
31
|
|
@@ -21,7 +21,7 @@ describe "/campaigns/create" do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should hide [Create Campaign] form and insert campaign partial" do
|
24
|
-
expect(rendered).to include("$('#campaigns').prepend('<li class=\\'campaign
|
24
|
+
expect(rendered).to include("$('#campaigns').prepend('<li class=\\'highlight campaign\\' id=\\'campaign_#{@campaign.id}\\'")
|
25
25
|
expect(rendered).to include(%/$('#campaign_#{@campaign.id}').effect("highlight"/)
|
26
26
|
end
|
27
27
|
|
@@ -20,7 +20,7 @@ describe "/campaigns/edit" do
|
|
20
20
|
params[:cancel] = "true"
|
21
21
|
|
22
22
|
render
|
23
|
-
expect(rendered).to include("$('#campaign_#{@campaign.id}').replaceWith('<li class=\\'campaign
|
23
|
+
expect(rendered).to include("$('#campaign_#{@campaign.id}').replaceWith('<li class=\\'highlight campaign\\' id=\\'campaign_#{@campaign.id}\\'")
|
24
24
|
end
|
25
25
|
|
26
26
|
it "cancel from campaign landing page: should hide [Edit Campaign] form" do
|
@@ -36,7 +36,7 @@ describe "/campaigns/edit" do
|
|
36
36
|
assign(:previous, previous = build_stubbed(:campaign, user: current_user))
|
37
37
|
|
38
38
|
render
|
39
|
-
expect(rendered).to include("$('#campaign_#{previous.id}').replaceWith('<li class=\\'campaign
|
39
|
+
expect(rendered).to include("$('#campaign_#{previous.id}').replaceWith('<li class=\\'highlight campaign\\' id=\\'campaign_#{previous.id}\\'")
|
40
40
|
end
|
41
41
|
|
42
42
|
it "edit: should remove previously open [Edit Campaign] if it's no longer available" do
|
@@ -19,7 +19,7 @@ describe "/campaigns/index" do
|
|
19
19
|
|
20
20
|
render template: 'campaigns/index', formats: [:js]
|
21
21
|
|
22
|
-
expect(rendered).to include("$('#campaigns').html('<li class=\\'campaign
|
22
|
+
expect(rendered).to include("$('#campaigns').html('<li class=\\'highlight campaign\\' id=\\'campaign_42\\'")
|
23
23
|
expect(rendered).to include("#paginate")
|
24
24
|
end
|
25
25
|
|
@@ -44,7 +44,7 @@ describe "/campaigns/update" do
|
|
44
44
|
|
45
45
|
it "should replace [Edit Campaign] with campaign partial and highlight it" do
|
46
46
|
render
|
47
|
-
expect(rendered).to include("$('#campaign_#{@campaign.id}').replaceWith('<li class=\\'campaign
|
47
|
+
expect(rendered).to include("$('#campaign_#{@campaign.id}').replaceWith('<li class=\\'highlight campaign\\' id=\\'campaign_#{@campaign.id}\\'")
|
48
48
|
expect(rendered).to include(%/$('#campaign_#{@campaign.id}').effect("highlight"/)
|
49
49
|
end
|
50
50
|
end
|
@@ -23,7 +23,7 @@ describe "/contacts/create" do
|
|
23
23
|
it "should hide [Create Contact] form and insert contact partial" do
|
24
24
|
render
|
25
25
|
|
26
|
-
expect(rendered).to include("$('#contacts').prepend('<li class=\\'contact
|
26
|
+
expect(rendered).to include("$('#contacts').prepend('<li class=\\'highlight contact\\' id=\\'contact_#{@contact.id}\\'")
|
27
27
|
expect(rendered).to include(%/$('#contact_#{@contact.id}').effect("highlight"/)
|
28
28
|
end
|
29
29
|
|
@@ -22,7 +22,7 @@ describe "/contacts/edit" do
|
|
22
22
|
params[:cancel] = "true"
|
23
23
|
|
24
24
|
render
|
25
|
-
expect(rendered).to include("$('#contact_#{@contact.id}').replaceWith('<li class=\\'contact
|
25
|
+
expect(rendered).to include("$('#contact_#{@contact.id}').replaceWith('<li class=\\'highlight contact\\' id=\\'contact_#{@contact.id}\\'")
|
26
26
|
end
|
27
27
|
|
28
28
|
it "cancel from contact landing page: should hide [Edit Contact] form" do
|
@@ -19,7 +19,7 @@ describe "/contacts/index" do
|
|
19
19
|
|
20
20
|
render template: 'contacts/index', formats: [:js]
|
21
21
|
|
22
|
-
expect(rendered).to include("$('#contacts').html('<li class=\\'contact
|
22
|
+
expect(rendered).to include("$('#contacts').html('<li class=\\'highlight contact\\' id=\\'contact_42\\'")
|
23
23
|
expect(rendered).to include("#paginate")
|
24
24
|
end
|
25
25
|
|
@@ -47,7 +47,7 @@ describe "/contacts/update" do
|
|
47
47
|
controller.request.env["HTTP_REFERER"] = "http://localhost/contacts"
|
48
48
|
|
49
49
|
render
|
50
|
-
expect(rendered).to include("$('#contact_#{@contact.id}').replaceWith('<li class=\\'contact
|
50
|
+
expect(rendered).to include("$('#contact_#{@contact.id}').replaceWith('<li class=\\'highlight contact\\' id=\\'contact_#{@contact.id}\\'")
|
51
51
|
expect(rendered).to include(%/$('#contact_#{@contact.id}').effect("highlight"/)
|
52
52
|
end
|
53
53
|
|
@@ -67,7 +67,7 @@ describe "/contacts/update" do
|
|
67
67
|
controller.request.env["HTTP_REFERER"] = "http://localhost/contacts"
|
68
68
|
|
69
69
|
render
|
70
|
-
expect(rendered).to include("$('#contact_#{@contact.id}').replaceWith('<li class=\\'contact
|
70
|
+
expect(rendered).to include("$('#contact_#{@contact.id}').replaceWith('<li class=\\'highlight contact\\' id=\\'contact_#{@contact.id}\\'")
|
71
71
|
expect(rendered).to include(%/$('#contact_#{@contact.id}').effect("highlight"/)
|
72
72
|
end
|
73
73
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fat_free_crm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.19.
|
4
|
+
version: 0.19.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Dvorkin
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-05-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -1539,40 +1539,6 @@ files:
|
|
1539
1539
|
- vendor/gems/globby-0.1.2/lib/globby/result.rb
|
1540
1540
|
- vendor/gems/globby-0.1.2/spec/gitignore_spec.rb
|
1541
1541
|
- vendor/gems/globby-0.1.2/spec/globby_spec.rb
|
1542
|
-
- vendor/gems/ransack_ui-1.3.4/.gitignore
|
1543
|
-
- vendor/gems/ransack_ui-1.3.4/Gemfile
|
1544
|
-
- vendor/gems/ransack_ui-1.3.4/LICENSE.txt
|
1545
|
-
- vendor/gems/ransack_ui-1.3.4/README.md
|
1546
|
-
- vendor/gems/ransack_ui-1.3.4/Rakefile
|
1547
|
-
- vendor/gems/ransack_ui-1.3.4/app/assets/images/ransack_ui/calendar.png
|
1548
|
-
- vendor/gems/ransack_ui-1.3.4/app/assets/images/ransack_ui/delete.png
|
1549
|
-
- vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack/predicates.js.coffee
|
1550
|
-
- vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
|
1551
|
-
- vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_bootstrap/index.js.coffee
|
1552
|
-
- vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_jquery/index.js
|
1553
|
-
- vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_jquery/search_form.js.coffee.erb
|
1554
|
-
- vendor/gems/ransack_ui-1.3.4/app/assets/stylesheets/ransack_ui_bootstrap/index.css
|
1555
|
-
- vendor/gems/ransack_ui-1.3.4/app/assets/stylesheets/ransack_ui_bootstrap/search.css.scss
|
1556
|
-
- vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_condition_fields.html.erb
|
1557
|
-
- vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_grouping_fields.html.erb
|
1558
|
-
- vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_search.html.erb
|
1559
|
-
- vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_sort_fields.html.erb
|
1560
|
-
- vendor/gems/ransack_ui-1.3.4/config/locales/en.yml
|
1561
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui.rb
|
1562
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/adapters/active_record.rb
|
1563
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/adapters/active_record/base.rb
|
1564
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/controller_helpers.rb
|
1565
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/rails/engine.rb
|
1566
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/adapters/active_record/base.rb
|
1567
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/configuration.rb
|
1568
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/context.rb
|
1569
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/helpers/form_builder.rb
|
1570
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/attribute.rb
|
1571
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/condition.rb
|
1572
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/grouping.rb
|
1573
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/version.rb
|
1574
|
-
- vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/view_helpers.rb
|
1575
|
-
- vendor/gems/ransack_ui-1.3.4/ransack_ui.gemspec
|
1576
1542
|
- zeus.json
|
1577
1543
|
homepage: http://fatfreecrm.com
|
1578
1544
|
licenses:
|
@@ -1593,8 +1559,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1593
1559
|
- !ruby/object:Gem::Version
|
1594
1560
|
version: '0'
|
1595
1561
|
requirements: []
|
1596
|
-
|
1597
|
-
rubygems_version: 2.7.6
|
1562
|
+
rubygems_version: 3.1.2
|
1598
1563
|
signing_key:
|
1599
1564
|
specification_version: 4
|
1600
1565
|
summary: Fat Free CRM
|
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 Nathan Broadbent
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# Ransack UI
|
2
|
-
|
3
|
-
Provides HTML templates and JavaScript to build a fully functional
|
4
|
-
advanced search form using Ransack.
|
5
|
-
|
6
|
-
Please note: this project is still in *alpha* and the following instructions are not yet complete/fully working.
|
7
|
-
|
8
|
-
## Installation
|
9
|
-
|
10
|
-
Add this line to your application's Gemfile:
|
11
|
-
|
12
|
-
gem 'ransack_ui'
|
13
|
-
|
14
|
-
And then execute:
|
15
|
-
|
16
|
-
$ bundle
|
17
|
-
|
18
|
-
Or install it yourself as:
|
19
|
-
|
20
|
-
$ gem install ransack_ui
|
21
|
-
|
22
|
-
## Usage
|
23
|
-
|
24
|
-
Make your model ransackable (if you name associations, it will enable you to search them aswell).
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
has_ransackable_associations %w(account tags)
|
28
|
-
ransack_can_autocomplete
|
29
|
-
```
|
30
|
-
|
31
|
-
In your controller, where you'd like to add search functionality, add the following before_filter hook. You can change the 'index' action if needed.
|
32
|
-
|
33
|
-
```ruby
|
34
|
-
before_filter :load_ransack_search, :only => :index
|
35
|
-
```
|
36
|
-
|
37
|
-
Insert the following helper call into your rails view code where you'd like the search form to appear.
|
38
|
-
|
39
|
-
```ruby
|
40
|
-
= ransack_ui_search
|
41
|
-
```
|
42
|
-
|
43
|
-
Now you can start playing with the results.
|
44
|
-
|
45
|
-
## Contributing
|
46
|
-
|
47
|
-
1. Fork it
|
48
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
-
5. Create new Pull Request
|
52
|
-
|
53
|
-
## Credits / Acknowledgements
|
54
|
-
|
55
|
-
* Nathan Broadbent (ndbroadbent) - creator of ransack_ui code
|
56
|
-
* Ernie Miller (ernie) for creating ransack - https://github.com/ernie/ransack
|
57
|
-
* Steve Kenworthy (steveyken) - for tiny tweaks
|
@@ -1 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
Binary file
|
Binary file
|
@@ -1,41 +0,0 @@
|
|
1
|
-
window.Ransack ?= {}
|
2
|
-
|
3
|
-
Ransack.predicates =
|
4
|
-
eq: 'not_eq'
|
5
|
-
cont: 'not_cont'
|
6
|
-
matches: 'does_not_match'
|
7
|
-
start: 'not_start'
|
8
|
-
end: 'not_end'
|
9
|
-
present: 'blank'
|
10
|
-
null: 'not_null'
|
11
|
-
lt: 'gteq'
|
12
|
-
gt: 'lteq'
|
13
|
-
in: 'not_in'
|
14
|
-
true: 'false'
|
15
|
-
|
16
|
-
# Setup supported predicates for each column type.
|
17
|
-
Ransack.type_predicates = {}
|
18
|
-
((o, f) -> f.call o) Ransack.type_predicates, ->
|
19
|
-
@text = @string = ['eq', 'cont', 'matches', 'start', 'end', 'present', 'in']
|
20
|
-
@boolean = ['true', 'null']
|
21
|
-
@integer = @float = @decimal = ['eq', 'null', 'lt', 'gt', 'in']
|
22
|
-
@date = @datetime = @time = ['eq', 'null', 'lt', 'gt']
|
23
|
-
|
24
|
-
# Setup input field types for each predicate
|
25
|
-
Ransack.predicate_inputs = {}
|
26
|
-
((o, f) -> f.call o) Ransack.predicate_inputs, ->
|
27
|
-
@cont = @matches = @start = @end = @in = 'string'
|
28
|
-
@present = @null = @true = false
|
29
|
-
@eq = @gt = @lt = (type) ->
|
30
|
-
switch type
|
31
|
-
when 'string','text' then 'string'
|
32
|
-
when 'integer','float','decimal' then 'numeric'
|
33
|
-
when 'date','datetime','time' then type
|
34
|
-
else false # Hide for unhandled types.
|
35
|
-
|
36
|
-
# Setup predicates for fixed select options. Includes relevant any/all permutations
|
37
|
-
Ransack.option_predicates = ['eq', 'eq_any', 'not_eq', 'not_eq_all', 'null', 'not_null']
|
38
|
-
|
39
|
-
# Use a tags input for 'in' if Select2 is available
|
40
|
-
if Select2?
|
41
|
-
Ransack.predicate_inputs.in = 'tags'
|
@@ -1,26 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Converts a select list into a bootstrap button-group with radio button behaviour
|
3
|
-
#
|
4
|
-
(($) ->
|
5
|
-
$.widget 'ransack.button_group_select',
|
6
|
-
options: {}
|
7
|
-
|
8
|
-
_create: ->
|
9
|
-
el = @element
|
10
|
-
val = el.val()
|
11
|
-
el.hide()
|
12
|
-
|
13
|
-
html = '<div class="btn-group btn-group-select" data-toggle="buttons-radio">'
|
14
|
-
el.find('option').each (i, o) ->
|
15
|
-
html += "<button class=\"btn#{if o.value == val then ' active' else ''}\" type=\"button\" value=\"#{o.value}\">#{o.text}</button>"
|
16
|
-
|
17
|
-
# Insert HTML after hidden select
|
18
|
-
el.after html
|
19
|
-
|
20
|
-
# Update select val when button is clicked
|
21
|
-
btn_group = el.next()
|
22
|
-
btn_group.on 'click', 'button.btn', (e) =>
|
23
|
-
@element.val $(e.currentTarget).val()
|
24
|
-
true
|
25
|
-
|
26
|
-
) jQuery
|
data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_jquery/search_form.js.coffee.erb
DELETED
@@ -1,499 +0,0 @@
|
|
1
|
-
(($) ->
|
2
|
-
$.widget 'ransack.ransack_search_form',
|
3
|
-
options: {}
|
4
|
-
|
5
|
-
_create: ->
|
6
|
-
el = @element
|
7
|
-
el.on 'click', '.add_fields', $.proxy(@add_fields, this)
|
8
|
-
el.on 'click', '.remove_fields', $.proxy(@remove_fields, this)
|
9
|
-
el.on 'change', 'select.ransack_predicate', $.proxy(@predicate_changed, this)
|
10
|
-
el.on 'change', 'select.ransack_attribute', $.proxy(@attribute_changed, this)
|
11
|
-
el.on 'change', 'input.ransack_query_multi', $.proxy(@multi_query_changed, this)
|
12
|
-
|
13
|
-
# Store initial predicates and set up Select2 on select lists in .filters
|
14
|
-
containers = el.find('.filters')
|
15
|
-
if Select2?
|
16
|
-
@init_select2(containers)
|
17
|
-
@store_initial_predicates(containers)
|
18
|
-
|
19
|
-
if $.ransack.button_group_select?
|
20
|
-
@init_button_group_select(@element)
|
21
|
-
|
22
|
-
# show spinner and disable the form when the search is underway
|
23
|
-
el.find("form input:submit").click $.proxy(@form_submit, this)
|
24
|
-
|
25
|
-
# Fire change event for any existing attribute selects,
|
26
|
-
# set initialize to true so that existing queries are not cleared.
|
27
|
-
el.find(".filters select.ransack_attribute").each (i, el) =>
|
28
|
-
@attribute_changed({currentTarget: el}, true)
|
29
|
-
|
30
|
-
attribute_changed: (e, initialize = false) ->
|
31
|
-
target = $(e.currentTarget)
|
32
|
-
selected_attribute = target.find('option:selected')
|
33
|
-
column_type = selected_attribute.data('type')
|
34
|
-
|
35
|
-
base_id = target.attr('id').slice(0, -8)
|
36
|
-
predicate_select = @element.find("select##{base_id}p")
|
37
|
-
available = predicate_select.data['predicates']
|
38
|
-
query_input = $("input##{base_id}v_0_value")
|
39
|
-
multi_id = query_input.attr('id') + '_multi'
|
40
|
-
multi_input = @element.find("##{multi_id}")
|
41
|
-
query_select2_id = "#s2id_#{base_id}v_0_value"
|
42
|
-
query_select2 = @element.find(query_select2_id)
|
43
|
-
predicate_select2_id = "#s2id_#{base_id}p"
|
44
|
-
predicate_select2 = @element.find(predicate_select2_id)
|
45
|
-
|
46
|
-
# Initialize datepicker if column is date/datetime/time
|
47
|
-
$.proxy(@init_datetimepicker, this)(base_id)
|
48
|
-
|
49
|
-
# Clear input value unless this is the first run
|
50
|
-
unless initialize
|
51
|
-
query_input.val('')
|
52
|
-
|
53
|
-
# Destroy any query select2 inputs on attribute change and clear input
|
54
|
-
if query_select2.length
|
55
|
-
query_input.select2('destroy')
|
56
|
-
|
57
|
-
# Destroy any multi-inputs on attribute change and clear input
|
58
|
-
if multi_input.length
|
59
|
-
@destroy_multi_input(multi_input, selected_attribute.val())
|
60
|
-
|
61
|
-
# Handle association columns with AJAX autocomplete
|
62
|
-
if selected_attribute.data('ajax-url') and Select2?
|
63
|
-
@set_option_predicates(base_id, available, column_type)
|
64
|
-
|
65
|
-
# Handle columns with options detected from validates :inclusion
|
66
|
-
else if selected_attribute.data('select-options') and Select2?
|
67
|
-
@set_option_predicates(base_id, available, column_type, true)
|
68
|
-
|
69
|
-
# Handle regular columns
|
70
|
-
else
|
71
|
-
if Select2?
|
72
|
-
predicate_select2.select2("enable")
|
73
|
-
|
74
|
-
# If Select2 is on query input, remove and set defaults
|
75
|
-
if query_select2.length > 0
|
76
|
-
query_input.select2('destroy')
|
77
|
-
query_input.val('')
|
78
|
-
previous_val = ''
|
79
|
-
else
|
80
|
-
previous_val = predicate_select.val()
|
81
|
-
|
82
|
-
# Build array of supported predicates
|
83
|
-
predicates = Ransack.type_predicates[column_type] || []
|
84
|
-
predicates = $.map predicates, (p) -> [p, Ransack.predicates[p]]
|
85
|
-
|
86
|
-
# Remove all predicates, and add any supported predicates
|
87
|
-
predicate_select.find('option').each (i, o) -> $(o).remove()
|
88
|
-
|
89
|
-
$.each available, (i, p) =>
|
90
|
-
[predicate, label] = [p[0], p[1]]
|
91
|
-
|
92
|
-
# Also allow compound predicates, unless column
|
93
|
-
# is a date type. (No support for any/all on dates yet.)
|
94
|
-
if !column_type?.match(/date|time/)
|
95
|
-
p_key = predicate.replace(/_(any|all)$/, '')
|
96
|
-
else
|
97
|
-
p_key = predicate
|
98
|
-
|
99
|
-
if p_key in predicates
|
100
|
-
# Get alternative predicate label depending on column type
|
101
|
-
label = @alt_predicate_label_or_default(predicate, column_type, label)
|
102
|
-
predicate_select.append $("<option value=#{predicate}>#{label}</option>")
|
103
|
-
|
104
|
-
# Select first predicate if current selection is invalid
|
105
|
-
if Select2?
|
106
|
-
predicate_select.select2('val', previous_val)
|
107
|
-
|
108
|
-
# Run predicate_changed callback
|
109
|
-
predicate_select.change()
|
110
|
-
|
111
|
-
return true
|
112
|
-
|
113
|
-
|
114
|
-
predicate_changed: (e) ->
|
115
|
-
target = $(e.currentTarget)
|
116
|
-
p = target.val() || ""
|
117
|
-
base_id = target.attr('id').slice(0, -1)
|
118
|
-
query_input = $("input##{base_id}v_0_value")
|
119
|
-
|
120
|
-
attribute_select = @element.find("select##{base_id}a_0_name")
|
121
|
-
selected_attribute = attribute_select.find('option:selected')
|
122
|
-
|
123
|
-
query_select2_id = "#s2id_#{base_id}v_0_value"
|
124
|
-
query_select2 = @element.find(query_select2_id)
|
125
|
-
query_select2_multi_id = "#s2id_#{base_id}v_0_value_multi"
|
126
|
-
query_select2_multi = @element.find(query_select2_multi_id)
|
127
|
-
|
128
|
-
no_query_predicates = ["true", "false", "blank", "present", "null", "not_null"]
|
129
|
-
|
130
|
-
# We need to use a dummy input to handle multiple terms
|
131
|
-
multi_id = query_input.attr('id') + '_multi'
|
132
|
-
multi_input = @element.find("##{multi_id}")
|
133
|
-
|
134
|
-
# If query was previously hidden, clear query input
|
135
|
-
if query_select2.length == 0 && multi_input.length == 0 && query_input.is(":hidden")
|
136
|
-
query_input.val('')
|
137
|
-
|
138
|
-
# Hide query input when not needed
|
139
|
-
if p in no_query_predicates
|
140
|
-
# If Select2 is on query input, remove and set defaults
|
141
|
-
if Select2? && query_select2.length
|
142
|
-
query_input.select2('destroy')
|
143
|
-
|
144
|
-
query_input.val("true")
|
145
|
-
query_input.hide()
|
146
|
-
query_input.parent().find('.ui-datepicker-trigger').hide()
|
147
|
-
|
148
|
-
if Select2?
|
149
|
-
# Turn query input into Select2 tag list when query accepts multiple values
|
150
|
-
if p in ["in", "not_in"] || p.match(/_(all|any)$/)
|
151
|
-
# Add dummy 'multi' input for select2 if not already added
|
152
|
-
if multi_input.length == 0 && query_select2_multi.length == 0
|
153
|
-
# Set up multi-query input with fixed options, if present
|
154
|
-
@setup_multi_query_input(target, query_input, multi_id, selected_attribute)
|
155
|
-
|
156
|
-
# If Select2 is on query input, remove and set defaults
|
157
|
-
if query_select2.length
|
158
|
-
query_input.select2('destroy').hide()
|
159
|
-
|
160
|
-
return
|
161
|
-
|
162
|
-
else
|
163
|
-
# Otherwise, remove Select2 from multi-query input, and remove input.
|
164
|
-
if multi_input.length
|
165
|
-
# Save label data from first value
|
166
|
-
if multi_input.select2('data') && multi_input.select2('data').length
|
167
|
-
multi_input_data = multi_input.select2('data').first()
|
168
|
-
Ransack.value_field_labels[selected_attribute.val()] ||= {}
|
169
|
-
Ransack.value_field_labels[selected_attribute.val()][multi_input_data.id] = multi_input_data.text
|
170
|
-
|
171
|
-
@destroy_multi_input(multi_input, selected_attribute.val())
|
172
|
-
|
173
|
-
if p not in no_query_predicates
|
174
|
-
#query_input.show()
|
175
|
-
query_input.css('display', '')
|
176
|
-
|
177
|
-
# Handle association columns with AJAX autocomplete
|
178
|
-
if selected_attribute.data('ajax-url')
|
179
|
-
if query_select2.length
|
180
|
-
query_input.hide()
|
181
|
-
else
|
182
|
-
@setup_select2_association(query_input, selected_attribute)
|
183
|
-
|
184
|
-
# Handle fixed options - set up Select2 for single values if not already present
|
185
|
-
if selected_attribute.data('select-options')
|
186
|
-
if query_select2.length
|
187
|
-
query_input.hide()
|
188
|
-
else
|
189
|
-
@setup_select2_options(query_input, selected_attribute)
|
190
|
-
|
191
|
-
# Otherwise, reset query input and show datepicker trigger if present
|
192
|
-
if p not in no_query_predicates
|
193
|
-
return if selected_attribute.data('select-options')
|
194
|
-
|
195
|
-
# Don't show query input if ajax auto complete is present on selected attribute
|
196
|
-
unless p in ['eq', 'not_eq'] and selected_attribute.data('ajax-url')
|
197
|
-
unless query_input.is(":visible")
|
198
|
-
query_input.val('')
|
199
|
-
#query_input.show()
|
200
|
-
query_input.css('display', '')
|
201
|
-
query_input.parent().find('.ui-datepicker-trigger').show()
|
202
|
-
|
203
|
-
|
204
|
-
# Disables predicate choices and sets it to 'eq'
|
205
|
-
set_option_predicates: (base_id, available_predicates, column_type, include_number_predicates = false) ->
|
206
|
-
predicate_select = @element.find("select##{base_id}p")
|
207
|
-
previous_val = predicate_select.val()
|
208
|
-
|
209
|
-
# Remove all predicates, and add any supported predicates
|
210
|
-
predicate_select.find('option').each (i, o) -> $(o).remove()
|
211
|
-
|
212
|
-
allowed_predicates = $.merge([], Ransack.option_predicates)
|
213
|
-
|
214
|
-
# Include number predicates if the option was given.
|
215
|
-
# For example, a integer column will have fixed select options,
|
216
|
-
# but will also allow less than and greater than.
|
217
|
-
if column_type in ['integer', 'float', 'decimal'] && include_number_predicates
|
218
|
-
allowed_predicates = allowed_predicates.concat(Ransack.type_predicates[column_type] || [])
|
219
|
-
|
220
|
-
$.each available_predicates, (i, p) =>
|
221
|
-
[predicate, label] = [p[0], p[1]]
|
222
|
-
|
223
|
-
if predicate in allowed_predicates
|
224
|
-
# Get alternative predicate label depending on column type
|
225
|
-
label = @alt_predicate_label_or_default(predicate, column_type, label)
|
226
|
-
predicate_select.append $("<option value=#{predicate}>#{label}</option>")
|
227
|
-
|
228
|
-
# Select first predicate if current selection is invalid
|
229
|
-
predicate_select.select2('val', previous_val)
|
230
|
-
|
231
|
-
# Attempts to find a predicate translation for the specific column type,
|
232
|
-
# or returns the default label.
|
233
|
-
# For example, 'lt' on an integer column will be translated to 'is less than',
|
234
|
-
# while a date column will have it translated as 'is before'.
|
235
|
-
# This is mainly to avoid confusion when building conditions using Chronic strings.
|
236
|
-
# 'created_at is less than 2 weeks ago' is misleading, and
|
237
|
-
# 'created_at is before 2 weeks ago' is much easier to understand.
|
238
|
-
alt_predicate_label_or_default: (p, type, default_label) ->
|
239
|
-
return default_label unless Ransack?.alt_predicates_i18n?
|
240
|
-
alt_labels = {}
|
241
|
-
switch type
|
242
|
-
when "date", "datetime", "time"
|
243
|
-
alt_labels = Ransack.alt_predicates_i18n["date"] || {}
|
244
|
-
else
|
245
|
-
alt_labels = Ransack.alt_predicates_i18n[type] || {}
|
246
|
-
|
247
|
-
alt_labels[p] || default_label
|
248
|
-
|
249
|
-
multi_query_changed: (e) ->
|
250
|
-
target = $(e.currentTarget)
|
251
|
-
|
252
|
-
# Fetch all query inputs for condition
|
253
|
-
base_name = target.data('base-name')
|
254
|
-
inputs = @element.find("input[name^=\"#{base_name}\"]")
|
255
|
-
|
256
|
-
# Set the original query input to the first value before shifting inputs and values
|
257
|
-
$(inputs[0]).val(e.val[0])
|
258
|
-
|
259
|
-
inputs = inputs.slice(1)
|
260
|
-
values = e.val.slice(1)
|
261
|
-
|
262
|
-
# If value was added after the first value, then append extra input with added value
|
263
|
-
if values.length && e.added
|
264
|
-
@add_query_input(target, base_name, inputs.length + 1, e.added.id)
|
265
|
-
|
266
|
-
else if e.removed
|
267
|
-
# If value was removed, clear all extra inputs, then rebuild inputs for extra terms
|
268
|
-
inputs.remove()
|
269
|
-
$.each values, (i, v) =>
|
270
|
-
@add_query_input(target, base_name, i + 1, v)
|
271
|
-
|
272
|
-
setup_multi_query_input: (predicate_el, query_input, multi_id, selected_attribute) ->
|
273
|
-
base_name = predicate_el.attr('name').slice(0, -3) + '[v]'
|
274
|
-
base_id = predicate_el.attr('id').slice(0, -1)
|
275
|
-
width = query_input.width() * 2
|
276
|
-
width = 200 if width < 10
|
277
|
-
query_input.after(
|
278
|
-
$('<input class="ransack_query_multi" id="' + multi_id + '" ' +
|
279
|
-
'style="width:' + width + 'px;" ' +
|
280
|
-
'data-base-name="' + base_name + '" />'))
|
281
|
-
|
282
|
-
query_select2_id = "#s2id_#{base_id}v_0_value"
|
283
|
-
query_select2 = @element.find(query_select2_id)
|
284
|
-
|
285
|
-
# Fetch all existing values
|
286
|
-
inputs = @element.find("input[name^=\"#{base_name}\"]")
|
287
|
-
values = $.map inputs, (el) -> el.value
|
288
|
-
# Hide all query inputs
|
289
|
-
inputs.hide()
|
290
|
-
|
291
|
-
if Select2?
|
292
|
-
# Find newly created input and setup Select2
|
293
|
-
multi_query = @element.find('#' + multi_id)
|
294
|
-
|
295
|
-
# Handle association columns with AJAX autocomplete
|
296
|
-
if selected_attribute.data('ajax-url')
|
297
|
-
# Set label to single association label, if anything was selected
|
298
|
-
if query_select2.length && query_input.select2('data')
|
299
|
-
query_input_data = query_input.select2('data')
|
300
|
-
Ransack.value_field_labels[selected_attribute.val()] ||= {}
|
301
|
-
Ransack.value_field_labels[selected_attribute.val()][query_input_data.id] = query_input_data.text
|
302
|
-
|
303
|
-
@setup_select2_association(multi_query, selected_attribute, true)
|
304
|
-
|
305
|
-
else
|
306
|
-
if selected_attribute.data('select-options')
|
307
|
-
# Setup Select2 with fixed multiple options
|
308
|
-
@setup_select2_options(multi_query, selected_attribute, true)
|
309
|
-
|
310
|
-
else
|
311
|
-
# Setup Select2 with tagging support (can create options)
|
312
|
-
multi_query.select2
|
313
|
-
tags: []
|
314
|
-
tokenSeparators: [',']
|
315
|
-
formatNoMatches: (t) ->
|
316
|
-
"Add a search term"
|
317
|
-
|
318
|
-
multi_query.select2('val', values)
|
319
|
-
|
320
|
-
setup_select2_association: (query_input, selected_attribute, multiple = false) ->
|
321
|
-
selected_attribute_val = selected_attribute.val()
|
322
|
-
# Set up Select2 for query input
|
323
|
-
query_input.select2
|
324
|
-
placeholder: "Search #{selected_attribute.data('ajax-entity')}"
|
325
|
-
minimumInputLength: 1
|
326
|
-
allowClear: true
|
327
|
-
multiple: multiple
|
328
|
-
ajax:
|
329
|
-
url: selected_attribute.data('ajax-url')
|
330
|
-
dataType: 'json'
|
331
|
-
type: selected_attribute.data('ajax-type')
|
332
|
-
data: (query, page) ->
|
333
|
-
obj = {}
|
334
|
-
obj[selected_attribute.data('ajax-key')] = query
|
335
|
-
obj
|
336
|
-
results: (data, page) ->
|
337
|
-
{results: $.map(data, (text, id) -> {id: id, text: text}) }
|
338
|
-
initSelection: (element, callback) ->
|
339
|
-
data = []
|
340
|
-
unless element.val().trim() == ""
|
341
|
-
$(element.val().split(",")).each (i, val) ->
|
342
|
-
label = Ransack.value_field_labels[selected_attribute_val]?[val]
|
343
|
-
if label
|
344
|
-
data.push {id: val, text: label}
|
345
|
-
else
|
346
|
-
data.push {id: val, text: val}
|
347
|
-
if data.length
|
348
|
-
callback(multiple and data or data[0])
|
349
|
-
else
|
350
|
-
# If no label could be found, clear value
|
351
|
-
element.select2('val', '')
|
352
|
-
|
353
|
-
setup_select2_options: (query_input, selected_attribute, multiple = false) ->
|
354
|
-
query_input.select2
|
355
|
-
data: selected_attribute.data('select-options')
|
356
|
-
placeholder: "Please select a #{selected_attribute.text()}"
|
357
|
-
allowClear: true
|
358
|
-
multiple: multiple
|
359
|
-
tokenSeparators: [',']
|
360
|
-
formatNoMatches:
|
361
|
-
if selected_attribute.data('select-options')
|
362
|
-
(t) -> "No matches found."
|
363
|
-
else
|
364
|
-
(t) -> "Add a search term"
|
365
|
-
initSelection: (element, callback) ->
|
366
|
-
data = []
|
367
|
-
unless element.val().trim() == ""
|
368
|
-
$(element.val().split(",")).each (i, val) ->
|
369
|
-
selected_attribute.data('select-options').each (option, i) ->
|
370
|
-
if option.id == val
|
371
|
-
data.push {id: option.id, text: option.text}
|
372
|
-
return false # Break out of inner each loop
|
373
|
-
|
374
|
-
if data.length
|
375
|
-
callback(multiple and data or data[0])
|
376
|
-
else
|
377
|
-
element.select2('val', '')
|
378
|
-
|
379
|
-
add_query_input: (base_input, base_name, id, value) ->
|
380
|
-
base_input.after $('<input name="'+base_name+'['+id+'][value]" '+
|
381
|
-
'value="'+value+'" style="display:none;" />')
|
382
|
-
|
383
|
-
destroy_multi_input: (multi_input, selected_attribute_val) ->
|
384
|
-
multi_input.select2('destroy').remove()
|
385
|
-
# Also remove all extra inputs
|
386
|
-
base_name = multi_input.data('base-name')
|
387
|
-
inputs = @element.find("input[name^=\"#{base_name}\"]")
|
388
|
-
inputs = inputs.slice(1)
|
389
|
-
inputs.remove()
|
390
|
-
|
391
|
-
form_submit: (e) ->
|
392
|
-
@element.css({ opacity: 0.4 })
|
393
|
-
true
|
394
|
-
|
395
|
-
add_fields: (e) ->
|
396
|
-
target = $(e.currentTarget)
|
397
|
-
type = target.data("fieldType")
|
398
|
-
content = target.data("content")
|
399
|
-
new_id = new Date().getTime()
|
400
|
-
regexp = new RegExp('new_' + type, 'g')
|
401
|
-
target.before content.replace(regexp, new_id)
|
402
|
-
prev_container = target.prev()
|
403
|
-
|
404
|
-
if Select2?
|
405
|
-
@init_select2(prev_container)
|
406
|
-
|
407
|
-
if $.ransack.button_group_select?
|
408
|
-
@init_button_group_select(prev_container)
|
409
|
-
|
410
|
-
@store_initial_predicates(prev_container)
|
411
|
-
# Fire change event on any new selects.
|
412
|
-
prev_container.find("select").change()
|
413
|
-
false
|
414
|
-
|
415
|
-
remove_fields: (e) ->
|
416
|
-
target = $(e.currentTarget)
|
417
|
-
container = target.closest('.fields')
|
418
|
-
if (container.siblings().length > 1)
|
419
|
-
container.remove()
|
420
|
-
else
|
421
|
-
container.parent().closest('.fields').remove()
|
422
|
-
false
|
423
|
-
|
424
|
-
store_initial_predicates: (container) ->
|
425
|
-
# Store current predicates in data attribute
|
426
|
-
predicate_select = container.find('select.ransack_predicate').first()
|
427
|
-
unless predicate_select.data['predicates']
|
428
|
-
predicates = []
|
429
|
-
predicate_select.find('option').each (i, o) ->
|
430
|
-
o = $(o)
|
431
|
-
predicates.push [o.val(), o.text()]
|
432
|
-
predicate_select.data['predicates'] = predicates
|
433
|
-
|
434
|
-
init_select2: (container) ->
|
435
|
-
container.find('select.ransack_predicate').select2
|
436
|
-
width: '160px'
|
437
|
-
formatNoMatches: (term) ->
|
438
|
-
"Select a field first"
|
439
|
-
|
440
|
-
container.find('select.ransack_attribute').select2
|
441
|
-
width: '230px'
|
442
|
-
placeholder: "Select a Field"
|
443
|
-
allowClear: true
|
444
|
-
formatSelection: (object, container) ->
|
445
|
-
# If initializing and element is not present,
|
446
|
-
# search for option element in original select tag
|
447
|
-
if !object.element
|
448
|
-
this.element.find('option').each (i, option) ->
|
449
|
-
if option.value == object.id
|
450
|
-
object.element = option
|
451
|
-
return false
|
452
|
-
|
453
|
-
# Return 'Model: field' unless column is on root model
|
454
|
-
if $(object.element).data('root-model')
|
455
|
-
object.text
|
456
|
-
else
|
457
|
-
group_label = $(object.element).parent().attr('label')
|
458
|
-
# Avoid labels like 'Contact: Contact'
|
459
|
-
if group_label == object.text
|
460
|
-
object.text
|
461
|
-
else if group_label?
|
462
|
-
group_label + ': ' + object.text
|
463
|
-
else
|
464
|
-
object.text
|
465
|
-
|
466
|
-
@element.find('select.ransack_sort').select2
|
467
|
-
width: '230px'
|
468
|
-
placeholder: "Select a Field"
|
469
|
-
|
470
|
-
init_button_group_select: (containers) ->
|
471
|
-
containers.find('select.ransack_combinator, select.ransack_sort_order').button_group_select()
|
472
|
-
|
473
|
-
init_datetimepicker: (base_id) ->
|
474
|
-
if $.ui?.timepicker?
|
475
|
-
query_input = @element.find("input##{base_id}v_0_value")
|
476
|
-
selected_attribute = @element.find("select##{base_id}a_0_name option:selected")
|
477
|
-
|
478
|
-
# Clear any datepicker from query input first
|
479
|
-
query_input.datepicker('destroy')
|
480
|
-
|
481
|
-
datepicker_options =
|
482
|
-
changeMonth: true
|
483
|
-
constrainInput: false
|
484
|
-
dateFormat: 'yy-mm-dd'
|
485
|
-
buttonImage: "<%= asset_path('ransack_ui/calendar.png') %>"
|
486
|
-
buttonImageOnly: true
|
487
|
-
showOn: 'button'
|
488
|
-
# Always prefer custom input text over selected date
|
489
|
-
onClose: (date) -> $(this).val(date)
|
490
|
-
|
491
|
-
# Show datepicker button for dates
|
492
|
-
switch selected_attribute.data('type')
|
493
|
-
when "date"
|
494
|
-
query_input.datepicker(datepicker_options)
|
495
|
-
when "datetime"
|
496
|
-
query_input.datetimepicker(datepicker_options)
|
497
|
-
when "time"
|
498
|
-
query_input.datetimepicker $.extend(datepicker_options, {timeOnly: true})
|
499
|
-
) jQuery
|