Mercurial > hg > soundsoftware-site
changeset 160:7eb2194ee428 feature_55
. institution field correctly handled in the user edit and show forms, and in the register view;
author | luisf |
---|---|
date | Fri, 28 Jan 2011 18:44:56 +0000 |
parents | e71a969c151a |
children | bad82329a115 |
files | app/controllers/users_controller.rb app/views/account/register.rhtml app/views/users/_form.rhtml public/javascripts/application.js |
diffstat | 4 files changed, 50 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controllers/users_controller.rb Thu Jan 27 18:46:29 2011 +0000 +++ b/app/controllers/users_controller.rb Fri Jan 28 18:44:56 2011 +0000 @@ -54,8 +54,14 @@ if @user.ssamr_user_detail != nil @description = @user.ssamr_user_detail.description - if @user.ssamr_user_detail.institution_id != nil - @institution_name = Institution.find(@user.ssamr_user_detail.institution_id).name + + if @user.ssamr_user_detail.institution_type != nil + # institution_type is true for listed institutions + if (@user.ssamr_user_detail.institution_type) + @institution_name = Institution.find(@user.ssamr_user_detail.institution_id).name + else + @institution_name = @user.ssamr_user_detail.other_institution + end end end
--- a/app/views/account/register.rhtml Thu Jan 27 18:46:29 2011 +0000 +++ b/app/views/account/register.rhtml Fri Jan 28 18:44:56 2011 +0000 @@ -34,25 +34,19 @@ <% fields_for :ssamr_user_details, :builder => TabularFormBuilder, :lang => current_language do |ssamr_user_detail| %> <p> - <%= ssamr_user_detail.text_area :description, :rows => 3, :cols => 40, :required => true, :class => 'wiki-edit' %> - <em> <%=l(:text_user_ssamr_description_info)%></em> </p> <p> - <%= radio_button_tag(:institution_type, "list", true) %> - <%= label_tag(:institution_type, "I am affiliated to this institution: ") %> + <%= ssamr_user_detail.radio_button :institution_type, true %> <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:prompt => true}) %> </p> <p> - <%= radio_button_tag(:institution_type, "other", false) %> - <%= label_tag("Other institution: ") %> - <%= ssamr_user_detail.text_field(:institution_id) %> + <%= ssamr_user_detail.radio_button :institution_type, false %> Other: + <%= ssamr_user_detail.text_field(:other_institution) %> </p> - - <% end %> <% if Setting.openid? %>
--- a/app/views/users/_form.rhtml Thu Jan 27 18:46:29 2011 +0000 +++ b/app/views/users/_form.rhtml Fri Jan 28 18:44:56 2011 +0000 @@ -1,3 +1,6 @@ + +<%= javascript_include_tag :defaults %> + <%= error_messages_for 'user' %> <!--[form:user]--> @@ -25,17 +28,16 @@ <p> <%= ssamr_user_detail.text_area :description, :rows => 3, :cols => 40, :required => true, :class => 'wiki-edit' %> </p> + <p> + <%= ssamr_user_detail.radio_button :institution_type, true, :onchange => "enable_disable_institution_field($('ssamr_user_details_institution_type_true')); enable_disable_institution_field('ssamr_user_details_institution_type_false');" %> + + <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:selected => @selected_institution_id} ) %> + </p> - <p> - <%= ssamr_user_detail.radio_button :institution_type, true, :checked => true %> - <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:selected => @selected_institution_id} ) %> - </p> - - <p> - <%= ssamr_user_detail.radio_button :institution_type, false, :checked => false %> Other: - <%= ssamr_user_detail.text_field(:other_institution) %> - </p> - + <p> + <%= ssamr_user_detail.radio_button :institution_type, false %> Other: + <%= ssamr_user_detail.text_field(:other_institution) %> + </p> <% end %> </div>
--- a/public/javascripts/application.js Thu Jan 27 18:46:29 2011 +0000 +++ b/public/javascripts/application.js Fri Jan 28 18:44:56 2011 +0000 @@ -239,3 +239,30 @@ } Event.observe(window, 'load', hideOnLoad); + + +/* SSAMR specific functions */ + +/* institution related functions */ +Event.observe(window, 'load', + function() { + if($('ssamr_user_details_institution_type_true').checked) + $('ssamr_user_details_other_institution').disable(); + else if($('ssamr_user_details_institution_type_false').checked) + $('ssamr_user_details_institution_id').disable(); + } +); + + +function enable_disable_institution_field(field){ + + // if($(field).enabled) + // field.disable(); + // else + field.enable(); + +} + + + +