contactable 0.1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Manifest +94 -14
- data/README.rdoc +27 -1
- data/Rakefile +1 -1
- data/app/controllers/addresses_controller.rb +3 -0
- data/app/controllers/cities_controller.rb +16 -0
- data/app/controllers/contact_field_actions.rb +60 -0
- data/app/controllers/divisions_controller.rb +17 -0
- data/app/controllers/emails_controller.rb +3 -0
- data/app/controllers/identifications_controller.rb +3 -0
- data/app/controllers/instant_messengers_controller.rb +3 -0
- data/app/controllers/phones_controller.rb +3 -0
- data/app/controllers/websites_controller.rb +3 -0
- data/app/helpers/contactable_helper.rb +46 -0
- data/app/models/address.rb +96 -0
- data/app/models/address_type.rb +5 -0
- data/app/models/city.rb +21 -0
- data/app/models/country.rb +8 -0
- data/app/models/division.rb +26 -0
- data/{generators/contactable/templates → app}/models/email.rb +0 -0
- data/app/models/email_type.rb +5 -0
- data/app/models/identification.rb +7 -0
- data/app/models/identification_type.rb +5 -0
- data/{generators/contactable/templates → app}/models/instant_messenger.rb +0 -0
- data/{generators/contactable/templates → app}/models/instant_messenger_protocol.rb +2 -2
- data/{generators/contactable/templates → app}/models/instant_messenger_type.rb +3 -3
- data/{generators/contactable/templates → app}/models/phone.rb +0 -0
- data/app/models/phone_type.rb +5 -0
- data/{generators/contactable/templates → app}/models/province.rb +0 -0
- data/{generators/contactable/templates → app}/models/website.rb +0 -0
- data/app/models/website_type.rb +5 -0
- data/app/views/addresses/_address.html.erb +31 -0
- data/app/views/cities/index.html.erb +6 -0
- data/app/views/contactable/_contactable.html.erb +11 -0
- data/app/views/contactable/_contactable_field.html.erb +8 -0
- data/app/views/contactable/_fields.html.erb +49 -0
- data/app/views/divisions/index.html.erb +9 -0
- data/app/views/emails/_email.html.erb +2 -0
- data/app/views/identifications/_identification.html.erb +2 -0
- data/app/views/instant_messengers/_instant_messenger.html.erb +3 -0
- data/app/views/phones/_phone.html.erb +2 -0
- data/app/views/websites/_website.html.erb +2 -0
- data/config/contactable_routes.rb +4 -0
- data/contactable.gemspec +5 -5
- data/generators/contactable/USAGE +1 -10
- data/generators/contactable/contactable_generator.rb +35 -32
- data/generators/contactable/lib/insert_commands.rb +33 -0
- data/generators/contactable/templates/README +12 -0
- data/generators/contactable/templates/migrations/create_contactable_related_tables.rb +153 -26
- data/generators/contactable_views/USAGE +1 -0
- data/generators/contactable_views/contactable_views_generator.rb +24 -0
- data/generators/contactable_views/templates/views/formtastic/addresses/_address.html.erb +31 -0
- data/generators/contactable_views/templates/views/formtastic/cities/index.html.erb +6 -0
- data/generators/contactable_views/templates/views/formtastic/contactable/_contactable.html.erb +11 -0
- data/generators/contactable_views/templates/views/formtastic/contactable/_contactable_field.html.erb +8 -0
- data/generators/contactable_views/templates/views/formtastic/contactable/_fields.html.erb +49 -0
- data/generators/contactable_views/templates/views/formtastic/divisions/index.html.erb +9 -0
- data/generators/contactable_views/templates/views/formtastic/emails/_email.html.erb +2 -0
- data/generators/contactable_views/templates/views/formtastic/identifications/_identification.html.erb +2 -0
- data/generators/contactable_views/templates/views/formtastic/instant_messengers/_instant_messenger.html.erb +3 -0
- data/generators/contactable_views/templates/views/formtastic/phones/_phone.html.erb +2 -0
- data/generators/contactable_views/templates/views/formtastic/websites/_website.html.erb +2 -0
- data/generators/contactable_views/templates/views/jintastic/addresses/_address.html.erb +31 -0
- data/generators/contactable_views/templates/views/jintastic/addresses/_form.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/addresses/create.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/addresses/destroy.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/addresses/update.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/cities/index.html.erb +6 -0
- data/generators/contactable_views/templates/views/jintastic/contactable/_birthday.html.erb +1 -0
- data/generators/contactable_views/templates/views/jintastic/contactable/_contactable.html.erb +16 -0
- data/generators/contactable_views/templates/views/jintastic/contactable/_contactable_field.html.erb +14 -0
- data/generators/contactable_views/templates/views/jintastic/contactable/_fields.html.erb +49 -0
- data/generators/contactable_views/templates/views/jintastic/contactable/_name.html.erb +3 -0
- data/generators/contactable_views/templates/views/jintastic/divisions/index.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/emails/_email.html.erb +2 -0
- data/generators/contactable_views/templates/views/jintastic/emails/_form.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/emails/create.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/emails/destroy.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/emails/update.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/identifications/_form.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/identifications/_identification.html.erb +2 -0
- data/generators/contactable_views/templates/views/jintastic/identifications/create.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/identifications/destroy.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/identifications/update.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/instant_messengers/_form.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/instant_messengers/_instant_messenger.html.erb +3 -0
- data/generators/contactable_views/templates/views/jintastic/instant_messengers/create.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/instant_messengers/destroy.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/instant_messengers/update.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/phones/_form.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/phones/_phone.html.erb +2 -0
- data/generators/contactable_views/templates/views/jintastic/phones/create.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/phones/destroy.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/phones/update.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/websites/_form.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/websites/_website.html.erb +2 -0
- data/generators/contactable_views/templates/views/jintastic/websites/create.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/websites/destroy.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/websites/update.js.rjs +3 -0
- data/lib/contactable.rb +6 -2
- data/lib/contactable/extensions/routes.rb +22 -0
- data/rails/init.rb +1 -0
- metadata +109 -19
- data/generators/contactable/templates/models/address.rb +0 -33
- data/generators/contactable/templates/models/address_type.rb +0 -5
- data/generators/contactable/templates/models/city.rb +0 -4
- data/generators/contactable/templates/models/country.rb +0 -4
- data/generators/contactable/templates/models/email_type.rb +0 -5
- data/generators/contactable/templates/models/phone_type.rb +0 -5
- data/generators/contactable/templates/models/website_type.rb +0 -5
@@ -0,0 +1 @@
|
|
1
|
+
script/generate contactable_views formtastic
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class ContactableViewsGenerator < Rails::Generator::NamedBase
|
2
|
+
|
3
|
+
def manifest
|
4
|
+
record do |m|
|
5
|
+
|
6
|
+
Dir[source_path("views/#{strategy}/**/**")].each do |full_path|
|
7
|
+
source_file_name = full_path.gsub(/.*templates\//,'')
|
8
|
+
destination_file_name = source_file_name.gsub(/.*#{strategy}\//,'app/views/')
|
9
|
+
if File.ftype(full_path) == "directory"
|
10
|
+
m.directory destination_file_name
|
11
|
+
else
|
12
|
+
m.file source_file_name, destination_file_name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def strategy
|
21
|
+
class_name.nil? ? 'formtastic' : class_name.underscore.downcase
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<% address ||= @field %>
|
2
|
+
<span id='<%= dom_id address %>_country'>
|
3
|
+
<% clear_children = "$('.#{dom_id address}.division').html('')" %>
|
4
|
+
<% update_child_division = remote_function(:url => {:controller => 'divisions', :action => 'index'}, :with => "'field_dom_id=#{dom_id address}&search[country_id]=' + $('##{dom_id address}_country #address_country_id').val()", :update => "#{dom_id address}_division1") %>
|
5
|
+
<%= f.input :country, :prompt => t('countries.prompt'), :include_blank => t('actions.clear'), :input_html => {:onchange => "#{clear_children};#{update_child_division}"}%>
|
6
|
+
</span>
|
7
|
+
<% (1..4).each do |level| %>
|
8
|
+
<span id='<%= dom_id address %>_division<%= level %>' class='<%= dom_id address %> division <%= (0..level - 1).to_a.reverse.map {|i| "child#{i} "} %>'>
|
9
|
+
<% if level == 1
|
10
|
+
empty = address.country.blank? || address.country.first_level_divisions.empty?
|
11
|
+
collection = address.country.first_level_divisions unless empty
|
12
|
+
else
|
13
|
+
empty = address.send("division#{level - 1}").blank? || address.send("division#{level - 1}").children.empty?
|
14
|
+
collection = address.send("division#{level - 1}").children unless empty
|
15
|
+
end %>
|
16
|
+
<% unless empty %>
|
17
|
+
<% clear_children = "$('.#{dom_id address}.division.child#{level}').html('')" %>
|
18
|
+
<% update_child_division = remote_function(:url => {:controller => 'divisions', :action => 'index'}, :with => "'field_dom_id=#{dom_id address}&search[country_id]=' + $('##{dom_id address}_country #address_country_id').val() + '&search[parent_id]=' + $('##{dom_id address}_division#{level} #address_division#{level}_id').val() +'&search[level]=#{level + 1}'", :update => "#{dom_id address}_division#{level + 1}") %>
|
19
|
+
<% update_city = remote_function(:url => {:controller => 'cities', :action => 'index'}, :with => "'field_dom_id=#{dom_id address}&search[country_id]=' + $('##{dom_id address}_country #address_country_id').val() + '&search[division_id]=' + $('##{dom_id address}_division#{level} #address_division#{level}_id').val()", :update => "#{dom_id address}_city") %>
|
20
|
+
<%= f.input "division#{level}".to_sym, :collection => collection, :prompt => t('divisions.prompt'), :include_blank => t('actions.clear'), :input_html => {:onchange => "#{clear_children};#{update_child_division};#{update_city}"} %>
|
21
|
+
<% end %>
|
22
|
+
</span>
|
23
|
+
<% end %>
|
24
|
+
<span id='<%= dom_id address %>_city' class='<%= dom_id address %> division child1 child2 child3 child4'>
|
25
|
+
<% unless address.cities.empty? %>
|
26
|
+
<%= f.input :city, :collection => address.cities, :prompt => t('cities.prompt'), :include_blank => t('actions.clear') %>
|
27
|
+
<% end %>
|
28
|
+
</span>
|
29
|
+
<%= f.input :address %>
|
30
|
+
<%= f.input :zip %>
|
31
|
+
<%= f.input :type %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<% unless @cities.empty? %>
|
2
|
+
<li id="address_city_input" class="select optional">
|
3
|
+
<label for="address_city_id">City</label>
|
4
|
+
<%= collection_select :address, :city_id, @cities, :id, :name, {:prompt => t('cities.prompt'), :include_blank => t('actions.clear')} %>
|
5
|
+
</li>
|
6
|
+
<% end %>
|
data/generators/contactable_views/templates/views/formtastic/contactable/_contactable.html.erb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= render contactable rescue nil%>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<span class='label'><%= contactable.class.human_attribute_name('name') %>:</span> <%= contactable.name %>
|
5
|
+
</p>
|
6
|
+
<p>
|
7
|
+
<span class='label'><%= contactable.class.human_attribute_name('birthday') %>:</span> <%= contactable.birthday %>
|
8
|
+
</p>
|
9
|
+
<% ['identification','phone', 'email', 'address', 'instant_messenger', 'website'].each do |field_name| %>
|
10
|
+
<%= render :partial => 'contactable/contactable_field', :locals => {:contactable => contactable, :field_name => field_name} %>
|
11
|
+
<% end %>
|
data/generators/contactable_views/templates/views/formtastic/contactable/_contactable_field.html.erb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<div class='multi <%= field_name.pluralize %>'>
|
2
|
+
<span class='label'><%= contactable.class.human_attribute_name(field_name.pluralize) %>:</span>
|
3
|
+
<ul>
|
4
|
+
<% contactable.send(field_name.pluralize).each do |field| %>
|
5
|
+
<li><%= send(field_name + '_label',field) %></li>
|
6
|
+
<% end %>
|
7
|
+
</ul>
|
8
|
+
</div>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<%= f.input :first_name %>
|
2
|
+
<%= f.input :middle_name %>
|
3
|
+
<%= f.input :last_name %>
|
4
|
+
<%= f.input :birthday, :as => :calendar %>
|
5
|
+
|
6
|
+
<div id='phones' class='multi phones'>
|
7
|
+
<%= f.label :phones, 'Phones' %>
|
8
|
+
<% f.inputs :for => :phones do |pf|%>
|
9
|
+
<%= render :partial => 'phones/phone', :locals => {:f => pf} %>
|
10
|
+
<%= remove_link_unless_new_record(pf) %>
|
11
|
+
<% end %>
|
12
|
+
</div>
|
13
|
+
<%= add_new_record_link f.object, :phone, f %>
|
14
|
+
|
15
|
+
<div id='addresses' class='multi addresses'>
|
16
|
+
<%= f.label :addresses, 'Addresses' %>
|
17
|
+
<% f.inputs :for => :addresses do |af|%>
|
18
|
+
<%= render :partial => 'addresses/address', :locals => {:address => af.object, :f => af} %>
|
19
|
+
<%= remove_link_unless_new_record(af) %>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
22
|
+
<%= add_new_record_link f.object, :address, f %>
|
23
|
+
|
24
|
+
<div id="emails" class='multi emails'>
|
25
|
+
<%= f.label :emails, 'Emails' %>
|
26
|
+
<% f.inputs :for => :emails do |ef| %>
|
27
|
+
<%= render :partial => 'emails/email', :locals => {:f => ef} %>
|
28
|
+
<%= remove_link_unless_new_record(ef) %>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
31
|
+
<%= add_new_record_link f.object, :email, f %>
|
32
|
+
|
33
|
+
<div id='instant_messengers' class='multi instant_messengers'>
|
34
|
+
<%= f.label :instant_messengers, 'Instant Messengers' %>
|
35
|
+
<% f.inputs :for => :instant_messengers do |imf|%>
|
36
|
+
<%= render :partial => 'instant_messengers/instant_messenger', :locals => {:f => imf } %>
|
37
|
+
<%= remove_link_unless_new_record(imf) %>
|
38
|
+
<% end %>
|
39
|
+
</div>
|
40
|
+
<%= add_new_record_link f.object, :instant_messenger, f %>
|
41
|
+
|
42
|
+
<div id='websites' class='multi websites'>
|
43
|
+
<%= f.label :websites, 'Websites'%>
|
44
|
+
<% f.inputs :for => :websites do |wf|%>
|
45
|
+
<%= render :partial => 'websites/website', :locals => {:f => wf} %>
|
46
|
+
<%= remove_link_unless_new_record(wf) %>
|
47
|
+
<% end %>
|
48
|
+
</div>
|
49
|
+
<%= add_new_record_link f.object, :website, f %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% unless @divisions.empty? %>
|
2
|
+
<li id="address_division<%= @level %>_input" class="select optional">
|
3
|
+
<label for="address_division<%= @level %>_id">Division<%=@level%></label>
|
4
|
+
<% clear_children = "$('.#{@field_dom_id}.division.child#{@level}').html('')" %>
|
5
|
+
<% update_child_division = remote_function(:url => {:controller => 'divisions', :action => 'index'}, :with => "'field_dom_id=#{@field_dom_id}&search[country_id]=' + $('##{@field_dom_id}_country #address_country_id').val() + '&search[parent_id]=' + $('##{@field_dom_id}_division#{@level} #address_division#{@level}_id').val() +'&search[level]=#{@level + 1}'", :update => "#{@field_dom_id}_division#{@level + 1}") %>
|
6
|
+
<% update_city = remote_function(:url => {:controller => 'cities', :action => 'index'}, :with => "'field_dom_id=#{@field_dom_id}&search[country_id]=' + $('##{@field_dom_id}_country #address_country_id').val() + '&search[division_id]=' + $('##{@field_dom_id}_division#{@level} #address_division#{@level}_id').val()", :update => "#{@field_dom_id}_city") %>
|
7
|
+
<%= collection_select :address, "division#{@level}_id", @divisions, :id, :name, {:prompt => t('divisions.prompt'), :include_blank => t('actions.clear')} , {:onchange => "#{clear_children};#{update_child_division};#{update_city}"} %>
|
8
|
+
</li>
|
9
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<% address ||= @field %>
|
2
|
+
<span id='<%= dom_id address %>_country'>
|
3
|
+
<% clear_children = "$('.#{dom_id address}.division').html('')" %>
|
4
|
+
<% update_child_division = remote_function(:url => {:controller => 'divisions', :action => 'index'}, :with => "'field_dom_id=#{dom_id address}&search[country_id]=' + $('##{dom_id address}_country #address_country_id').val()", :update => "#{dom_id address}_division1") %>
|
5
|
+
<%= f.input :country, :prompt => t('countries.prompt'), :include_blank => t('actions.clear'), :input_html => {:onchange => "#{clear_children};#{update_child_division}"}%>
|
6
|
+
</span>
|
7
|
+
<% (1..4).each do |level| %>
|
8
|
+
<span id='<%= dom_id address %>_division<%= level %>' class='<%= dom_id address %> division <%= (0..level - 1).to_a.reverse.map {|i| "child#{i} "} %>'>
|
9
|
+
<% if level == 1
|
10
|
+
empty = address.country.blank? || address.country.first_level_divisions.empty?
|
11
|
+
collection = address.country.first_level_divisions unless empty
|
12
|
+
else
|
13
|
+
empty = address.send("division#{level - 1}").blank? || address.send("division#{level - 1}").children.empty?
|
14
|
+
collection = address.send("division#{level - 1}").children unless empty
|
15
|
+
end %>
|
16
|
+
<% unless empty %>
|
17
|
+
<% clear_children = "$('.#{dom_id address}.division.child#{level}').html('')" %>
|
18
|
+
<% update_child_division = remote_function(:url => {:controller => 'divisions', :action => 'index'}, :with => "'field_dom_id=#{dom_id address}&search[country_id]=' + $('##{dom_id address}_country #address_country_id').val() + '&search[parent_id]=' + $('##{dom_id address}_division#{level} #address_division#{level}_id').val() +'&search[level]=#{level + 1}'", :update => "#{dom_id address}_division#{level + 1}") %>
|
19
|
+
<% update_city = remote_function(:url => {:controller => 'cities', :action => 'index'}, :with => "'field_dom_id=#{dom_id address}&search[country_id]=' + $('##{dom_id address}_country #address_country_id').val() + '&search[division_id]=' + $('##{dom_id address}_division#{level} #address_division#{level}_id').val()", :update => "#{dom_id address}_city") %>
|
20
|
+
<%= f.input "division#{level}".to_sym, :collection => collection, :prompt => t('divisions.prompt'), :include_blank => t('actions.clear'), :input_html => {:onchange => "#{clear_children};#{update_child_division};#{update_city}"} %>
|
21
|
+
<% end %>
|
22
|
+
</span>
|
23
|
+
<% end %>
|
24
|
+
<span id='<%= dom_id address %>_city' class='<%= dom_id address %> division child1 child2 child3 child4'>
|
25
|
+
<% unless address.cities.empty? %>
|
26
|
+
<%= f.input :city, :collection => address.cities, :prompt => t('cities.prompt'), :include_blank => t('actions.clear') %>
|
27
|
+
<% end %>
|
28
|
+
</span>
|
29
|
+
<%= f.input :address %>
|
30
|
+
<%= f.input :zip %>
|
31
|
+
<%= f.input :type %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% semantic_remote_form_for [address.owner, address] do |f| %>
|
2
|
+
<% f.inputs do %>
|
3
|
+
<%= render :partial => 'addresses/address', :locals => {:f => f, :address => address} %>
|
4
|
+
<% end %>
|
5
|
+
<% f.buttons do %>
|
6
|
+
<%= f.commit_button %>
|
7
|
+
<li><%= link_to_function t('actions.cancel'), "$('#new_address_form').hide();$('#new_address').reset();$('#new_address_link').show()" %></li>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<% unless @cities.empty? %>
|
2
|
+
<li id="address_city_input" class="select optional">
|
3
|
+
<label for="address_city_id">City</label>
|
4
|
+
<%= collection_select :address, :city_id, @cities, :id, :name, {:prompt => t('cities.prompt'), :include_blank => t('actions.clear')} %>
|
5
|
+
</li>
|
6
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= f.input :birthday, :as => :calendar %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<div id='<%= dom_id contactable %>'>
|
2
|
+
|
3
|
+
<%= render contactable rescue nil%>
|
4
|
+
|
5
|
+
<p>
|
6
|
+
<span class='label'><%= contactable.class.human_attribute_name('name') %>:</span>
|
7
|
+
<%= in_place_editor_for contactable, {:name => 'contactable/name'}, {:display => contactable.name.blank? ? '-' : contactable.name} %>
|
8
|
+
</p>
|
9
|
+
<p>
|
10
|
+
<span class='label'><%= contactable.class.human_attribute_name('birthday') %>:</span>
|
11
|
+
<%= in_place_editor_for contactable, {:birthday => 'contactable/birthday'}, {:display => contactable.birthday.blank? ? '-' : contactable.birthday} %>
|
12
|
+
</p>
|
13
|
+
<% ['identification','phone', 'email', 'address', 'instant_messenger', 'website'].each do |field_name| %>
|
14
|
+
<%= render :partial => 'contactable/contactable_field', :locals => {:contactable => contactable, :field_name => field_name} %>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
data/generators/contactable_views/templates/views/jintastic/contactable/_contactable_field.html.erb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
<div class='multi <%= field_name.pluralize %>'>
|
2
|
+
<span class='label'><%= contactable.class.human_attribute_name(field_name.pluralize) %>:</span>
|
3
|
+
<ul>
|
4
|
+
<% contactable.send(field_name.pluralize).each do |field| %>
|
5
|
+
<% @field = field %>
|
6
|
+
<li id='<%= dom_id field %>'><%= in_place_editor_for [contactable, field], {field_name.to_sym => field_name.pluralize + '/' + field_name}, {:display => send(field_name + '_label',field)} %> <span>(<%= link_to_remote t('actions.destroy'), { :url => url_for([field.owner, field]), :confirm => t('actions.confirm_destroy'), :method => :delete } %>)</span></li>
|
7
|
+
<% end %>
|
8
|
+
</ul>
|
9
|
+
<%= link_to_function t(contactable.class.to_s.downcase.pluralize.dasherize + '.' + contactable.class.to_s.downcase.dasherize + '.add_' + field_name), "$('#new_#{field_name}_form').show();$('#new_#{field_name}_link').hide()", :id => "new_#{field_name}_link" %>
|
10
|
+
<div id='new_<%= field_name %>_form' class = 'new_field_form' style='display: none;'>
|
11
|
+
<% @field = contactable.send(field_name.pluralize).new %>
|
12
|
+
<%= render :partial => field_name.pluralize + '/form', :locals => {field_name.to_sym => @field } %>
|
13
|
+
</div>
|
14
|
+
</div>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<%= f.input :first_name %>
|
2
|
+
<%= f.input :middle_name %>
|
3
|
+
<%= f.input :last_name %>
|
4
|
+
<%= f.input :birthday, :as => :calendar %>
|
5
|
+
|
6
|
+
<div id='phones' class='multi phones'>
|
7
|
+
<%= f.label :phones, 'Phones' %>
|
8
|
+
<% f.inputs :for => :phones do |pf|%>
|
9
|
+
<%= render :partial => 'phones/phone', :locals => {:f => pf} %>
|
10
|
+
<%= remove_link_unless_new_record(pf) %>
|
11
|
+
<% end %>
|
12
|
+
</div>
|
13
|
+
<%= add_new_record_link f.object, :phone, f %>
|
14
|
+
|
15
|
+
<div id='addresses' class='multi addresses'>
|
16
|
+
<%= f.label :addresses, 'Addresses' %>
|
17
|
+
<% f.inputs :for => :addresses do |af|%>
|
18
|
+
<%= render :partial => 'addresses/address', :locals => {:f => af} %>
|
19
|
+
<%= remove_link_unless_new_record(af) %>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
22
|
+
<%= add_new_record_link f.object, :address, f %>
|
23
|
+
|
24
|
+
<div id="emails" class='multi emails'>
|
25
|
+
<%= f.label :emails, 'Emails' %>
|
26
|
+
<% f.inputs :for => :emails do |ef| %>
|
27
|
+
<%= render :partial => 'emails/email', :locals => {:f => ef} %>
|
28
|
+
<%= remove_link_unless_new_record(ef) %>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
31
|
+
<%= add_new_record_link f.object, :email, f %>
|
32
|
+
|
33
|
+
<div id='instant_messengers' class='multi instant_messengers'>
|
34
|
+
<%= f.label :instant_messengers, 'Instant Messengers' %>
|
35
|
+
<% f.inputs :for => :instant_messengers do |imf|%>
|
36
|
+
<%= render :partial => 'instant_messengers/instant_messenger', :locals => {:f => imf } %>
|
37
|
+
<%= remove_link_unless_new_record(imf) %>
|
38
|
+
<% end %>
|
39
|
+
</div>
|
40
|
+
<%= add_new_record_link f.object, :instant_messenger, f %>
|
41
|
+
|
42
|
+
<div id='websites' class='multi websites'>
|
43
|
+
<%= f.label :websites, 'Websites'%>
|
44
|
+
<% f.inputs :for => :websites do |wf|%>
|
45
|
+
<%= render :partial => 'websites/website', :locals => {:f => wf} %>
|
46
|
+
<%= remove_link_unless_new_record(wf) %>
|
47
|
+
<% end %>
|
48
|
+
</div>
|
49
|
+
<%= add_new_record_link f.object, :website, f %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% unless @divisions.empty? %>
|
2
|
+
<li id="address_division<%= @level %>_input" class="select optional">
|
3
|
+
<label for="address_division<%= @level %>_id">Division<%=@level%></label>
|
4
|
+
<% clear_children = "$('.#{@field_dom_id}.division.child#{@level}').html('')" %>
|
5
|
+
<% update_child_division = remote_function(:url => {:controller => 'divisions', :action => 'index'}, :with => "'field_dom_id=#{@field_dom_id}&search[country_id]=' + $('##{@field_dom_id}_country #address_country_id').val() + '&search[parent_id]=' + $('##{@field_dom_id}_division#{@level} #address_division#{@level}_id').val() +'&search[level]=#{@level + 1}'", :update => "#{@field_dom_id}_division#{@level + 1}") %>
|
6
|
+
<% update_city = remote_function(:url => {:controller => 'cities', :action => 'index'}, :with => "'field_dom_id=#{@field_dom_id}&search[country_id]=' + $('##{@field_dom_id}_country #address_country_id').val() + '&search[division_id]=' + $('##{@field_dom_id}_division#{@level} #address_division#{@level}_id').val()", :update => "#{@field_dom_id}_city") %>
|
7
|
+
<%= collection_select :address, "division#{@level}_id", @divisions, :id, :name, {:prompt => t('divisions.prompt'), :include_blank => t('actions.clear')} , {:onchange => "#{clear_children};#{update_child_division};#{update_city}"} %>
|
8
|
+
</li>
|
9
|
+
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% semantic_remote_form_for [email.owner, email] do |f| %>
|
2
|
+
<% f.inputs do %>
|
3
|
+
<%= render :partial => 'emails/email', :locals => {:f => f} %>
|
4
|
+
<% end %>
|
5
|
+
<% f.buttons do %>
|
6
|
+
<%= f.commit_button %>
|
7
|
+
<li><%= link_to_function t('actions.cancel'), "$('#new_email_form').hide();$('#new_email').reset();$('#new_email_link').show()" %></li>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% semantic_remote_form_for [identification.owner, identification] do |f| %>
|
2
|
+
<% f.inputs do %>
|
3
|
+
<%= render :partial => 'identifications/identification', :locals => {:f => f} %>
|
4
|
+
<% end %>
|
5
|
+
<% f.buttons do %>
|
6
|
+
<%= f.commit_button %>
|
7
|
+
<li><%= link_to_function t('actions.cancel'), "$('#new_identification_form').hide();$('#new_identification').reset();$('#new_identification_link').show()" %></li>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% semantic_remote_form_for [instant_messenger.owner, instant_messenger] do |f| %>
|
2
|
+
<% f.inputs do %>
|
3
|
+
<%= render :partial => 'instant_messengers/instant_messenger', :locals => {:f => f} %>
|
4
|
+
<% end %>
|
5
|
+
<% f.buttons do %>
|
6
|
+
<%= f.commit_button %>
|
7
|
+
<li><%= link_to_function t('actions.cancel'), "$('#new_instant_messenger_form').hide();$('#new_instant_messenger').reset();$('#new_instant_messenger_link').show()" %></li>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% semantic_remote_form_for [phone.owner, phone] do |f| %>
|
2
|
+
<% f.inputs do %>
|
3
|
+
<%= render :partial => 'phones/phone', :locals => {:f => f} %>
|
4
|
+
<% end %>
|
5
|
+
<% f.buttons do %>
|
6
|
+
<%= f.commit_button %>
|
7
|
+
<li><%= link_to_function t('actions.cancel'), "$('#new_phone_form').hide();$('#new_phone').reset();$('#new_phone_link').show()"%></li>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|