From 0b85c9500f4301c1114c1a0334764ed26f17d1fb Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Wed, 18 Jul 2012 12:16:52 -0300 Subject: [PATCH] [multiple-templates] Listing available templates on profile creation --- app/helpers/application_helper.rb | 16 ++++++++++++++++ app/views/account/_signup_form.rhtml | 2 ++ app/views/enterprise_registration/basic_information.rhtml | 2 ++ app/views/memberships/new_community.rhtml | 2 ++ public/stylesheets/application.css | 24 ++++++++++++++++++++++++ 5 files changed, 46 insertions(+), 0 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 90f0d98..f0c35c2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1331,4 +1331,20 @@ module ApplicationHelper _("Are you sure that you want to remove the item \"#{article.name}\"?") end end + + def template_options(klass, field_name) + return hidden_field_tag("#{field_name}[template_id]", klass.templates.first) if klass.templates.count == 1 + + counter = 0 + radios = klass.templates.map do |template| + counter += 1 + content_tag('li', labelled_radio_button(link_to(template.name, template.url, :target => '_blank'), "#{field_name}[template_id]", template.id, counter==1)) + end.join("\n") + + content_tag('div', content_tag('span', _('Template:')) + + content_tag('ul', radios, :style => 'list-style: none; padding-left: 0; margin-top: 0.5em;'), + :id => 'template-options', + :style => 'margin-top: 1em' + ) + end end diff --git a/app/views/account/_signup_form.rhtml b/app/views/account/_signup_form.rhtml index d5b3118..47e2932 100644 --- a/app/views/account/_signup_form.rhtml +++ b/app/views/account/_signup_form.rhtml @@ -69,6 +69,8 @@
+ <%= template_options(Person, 'profile_data') %> + <% labelled_fields_for :profile_data, @person do |f| %> <%= render :partial => 'profile_editor/person_form', :locals => {:f => f} %> <% end %> diff --git a/app/views/enterprise_registration/basic_information.rhtml b/app/views/enterprise_registration/basic_information.rhtml index 7600470..14c5724 100644 --- a/app/views/enterprise_registration/basic_information.rhtml +++ b/app/views/enterprise_registration/basic_information.rhtml @@ -28,6 +28,8 @@ <%= hidden_field_tag 'create_enterprise[target_id]', environment.id %> <% end %> + <%= template_options(Enterprise, 'create_enterprise')%> + <% button_bar do %> <%= submit_button('next', _('Next'), :cancel => {:profile => current_user.person.identifier, :action=>"enterprises", :controller=>"profile"}) %> <% end %> diff --git a/app/views/memberships/new_community.rhtml b/app/views/memberships/new_community.rhtml index 6f6329c..76e3e70 100644 --- a/app/views/memberships/new_community.rhtml +++ b/app/views/memberships/new_community.rhtml @@ -38,6 +38,8 @@
+ <%= template_options(Community, 'community')%> + <% button_bar do %> <%= submit_button(:save, _('Create')) %> <%= button(:cancel, _('Cancel'), :action => 'index') %> diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 0498851..e4be2dc 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -5675,8 +5675,32 @@ h1#agenda-title { #signup-form .fieldgroup { margin: 5px 10px; + +} + + +#signup-form #template-options a, +#signup-form #template-options label, +#signup-form #template-options span { + color: #6D786E; + font-size: 20px; + font-family: droidserif; +} + +#signup-form #template-options span { + color: #4A4A4A; +} + +#signup-form #template-options label { + display: inline; + margin-left: 8px; } +#signup-form #template-options input { + width: auto; +} + + #signup-form label[for=profile_data_sex_female], #signup-form label[for=profile_data_sex_male] { color: #6d786e; -- libgit2 0.21.2