Fix: Use $tgNavUrls to get urls

stable
David Barragán Merino 2014-09-18 15:25:34 +02:00
parent add92dddf4
commit 69af98d3bf
19 changed files with 217 additions and 196 deletions

View File

@ -40,10 +40,11 @@ class MembershipsController extends mixOf(taiga.Controller, taiga.PageMixin, tai
"$routeParams",
"$q",
"$tgLocation",
"$tgNavUrls",
"$appTitle"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appTitle) ->
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @navUrls, @appTitle) ->
_.bindAll(@)
@scope.sectionName = "Manage Members" #i18n
@ -55,8 +56,11 @@ class MembershipsController extends mixOf(taiga.Controller, taiga.PageMixin, tai
promise.then () =>
@appTitle.set("Membership - " + @scope.project.name)
promise.then null, ->
console.log "FAIL" #TODO
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
@scope.$on("membersform:new:success", @.loadMembers)
@ -80,10 +84,6 @@ class MembershipsController extends mixOf(taiga.Controller, taiga.PageMixin, tai
@scope.projectId = data.project
return data
promise.then null, =>
@location.path("/not-found")
@location.replace()
return promise.then(=> @.loadProject())
.then(=> @.loadUsersAndRoles())
.then(=> @.loadMembers())

View File

@ -45,10 +45,11 @@ class ProjectProfileController extends mixOf(taiga.Controller, taiga.PageMixin)
"$routeParams",
"$q",
"$tgLocation",
"$tgNavUrls",
"$appTitle"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appTitle) ->
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @navUrls, @appTitle) ->
@scope.project = {}
promise = @.loadInitialData()
@ -58,7 +59,7 @@ class ProjectProfileController extends mixOf(taiga.Controller, taiga.PageMixin)
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)

View File

@ -44,10 +44,11 @@ class ProjectValuesController extends mixOf(taiga.Controller, taiga.PageMixin)
"$routeParams",
"$q",
"$tgLocation",
"$tgNavUrls",
"$appTitle"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appTitle) ->
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @navUrls, @appTitle) ->
@scope.project = {}
promise = @.loadInitialData()
@ -55,8 +56,11 @@ class ProjectValuesController extends mixOf(taiga.Controller, taiga.PageMixin)
promise.then () =>
@appTitle.set("Project values - " + @scope.sectionName + " - " + @scope.project.name)
promise.then null, ->
console.log "FAIL" #TODO
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
@scope.$on("admin:project-values:move", @.moveValue)
@ -76,10 +80,6 @@ class ProjectValuesController extends mixOf(taiga.Controller, taiga.PageMixin)
@scope.projectId = data.project
return data
promise.then null, =>
@location.path("/not-found")
@location.replace()
return promise.then( => @q.all([
@.loadProject(),
@.loadValues(),

View File

@ -41,10 +41,11 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
"$routeParams",
"$q",
"$tgLocation",
"$tgNavUrls",
"$appTitle"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appTitle) ->
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @navUrls, @appTitle) ->
_.bindAll(@)
@scope.sectionName = "Permissions" #i18n
@ -55,8 +56,11 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
promise.then () =>
@appTitle.set("Roles - " + @scope.project.name)
promise.then null, ->
console.log "FAIL" #TODO
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>
@ -75,10 +79,6 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
@scope.projectId = data.project
return data
promise.then null, =>
@location.path("/not-found")
@location.replace()
return promise.then(=> @.loadProject())
.then(=> @.loadUsersAndRoles())
.then(=> @.loadRoles())

View File

@ -214,7 +214,7 @@ module.directive("tgLogin", ["$tgAuth", "$tgConfirm", "$tgLocation", "$routePara
RegisterDirective = ($auth, $confirm, $location, $navUrls, $config) ->
link = ($scope, $el, $attrs) ->
if not $config.get("publicRegisterEnabled")
$location.path("/not-found")
$location.path($navUrls.resolve("not-found"))
$location.replace()
$scope.data = {}

View File

@ -45,10 +45,12 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
"$q",
"$tgLocation",
"$appTitle",
"$tgNavUrls",
"tgLoader"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appTitle, tgLoader) ->
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appTitle, @navUrls,
tgLoader) ->
_.bindAll(@)
@scope.sectionName = "Backlog"
@ -76,7 +78,7 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)

View File

@ -45,6 +45,8 @@ module.directive("tgMain", ["$rootScope", "$window", TaigaMainDirective])
urls = {
"home": "/"
"error": "/error"
"not-found": "/not-found"
"login": "/login"
"forgot-password": "/forgot-password"
"change-password": "/change-password/:token"

View File

@ -61,7 +61,7 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)

View File

@ -48,10 +48,12 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
"$q",
"$tgLocation",
"$appTitle",
"$tgNavUrls",
"tgLoader"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @urls, @params, @q, @location, @appTitle, tgLoader) ->
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @urls, @params, @q, @location, @appTitle,
@navUrls, tgLoader) ->
@scope.sectionName = "Issues"
@scope.filters = {}
@ -72,7 +74,7 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)

View File

@ -58,10 +58,12 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
"$q",
"$tgLocation",
"$appTitle",
"$tgNavUrls",
"tgLoader"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appTitle, tgLoader) ->
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appTitle, @navUrls,
tgLoader) ->
_.bindAll(@)
@scope.sectionName = "Kanban"
@scope.statusViewModes = {}
@ -73,17 +75,10 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
@appTitle.set("Kanban - " + @scope.project.name)
tgLoader.pageLoaded()
# $(".task-column").mCustomScrollbar({
# theme: 'minimal-dark'
# scrollInertia: 0
# axis: 'y'
# });
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)

View File

@ -26,6 +26,7 @@ bindOnce = @.taiga.bindOnce
class ProjectsController extends taiga.Controller
@.$inject = [
"$scope",
"$q",
"$tgResources",
"$rootScope",
"$tgNavUrls",
@ -36,20 +37,28 @@ class ProjectsController extends taiga.Controller
"tgLoader"
]
constructor: (@scope, @rs, @rootscope, @navurls, @auth, @location, @appTitle, @projectUrl, @tgLoader, @navUrls) ->
constructor: (@scope, @q, @rs, @rootscope, @navUrls, @auth, @location, @appTitle, @projectUrl,
@tgLoader) ->
@appTitle.set("Projects")
if !@auth.isAuthenticated()
@location.path(@navurls.resolve("login"))
@location.path(@navUrls.resolve("login"))
@.user = @auth.getUser()
@.projects = []
@.loadInitialData()
.then () =>
promise = @.loadInitialData()
promise.then () =>
@scope.$emit("projects:loaded")
@tgLoader.pageLoaded()
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
loadInitialData: ->
return @rs.projects.list().then (projects) =>
@.projects = {'recents': projects.slice(0, 8), 'all': projects.slice(8)}
@ -57,12 +66,14 @@ class ProjectsController extends taiga.Controller
for project in projects
project.url = @projectUrl.get(project)
return projects
newProject: ->
@rootscope.$broadcast("projects:create")
logout: ->
@auth.logout()
@location.path(@navurls.resolve("login"))
@location.path(@navUrls.resolve("login"))
module.controller("ProjectsController", ProjectsController)
@ -76,13 +87,21 @@ class ProjectController extends taiga.Controller
"$q",
"$rootScope",
"$appTitle",
"$tgLocation"
"$tgLocation",
"$tgNavUrls"
]
constructor: (@scope, @rs, @repo, @params, @q, @rootscope, @appTitle, @location) ->
@.loadInitialData()
.then () =>
@appTitle.set(@scope.project.name)
constructor: (@scope, @rs, @repo, @params, @q, @rootscope, @appTitle, @location, @navUrls) ->
promise = @.loadInitialData()
promise.then () =>
@appTitle.set(@scope.project.name)
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
loadInitialData: ->
# Resolve project slug
@ -90,13 +109,8 @@ class ProjectController extends taiga.Controller
@scope.projectId = data.project
return data
promise.then null, =>
@location.path("/not-found")
@location.replace()
return promise
.then(=> @.loadPageData())
.then(=> @scope.$emit("project:loaded", @scope.project))
return promise.then(=> @.loadPageData())
.then(=> @scope.$emit("project:loaded", @scope.project))
loadPageData: ->
return @q.all([

View File

@ -43,10 +43,11 @@ class SearchController extends mixOf(taiga.Controller, taiga.PageMixin)
"$q",
"$tgLocation",
"$appTitle",
"$tgNavUrls",
"tgLoader"
]
constructor: (@scope, @repo, @rs, @params, @q, @location, @appTitle, @tgLoader) ->
constructor: (@scope, @repo, @rs, @params, @q, @location, @appTitle, @navUrls, @tgLoader) ->
@scope.sectionName = "Search"
promise = @.loadInitialData()
@ -54,8 +55,11 @@ class SearchController extends mixOf(taiga.Controller, taiga.PageMixin)
promise.then () =>
@appTitle.set("Search")
promise.then null, ->
console.log "FAIL" #TODO
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
# Search input watcher
@scope.searchTerm = ""
@ -97,10 +101,6 @@ class SearchController extends mixOf(taiga.Controller, taiga.PageMixin)
@scope.projectId = data.project
return data
promise.then null, =>
@location.path("/not-found")
@location.replace()
return promise.then(=> @.loadProject())
.then(=> @.loadUsersAndRoles())

View File

@ -45,10 +45,12 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
"$q",
"$appTitle",
"$tgLocation",
"$tgNavUrls"
"tgLoader"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @appTitle, @location, tgLoader) ->
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @appTitle, @location, @navUrls,
tgLoader) ->
_.bindAll(@)
@scope.sectionName = "Taskboard"
@ -63,7 +65,7 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)

View File

@ -46,7 +46,8 @@ class TaskDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
"tgLoader"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @log, @appTitle, @navUrls, tgLoader) ->
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @log, @appTitle, @navUrls,
tgLoader) ->
@scope.taskRef = @params.taskref
@scope.sectionName = "Task Details"
@ -56,8 +57,11 @@ class TaskDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
@appTitle.set(@scope.task.subject + " - " + @scope.project.name)
tgLoader.pageLoaded()
promise.then null, ->
console.log "FAIL" #TODO
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
@scope.$on("attachment:create", => @rootscope.$broadcast("history:reload"))
@ -111,10 +115,6 @@ class TaskDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
@scope.taskId = data.task
return data
promise.then null, =>
@location.path("/not-found")
@location.replace()
return promise.then(=> @.loadProject())
.then(=> @.loadUsersAndRoles())
.then(=> @.loadTask())

View File

@ -31,54 +31,55 @@ module = angular.module("taigaUserSettings")
#############################################################################
class UserChangePasswordController extends mixOf(taiga.Controller, taiga.PageMixin)
@.$inject = [
"$scope",
"$rootScope",
"$tgRepo",
"$tgConfirm",
"$tgResources",
"$routeParams",
"$q",
"$tgLocation",
"$tgAuth"
]
@.$inject = [
"$scope",
"$rootScope",
"$tgRepo",
"$tgConfirm",
"$tgResources",
"$routeParams",
"$q",
"$tgLocation",
"$tgNavUrls",
"$tgAuth"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @auth) ->
@scope.sectionName = "Change Password" #i18n
@scope.project = {}
@scope.user = @auth.getUser()
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @navUrls, @auth) ->
@scope.sectionName = "Change Password" #i18n
@scope.project = {}
@scope.user = @auth.getUser()
promise = @.loadInitialData()
promise.then null, ->
console.log "FAIL" #TODO
promise = @.loadInitialData()
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>
@scope.project = project
@scope.$emit('project:loaded', project)
return project
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
loadInitialData: ->
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
@scope.projectId = data.project
return data
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>
@scope.project = project
@scope.$emit('project:loaded', project)
return project
promise.then null, =>
@location.path("/not-found")
@location.replace()
loadInitialData: ->
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
@scope.projectId = data.project
return data
return promise.then(=> @.loadProject())
return promise.then(=> @.loadProject())
save: ->
if @scope.newPassword1 != @scope.newPassword2
@confirm.notify('error', "The passwords dosn't match")
return
save: ->
if @scope.newPassword1 != @scope.newPassword2
@confirm.notify('error', "The passwords dosn't match")
return
promise = @rs.userSettings.changePassword(@scope.currentPassword, @scope.newPassword1)
promise.then =>
@confirm.notify('success')
promise.then null, (response) =>
@confirm.notify('error', response.data._error_message)
promise = @rs.userSettings.changePassword(@scope.currentPassword, @scope.newPassword1)
promise.then =>
@confirm.notify('success')
promise.then null, (response) =>
@confirm.notify('error', response.data._error_message)
module.controller("UserChangePasswordController", UserChangePasswordController)

View File

@ -29,62 +29,63 @@ module = angular.module("taigaUserSettings")
#############################################################################
class UserSettingsController extends mixOf(taiga.Controller, taiga.PageMixin)
@.$inject = [
"$scope",
"$rootScope",
"$tgRepo",
"$tgConfirm",
"$tgResources",
"$routeParams",
"$q",
"$tgLocation",
"$tgAuth"
]
@.$inject = [
"$scope",
"$rootScope",
"$tgRepo",
"$tgConfirm",
"$tgResources",
"$routeParams",
"$q",
"$tgLocation",
"$tgNavUrls",
"$tgAuth"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @auth) ->
@scope.sectionName = "User Profile" #i18n
@scope.project = {}
@scope.user = @auth.getUser()
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @navUrls, @auth) ->
@scope.sectionName = "User Profile" #i18n
@scope.project = {}
@scope.user = @auth.getUser()
promise = @.loadInitialData()
promise.then null, ->
console.log "FAIL" #TODO
promise = @.loadInitialData()
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>
@scope.project = project
@scope.$emit('project:loaded', project)
return project
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
loadInitialData: ->
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
@scope.projectId = data.project
return data
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>
@scope.project = project
@scope.$emit('project:loaded', project)
return project
promise.then null, =>
@location.path("/not-found")
@location.replace()
loadInitialData: ->
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
@scope.projectId = data.project
return data
return promise.then(=> @.loadProject())
return promise.then(=> @.loadProject())
saveUserProfile: ->
updatingEmail = @scope.user.isAttributeModified("email")
promise = @repo.save(@scope.user)
promise.then =>
@auth.setUser(@scope.user)
if updatingEmail
@confirm.success("<strong>Check your inbox!</strong><br />
We have sent a mail to your account<br />
with the instructions to set your new address") #TODO: i18n
else
@confirm.notify('success')
saveUserProfile: ->
updatingEmail = @scope.user.isAttributeModified("email")
promise = @repo.save(@scope.user)
promise.then =>
@auth.setUser(@scope.user)
if updatingEmail
@confirm.success("<strong>Check your inbox!</strong><br />
We have sent a mail to your account<br />
with the instructions to set your new address") #TODO: i18n
else
@confirm.notify('success')
promise.then null, (response) =>
@confirm.notify('error', response._error_message)
@scope.user = @auth.getUser()
promise.then null, (response) =>
@confirm.notify('error', response._error_message)
@scope.user = @auth.getUser()
openDeleteLightbox: ->
@rootscope.$broadcast("deletelightbox:new", @scope.user)
openDeleteLightbox: ->
@rootscope.$broadcast("deletelightbox:new", @scope.user)
module.controller("UserSettingsController", UserSettingsController)

View File

@ -31,49 +31,50 @@ module = angular.module("taigaUserSettings")
#############################################################################
class UserNotificationsController extends mixOf(taiga.Controller, taiga.PageMixin)
@.$inject = [
"$scope",
"$rootScope",
"$tgRepo",
"$tgConfirm",
"$tgResources",
"$routeParams",
"$q",
"$tgLocation",
"$tgAuth"
]
@.$inject = [
"$scope",
"$rootScope",
"$tgRepo",
"$tgConfirm",
"$tgResources",
"$routeParams",
"$q",
"$tgLocation",
"$tgNavUrls",
"$tgAuth"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @auth) ->
@scope.sectionName = "Email Notifications" #i18n
@scope.project = {}
@scope.user = @auth.getUser()
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @navUrls, @auth) ->
@scope.sectionName = "Email Notifications" #i18n
@scope.project = {}
@scope.user = @auth.getUser()
promise = @.loadInitialData()
promise.then null, ->
console.log "FAIL" #TODO
promise = @.loadInitialData()
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>
@scope.project = project
@scope.$emit('project:loaded', project)
return project
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
loadNotifyPolicies: ->
return @rs.notifyPolicies.list().then (notifyPolicies) =>
@scope.notifyPolicies = notifyPolicies
return notifyPolicies
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>
@scope.project = project
@scope.$emit('project:loaded', project)
return project
loadInitialData: ->
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
@scope.projectId = data.project
return data
loadNotifyPolicies: ->
return @rs.notifyPolicies.list().then (notifyPolicies) =>
@scope.notifyPolicies = notifyPolicies
return notifyPolicies
promise.then null, =>
@location.path("/not-found")
@location.replace()
loadInitialData: ->
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
@scope.projectId = data.project
return data
return promise.then(=> @.loadProject())
.then(=> @.loadNotifyPolicies())
return promise.then(=> @.loadProject())
.then(=> @.loadNotifyPolicies())
module.controller("UserNotificationsController", UserNotificationsController)

View File

@ -61,7 +61,7 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)

View File

@ -65,7 +65,7 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)