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.
@@ -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 => 100)
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(" "), directory_update_vcard_path(vcard, :vcard => address.to_vcard_attributes), :method => :post
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}
@@ -1,4 +1,4 @@
1
1
  $('#directory_lookup').remove();
2
2
 
3
- $('body').append('<%=j render "directory_lookup", :vcard => @vcard %>');
3
+ $('body').append('<%=j render "vcards/directory_lookup", :vcard => @vcard %>');
4
4
  $('#directory_lookup').modal({show: true});
data/config/routes.rb CHANGED
@@ -13,4 +13,7 @@ Rails.application.routes.draw do
13
13
  post :directory_update
14
14
  end
15
15
  end
16
+
17
+ # Directory Lookup
18
+ get 'directory_lookup/search' => 'directory_lookup#search'
16
19
  end
@@ -1,3 +1,3 @@
1
1
  module HasVcards
2
- VERSION = '0.17.2'
2
+ VERSION = '0.18.0'
3
3
  end
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: 95
4
+ hash: 87
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 17
9
- - 2
10
- version: 0.17.2
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-06 00:00:00 +02:00
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