Skip to content

Commit

Permalink
Feature [#39518117] Re-add company switcher
Browse files Browse the repository at this point in the history
Moved company switcher to general layout template to avoid duplication.
  • Loading branch information
Veejay committed Feb 19, 2013
1 parent d79e24b commit dba1753
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
Expand Up @@ -4,5 +4,9 @@ class StaffPlan.View extends Support.CompositeView

@$el.html StaffPlan.Templates.Layouts.application
currentUserId: StaffPlan.currentUser.id

if StaffPlan.userCompanies.length > 1
companySwitcher = new StaffPlan.Views.Shared.CompanySwitcher
@$el.find('header .inner ul:first').append companySwitcher.render().el

$( document.body ).trigger( 'view:rendered' );
$( document.body ).trigger( 'view:rendered' );
Expand Up @@ -3,8 +3,6 @@ class StaffPlan.Views.Shared.CompanySwitcher extends Backbone.View
className: "company-switcher"

initialize: ->
@companies = @options.companies
@parent = @options.parent

events:
"click a.switcher": "changeCompany"
Expand All @@ -16,7 +14,7 @@ class StaffPlan.Views.Shared.CompanySwitcher extends Backbone.View
user = StaffPlan.users.get StaffPlan.currentUser.id
user.save {current_company_id: selectedCompanyId},
success: (model, response, options) ->
window.location.reload(true)
window.location.href = "/staffplans/#{user.id}"
, error: (model, xhr, options) ->
alert "An error occurred while switching companies. Please try again."
render: ->
Expand Down
3 changes: 0 additions & 3 deletions app/assets/javascripts/views/projects/index.js.coffee
Expand Up @@ -57,9 +57,6 @@ class window.StaffPlan.Views.Projects.Index extends StaffPlan.View
years: StaffPlan.relevantYears
parent: @
@$el.find('header .inner ul:first').append @yearFilter.render().el
if StaffPlan.userCompanies.length > 1
@companySwitcher = new StaffPlan.Views.Shared.CompanySwitcher
@$el.find('header .inner ul:first').append @companySwitcher.render().el

@collection.each (project) =>
view = new StaffPlan.Views.Projects.ListItem
Expand Down
3 changes: 0 additions & 3 deletions app/assets/javascripts/views/projects/show.js.coffee
Expand Up @@ -104,9 +104,6 @@ class StaffPlan.Views.Projects.Show extends StaffPlan.View
years: StaffPlan.relevantYears.sort()
parent: @
@$el.find('header .inner ul:first').append @yearFilter.render().el
if StaffPlan.userCompanies.length > 1
@companySwitcher = new StaffPlan.Views.Shared.CompanySwitcher
@$el.find('header .inner ul:first').append @companySwitcher.render().el

# THE USERS AND THEIR INPUTS
@model.getAssignments().each (assignment) =>
Expand Down

0 comments on commit dba1753

Please sign in to comment.