Permalink
Browse files

Organization Selection/Creation Form

  • Loading branch information...
1 parent 16045c8 commit 53908c680004d1fb372c8826cd5a9c1ab4905731 @lapluviosilla lapluviosilla committed Sep 29, 2013
View
5 app/assets/javascripts/projects_setup.js.coffee
@@ -35,4 +35,9 @@ ipo['projects_setup']['show'] = ->
$("#private-location").click (e) ->
select_group_element $(@), e, "private-location", "#project_location_private"
+ $('#organizations .tab').click (e) ->
+ $(@).addClass('active').siblings().first().removeClass 'active'
+ $($(@).data('box')).show().siblings('.tab-box').first().hide()
+ $('#is_new_organization').val(($(@).data('box') == "#new-organization"))
+
ipo['projects_setup']['update'] = ipo['projects_setup']['show']
View
12 app/assets/stylesheets/projects.css.scss
@@ -177,6 +177,18 @@ ul.weekly-cost {
@include trailer(1);
}
+// -----
+// Step 1
+// ------
+.project_organization {
+ @include span-columns(4, 8);
+}
+#existing-organization p {
+ @include pre(1,8);
+ @include leader(1);
+ @include span-columns(3 omega, 8);
+}
+
// ------
// Step 4
// ------
View
11 app/controllers/projects_setup_controller.rb
@@ -17,6 +17,17 @@ def show
def update
@project = current_project
+
+ case step
+ when :about_you
+ if params[:is_new_organization] == "true"
+ params[:project].delete(:organization_id)
+ @project.build_organization
+ else
+ params[:project].delete(:organization_attributes)
+ end
+ end
+
@project.update_attributes params[:project]
render_wizard @project
session[:project_id] = @project.id
View
2 app/models/project.rb
@@ -21,7 +21,7 @@ class Project < ActiveRecord::Base
:address, :internet_distance, :location_private, :location_type, :transportation_available,
:location_description, :culture_description, :housing_type, :dining_location, :housing_description,
:safety_level, :challenges_description, :typical_attire, :guidelines_description, :agree_memo, :agree_to_transport,
- :field_host_attributes, :organization_attributes
+ :field_host_attributes, :organization_attributes, :organization_id
accepts_nested_attributes_for :field_host
accepts_nested_attributes_for :organization
View
14 app/views/projects_setup/about_you.html.haml
@@ -21,12 +21,16 @@
.background.c12.omega
%h3.center Your Background
- %fieldset
+ %fieldset#organizations
+ = hidden_field_tag 'is_new_organization', false
%ul.tab-list.small
- %li.tab Choose Existing
- %li.tab.active New Organization
- .tab-box.w-padding
- = f.fields_for :organization do |f_organization|
+ %li.tab.active(data-box="#existing-organization") Choose Existing
+ %li.tab(data-box="#new-organization") New Organization
+ #existing-organization.tab-box.w-padding
+ = f.association :organization, include_blank: true, label: "Select Organization"
+ %p If you can't find your organization please choose the "New Organization" tab and fill it out
+ #new-organization.tab-box.w-padding(style="display: none")
+ = f.fields_for :organization, Organization.new, validate: true do |f_organization|
= f_organization.input :name
= f_organization.input :organization_type
= f_organization.input :website

0 comments on commit 53908c6

Please sign in to comment.