Permalink
Browse files

Implemented Chosen

Got chosen working.  Made a class called chosen that triggers the plugin since it won't be used everywhere.
  • Loading branch information...
1 parent 1ca6785 commit 0d2f098ce70efd144186129e2ae02d163ac4c98f @kcalmes kcalmes committed Dec 22, 2011
@@ -59,13 +59,6 @@ def current_user
@current_user = User.find_by_net_id(cookies[:net_id])
@current_user = User.create(:net_id => cookies[:net_id], :roles => [Role.find_by_name('student')]) if (not @current_user) && (cookies[:net_id] != "")
end
- if @current_user
- if not @current_user[:firstname].blank?
- @current_user[:display_name] = @current_user[:firstname] + " " + @current_user[:lastname]
- else
- @current_user[:display_name] = @current_user[:net_id]
- end
- end
@current_user
end
@@ -4,6 +4,10 @@ class Location < ActiveRecord::Base
belongs_to :country
validates_presence_of :city
+
+ def display_name
+ "#{self.city}, #{self.country.name}"
+ end
end
# == Schema Information
View
@@ -7,10 +7,16 @@ class User < ActiveRecord::Base
has_many :short_term_goals
has_many :long_term_goals
- attr_accessor :display_name
-
def has_role roles
roles = roles.map{|role_name| Role.find_by_name(role_name)}
not (roles & self.roles).empty?
end
+
+ def display_name
+ if not self.firstname.blank?
+ "#{self.firstname self.lastname}"
+ else
+ "#{self.net_id}"
+ end
+ end
end
@@ -38,7 +38,7 @@
</div>
<div class="field">
<%= f.label :department_id %>
- <%= f.collection_select :department_id, Department.all, :id, :name %>
+ <%= f.collection_select :department_id, Department.all, :id, :name, {}, {:class => 'chosen'} %>
</div>
<% end %>
@@ -2,7 +2,6 @@
<% if @academic_focus.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@academic_focus.errors.count, "error") %> prohibited this academic_focus from being saved:</h2>
-
<ul>
<% @academic_focus.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
@@ -20,17 +19,17 @@
<div class="box grid_8">
<div class="block">
- <div class="field">
- <%= f.label :name %>
- <%= f.text_field :name %>
- </div>
+ <div class="field">
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+ </div>
<div class="field">
<%= f.label :academic_focus_type_id %>
- <%= f.collection_select :academic_focus_type_id, AcademicFocusType.all, :id, :name %>
+ <%= f.collection_select :academic_focus_type_id, AcademicFocusType.all, :id, :name, {}, {:class => 'chosen'} %>
</div>
<div class="field">
<%= f.label :department_id %>
- <%= f.collection_select :department_id, Department.all, :id, :name %>
+ <%= f.collection_select :department_id, Department.all, :id, :name, {}, {:class => 'chosen'} %>
</div>
</div>
</div>
@@ -27,7 +27,7 @@
</div>
<div class="field">
<%= f.label :college_id %>
- <%= f.collection_select :college_id, College.all, :id, :name %>
+ <%= f.collection_select :college_id, College.all, :id, :name, {}, {:class => 'chosen'} %>
</div>
</div></div>
@@ -26,7 +26,7 @@
</div>
<div class="field">
<%= f.label :industry_id %>
- <%= f.collection_select :industry_id, Industry.all, :id, :name %>
+ <%= f.collection_select :industry_id, Industry.all, :id, :name, {}, {:class => 'chosen'} %>
</div>
<% end %>
@@ -25,7 +25,7 @@
</div>
<div class="field">
<%= f.label :financial_assistance_option_type_id %>
- <%= f.collection_select :financial_assistance_option_type_id, FinancialAssistanceOptionType.all, :id, :name %>
+ <%= f.collection_select :financial_assistance_option_type_id, FinancialAssistanceOptionType.all, :id, :name, {}, {:class => 'chosen'} %>
</div>
<div class="field">
<%= f.label :how_much, "How much (in dollars)" %>
@@ -1,4 +1,5 @@
<script>
+/*
$(function(){
$("#internship_provider_id").change(function(){
$.ajax({
@@ -73,9 +74,9 @@
}
});
}
+*/
</script>
<style>
-
.add_img{
float: right;
width: 25px;
@@ -129,7 +130,7 @@
<div class="field">
<%= f.label :provider_id %>
<div class="input_group">
- <%= f.collection_select :provider_id, Provider.all, :id, :name %>
+ <%= f.collection_select :provider_id, Provider.all, :id, :name, {}, {:class => 'chosen'} %>
</div>
<img class="add_img select" model="providers">
</div>
@@ -151,68 +152,67 @@
<%= theme_box(8, "Tags", true) do %>
<div class="field">
- <%= f.label :fields, "Fields" %>
- <%= f.autosuggest_field :fields, autosuggest_fields_path, :autosuggest_options => {"selectedValuesProp" => "value", "selectedItemProp" => "name", "preFill" => fields_json(@internship.fields)} %>
+ <%= f.label :fields, "Fields" %><br />
+ <%= f.collection_select :field_ids, Field.all, :id, :name, {}, {:multiple => true, :class => 'chosen'} %>
<img class="add_img" model="fields">
</div>
<div class="field">
- <%= f.label :academic_focuses, "Majors/Minors" %>
- <%= f.autosuggest_field :academic_focuses, autosuggest_academic_focuses_path, :autosuggest_options => {"selectedValuesProp" => "value", "selectedItemProp" => "name", "preFill" => academic_focuses_json(@internship.academic_focuses)} %>
+ <%= f.label :academic_focuses, "Majors/Minors" %><br />
+ <%= f.collection_select :academic_focus_ids, AcademicFocus.all, :id, :name, {}, {:multiple => true, :class => 'chosen'} %>
<img class="add_img" model="academic_focuses">
</div>
<div class="field">
- <%= f.label :locations, "Locations" %>
- <%= f.autosuggest_field :locations, autosuggest_locations_path, :autosuggest_options => {"selectedValuesProp" => "value", "selectedItemProp" => "name", "preFill" => locations_json(@internship.locations)} %>
+ <%= f.label :locations, "Locations" %><br />
+ <%= f.collection_select :location_ids, Location.all, :id, :display_name, {}, {:multiple => true, :class => 'chosen'} %>
<img class="add_img" model="locations">
</div>
<div class="field">
- <%= f.label :semesters, "Semesters" %>
- <%= f.autosuggest_field :semesters, autosuggest_semesters_path, :autosuggest_options => {"selectedValuesProp" => "value", "selectedItemProp" => "name", "preFill" => semesters_json(@internship.semesters)} %>
+ <%= f.label :semesters, "Semesters" %><br />
+ <%= f.collection_select :semester_ids, Semester.all, :id, :name, {}, {:multiple => true, :class => 'chosen'} %>
<img class="add_img" model="semesters">
</div>
<div class="field">
- <%= f.label :languages, "Languages" %>
- <%= f.autosuggest_field :languages, autosuggest_languages_path, :autosuggest_options => {"selectedValuesProp" => "value", "selectedItemProp" => "name", "preFill" => languages_json(@internship.languages)} %>
+ <%= f.label :languages, "Languages" %><br />
+ <%= f.collection_select :language_ids, Language.all, :id, :name, {}, {:multiple => true, :class => 'chosen'} %>
<img class="add_img" model="languages">
</div>
<div class="field">
- <%= f.label :financial_assistance_options, "Financial Assistance Options" %>
- <%= f.autosuggest_field :financial_assistance_options, autosuggest_financial_assistance_options_path, :autosuggest_options => {"selectedValuesProp" => "value", "selectedItemProp" => "name", "preFill" => financial_assistance_options_json(@internship.financial_assistance_options)} %>
- <img class="add_img" model="financial_assistance_options">
+ <%= f.label :financial_assistance_options, "Financial Assistance Options" %><br />
+ <%= f.collection_select :financial_assistance_options, FinancialAssistanceOption.all, :id, :name, {}, {:multiple => true, :class => 'chosen'} %>
+ <img class="add_img" model="financial_assistance_options">
</div>
<% end %>
-
- <%= theme_box(8, "Qualifications", true, false) do %>
- <div class="field">
- <%= f.label :qualifications %>
- <%= f.text_area :qualifications, :class => 'tiny_editor' %>
- </div>
- <div class="field">
- <%= f.label :qualifications_academic %>
- <%= f.text_area :qualifications_academic, :class => 'tiny_editor' %>
- </div>
- <div class="field">
- <%= f.label :requires_us_citizenship %>
- <%= f.check_box :requires_us_citizenship %>
- </div>
- <% end %>
-
- <%= theme_box(8, "Contact Information", true) do %>
- <div class="field">
- <%= f.label :academic_contact_id %>
- <div class="input_group">
- <%= f.collection_select :academic_contact_id, AcademicContact.all, :id, :name %>
+ <div class="grid_8">
+ <%= theme_box(16, "Contact Information", true) do %>
+ <div class="field">
+ <%= f.label :academic_contact_id %>
+ <div class="input_group">
+ <%= f.collection_select :academic_contact_id, AcademicContact.all, :id, :name, {}, {:class => 'chosen'} %>
+ </div>
+ <img class="add_img select" model="academic_contacts">
</div>
- <img class="add_img select" model="academic_contacts">
- </div>
- <div class="field">
- <%= f.label :provider_contact_id %>
- <div class="input_group">
- <%= f.collection_select :provider_contact_id, ProviderContact.all, :id, :name %>
+ <div class="field">
+ <%= f.label :provider_contact_id %>
+ <div class="input_group">
+ <%= f.collection_select :provider_contact_id, ProviderContact.all, :id, :name, {}, {:class => 'chosen'} %>
+ </div>
+ <img class="add_img select" model="provider_contacts">
</div>
- <img class="add_img select" model="provider_contacts">
- </div>
- <% end %>
+ <% end %>
+ <%= theme_box(16, "Qualifications", true, false) do %>
+ <div class="field">
+ <%= f.label :qualifications %>
+ <%= f.text_area :qualifications, :class => 'tiny_editor' %>
+ </div>
+ <div class="field">
+ <%= f.label :qualifications_academic %>
+ <%= f.text_area :qualifications_academic, :class => 'tiny_editor' %>
+ </div>
+ <div class="field">
+ <%= f.check_box :requires_us_citizenship %>Requires us citizenship?
+ </div>
+ <% end %>
+ </div>
<%= theme_box(8, "Additional Information", true) do %>
<div class="field">
@@ -231,25 +231,24 @@
<%= f.label :notes %><br />
<%= f.text_area :notes, :class => 'tiny_editor' %>
</div>
- <% end %>
-
- <% if can? :manage, :users %>
- <%= theme_box(8, "Ownership", true) do %>
+ <% if can? :manage, :users %>
+
<div class="field">
- <label>Net Id</label>
+ <label>Owner</label>
<div class="input_group">
- <%= f.collection_select :user_id, User.all, :id, :net_id, {:selected => @internship.user.id} %>
+ <%= f.collection_select :user_id, User.all, :id, :net_id, {:selected => @internship.user.id}, {:class => 'chosen'} %>
</div>
</div>
+
+ <% else %>
+ <%= f.hidden_field :user_id %>
<% end %>
- <% else %>
- <%= f.hidden_field :user_id %>
- <% end %>
-
+ <% end %>
<% end %>
+
<script>
$(function(){
- $(".as-selections").width($(".as-selections").width() - 30);
+ //$(".as-selections").width($(".as-selections").width() - 30);
});
</script>
@@ -13,7 +13,7 @@
Guest
<% end %>
</h2>
- <h3><a class="text_shadow" href="#profile"><%= @current_user[:display_name] %></a></h3>
+ <h3><a class="text_shadow" href="#profile"><%= @current_user.display_name %></a></h3>
<ul>
<li><a href="#">settings</a><span class="divider">|</span></li>
<li><%= link_to 'logout', logout_path %></li>
@@ -25,11 +25,11 @@
</div>
<div class="field">
<%= f.label :state_id %>
- <%= f.collection_select :state_id, State.all, :id, :name %>
+ <%= f.collection_select :state_id, State.all, :id, :name, {}, {:class => 'chosen'} %>
</div>
<div class="field">
<%= f.label :country_id %>
- <%= f.collection_select :country_id, Country.all, :id, :name %>
+ <%= f.collection_select :country_id, Country.all, :id, :name, {}, {:class => 'chosen'} %>
</div>
<% end %>
@@ -32,7 +32,7 @@
<div class="field">
<label>Net Id</label>
<div class="input_group">
- <%= f.collection_select :user_id, User.all, :id, :net_id, {:selected => @long_term_goal.user.id} %>
+ <%= f.collection_select :user_id, User.all, :id, :net_id, {:selected => @long_term_goal.user.id},{:class => 'chosen'} %>
</div>
</div>
<% else %>
@@ -5,7 +5,7 @@
<div id="header" class=""><!--My Guide--></div>
<div class="grid_4 year">
<% if can? :manage, :myguide %>
- <%= select_tag :active_user, options_from_collection_for_select(User.order(:net_id), :id, :net_id, @myguide_user_id) %>
+ <%= select_tag :active_user, options_from_collection_for_select(User.order(:net_id), :id, :net_id, @myguide_user_id), {:class => 'chosen'} %>
<% end %>
</div>
<div class="grid_5">
@@ -25,7 +25,7 @@
<% end %>
</div>
-<%= theme_box(8, "Basic Information") do %>
+ <%= theme_box(8, "Basic Information") do %>
<div class="field">
<%= f.label :name %>
<%= f.text_field :name %>
@@ -48,9 +48,9 @@
</div>
<div class="field">
<%= f.label :provider_id %>
- <%= f.collection_select :provider_id, Provider.all, :id, :name %>
+ <%= f.collection_select :provider_id, Provider.all, :id, :name, {}, {:class => 'chosen'} %>
</div>
-<% end %>
+ <% end %>
<% end %>
@@ -36,7 +36,7 @@
</div>
<div class="field">
<%= f.label :provider_type %>
- <%= f.collection_select :provider_type_id, ProviderType.all, :id, :name %>
+ <%= f.collection_select :provider_type_id, ProviderType.all, :id, :name, {}, {:class => 'chosen'} %>
</div>
<% end %>
@@ -122,13 +122,13 @@
</div>
<div class="field">
<%= f.label :tag_id %><br />
- <%= f.collection_select :tag_id, Tag.order(:name), :id, :name %>
+ <%= f.collection_select :tag_id, Tag.order(:name), :id, :name, {}, {:class => 'chosen'} %>
</div>
<% if can? :manage, :users %>
<div class="field">
<label>Net Id</label>
<div class="input_group">
- <%= f.collection_select :user_id, User.all, :id, :net_id, {:selected => @short_term_goal.user.id} %>
+ <%= f.collection_select :user_id, User.all, :id, :net_id, {:selected => @short_term_goal.user.id}, {:class => 'chosen'} %>
</div>
</div>
<% else %>
@@ -1,3 +1,9 @@
+<style>
+ select.chosen, input:not([type="submit"]){
+ width: 300px;
+ }
+
+</style>
<%= form_for(@user) do |f| %>
<% if @user.errors.any? %>
<div id="error_explanation">
@@ -25,7 +31,7 @@
</div>
<div class="field">
<%= f.label :roles %><br />
- <%= f.collection_select :role_ids, Role.all, :id, :name, {}, {:multiple => true} %>
+ <%= f.collection_select :role_ids, Role.all, :id, :name, {}, {:multiple => true, :class => 'chosen'} %>
</div>
<div class="actions">
Oops, something went wrong. Retry.

0 comments on commit 0d2f098

Please sign in to comment.