has_vcards 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/models/phone_number.rb +10 -0
- data/app/models/vcard.rb +1 -0
- data/app/views/vcards/_form.html.haml +2 -2
- data/lib/has_vcards/version.rb +1 -1
- metadata +4 -4
data/app/models/phone_number.rb
CHANGED
@@ -1,9 +1,18 @@
|
|
1
1
|
class PhoneNumber < ActiveRecord::Base
|
2
|
+
# Vcard association
|
2
3
|
belongs_to :vcard
|
3
4
|
belongs_to :object, :polymorphic => true
|
4
5
|
|
6
|
+
# Validation
|
5
7
|
validates_presence_of :number
|
6
8
|
|
9
|
+
# phone number types
|
10
|
+
scope :by_type, lambda {|value| where(:phone_number_type => value)}
|
11
|
+
scope :phone, by_type('phone')
|
12
|
+
scope :fax, by_type('fax')
|
13
|
+
scope :mobile, by_type('mobile')
|
14
|
+
scope :email, by_type('mobile')
|
15
|
+
|
7
16
|
def label
|
8
17
|
case phone_number_type
|
9
18
|
when 'phone'
|
@@ -19,6 +28,7 @@ class PhoneNumber < ActiveRecord::Base
|
|
19
28
|
end
|
20
29
|
end
|
21
30
|
|
31
|
+
# String
|
22
32
|
def to_s(separator = " ", format = :default)
|
23
33
|
case format
|
24
34
|
when :label
|
data/app/models/vcard.rb
CHANGED
@@ -73,6 +73,7 @@ class Vcard < ActiveRecord::Base
|
|
73
73
|
|
74
74
|
# Phone numbers
|
75
75
|
has_many :contacts, :class_name => 'PhoneNumber', :as => :object
|
76
|
+
accepts_nested_attributes_for :contacts
|
76
77
|
|
77
78
|
has_many :phone_numbers, :class_name => 'PhoneNumber', :as => :object, :conditions => ["phone_number_type = ?", 'phone'], :after_add => :add_phone_number
|
78
79
|
def add_phone_number(number)
|
@@ -4,5 +4,5 @@
|
|
4
4
|
= address.input :extended_address
|
5
5
|
= address.input :street_address
|
6
6
|
= address.input :post_office_box
|
7
|
-
= address.input :postal_code
|
8
|
-
= address.input :locality
|
7
|
+
= address.input :postal_code, :wrapper_html => {:class => 'col1'}
|
8
|
+
= address.input :locality, :wrapper_html => {:class => 'col2'}
|
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: 51
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 11
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.11.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: 2011-
|
18
|
+
date: 2011-11-18 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|