has_vcards 0.17.0 → 0.17.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,4 +6,15 @@ class VcardsController < ApplicationController
6
6
  def directory_lookup
7
7
  @vcard = Vcard.find(params[:id])
8
8
  end
9
+
10
+ def directory_update
11
+ @vcard = Vcard.find(params[:id])
12
+ new_params = params[:vcard].select{|key, value| ['family_name', 'given_name', 'street_address', 'postal_code', 'locality'].include?(key)}
13
+
14
+ @vcard.update_attributes(new_params)
15
+
16
+ @vcard.save
17
+
18
+ redirect_to @vcard.object
19
+ end
9
20
  end
@@ -0,0 +1,21 @@
1
+ module Vcard::DirectoryAddress
2
+ def to_vcard
3
+ Vcard.new(
4
+ :given_name => first_name,
5
+ :family_name => family_name,
6
+ :street_address => street,
7
+ :postal_code => zip_code,
8
+ :locality => city
9
+ )
10
+ end
11
+
12
+ def to_vcard_attributes
13
+ {
14
+ :given_name => first_name,
15
+ :family_name => family_name,
16
+ :street_address => street,
17
+ :postal_code => zip_code,
18
+ :locality => city
19
+ }
20
+ end
21
+ end
@@ -1,4 +1,5 @@
1
1
  %tr
2
- %td= [address.first_name, address.family_name].join(" ")
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
4
  %td= address.street
4
5
  %td= [address.zip_code, address.city].join(" ")
@@ -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
4
+ = render :partial => 'address', :collection => matches, :locals => {:vcard => vcard}
data/config/routes.rb CHANGED
@@ -10,6 +10,7 @@ Rails.application.routes.draw do
10
10
  # DirectoryLookup
11
11
  member do
12
12
  get :directory_lookup
13
+ post :directory_update
13
14
  end
14
15
  end
15
16
  end
@@ -9,6 +9,8 @@ module HasVcards
9
9
  ActionController::Base.helper HasVcardsHelper
10
10
 
11
11
  ActiveRecord::Base.extend(HasVcardsClassMethods)
12
+
13
+ SwissMatch::Address.send :include, Vcard::DirectoryAddress if defined?(SwissMatch::Address)
12
14
  end
13
15
  end
14
16
  end
@@ -1,3 +1,3 @@
1
1
  module HasVcards
2
- VERSION = '0.17.0'
2
+ VERSION = '0.17.1'
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: 91
4
+ hash: 89
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 17
9
- - 0
10
- version: 0.17.0
9
+ - 1
10
+ version: 0.17.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Simon H\xC3\xBCrlimann (CyT)"
@@ -63,6 +63,7 @@ files:
63
63
  - app/models/address.rb
64
64
  - app/models/phone_number.rb
65
65
  - app/models/vcard.rb
66
+ - app/models/vcard/directory_address.rb
66
67
  - app/models/vcard/directory_lookup.rb
67
68
  - app/views/phone_numbers/_form.html.haml
68
69
  - app/views/phone_numbers/_list.html.haml