multi-solr 01.07.02 → 01.07.03

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,24 +44,6 @@ class MultiSolr::SolrFilterCollection < MultiSolr::SolrFilterSimple
44
44
  end
45
45
 
46
46
 
47
- # Generieren Select-Box für ein Sematic-Form
48
- # Params: siehe MultiSolr::SolrFilterSimple#render_for_semantic_form
49
- # returns: HTML-Code des Input-Feldes als Select-Box
50
- def render_for_semantic_form sform, value, context=nil, form_input_options={}
51
- form_input_options = @options[:semantic_form].merge form_input_options if @options.key? :semantic_form
52
- set_label form_input_options
53
- data = self.collection_data(nil, context)
54
- html_options = form_input_options[:input_html]
55
- if html_options
56
- if html_options[:size]
57
- # size wird als max-size verstanden. wenn akt. Data-Range kleiner
58
- # ist, dann darauf reduzieren
59
- html_options[:size] = [data.size+1, html_options[:size].to_i].min
60
- end
61
- end
62
- form_input_options.merge! :collection => data
63
- sform.input "filter_#{@name}", form_input_options
64
- end
65
47
 
66
48
 
67
49
  # Ermittelt den Wertebereich entweder über die bei den Options angegebene Proc
@@ -10,25 +10,6 @@ class MultiSolr::SolrFilterDateRange < MultiSolr::SolrFilterRange
10
10
  end
11
11
 
12
12
 
13
- # Generieren der 2 Input-Felder mit der Option :as => :date_picker
14
- # Dadurch können diesem Felder das jQuery-Datepicker-UI nutzen
15
- # Params: siehe MultiSolr::SolrFilterSimple#render_for_semantic_form
16
- # returns: HTML-Code mit 2 Input-Feldern
17
- def render_for_semantic_form sform, value, context=nil, form_input_options={}
18
- set_label form_input_options
19
- label = form_input_options[:label]
20
- form_input_options.merge! :as => :date_picker
21
- from, to = extract_from_to value
22
- date_range = Struct.new("#{@name}_from".to_sym, "#{@name}_to".to_sym).new from,to
23
- sform.semantic_fields_for "filter_#{@name}", date_range do |filter_form|
24
- form_input_options[:label] = "#{label} ab"
25
- sform.template.concat filter_form.input("#{@name}_from", form_input_options)
26
- form_input_options[:label] = "#{label} bis"
27
- sform.template.concat filter_form.input("#{@name}_to", form_input_options)
28
- end
29
- end
30
-
31
-
32
13
 
33
14
  def extract_from_to_in_ISO8601 value
34
15
  from, to = extract_from_to value
@@ -14,21 +14,21 @@ class MultiSolr::SolrFilterRange < MultiSolr::SolrFilterSimple
14
14
  from, to = extract_from_to value
15
15
  return '' if from.nil? && to.nil?
16
16
  s = []
17
- s << "&gt;=#{from}" unless from.blank?
18
- s << "&lt;=#{to}" unless to.blank?
19
- s.join(' und ')
17
+ s << "von #{from}" unless from.blank?
18
+ s << "bis #{to}" unless to.blank?
19
+ s.join(' ')
20
20
  end
21
21
 
22
22
 
23
23
 
24
24
  # Aus dem 'value' von und bis extrahieren
25
25
  # Params:
26
- # value: Hash mit from- und to-Datumsangabe (mit Filternamen als Prefix)
27
- # Beispiel: { 'create_date_from' => '2011-01-01', 'create_date_to' => '2011-06-01' }
26
+ # value: Hash mit from- und to-Werten
27
+ # Beispiel: { 'from' => '2011-01-01', 'to' => '2011-06-01' }
28
28
  # returns: Array mit von und bis ['2011-01-01', '2011-06-01']
29
29
  def extract_from_to value
30
30
  return nil if value.blank? || !value.is_a?(Hash) || value.empty?
31
- [ value["#{@name}_from"], value["#{@name }_to"] ]
31
+ [ value["from"], value["to"] ]
32
32
  end
33
33
 
34
34
  end
@@ -57,38 +57,10 @@ class MultiSolr::SolrFilterSimple
57
57
 
58
58
 
59
59
 
60
- # Konvertieren der Wertes in HTML-String für ein Semantic-Form
61
- # Params:
62
- # sform: das Semantic-Form-Object
63
- # value: der konkrete Wert für diesen Filter
64
- # context: optionaler Hash mit dem Such-Context z.B. mit;
65
- # :solr_searcher_class => Classe des konkreten Searchers
66
- # :force_query_params => Parameter für die SolR-Force-Query
67
- # form_input_options: optionale Formula-Input-Feld-Options.
68
- # Diese werden 1:1 an die Semantic-Form-Methode 'input' weitergegeben
69
- #
70
- # returns: HTML-Code des Input-Feldes
71
- def render_for_semantic_form sform, value, context=nil, form_input_options={}
72
- form_input_options = @options[:semantic_form].merge form_input_options if @options.key? :semantic_form
73
- set_label form_input_options
74
- sform.input "filter_#{@name}", form_input_options
75
- end
76
-
77
-
78
60
  def label
79
61
  I18n.t("solr_search.#{@name}", :default => @name.to_s)
80
62
  end
81
63
 
82
- protected
83
-
84
- # Setzt in die angegebebn 'form_input_options' das Label (nur wenn in diesen noch kein :label definiert ist).
85
- # Dieses wird gebildet aus den Filter-Namen unter Nutzung von I18n mit den Prefiy 'solr_search.'.
86
- # Beispiel:
87
- # filter-name = :lkz => I18n.t('solr_search.lkz')
88
- def set_label form_input_options
89
- form_input_options.merge!(:label => self.label) unless form_input_options.key?(:label)
90
- end
91
-
92
64
  end
93
65
 
94
66
 
@@ -1,3 +1,3 @@
1
1
  module MultiSolr
2
- VERSION = "01.07.02"
2
+ VERSION = "01.07.03"
3
3
  end
@@ -7,15 +7,15 @@ describe MultiSolr::SolrFilterRange do
7
7
 
8
8
  context 'render_value' do
9
9
  it "should return '>= 10' if value from is 10" do
10
- subject.render_value('test_from' => 10).should == '&gt;=10'
10
+ subject.render_value('from' => 10).should == 'von 10'
11
11
  end
12
12
 
13
13
  it "should return '<= 20' if value to is 20" do
14
- subject.render_value('test_to' => 20).should == '&lt;=20'
14
+ subject.render_value('to' => 20).should == 'bis 20'
15
15
  end
16
16
 
17
17
  it "should return '>=10 und <= 20' if value from is 10 and to is 20" do
18
- subject.render_value('test_from' => 10, 'test_to' => 20).should == '&gt;=10 und &lt;=20'
18
+ subject.render_value('from' => 10, 'to' => 20).should == 'von 10 bis 20'
19
19
  end
20
20
 
21
21
  it "should return empty string if no value given" do
@@ -27,15 +27,15 @@ describe MultiSolr::SolrFilterRange do
27
27
 
28
28
  context 'build_solr_query' do
29
29
  it do
30
- subject.build_solr_query('test_from' => 10).should == 'test:[10 TO *]'
30
+ subject.build_solr_query('from' => 10).should == 'test:[10 TO *]'
31
31
  end
32
32
 
33
33
  it do
34
- subject.build_solr_query('test_to' => 20).should == 'test:[* TO 20]'
34
+ subject.build_solr_query('to' => 20).should == 'test:[* TO 20]'
35
35
  end
36
36
 
37
37
  it do
38
- subject.build_solr_query('test_from' => 10, 'test_to' => 20).should == 'test:[10 TO 20]'
38
+ subject.build_solr_query('from' => 10, 'to' => 20).should == 'test:[10 TO 20]'
39
39
  end
40
40
  end
41
41
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi-solr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 7
9
- - 2
10
- version: 01.07.02
9
+ - 3
10
+ version: 01.07.03
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bernd Ledig
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-01-22 00:00:00 Z
18
+ date: 2013-01-24 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rsolr