Commit 0b85c9500f4301c1114c1a0334764ed26f17d1fb

Authored by Rodrigo Souto
Committed by Daniela Feitosa
1 parent 00dacfc2

[multiple-templates] Listing available templates on profile creation

(ActionItem2378)
app/helpers/application_helper.rb
... ... @@ -1331,4 +1331,20 @@ module ApplicationHelper
1331 1331 _("Are you sure that you want to remove the item \"#{article.name}\"?")
1332 1332 end
1333 1333 end
  1334 +
  1335 + def template_options(klass, field_name)
  1336 + return hidden_field_tag("#{field_name}[template_id]", klass.templates.first) if klass.templates.count == 1
  1337 +
  1338 + counter = 0
  1339 + radios = klass.templates.map do |template|
  1340 + counter += 1
  1341 + content_tag('li', labelled_radio_button(link_to(template.name, template.url, :target => '_blank'), "#{field_name}[template_id]", template.id, counter==1))
  1342 + end.join("\n")
  1343 +
  1344 + content_tag('div', content_tag('span', _('Template:')) +
  1345 + content_tag('ul', radios, :style => 'list-style: none; padding-left: 0; margin-top: 0.5em;'),
  1346 + :id => 'template-options',
  1347 + :style => 'margin-top: 1em'
  1348 + )
  1349 + end
1334 1350 end
... ...
app/views/account/_signup_form.rhtml
... ... @@ -69,6 +69,8 @@
69 69  
70 70 <div id="signup-form-profile">
71 71  
  72 + <%= template_options(Person, 'profile_data') %>
  73 +
72 74 <% labelled_fields_for :profile_data, @person do |f| %>
73 75 <%= render :partial => 'profile_editor/person_form', :locals => {:f => f} %>
74 76 <% end %>
... ...
app/views/enterprise_registration/basic_information.rhtml
... ... @@ -28,6 +28,8 @@
28 28 <%= hidden_field_tag 'create_enterprise[target_id]', environment.id %>
29 29 <% end %>
30 30  
  31 + <%= template_options(Enterprise, 'create_enterprise')%>
  32 +
31 33 <% button_bar do %>
32 34 <%= submit_button('next', _('Next'), :cancel => {:profile => current_user.person.identifier, :action=>"enterprises", :controller=>"profile"}) %>
33 35 <% end %>
... ...
app/views/memberships/new_community.rhtml
... ... @@ -38,6 +38,8 @@
38 38 </div>
39 39 </div>
40 40  
  41 + <%= template_options(Community, 'community')%>
  42 +
41 43 <% button_bar do %>
42 44 <%= submit_button(:save, _('Create')) %>
43 45 <%= button(:cancel, _('Cancel'), :action => 'index') %>
... ...
public/stylesheets/application.css
... ... @@ -5675,8 +5675,32 @@ h1#agenda-title {
5675 5675  
5676 5676 #signup-form .fieldgroup {
5677 5677 margin: 5px 10px;
  5678 +
  5679 +}
  5680 +
  5681 +
  5682 +#signup-form #template-options a,
  5683 +#signup-form #template-options label,
  5684 +#signup-form #template-options span {
  5685 + color: #6D786E;
  5686 + font-size: 20px;
  5687 + font-family: droidserif;
  5688 +}
  5689 +
  5690 +#signup-form #template-options span {
  5691 + color: #4A4A4A;
  5692 +}
  5693 +
  5694 +#signup-form #template-options label {
  5695 + display: inline;
  5696 + margin-left: 8px;
5678 5697 }
5679 5698  
  5699 +#signup-form #template-options input {
  5700 + width: auto;
  5701 +}
  5702 +
  5703 +
5680 5704 #signup-form label[for=profile_data_sex_female],
5681 5705 #signup-form label[for=profile_data_sex_male] {
5682 5706 color: #6d786e;
... ...