smart_search 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,46 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class SearchController < ApplicationController
3
+
4
+ def all
5
+
6
+ if params[:search]
7
+ @query = params[:search][:query]
8
+ else
9
+ @query = params[:query]
10
+ end
11
+
12
+ unless @query.blank?
13
+ team = current_user.get_team_tree(:get_ids => true )
14
+ @results = []
15
+ SmartSearch::Config.get_search_models.each do |m|
16
+ if params[:only].nil? || params[:only] == m.to_s.split("::").last
17
+ #if (admin? || backoffice? || controller? || backoffice_vertrieb?) || !m.column_names.include?("user_id") || SmartSearch::Config.get_public_models.include?(m)
18
+
19
+ if SmartSearch::Config.get_public_models.include?(m)
20
+ @results << m.find_by_tags(@query)
21
+ elsif m.column_names.include?("user_id")
22
+ @results << m.find_by_tags(@query, {:user_id => team})
23
+ elsif m.column_names.include?("account_id")
24
+ @results << m.find_by_tags(@query, {:account_id => current_user.account_id})
25
+ else
26
+
27
+ end
28
+ end
29
+ end
30
+
31
+ @empty = @results.flatten.empty?
32
+
33
+ if request.xhr?
34
+ render :partial => "/search/results_small", :locals => {:results => @results, :no_limit => !params[:only].nil?}, :layout => params[:layout]
35
+ end
36
+ else
37
+ render :text => "Bitte geben Sie einen Suchbegriff ein"
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
44
+
45
+
46
+ # (admin? || backoffice? || controller? || backoffice_vertrieb?) ||
@@ -0,0 +1,25 @@
1
+ <div id="smartsearch-results-container-small">
2
+ <div class="bold teaser">
3
+ <%= "keine " if @empty %>Suchergebnisse für
4
+ <%= form_for :search, :url => {:controller => "search", :action => "all", :layout => "info_overlay"}, :html => default_ajax_link(:update => FOOTER_SEARCH_RESULTS_ID).merge!(:style => "display: inline;") do |f| %>
5
+ <%= f.text_field :query, :value => "Suchbegriff eingeben", :value => @query, :style => "width: 25%" %>
6
+ <% end %>
7
+ </div>
8
+ <% @results.each do |results| %>
9
+ <% limit = no_limit ? results.size : 5 %>
10
+ <% unless results.empty? %>
11
+ <h3 class="result-small-header cf"><%= "Suchergebnisse in #{(results[0].class.name+'_results').to_label}" %> <%= " - Zeige #{limit} von #{results.size}" if (results.size > limit) %> <%#= link_to_if(results.size > limit, "Alle (#{results.size})", ) %>
12
+ <% if (results.size > limit) %>
13
+ <span class="metainfo"><%= link_to "Zeige alle Ergebnisse", { :controller => "/search", :action => "all", :only => results[0].class.name, :query => (params[:search][:query] rescue params[:query]), :layout => params[:layout]}, default_ajax_link(:update => FOOTER_SEARCH_RESULTS_ID, :load_message => true, :class => "next-link") %></span>
14
+ <% elsif no_limit %>
15
+ <span class="metainfo"><%= link_to "zurück", { :controller => "/search", :action => "all", :query => (params[:search][:query] rescue params[:query]), :layout => params[:layout]}, default_ajax_link(:update => FOOTER_SEARCH_RESULTS_ID, :load_message => true, :class => "prev-link") %></span>
16
+ <% end %>
17
+ </h3>
18
+ <% results.first(limit).each do |r| %>
19
+ <div class="result-block-small"><%= render :partial => r.result_template_path, :locals => {:result => r, :small => true} %></div>
20
+ <% end %>
21
+ <div class="seperator small">&nbsp;</div>
22
+ <% end %>
23
+ <% end %>
24
+
25
+ </div>
@@ -0,0 +1,15 @@
1
+ <div class="search-">
2
+ <%= page_title "Suchergebnisse für '#{@query}'" %>
3
+
4
+ <div id="smartsearch-results-container">
5
+ <% @results.each do |results| %>
6
+ <% if results.empty? %>
7
+ <% else %>
8
+ <h3>Suchergebnisse in <%= "#{results[0].class.name}_results".to_label %> (<%= results.size %>)</h3>
9
+ <% results.each do |r| %>
10
+ <%= render :partial => r.result_template_path, :locals => {:result => r } %>
11
+ <% end %>
12
+ <%= seperator %>
13
+ <% end %>
14
+ <% end %>
15
+ </div>
@@ -0,0 +1,8 @@
1
+ <div class="spacer highlighter">
2
+ <div class="field-container-4-cols cf">
3
+ <div class="container"><%= link_to result.company.name, {:controller => "/companies", :action => "show", :id => result.company.id}, default_ajax_link() %><br /></div>
4
+ <div class="center-left"><%= result.name %> (<%= result.art %>)</div>
5
+ <div class="center-right"><%= result.phone %></div>
6
+ <div class="container"><%= email_link(result.email) %></div>
7
+ </div>
8
+ </div>
@@ -0,0 +1,29 @@
1
+ <% small ||= false %>
2
+
3
+ <% if small == false %>
4
+ <div class="highlighter <%= cycle('odd', 'even', :name => "customer_results") %> <%= result.css_class %>">
5
+ <b><%= link_to result.name, {} %></b><br />
6
+ <div class="field-container-4-cols cf">
7
+ <div class="container">
8
+ <div class="metainfo">Status</div>
9
+ <div><%= result.type(:name) %></div>
10
+ <div><%= result.status %></div>
11
+ </div>
12
+ <div class="center-left">
13
+ <div class="metainfo">Beginn/Ende</div>
14
+ <div>von <%= result.starts_at.to_de %></div>
15
+ <div>bis <%= result.ends_at.to_de %></div>
16
+ </div>
17
+ <div class="center-right">
18
+ <div class="metainfo">Berater</div>
19
+ <div><%= result.user.full_name %></div>
20
+ </div>
21
+ <div class="container">
22
+ </div>
23
+ </div>
24
+ </div>
25
+ <% else %>
26
+ <%= link_to result.name, {} %> (<span class="metainfo"><%= result.user.full_name rescue "-" %></span>)
27
+ <br />
28
+ <%= result.type(:name) %> | <%= result.status %> | <%= result.starts_at.to_de %>
29
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <% small ||= false %>
2
+
3
+ <% if small == false %>
4
+ <div class="highlighter <%= cycle('odd', 'even', :name => "company_results") %>">
5
+ <b><%= link_to result.name, {} %></b><br />
6
+ <div class="field-container-4-cols cf">
7
+ <div class="container">
8
+ <div class="metainfo">Anbindung</div>
9
+ <div><%= result.direct ? "Direktanbindung" : "keine Direktanbindung" %></div>
10
+ </div>
11
+ <div class="center-left">
12
+ <div class="metainfo">VP-Nr</div>
13
+ <div><%= result.direct ? result.vp_nr : "keine VP-Nummer" %></div>
14
+ </div>
15
+ <div class="center-right">
16
+
17
+ </div>
18
+ <div class="container">
19
+ </div>
20
+ </div>
21
+ </div>
22
+ <% else %>
23
+ <%= link_to result.name, {:controller => "/companies", :action => "show", :id => result.id}, default_ajax_link() %><br />
24
+ <%#= result.direct ? "Direktanbindung" : "keine Direktanbindung" %> / <%#= result.direct ? "VP-Nr: #{result.vp_nr}" : "keine VP-Nummer" %>
25
+ <% end %>
@@ -0,0 +1,26 @@
1
+ <div class="highlighter <%= cycle('odd', 'even', :name => "customer_results") %>">
2
+ <b><%= link_to result.customer.full_name, :controller => "/concepts", :action => "data_form", :concept_id => result.id %></b><br />
3
+ <div class="field-container-4-cols cf">
4
+ <div class="container">
5
+ <div class="metainfo">Status</div>
6
+ <div>
7
+ <% if result.firma_concept %>
8
+ Firmenkonzept
9
+ <% elsif result.family_concept %>
10
+ Familienkonzept
11
+ <% else %>
12
+ Standardkonzept
13
+ <% end %>
14
+ <%= progress_bar(result.ist_concept.progress_percent) %>
15
+ </div>
16
+ </div>
17
+ <div class="center-left">
18
+ <div class="metainfo">Datum</div>
19
+ <div>erstellt: <%= result.created_at.to_de %></div>
20
+ </div>
21
+ <div class="center-right">
22
+ </div>
23
+ <div class="container">
24
+ </div>
25
+ </div>
26
+ </div>
@@ -0,0 +1,51 @@
1
+ <% small ||= false %>
2
+
3
+ <% if small == false %>
4
+ <div class="highlighter <%= cycle('odd', 'even', :name => "customer_results") %>">
5
+ <b><%= link_to result.full_name, :controller => "/customers", :action => "show", :id => result.id %></b><br />
6
+ <div><%= result.notes.clear_html rescue nil %></div>
7
+ <div class="field-container-4-cols cf">
8
+ <div class="container">
9
+ <div class="metainfo">Kontaktdaten</div>
10
+ <div><%= result.personal_data.phone %></div>
11
+ <div><%= result.personal_data.mobile %></div>
12
+ <div><%= result.personal_data.email %></div>
13
+ </div>
14
+ <div class="center-left">
15
+ <div class="metainfo">Anschrift</div>
16
+ <div><%= result.personal_data.adress %></div>
17
+ </div>
18
+ <div class="center-right">
19
+ <div class="metainfo">Persönliches</div>
20
+ <div>geb. <%= result.personal_data.birthday %></div>
21
+ </div>
22
+ <div class="container">
23
+ <div class="metainfo">
24
+ <% if result.concepts.empty? %>
25
+ keine Konzepte
26
+ <% else %>
27
+ <%= result.ist_concepts.size %> Konzept(e)
28
+ <% end %>
29
+ </div>
30
+ <% result.ist_concepts.each do |concept| %>
31
+ <% if concept.firma_concept %>
32
+ Firmenkonzept
33
+ <% elsif concept.family_concept %>
34
+ Familienkonzept
35
+ <% else %>
36
+ Standardkonzept
37
+ <% end %> (<%= concept.created_at.to_de %>)
38
+ <%= progress_bar(concept.progress_percent, :size => :small) %>
39
+ <% end %>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ <% else %>
44
+ <div class="field-container-4-cols highlighter cf">
45
+ <div class="container"><%= link_to(result.full_name, {:controller => "/customers", :action => "customer_detail_ajax", :id => result.id, :layout => "ajax_overlay"}, default_ajax_link()) %> </div>
46
+ <div class="center-left metainfo"><%= result.user.full_name rescue "-" %></div>
47
+ <div class="center-right"></div>
48
+ <div class="container"></div>
49
+ </div>
50
+
51
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render :partial => "/smart/search/results/customer", :locals => {:result => result, :small => small} %>
@@ -0,0 +1 @@
1
+ <%= render :partial => "/smart/search/results/customer", :locals => {:result => result} %>
@@ -0,0 +1,37 @@
1
+ <% small ||= false %>
2
+
3
+ <% if small == false %>
4
+ <div class="highlighter <%= cycle('odd', 'even', :name => "customer_results") %>">
5
+ <b><%= link_to result.tarif_name, {:controller => "/products", :action => "show", :id => result.id } %></b><br />
6
+ <div><%= result.tarif_base.bemerkung.clear_html rescue nil %></div>
7
+ <div class="field-container-4-cols cf">
8
+ <div class="container">
9
+ <div class="metainfo">Gesellschaft</div>
10
+ <div><%= result.company.name %></div>
11
+ </div>
12
+ <div class="center-left">
13
+ <div class="metainfo">Sparte</div>
14
+ <div><%= result.product_category.name %></div>
15
+ </div>
16
+ <div class="center-right">
17
+ <div class="metainfo">Leistung</div>
18
+ <%= progress_bar(result.must_haves_ratio) %>
19
+ </div>
20
+ <div class="container"></div>
21
+ </div>
22
+ <div class="field-container-4-cols cf">
23
+ <div class="left">
24
+
25
+ </div>
26
+ <div class="right"></div>
27
+ </div>
28
+ </div>
29
+ <% else %>
30
+ <div class="field-container-4-cols spacer-small highlighter cf">
31
+ <div class="container"><%= link_to "#{result.company.name}", {:controller => "/products", :action => "show", :id => result.id }, default_ajax_link() %><br /></div>
32
+ <div class="center-left"><%= link_to "#{result.tarif_name}", {:controller => "/products", :action => "show", :id => result.id }, default_ajax_link() %><br /></div>
33
+ <div class="center-right"><%= result.sparte %></div>
34
+ <div class="container"></div>
35
+ </div>
36
+
37
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <% small ||= false %>
2
+ <div class="field-container-2-cols highlighter cf">
3
+ <div class="left">
4
+ <%= link_to_file result %>
5
+ </div>
6
+ <div class="right"><%= result.category.name %></div>
7
+ </div>
8
+
@@ -0,0 +1,8 @@
1
+ <% small ||= false %>
2
+
3
+ <div>
4
+ <%= link_to result.title, {:controller => "/topics", :action => "show", :id => result.id, :forum_id => result.forum_id}%>
5
+ <div class="metainfo small">
6
+ <%= result.search_tags.match(/.{1,25}#{@query}.{1,25}/i) %>...
7
+ </div>
8
+ </div>
@@ -0,0 +1 @@
1
+ <%= render :partial => "/smart/search/results/umsatz_refactor", :locals => {:result => result} %>
@@ -0,0 +1,4 @@
1
+ <ul class="icon-list no-margin">
2
+ <li><%= link_to "#{result.customer_name} - #{result.tarif_name}", {:controller => "/umsatzs", :action => "details", :id => result.id}, :class => result.status_icon %> (<span class="metainfo"><%= result.user.full_name rescue "-" %></span>)</li>
3
+ <li>Vers-Nr.: <%= result.vers_nr %> / Beginn: <%= result.tarif.beginn.to_de rescue "-" %></li>
4
+ </ul>
@@ -0,0 +1 @@
1
+ <%= render :partial => "/smart/search/results/umsatz_refactor", :locals => {:result => result} %>
@@ -0,0 +1,3 @@
1
+ <%= link_to(result.full_name, {:controller => "/users", :action => "ajax_me", :id => result.id, :layout => "ajax_overlay"}, default_ajax_link()) %>
2
+ <span class="position-display"><%= result.status == "user" ? result.position.abbr : result.status.to_label %></span>
3
+ (<span class="metainfo"><%= result.personal_data.telefonnummer(true) rescue "-" %></span>)
@@ -0,0 +1,9 @@
1
+ <% small ||= false %>
2
+
3
+ <div>
4
+ <%= link_to result.title, result.wiki_fancy_url %>
5
+ <div class="metainfo small">
6
+ <%= result.subtitle %><br />
7
+ <%= result.text.clear_html.match(/.{1,25}#{@query}.{1,25}/i) %>...
8
+ </div>
9
+ </div>
@@ -0,0 +1,8 @@
1
+ # -*- encoding : utf-8 -*-
2
+ Rails.application.routes.draw do
3
+
4
+ #=== Search Routing
5
+ get "/find", :controller => "search", :action => "all"
6
+ post "/find", :controller => "search", :action => "all"
7
+
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,14 +12,33 @@ cert_chain: []
12
12
  date: 2013-03-11 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Adds easy to use full-text search to ActiveRecord models, based the attributes
15
- you want to search.
15
+ you want to search. Including Controllers
16
16
  email: it-support@friends-systems.de
17
17
  executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
- - lib/smart_search.rb
22
21
  - lib/add_search_tags.rb
22
+ - lib/smart_search.rb
23
+ - app/controllers/search_controller.rb
24
+ - app/views/search/_results_small.html.erb
25
+ - app/views/search/all.html.erb
26
+ - app/views/search/results/_ansprechpartner.html.erb
27
+ - app/views/search/results/_calendar_entry.html.erb
28
+ - app/views/search/results/_company.html.erb
29
+ - app/views/search/results/_concept.html.erb
30
+ - app/views/search/results/_customer.html.erb
31
+ - app/views/search/results/_family.html.erb
32
+ - app/views/search/results/_firma.html.erb
33
+ - app/views/search/results/_product.html.erb
34
+ - app/views/search/results/_smart_document.html.erb
35
+ - app/views/search/results/_topic.html.erb
36
+ - app/views/search/results/_umsatz.html.erb
37
+ - app/views/search/results/_umsatz_refactor.html.erb
38
+ - app/views/search/results/_umsatz_storno.html.erb
39
+ - app/views/search/results/_user.html.erb
40
+ - app/views/search/results/_wiki_page.html.erb
41
+ - config/routes.rb
23
42
  homepage: https://rubygems.org/gems/smart_search
24
43
  licenses: []
25
44
  post_install_message: