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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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