jakewendt-active_record_sunspotter 4.2.3 → 4.3.0

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: 6810cf2b3c02218cc34009c92e9e1ecb08660ea0
4
- data.tar.gz: 3e9be60fba6f8cae035a2db6f11811c8defd2213
3
+ metadata.gz: 35f83b3ce50782184ab2796a0494209427149d6a
4
+ data.tar.gz: b8d8f067f22acdf040dd60f403242a5a4480fcbc
5
5
  SHA512:
6
- metadata.gz: f011ea06d05c0627205cca1ec6b7989d3b2b22c62fb44af5f37789c6bb55ea610bb7b6d13bcca21171d9ae998acd11a757e42de0b270ba44fb5615bb5394e1b3
7
- data.tar.gz: 2f2515f9c60cd4cbd86601ca5b94b1e075d0d046862cd3abd57d56d64fefbbeda8c890518ee06b9a6cd1d9bd71f614ce327e3bb0f464a6059ff3b077551350b3
6
+ metadata.gz: adc093eabbd67feff1b5b7e6cf4cccd8b71f1cf6a7ea72dc11e911e15c485142783ae6867a7dcb1e027cfa3174234c09b7b656e31dc6c523f7c383780978777f
7
+ data.tar.gz: e3208e3f2211fe1596df752e4fe7634edeaf8c9b98fd675bfe4cd92096252d7858959930b697cca6fbfe67929164a2cafb1a6e26ac4e027e2073b2a04e2a0ac9
@@ -77,6 +77,9 @@ module ActiveRecordSunspotter::SearchSunspotFor
77
77
 
78
78
  end # if params[p]
79
79
 
80
+ #if f.type == :dynamic
81
+ # dynamic f.namespace { facet f.
82
+ #else
80
83
  # facet.sort
81
84
  # This param determines the ordering of the facet field constraints.
82
85
  # count - sort the constraints by count (highest count first)
@@ -90,6 +93,7 @@ module ActiveRecordSunspotter::SearchSunspotFor
90
93
  # put this inside the else condition as the if block is
91
94
  # for ranges and it calls facet
92
95
  facet p.to_sym, :sort => :index if f.facetable
96
+ #end
93
97
 
94
98
  end
95
99
 
@@ -4,6 +4,7 @@ class ActiveRecordSunspotter::SunspotColumn < OpenStruct
4
4
  def initialize(*args)
5
5
  # some sensible defaults
6
6
  default_options = {
7
+ :group => 'Main',
7
8
  :type => :string,
8
9
  :orderable => true,
9
10
  :facetable => false,
@@ -16,13 +17,7 @@ class ActiveRecordSunspotter::SunspotColumn < OpenStruct
16
17
  options[:name] = args.first.to_s
17
18
  end
18
19
 
19
- # if( options[:type] == :null_yndk_string ) && options[:meth].blank?
20
- # options[:meth] = ->(s){ YNDK[s.send(:name)]||'NULL' }
21
- # options[:type] = :string
22
- # end
23
-
24
20
  default_options.update(options)
25
- # default_options[:orderable] = false if options[:type] == :multistring
26
21
  default_options[:orderable] = false if options[:multiple]
27
22
  default_options[:filterable] = true if options[:facetable]
28
23
  super default_options
@@ -89,8 +89,7 @@ module ActiveRecordSunspotter::SunspotHelper
89
89
  next if row.value.blank?
90
90
 
91
91
  label = if col.ranges
92
- col.ranges.detect{|r|
93
- r[:range].to_s == row.value.to_s }[:name] || 'RANGE NOT FOUND'
92
+ col.ranges.detect{|r| r[:range].to_s == row.value.to_s }[:name] || 'RANGE NOT FOUND'
94
93
  else
95
94
  row.value
96
95
  end
@@ -6,19 +6,23 @@ module ActiveRecordSunspotter::Sunspotability
6
6
  #
7
7
  # MUST delay execution of code until included as cattr_accessor is ActiveRecord specific
8
8
  #
9
- cattr_accessor :all_sunspot_columns
10
- self.all_sunspot_columns = [] # order is only relevant to the facets
9
+ cattr_accessor :sunspot_columns
10
+ cattr_accessor :sunspot_column_groups
11
+ self.sunspot_columns = [] # order is only relevant to the facets
12
+ self.sunspot_column_groups = []
11
13
  end
12
14
  end
13
15
 
14
16
  module ClassMethods
15
17
 
16
18
  def add_sunspot_column(*args)
17
- all_sunspot_columns.push( ActiveRecordSunspotter::SunspotColumn.new( *args ) )
19
+ new_column = ActiveRecordSunspotter::SunspotColumn.new( *args )
20
+ sunspot_columns.push( new_column )
21
+ sunspot_column_groups.push( new_column.group ) unless sunspot_column_groups.include?( new_column.group )
18
22
  end
19
23
 
20
24
  def sunspot_orderable_columns
21
- all_sunspot_columns.select{|c|c.orderable}
25
+ sunspot_columns.select{|c|c.orderable}
22
26
  end
23
27
 
24
28
  def sunspot_orderable_column_names
@@ -26,7 +30,7 @@ module ActiveRecordSunspotter::Sunspotability
26
30
  end
27
31
 
28
32
  def sunspot_default_columns
29
- all_sunspot_columns.select{|c|c.default}
33
+ sunspot_columns.select{|c|c.default}
30
34
  end
31
35
 
32
36
  def sunspot_default_column_names
@@ -34,23 +38,26 @@ module ActiveRecordSunspotter::Sunspotability
34
38
  end
35
39
 
36
40
  def sunspot_all_filters
37
- all_sunspot_columns.select{|c|c.filterable}
41
+ sunspot_columns.select{|c|c.filterable}
38
42
  end
39
43
 
40
44
  # in the order that they will appear on the page
41
45
  def sunspot_all_facets
42
- all_sunspot_columns.select{|c|c.facetable}
46
+ sunspot_columns.select{|c|c.facetable}
43
47
  end
44
48
  def sunspot_all_facet_names
45
49
  sunspot_all_facets.collect(&:name)
46
50
  end
47
51
 
48
- def sunspot_columns
49
- all_sunspot_columns
52
+ def all_sunspot_columns
53
+ sunspot_columns
50
54
  end
55
+ # def sunspot_columns
56
+ # all_sunspot_columns
57
+ # end
51
58
 
52
59
  def sunspot_column_names
53
- all_sunspot_columns.collect(&:name)
60
+ sunspot_columns.collect(&:name)
54
61
  end
55
62
 
56
63
  def sunspot_available_column_names
@@ -58,21 +65,57 @@ module ActiveRecordSunspotter::Sunspotability
58
65
  end
59
66
 
60
67
  def sunspot_date_columns
61
- all_sunspot_columns.select{|c|c.type == :date }
68
+ sunspot_columns.select{|c|c.type == :date }
69
+ end
70
+
71
+ def sunspot_columns_in_group(group)
72
+ sunspot_columns.select{|c|c.group == group }
73
+ end
74
+ def sunspot_column_names_in_group(group)
75
+ sunspot_columns.select{|c|c.group == group }.collect(&:name).sort
62
76
  end
63
77
 
64
78
  def searchable_plus(&block)
65
79
  searchable do
66
- #
67
- # Trying to simplify. Simplify? Minimize?
68
- # Will I need all of the above methods after this is done?
69
- #
70
- # .select{|c| c.facetable }
71
- # or just use "sunspot_all_facets" instead of "all_sunspot_columns"
72
- # WAIT! If aren't indexed, then can't be sorted on.
73
- all_sunspot_columns.select{|c| ![:boolean,:nulled_string].include?(c.type) }.each{|c|
80
+
81
+ sunspot_columns.select{|c| ![:boolean].include?(c.type) }.each{|c|
74
82
  options = {}
75
83
  options[:multiple] = true if( c.multiple )
84
+ options[:trie] = true if( [:integer,:float,:time].include?(c.type) )
85
+ # if c.type == :dynamic
86
+ # dynamic_string c.namespace do
87
+ # c.kvp.call(self)
88
+ # end
89
+ # else
90
+ send( c.type, c.name, options ){
91
+ c.hash_table.has_key?(:meth) ? c.meth.call(self) : send( c.name )
92
+ }
93
+ # end
94
+ }
95
+
96
+ #
97
+ # yield if block_given?
98
+ # yield block if block_given?
99
+ #
100
+ #
101
+ # 20140815 - Something like this is probably what is needed
102
+ # could then possibly just override the searchable method.
103
+ #
104
+ # instance_exec(&block)
105
+ #
106
+
107
+ end
108
+ #
109
+ # this works, but why can't I just yield inside the block
110
+ #
111
+ searchable &block if block_given?
112
+
113
+ end
114
+
115
+ end # module ClassMethods
116
+
117
+ end
118
+ __END__
76
119
  #
77
120
  # I don't think that trie works with :long or :double
78
121
  # I got this when I tried a :double
@@ -81,7 +124,8 @@ module ActiveRecordSunspotter::Sunspotability
81
124
  # I found documentation that says that Lucene/Solr should work for longs and doubles?
82
125
  #
83
126
  #
84
- # these are missing in sunspot 2.0. I added them in my taxonomy app
127
+ # these are missing in sunspot 2.0. I added them in my taxonomy app.
128
+ # Still not in 2.1.1 sunspot-2.1.1/lib/sunspot/type.rb
85
129
  #
86
130
  # module Sunspot::Type
87
131
  # class TrieDoubleType < DoubleType
@@ -97,29 +141,10 @@ module ActiveRecordSunspotter::Sunspotability
97
141
  # end
98
142
  #
99
143
  # options[:trie] = true if( [:integer,:long,:double,:float,:time].include?(c.type) )
100
- options[:trie] = true if( [:integer,:float,:time].include?(c.type) )
101
- send( c.type, c.name, options ){
102
- c.hash_table.has_key?(:meth) ? c.meth.call(self) : send( c.name )
103
- }
104
- #
105
- # booleans? nulled_strings?
106
- #
107
- }
108
-
109
-
110
- # yield if block_given?
111
- # yield block if block_given?
112
- end
113
-
114
- # this works, but why can't I just yield inside the block
115
- searchable &block if block_given?
116
-
117
- end
118
144
 
119
- end # module ClassMethods
120
145
 
121
- end
122
- __END__
146
+
147
+
123
148
 
124
149
  What's the point of adding a column to the index that isn't faceted?
125
150
  It would basically just be useful as a column, which is why I was
@@ -10,10 +10,12 @@ jQuery(function(){
10
10
  jQuery(this).parent().next().toggle('blind',500);
11
11
  jQuery(this).prev().toggleClass('ui-icon-triangle-1-e');
12
12
  jQuery(this).prev().toggleClass('ui-icon-triangle-1-s');
13
+ // jQuery(this).parent().toggleClass('open');
13
14
  return false;
14
15
  });
15
16
 
16
- jQuery( "#selected_columns, #unselected_columns" ).sortable({
17
+ // jQuery( "#selected_columns, #unselected_columns" ).sortable({
18
+ jQuery( ".selectable_columns" ).sortable({
17
19
  connectWith: ".selectable_columns"
18
20
  }).disableSelection();
19
21
 
@@ -123,6 +123,7 @@ tr:nth-child(2n+1) { background-color: #F5F1E8; }
123
123
  display:block;
124
124
  padding: 5px;
125
125
  border-top: 1px solid silver;
126
+ border-left: 1px solid silver;
126
127
  background-color:#EEE;
127
128
  text-align: left;
128
129
  * {
@@ -139,6 +140,7 @@ tr:nth-child(2n+1) { background-color: #F5F1E8; }
139
140
  }
140
141
  div.facet_field {
141
142
  display:none;
143
+ margin-left: 5px;
142
144
  ul {
143
145
  padding-left: 35px;
144
146
  /* I want a 10px padding, but also want the wordwrap indented
@@ -1,8 +1,13 @@
1
+ <hr/>
1
2
  <div class="facet_toggle">
2
- <span class="ui-icon ui-icon-triangle-1-e">&nbsp;</span><a href="javascript:void(0)">Column Selection</a>
3
- </div>
4
- <div id='columns' class='facet_field'>
5
- <p>Used Columns</p>
3
+ <span class="ui-icon ui-icon-triangle-1-e">&nbsp;</span
4
+ ><a href="javascript:void(0)">Column Selection</a>
5
+ </div><!-- div class="facet_toggle" -->
6
+
7
+ <!--<div id='columns' class='facet_field'> Is the id needed here? Doesn't appear so. -->
8
+ <div class='facet_field'>
9
+ <p>Selected Columns</p>
10
+ <!-- Is id needed for select all AND MORE IMPORTANTLY THE CONVERSION TO PARAMS QUERY -->
6
11
  <ul id="selected_columns" class="selectable_columns">
7
12
  <% columns.each do |column| %>
8
13
  <%# NEED to find a way to use the id, but already using id matching these
@@ -10,15 +15,44 @@
10
15
  <%= content_tag(:li, column )%>
11
16
  <% end %>
12
17
  </ul>
13
- <p>Unused Columns</p>
14
- <ul id="unselected_columns" class="selectable_columns">
15
- <% (@sunspot_search_class.sunspot_available_column_names - columns).each do |column| %>
16
- <%# NEED to find a way to use the id, but already using id matching these
17
- column names in the facet selectors %>
18
- <%= content_tag(:li, column )%>
18
+
19
+ <% if @sunspot_search_class.sunspot_column_groups.length > 1 %>
20
+ <p>Available Columns (now grouped)</p>
21
+ <% else %>
22
+ <p>Available Columns</p>
23
+ <% end %>
24
+ <!--<ul id="unselected_columns" class="selectable_columns"> id needed for select all-->
25
+
26
+ <% @sunspot_search_class.sunspot_column_groups.each do |group| %>
27
+
28
+ <% if @sunspot_search_class.sunspot_column_groups.length > 1 %>
29
+ <div class="facet_toggle">
30
+ <span class="ui-icon ui-icon-triangle-1-e">&nbsp;</span
31
+ ><a href="javascript:void(0)"><%= group %></a>
32
+ </div><!-- div class="facet_toggle" -->
33
+ <div class='facet_field'>
19
34
  <% end %>
20
- </ul>
35
+
36
+ <ul class="selectable_columns">
37
+ <% @sunspot_search_class.sunspot_column_names_in_group(group).each do |column| %>
38
+ <% unless columns.include?( column ) %>
39
+ <%# NEED to find a way to use the id, but already using id matching these
40
+ column names in the facet selectors %>
41
+ <%# 20141114 - WHY? I write comments like these without reasons? %>
42
+ <%= content_tag(:li, column )%>
43
+ <% end %><%# unless columns.include?( column ) %>
44
+ <% end %>
45
+ </ul>
46
+
47
+ <% if @sunspot_search_class.sunspot_column_groups.length > 1 %>
48
+ </div><!-- div class='facet_field' -->
49
+ <% end %>
50
+
51
+ <% end %><%# @sunspot_search_class.sunspot_column_groups.each do |group| %>
52
+
53
+ <!--
21
54
  <p><a id='select_all_columns' href="javascript:void(0)">Select All</a>&nbsp;
22
55
  <a id='unselect_all_columns' href="javascript:void(0)">Unselect All</a></p>
23
56
  <p>too many columns can result in a uri which is too large.</p>
57
+ -->
24
58
  </div>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jakewendt-active_record_sunspotter
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.3
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - George 'Jake' Wendt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-04 00:00:00.000000000 Z
11
+ date: 2014-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sunspot_rails