innetra-easy_contacts 0.0.1

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.
Files changed (78) hide show
  1. data/Rakefile +14 -0
  2. data/easy_contacts.gemspec +31 -0
  3. data/generators/easy_contacts/easy_contacts_generator.rb +160 -0
  4. data/generators/easy_contacts/templates/controllers/addresses_controller.rb +12 -0
  5. data/generators/easy_contacts/templates/controllers/cities_controller.rb +7 -0
  6. data/generators/easy_contacts/templates/controllers/companies_controller.rb +75 -0
  7. data/generators/easy_contacts/templates/controllers/contacts_controller.rb +10 -0
  8. data/generators/easy_contacts/templates/controllers/countries_controller.rb +7 -0
  9. data/generators/easy_contacts/templates/controllers/emails_controller.rb +12 -0
  10. data/generators/easy_contacts/templates/controllers/instant_messengers_controller.rb +12 -0
  11. data/generators/easy_contacts/templates/controllers/people_controller.rb +89 -0
  12. data/generators/easy_contacts/templates/controllers/phones_controller.rb +12 -0
  13. data/generators/easy_contacts/templates/controllers/provinces_controller.rb +7 -0
  14. data/generators/easy_contacts/templates/controllers/web_sites_controller.rb +12 -0
  15. data/generators/easy_contacts/templates/helpers/addresses_helper.rb +5 -0
  16. data/generators/easy_contacts/templates/helpers/emails_helper.rb +5 -0
  17. data/generators/easy_contacts/templates/helpers/form_helper.rb +5 -0
  18. data/generators/easy_contacts/templates/helpers/instant_messengers_helper.rb +6 -0
  19. data/generators/easy_contacts/templates/helpers/phones_helper.rb +5 -0
  20. data/generators/easy_contacts/templates/helpers/shadowbox_helper.rb +23 -0
  21. data/generators/easy_contacts/templates/helpers/web_sites_helper.rb +5 -0
  22. data/generators/easy_contacts/templates/locales/en.easy_contacts.yml +59 -0
  23. data/generators/easy_contacts/templates/locales/es-MX.easy_contacts.yml +92 -0
  24. data/generators/easy_contacts/templates/migrations/easy_contacts.rb +123 -0
  25. data/generators/easy_contacts/templates/models/address.rb +33 -0
  26. data/generators/easy_contacts/templates/models/address_type.rb +2 -0
  27. data/generators/easy_contacts/templates/models/city.rb +2 -0
  28. data/generators/easy_contacts/templates/models/company.rb +5 -0
  29. data/generators/easy_contacts/templates/models/contact.rb +121 -0
  30. data/generators/easy_contacts/templates/models/country.rb +2 -0
  31. data/generators/easy_contacts/templates/models/email.rb +14 -0
  32. data/generators/easy_contacts/templates/models/email_type.rb +2 -0
  33. data/generators/easy_contacts/templates/models/instant_messenger.rb +5 -0
  34. data/generators/easy_contacts/templates/models/instant_messenger_protocol.rb +2 -0
  35. data/generators/easy_contacts/templates/models/instant_messenger_type.rb +2 -0
  36. data/generators/easy_contacts/templates/models/person.rb +38 -0
  37. data/generators/easy_contacts/templates/models/phone.rb +4 -0
  38. data/generators/easy_contacts/templates/models/phone_type.rb +2 -0
  39. data/generators/easy_contacts/templates/models/province.rb +2 -0
  40. data/generators/easy_contacts/templates/models/web_site.rb +4 -0
  41. data/generators/easy_contacts/templates/models/web_site_type.rb +2 -0
  42. data/generators/easy_contacts/templates/stylesheets/companies.css +4 -0
  43. data/generators/easy_contacts/templates/stylesheets/default.css +46 -0
  44. data/generators/easy_contacts/templates/stylesheets/people.css +13 -0
  45. data/generators/easy_contacts/templates/views/addresses/_address.html.erb +65 -0
  46. data/generators/easy_contacts/templates/views/addresses/_addresses.html.erb +5 -0
  47. data/generators/easy_contacts/templates/views/addresses/destroy.js.rjs +1 -0
  48. data/generators/easy_contacts/templates/views/cities/index.js.erb +1 -0
  49. data/generators/easy_contacts/templates/views/companies/_company.html.erb +17 -0
  50. data/generators/easy_contacts/templates/views/companies/edit.html.erb +13 -0
  51. data/generators/easy_contacts/templates/views/companies/index.html.erb +21 -0
  52. data/generators/easy_contacts/templates/views/companies/index.js.erb +1 -0
  53. data/generators/easy_contacts/templates/views/companies/new.html.erb +13 -0
  54. data/generators/easy_contacts/templates/views/companies/show.html.erb +19 -0
  55. data/generators/easy_contacts/templates/views/contacts/_contact.html.erb +14 -0
  56. data/generators/easy_contacts/templates/views/contacts/_contact_info.html.erb +61 -0
  57. data/generators/easy_contacts/templates/views/contacts/index.html.erb +21 -0
  58. data/generators/easy_contacts/templates/views/countries/index.js.erb +1 -0
  59. data/generators/easy_contacts/templates/views/emails/_email.html.erb +20 -0
  60. data/generators/easy_contacts/templates/views/emails/_emails.html.erb +13 -0
  61. data/generators/easy_contacts/templates/views/emails/destroy.js.rjs +1 -0
  62. data/generators/easy_contacts/templates/views/instant_messengers/_instant_messenger.html.erb +21 -0
  63. data/generators/easy_contacts/templates/views/instant_messengers/_instant_messengers.html.erb +14 -0
  64. data/generators/easy_contacts/templates/views/instant_messengers/destroy.js.rjs +1 -0
  65. data/generators/easy_contacts/templates/views/people/_person.html.erb +44 -0
  66. data/generators/easy_contacts/templates/views/people/edit.html.erb +13 -0
  67. data/generators/easy_contacts/templates/views/people/index.html.erb +21 -0
  68. data/generators/easy_contacts/templates/views/people/new.html.erb +13 -0
  69. data/generators/easy_contacts/templates/views/people/show.html.erb +13 -0
  70. data/generators/easy_contacts/templates/views/phones/_phone.html.erb +17 -0
  71. data/generators/easy_contacts/templates/views/phones/_phones.html.erb +14 -0
  72. data/generators/easy_contacts/templates/views/phones/destroy.js.rjs +1 -0
  73. data/generators/easy_contacts/templates/views/provinces/index.js.erb +1 -0
  74. data/generators/easy_contacts/templates/views/web_sites/_web_site.html.erb +19 -0
  75. data/generators/easy_contacts/templates/views/web_sites/_web_sites.html.erb +14 -0
  76. data/generators/easy_contacts/templates/views/web_sites/destroy.js.rjs +1 -0
  77. data/tasks/init.rake +43 -0
  78. metadata +133 -0
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('easy_contacts', '0.0.1') do |e|
6
+ e.description = "Easy Contacts for Ruby on Rails 2.2 (i18n)"
7
+ e.url = "http://github.com/innetra/easy_contacts"
8
+ e.author = "Ivan Torres"
9
+ e.email = "mexpolk@gmail.com"
10
+ e.ignore_pattern = ["tmp/*", "script/*"]
11
+ e.development_dependencies = []
12
+ end
13
+
14
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].each { |f| load f }
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{easy_contacts}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Ivan Torres"]
9
+ s.date = %q{2009-01-17}
10
+ s.description = %q{Easy Contacts for Ruby on Rails 2.2 (i18n)}
11
+ s.email = %q{mexpolk@gmail.com}
12
+ s.extra_rdoc_files = ["tasks/init.rake"]
13
+ s.files = ["Manifest", "tasks/init.rake", "generators/easy_contacts/easy_contacts_generator.rb", "generators/easy_contacts/templates/stylesheets/people.css", "generators/easy_contacts/templates/stylesheets/companies.css", "generators/easy_contacts/templates/stylesheets/default.css", "generators/easy_contacts/templates/helpers/emails_helper.rb", "generators/easy_contacts/templates/helpers/shadowbox_helper.rb", "generators/easy_contacts/templates/helpers/phones_helper.rb", "generators/easy_contacts/templates/helpers/web_sites_helper.rb", "generators/easy_contacts/templates/helpers/instant_messengers_helper.rb", "generators/easy_contacts/templates/helpers/addresses_helper.rb", "generators/easy_contacts/templates/helpers/form_helper.rb", "generators/easy_contacts/templates/migrations/easy_contacts.rb", "generators/easy_contacts/templates/views/phones/destroy.js.rjs", "generators/easy_contacts/templates/views/phones/_phones.html.erb", "generators/easy_contacts/templates/views/phones/_phone.html.erb", "generators/easy_contacts/templates/views/companies/index.html.erb", "generators/easy_contacts/templates/views/companies/show.html.erb", "generators/easy_contacts/templates/views/companies/edit.html.erb", "generators/easy_contacts/templates/views/companies/new.html.erb", "generators/easy_contacts/templates/views/companies/index.js.erb", "generators/easy_contacts/templates/views/companies/_company.html.erb", "generators/easy_contacts/templates/views/countries/index.js.erb", "generators/easy_contacts/templates/views/emails/destroy.js.rjs", "generators/easy_contacts/templates/views/emails/_email.html.erb", "generators/easy_contacts/templates/views/emails/_emails.html.erb", "generators/easy_contacts/templates/views/instant_messengers/destroy.js.rjs", "generators/easy_contacts/templates/views/instant_messengers/_instant_messengers.html.erb", "generators/easy_contacts/templates/views/instant_messengers/_instant_messenger.html.erb", "generators/easy_contacts/templates/views/people/index.html.erb", "generators/easy_contacts/templates/views/people/show.html.erb", "generators/easy_contacts/templates/views/people/edit.html.erb", "generators/easy_contacts/templates/views/people/new.html.erb", "generators/easy_contacts/templates/views/people/_person.html.erb", "generators/easy_contacts/templates/views/web_sites/_web_site.html.erb", "generators/easy_contacts/templates/views/web_sites/destroy.js.rjs", "generators/easy_contacts/templates/views/web_sites/_web_sites.html.erb", "generators/easy_contacts/templates/views/provinces/index.js.erb", "generators/easy_contacts/templates/views/contacts/_contact_info.html.erb", "generators/easy_contacts/templates/views/contacts/index.html.erb", "generators/easy_contacts/templates/views/contacts/_contact.html.erb", "generators/easy_contacts/templates/views/cities/index.js.erb", "generators/easy_contacts/templates/views/addresses/destroy.js.rjs", "generators/easy_contacts/templates/views/addresses/_address.html.erb", "generators/easy_contacts/templates/views/addresses/_addresses.html.erb", "generators/easy_contacts/templates/models/city.rb", "generators/easy_contacts/templates/models/web_site.rb", "generators/easy_contacts/templates/models/web_site_type.rb", "generators/easy_contacts/templates/models/phone.rb", "generators/easy_contacts/templates/models/country.rb", "generators/easy_contacts/templates/models/email.rb", "generators/easy_contacts/templates/models/address.rb", "generators/easy_contacts/templates/models/company.rb", "generators/easy_contacts/templates/models/email_type.rb", "generators/easy_contacts/templates/models/instant_messenger.rb", "generators/easy_contacts/templates/models/instant_messenger_protocol.rb", "generators/easy_contacts/templates/models/province.rb", "generators/easy_contacts/templates/models/instant_messenger_type.rb", "generators/easy_contacts/templates/models/phone_type.rb", "generators/easy_contacts/templates/models/address_type.rb", "generators/easy_contacts/templates/models/person.rb", "generators/easy_contacts/templates/models/contact.rb", "generators/easy_contacts/templates/controllers/web_sites_controller.rb", "generators/easy_contacts/templates/controllers/phones_controller.rb", "generators/easy_contacts/templates/controllers/people_controller.rb", "generators/easy_contacts/templates/controllers/emails_controller.rb", "generators/easy_contacts/templates/controllers/countries_controller.rb", "generators/easy_contacts/templates/controllers/cities_controller.rb", "generators/easy_contacts/templates/controllers/contacts_controller.rb", "generators/easy_contacts/templates/controllers/addresses_controller.rb", "generators/easy_contacts/templates/controllers/provinces_controller.rb", "generators/easy_contacts/templates/controllers/instant_messengers_controller.rb", "generators/easy_contacts/templates/controllers/companies_controller.rb", "generators/easy_contacts/templates/locales/en.easy_contacts.yml", "generators/easy_contacts/templates/locales/es-MX.easy_contacts.yml", "Rakefile", "easy_contacts.gemspec"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/innetra/easy_contacts}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Easy_contacts"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{easy_contacts}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{Easy Contacts for Ruby on Rails 2.2 (i18n)}
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 2
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ else
28
+ end
29
+ else
30
+ end
31
+ end
@@ -0,0 +1,160 @@
1
+ class EasyContactsGenerator < Rails::Generator::Base
2
+
3
+ default_options :skip_migrations => false,
4
+ :skip_routes => false
5
+
6
+ def manifest
7
+ record do |m|
8
+
9
+ # Controllers
10
+ controllers.each do |controller_name|
11
+ m.template "controllers/#{controller_name}_controller.rb",
12
+ File.join("app/controllers", "#{controller_name}_controller.rb")
13
+ m.directory(File.join("app/views", controller_name))
14
+ end
15
+
16
+ # Helpers
17
+ helpers.each do |helper_name|
18
+ m.template "helpers/#{helper_name}_helper.rb",
19
+ File.join("app/helpers", "#{helper_name}_helper.rb")
20
+ end
21
+
22
+ # Views
23
+ views.each do |view_name|
24
+ m.template "views/#{view_name}",
25
+ File.join("app/views", "#{view_name}")
26
+ end
27
+
28
+ # Stylesheets
29
+ unless options[:skip_css]
30
+ m.directory("public/stylesheets/easy_contacts")
31
+ stylesheets.each do |stylesheet_name|
32
+ m.template "stylesheets/#{stylesheet_name}.css",
33
+ File.join("public/stylesheets/easy_contacts", "#{stylesheet_name}.css")
34
+ end
35
+ end
36
+
37
+ # Models
38
+ models.each do |model_name|
39
+ m.template "models/#{model_name}.rb",
40
+ File.join("app/models", "#{model_name}.rb")
41
+ end
42
+
43
+ # Locales
44
+ m.template "locales/en.easy_contacts.yml",
45
+ "config/locales/en.easy_contacts.yml"
46
+ m.template "locales/es-MX.easy_contacts.yml",
47
+ "config/locales/es-MX.easy_contacts.yml"
48
+
49
+ # Necessary Routes
50
+ unless options[:skip_routes]
51
+ generate_routes
52
+ end
53
+
54
+ # Migrations
55
+ unless options[:skip_migrations]
56
+ m.migration_template "migrations/easy_contacts.rb", "db/migrate",
57
+ :migration_file_name => "create_easy_contacts"
58
+ end
59
+
60
+ end
61
+ end
62
+
63
+ protected
64
+
65
+ def controllers
66
+ %w[ addresses cities companies contacts countries emails
67
+ instant_messengers people phones provinces web_sites ]
68
+ end
69
+
70
+ def helpers
71
+ %w[ addresses emails instant_messengers phones web_sites form shadowbox ]
72
+ end
73
+
74
+ def views
75
+ %w[ addresses/_address.html.erb
76
+ addresses/_addresses.html.erb
77
+ addresses/destroy.js.rjs
78
+ cities/index.js.erb
79
+ companies/_company.html.erb
80
+ companies/index.html.erb
81
+ companies/index.js.erb
82
+ companies/edit.html.erb
83
+ companies/new.html.erb
84
+ companies/show.html.erb
85
+ contacts/_contact.html.erb
86
+ contacts/_contact_info.html.erb
87
+ contacts/index.html.erb
88
+ countries/index.js.erb
89
+ emails/destroy.js.rjs
90
+ emails/_email.html.erb
91
+ emails/_emails.html.erb
92
+ instant_messengers/destroy.js.rjs
93
+ instant_messengers/_instant_messenger.html.erb
94
+ instant_messengers/_instant_messengers.html.erb
95
+ people/index.html.erb
96
+ people/edit.html.erb
97
+ people/new.html.erb
98
+ people/_person.html.erb
99
+ people/show.html.erb
100
+ phones/destroy.js.rjs
101
+ phones/_phone.html.erb
102
+ phones/_phones.html.erb
103
+ provinces/index.js.erb
104
+ web_sites/destroy.js.rjs
105
+ web_sites/_web_site.html.erb
106
+ web_sites/_web_sites.html.erb ]
107
+ end
108
+
109
+ def stylesheets
110
+ %w[ default companies people ]
111
+ end
112
+
113
+ def models
114
+ %w[ address address_type city company contact country email email_type
115
+ instant_messenger instant_messenger_protocol instant_messenger_type
116
+ person phone phone_type province web_site web_site_type ]
117
+ end
118
+
119
+ def banner
120
+ "Usage: #{$0} easy_contacts"
121
+ end
122
+
123
+ def add_options!(opt)
124
+ opt.separator ""
125
+ opt.separator "Options:"
126
+ opt.on("--skip-migrations",
127
+ "Don't generate migrations") { |v| options[:skip_migrations] = v }
128
+ opt.on("--skip-routes",
129
+ "Don't map resources in routes file") { |v| options[:skip_routes] = v }
130
+ end
131
+
132
+ def gsub_file(relative_destination, regexp, *args, &block)
133
+ path = destination_path(relative_destination)
134
+ content = File.read(path).gsub(regexp, *args, &block)
135
+ File.open(path, 'wb') { |file| file.write(content) }
136
+ end
137
+
138
+ def generate_routes
139
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
140
+
141
+ # Do not change indentation in this method!!!
142
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
143
+ %{#{match}\n
144
+ # Easy Contacts
145
+ map.resources :addresses, :only => :destroy
146
+ map.resources :cities, :only => :index
147
+ map.resources :companies
148
+ map.resources :contacts, :only => :index
149
+ map.resources :countries, :only => :index
150
+ map.resources :emails, :only => :destroy
151
+ map.resources :instant_messengers, :only => :destroy
152
+ map.resources :people
153
+ map.resources :phones, :only => :destroy
154
+ map.resources :provinces, :only => :index
155
+ map.resources :web_sites, :only => :destroy
156
+ # Easy Contacts
157
+ }
158
+ end
159
+ end
160
+ end
@@ -0,0 +1,12 @@
1
+ class AddressesController < ApplicationController
2
+
3
+ def destroy
4
+ @address = Address.find(params[:id])
5
+ @address.destroy
6
+
7
+ respond_to do |format|
8
+ format.js
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,7 @@
1
+ class CitiesController < ApplicationController
2
+
3
+ def index
4
+ @cities = City.all(:conditions => ["name LIKE ?", "%#{params[:search]}%"] )
5
+ end
6
+
7
+ end
@@ -0,0 +1,75 @@
1
+ class CompaniesController < ApplicationController
2
+
3
+ def index
4
+ if params.has_key?(:search)
5
+ @companies = Company.all(:conditions => ["name LIKE ?", "%#{params[:search]}%"] )
6
+ else
7
+ @companies = Company.all
8
+ end
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.js
13
+ format.xml { render :xml => @companies }
14
+ end
15
+ end
16
+
17
+ def new
18
+ @company = Company.new
19
+ 2.times { @company.phones.build }
20
+ @company.emails.build
21
+ @company.instant_messengers.build
22
+ @company.web_sites.build
23
+ @company.addresses.build
24
+
25
+ respond_to do |format|
26
+ format.html # new.html.erb
27
+ format.xml { render :xml => @company }
28
+ end
29
+ end
30
+
31
+ def create
32
+ @company = Company.new(params[:company])
33
+
34
+ respond_to do |format|
35
+ if @company.save
36
+ flash[:notice] = t("companies.flash.create")
37
+ format.html { redirect_to(@company) }
38
+ format.xml { render :xml => @company, :status => :created, :location => @company }
39
+ else
40
+ format.html { render :action => "new" }
41
+ format.xml { render :xml => @company.errors, :status => :unprocessable_entity }
42
+ end
43
+ end
44
+ end
45
+
46
+ def show
47
+ @company = Company.find_by_id(params[:id])
48
+
49
+ respond_to do |format|
50
+ format.html # show.html.erb
51
+ format.xml { render :xml => @company }
52
+ end
53
+ end
54
+
55
+ def edit
56
+ @company = Company.find_by_id(params[:id])
57
+ end
58
+
59
+ def update
60
+ @company = Company.find_by_id(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @company.update_attributes(params[:company])
64
+ flash[:notice] = t('companies.flash.update')
65
+ format.html { redirect_to(@company) }
66
+ format.xml { head :ok }
67
+ else
68
+ format.html { render :action => "edit" }
69
+ format.xml { render :xml => @company.errors, :status => :unprocessable_entity }
70
+ end
71
+ end
72
+ end
73
+
74
+
75
+ end
@@ -0,0 +1,10 @@
1
+ class ContactsController < ApplicationController
2
+ def index
3
+ @people = Person.all(:order => "name, last_name")
4
+
5
+ respond_to do |format|
6
+ format.html # index.html.erb
7
+ format.xml { render :xml => @people }
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ class CountriesController < ApplicationController
2
+
3
+ def index
4
+ @countries = Country.all(:conditions => ["name LIKE ?", "%#{params[:search]}%"] )
5
+ end
6
+
7
+ end
@@ -0,0 +1,12 @@
1
+ class EmailsController < ApplicationController
2
+
3
+ def destroy
4
+ @email = Email.find(params[:id])
5
+ @email.destroy
6
+
7
+ respond_to do |format|
8
+ format.js
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ class InstantMessengersController < ApplicationController
2
+
3
+ def destroy
4
+ @instant_messenger = InstantMessenger.find(params[:id])
5
+ @instant_messenger.destroy
6
+
7
+ respond_to do |format|
8
+ format.js
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,89 @@
1
+ class PeopleController < ApplicationController
2
+
3
+ def index
4
+ @people = Person.all
5
+
6
+ respond_to do |format|
7
+ format.html # index.html.erb
8
+ format.xml { render :xml => @people }
9
+ end
10
+ end
11
+
12
+ def new
13
+ @person = Person.new
14
+
15
+ # Build Person contact fields
16
+ @person.phones.build
17
+ @person.phones.build(:phone_type_id => 2)
18
+ @person.emails.build
19
+ @person.emails.build(:email_type_id => 2)
20
+ @person.instant_messengers.build
21
+ @person.web_sites.build
22
+ @person.addresses.build
23
+
24
+ respond_to do |format|
25
+ format.html # new.html.erb
26
+ format.xml { render :xml => @person }
27
+ end
28
+ end
29
+
30
+ def create
31
+ @person = Person.new(params[:person])
32
+
33
+ respond_to do |format|
34
+ if @person.save
35
+ flash[:notice] = t('people.flash.create')
36
+ format.html { redirect_to(@person) }
37
+ format.xml { render :xml => @person, :status => :created, :location => @person }
38
+ else
39
+ format.html { render :action => "new" }
40
+ format.xml { render :xml => @person.errors, :status => :unprocessable_entity }
41
+ end
42
+ end
43
+ end
44
+
45
+ def show
46
+ @person = Person.find_by_id(params[:id])
47
+
48
+ respond_to do |format|
49
+ format.html # show.html.erb
50
+ format.xml { render :xml => @person }
51
+ end
52
+ end
53
+
54
+ def edit
55
+ @person = Person.find_by_id(params[:id])
56
+
57
+ # Build Person contact fields if blank
58
+ if @person.phones.blank?
59
+ @person.phones.build
60
+ @person.phones.build(:phone_type_id => 2)
61
+ end
62
+
63
+ if @person.emails.blank?
64
+ @person.emails.build
65
+ @person.emails.build(:email_type_id => 2)
66
+ end
67
+
68
+ @person.instant_messengers.build if @person.instant_messengers.blank?
69
+ @person.web_sites.build if @person.web_sites.blank?
70
+ @person.addresses.build if @person.addresses.blank?
71
+
72
+ end
73
+
74
+ def update
75
+ @person = Person.find_by_id(params[:id])
76
+
77
+ respond_to do |format|
78
+ if @person.update_attributes(params[:person])
79
+ flash[:notice] = t('people.flash.update')
80
+ format.html { redirect_to(@person) }
81
+ format.xml { head :ok }
82
+ else
83
+ format.html { render :action => "edit" }
84
+ format.xml { render :xml => @person.errors, :status => :unprocessable_entity }
85
+ end
86
+ end
87
+ end
88
+
89
+ end
@@ -0,0 +1,12 @@
1
+ class PhonesController < ApplicationController
2
+
3
+ def destroy
4
+ @phone = Phone.find(params[:id])
5
+ @phone.destroy
6
+
7
+ respond_to do |format|
8
+ format.js
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,7 @@
1
+ class ProvincesController < ApplicationController
2
+
3
+ def index
4
+ @provinces = Province.all(:conditions => ["name LIKE ?", "%#{params[:search]}%"] )
5
+ end
6
+
7
+ end
@@ -0,0 +1,12 @@
1
+ class WebSitesController < ApplicationController
2
+
3
+ def destroy
4
+ @web_site = WebSite.find(params[:id])
5
+ @web_site.destroy
6
+
7
+ respond_to do |format|
8
+ format.js
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,5 @@
1
+ module AddressesHelper
2
+ def place_address_form(owner)
3
+ render :partial => "addresses/addresses", :locals => { :owner => owner }
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module EmailsHelper
2
+ def place_email_form(owner)
3
+ render :partial => "emails/emails", :locals => { :owner => owner }
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module FormHelper
2
+ def required_field
3
+ "<span class=\"required\">*</span>"
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module InstantMessengersHelper
2
+ def place_instant_messenger_form(owner)
3
+ render :partial => "instant_messengers/instant_messengers",
4
+ :locals => { :owner => owner }
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module PhonesHelper
2
+ def place_phone_form(owner)
3
+ render :partial => "phones/phones", :locals => { :owner => owner }
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ module ShadowboxHelper
2
+ def shadowbox(id, options = {}, &block)
3
+ class_name = "container "
4
+ class_name << options[:class] if options.has_key?(:class)
5
+ concat content_tag(:div,
6
+ content_tag(:div,
7
+ content_tag(:div,
8
+ content_tag(:div,
9
+ content_tag(:div,
10
+ capture(&block),
11
+ :class => class_name
12
+ ),
13
+ :class => "shadow3"
14
+ ),
15
+ :class => "shadow2"
16
+ ),
17
+ :class => "shadow1"
18
+ ),
19
+ :id => id.downcase.strip.gsub(' ', '_'),
20
+ :class => "shadow"
21
+ )
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module WebSitesHelper
2
+ def place_web_site_form(owner)
3
+ render :partial => "web_sites/web_sites", :locals => { :owner => owner }
4
+ end
5
+ end
@@ -0,0 +1,59 @@
1
+ en:
2
+
3
+ actions:
4
+ edit: "Edit"
5
+ delete: "Delete"
6
+
7
+ forms:
8
+ save: "Save"
9
+ cancel: "Cancel"
10
+ update: "Update"
11
+ optional_fields: "Optional Fields"
12
+
13
+ addresses:
14
+ title: "Address"
15
+ add_link: "add address"
16
+ companies:
17
+ flash:
18
+ create: "Company created."
19
+ update: "Company updated."
20
+ index:
21
+ title: "Companies"
22
+ new_company_link: "Add new company"
23
+ new:
24
+ title: "New Company"
25
+ edit:
26
+ title: "Edit Company \"{{name}}\""
27
+ show:
28
+ people_in_this_company: "Contacts"
29
+ contacts:
30
+ info:
31
+ title: "Contact {{name}}"
32
+ index:
33
+ title: "Contacts"
34
+ new_person_link: "add new contact"
35
+ new_company_link: "add new company"
36
+ add_link: "add"
37
+ emails:
38
+ title: "Email"
39
+ add_link: "add"
40
+ instant_messengers:
41
+ title: "Instant Messenger"
42
+ add_link: "add"
43
+ people:
44
+ flash:
45
+ create: "User created."
46
+ update: "User updated."
47
+ new:
48
+ title: "Add New Contact"
49
+ edit:
50
+ title: "Edit Contact \"{{full_name}}\""
51
+ show:
52
+ title_description: "{{title}} at {{company}}"
53
+ contact_data: "Contact Data {{name}}"
54
+ phones:
55
+ title: "Phones"
56
+ add_link: "add"
57
+ web_sites:
58
+ title: "Internet"
59
+ add_link: "add"