has_vcards 0.17.2 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/directory_lookup_controller.rb +17 -0
- data/app/models/vcard/directory_lookup.rb +2 -1
- data/app/views/vcards/_address.html.haml +1 -1
- data/app/views/vcards/_directory_lookup.html.haml +4 -4
- data/app/views/vcards/_directory_matches.html.haml +1 -1
- data/app/views/vcards/directory_lookup.js.erb +1 -1
- data/config/routes.rb +3 -0
- data/lib/has_vcards/version.rb +1 -1
- metadata +6 -5
@@ -0,0 +1,17 @@
|
|
1
|
+
class DirectoryLookupController < ApplicationController
|
2
|
+
def search
|
3
|
+
@selector = params[:selector]
|
4
|
+
vcard_params = extract_vcard_params(params, @selector)
|
5
|
+
|
6
|
+
@vcard = Vcard.new(vcard_params)
|
7
|
+
render 'vcards/directory_lookup'
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
def extract_vcard_params(params, selector)
|
12
|
+
keys = selector.delete(']').split('[');
|
13
|
+
vcard_params = params
|
14
|
+
keys.each {|key| vcard_params = vcard_params[key]}
|
15
|
+
return vcard_params
|
16
|
+
end
|
17
|
+
end
|
@@ -15,10 +15,11 @@ module Vcard::DirectoryLookup
|
|
15
15
|
|
16
16
|
search.reject!{|key, value| ignore_fields.include? key}
|
17
17
|
|
18
|
+
logger.warn('[tel.search] Query')
|
18
19
|
# TODO:
|
19
20
|
# We should fetch additional pages if the result indicates there
|
20
21
|
# are more pages.
|
21
|
-
::SwissMatch.directory_service.addresses(search, :per_page =>
|
22
|
+
::SwissMatch.directory_service.addresses(search, :per_page => 10)
|
22
23
|
end
|
23
24
|
|
24
25
|
def directory_found?(ignore_fields = [])
|
@@ -1,5 +1,5 @@
|
|
1
1
|
%tr
|
2
2
|
%td
|
3
|
-
= link_to [address.first_name, address.family_name].join(" "),
|
3
|
+
= link_to [address.first_name, address.family_name].join(" "), '#', 'data-directory-lookup-selector' => @selector, 'data-directory-lookup-attributes' => h(address.to_vcard_attributes.to_json)
|
4
4
|
%td= address.street
|
5
5
|
%td= [address.zip_code, address.city].join(" ")
|
@@ -12,10 +12,10 @@
|
|
12
12
|
%tr
|
13
13
|
%th{:colspan => 4}= t('directory_lookup.title')
|
14
14
|
|
15
|
-
= render 'directory_matches', :vcard => vcard, :match_type => :great
|
16
|
-
= render 'directory_matches', :vcard => vcard, :match_type => :family_name
|
17
|
-
= render 'directory_matches', :vcard => vcard, :match_type => :address
|
18
|
-
= render 'directory_matches', :vcard => vcard, :match_type => :locality
|
15
|
+
= render 'vcards/directory_matches', :vcard => vcard, :match_type => :great
|
16
|
+
= render 'vcards/directory_matches', :vcard => vcard, :match_type => :family_name
|
17
|
+
= render 'vcards/directory_matches', :vcard => vcard, :match_type => :address
|
18
|
+
= render 'vcards/directory_matches', :vcard => vcard, :match_type => :locality
|
19
19
|
|
20
20
|
.modal-footer
|
21
21
|
= link_to t_action(:cancel), '#', :class => 'btn', 'data-dismiss' => 'modal'
|
@@ -1,4 +1,4 @@
|
|
1
1
|
- matches = vcard.send("#{match_type}_matches") - @seen_matches
|
2
2
|
- if matches.present?
|
3
3
|
- @seen_matches += matches
|
4
|
-
= render :partial => 'address', :collection => matches, :locals => {:vcard => vcard}
|
4
|
+
= render :partial => 'vcards/address', :collection => matches, :locals => {:vcard => vcard}
|
data/config/routes.rb
CHANGED
data/lib/has_vcards/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_vcards
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 87
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 18
|
9
|
+
- 0
|
10
|
+
version: 0.18.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Simon H\xC3\xBCrlimann (CyT)"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-09-
|
18
|
+
date: 2012-09-11 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -57,6 +57,7 @@ extra_rdoc_files:
|
|
57
57
|
- MIT-LICENSE
|
58
58
|
- README.markdown
|
59
59
|
files:
|
60
|
+
- app/controllers/directory_lookup_controller.rb
|
60
61
|
- app/controllers/phone_numbers_controller.rb
|
61
62
|
- app/controllers/vcards_controller.rb
|
62
63
|
- app/helpers/has_vcards_helper.rb
|