Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Feature [#39518117] Re-add company switcher

Moved company switcher to general layout template to avoid duplication.
  • Loading branch information...
commit dba17532f39f4e4050c4a5739270b348a041d469 1 parent d79e24b
@Veejay Veejay authored
View
6 app/assets/javascripts/views/_shared/_staffplan.view.js.coffee
@@ -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' );
View
4 app/assets/javascripts/views/_shared/company_switcher.js.coffee
@@ -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"
@@ -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: ->
View
3  app/assets/javascripts/views/projects/index.js.coffee
@@ -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
View
3  app/assets/javascripts/views/projects/show.js.coffee
@@ -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) =>
Please sign in to comment.
Something went wrong with that request. Please try again.