Fix bug #747 and fix some typos in the code too

stable
David Barragán Merino 2014-08-28 12:34:34 +02:00
parent 94193ea3cb
commit 738e66d333
11 changed files with 106 additions and 66 deletions

View File

@ -136,17 +136,17 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, tgLoade
$httpProvider.defaults.headers.get = {}
# Add next param when user try to access to a secction need auth permissions.
authHttpIntercept = ($q, $location, $confirm) ->
authHttpIntercept = ($q, $location, $confirm, $navUrls) ->
return (promise) ->
return promise.then null, (response) ->
if response.status == 0
$location.path("/error")
$location.path($navUrls.resolve("error"))
else if response.status == 401
nextPath = $location.path()
$location.url("/login").search("next=#{nextPath}")
$location.url($navUrls.resolve("login")).search("next=#{nextPath}")
return $q.reject(response)
$provide.factory("authHttpIntercept", ["$q", "$location", "$tgConfirm", authHttpIntercept])
$provide.factory("authHttpIntercept", ["$q", "$location", "$tgConfirm", "$tgNavUrls", authHttpIntercept])
$httpProvider.responseInterceptors.push('authHttpIntercept')
$httpProvider.interceptors.push('loaderInterceptor')

View File

@ -30,6 +30,7 @@ bindOnce = @.taiga.bindOnce
module = angular.module("taigaAdmin")
#############################################################################
## Project Profile Controller
#############################################################################
@ -85,14 +86,14 @@ class ProjectProfileController extends mixOf(taiga.Controller, taiga.PageMixin)
openDeleteLightbox: ->
@rootscope.$broadcast("deletelightbox:new", @scope.project)
module.controller("ProjectProfileController", ProjectProfileController)
#############################################################################
## Project Profile Directive
#############################################################################
ProjectProfileDirective = ($rootscope, $log, $repo, $confirm, $location) ->
ProjectProfileDirective = ($rootscope, $log, $repo, $confirm) ->
link = ($scope, $el, $attrs) ->
form = $el.find("form").checksley({"onlyOneErrorElement": true})
submit = =>
@ -101,7 +102,6 @@ ProjectProfileDirective = ($rootscope, $log, $repo, $confirm, $location) ->
promise = $repo.save($scope.project)
promise.then ->
$confirm.notify("success")
$location.path("/project/#{$scope.project.slug}/admin/project-profile/details")
$scope.$emit("project:loaded", $scope.project)
promise.then null, (data) ->
@ -119,6 +119,9 @@ ProjectProfileDirective = ($rootscope, $log, $repo, $confirm, $location) ->
return {link:link}
module.directive("tgProjectProfile", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", ProjectProfileDirective])
#############################################################################
## Project Features Directive
#############################################################################
@ -161,5 +164,4 @@ ProjectFeaturesDirective = ($rootscope, $log, $repo, $confirm) ->
return {link:link}
module.directive("tgProjectProfile", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", "$tgLocation", ProjectProfileDirective])
module.directive("tgProjectFeatures", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", ProjectFeaturesDirective])

View File

@ -403,7 +403,7 @@ ChangeEmailDirective = ($repo, $model, $auth, $confirm, $location, $params, $nav
onSuccessSubmit = (response) ->
$repo.queryOne("users", $auth.getUser().id).then (data) =>
$auth.setUser(data)
$location.path($navUrls.resolve("home")) # TODO: Use the future 'urls' service
$location.path($navUrls.resolve("home"))
$confirm.success("Our Oompa Loompas updated your email") #TODO: i18n
onErrorSubmit = (response) ->

View File

@ -72,6 +72,7 @@ urls = {
"project-wiki": "/project/:project/wiki",
"project-wiki-page": "/project/:project/wiki/:slug",
"project-wiki-page-edit": "/project/:project/wiki/:slug/edit",
# Admin
"project-admin-home": "/project/:project/admin/project-profile/details"

View File

@ -25,9 +25,11 @@ bindOnce = @.taiga.bindOnce
module = angular.module("taigaNavMenu", [])
#############################################################################
## Projects Navigation
#############################################################################
class ProjectsNavigationController extends taiga.Controller
@.$inject = ["$scope", "$rootScope", "$tgResources", "$tgNavUrls", "$projectUrl"]
@ -59,7 +61,9 @@ class ProjectsNavigationController extends taiga.Controller
@rootscope.$broadcast("projects:create")
filterProjects: (text) ->
@scope.filteredProjects = _.filter(@scope.projects, (project) -> project.name.toLowerCase().indexOf(text) > -1)
@scope.filteredProjects = _.filter @scope.projects, (project) ->
project.name.toLowerCase().indexOf(text) > -1
@scope.filterText = text
@rootscope.$broadcast("projects:filtered")
@ -193,7 +197,7 @@ module.directive("tgProjectsNav", ["$rootScope", "animationFrame", "$timeout", "
## Project
#############################################################################
ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location) ->
ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $navUrls) ->
menuEntriesTemplate = _.template("""
<div class="menu-container">
<ul class="main-nav">
@ -322,7 +326,7 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location) -
event.preventDefault()
$auth.logout()
$scope.$apply ->
$location.path("/login")
$location.path($navUrls.resolve("login"))
$el.on "click", "#nav-search > a", (event) ->
event.preventDefault()
@ -342,5 +346,5 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location) -
return {link: link}
module.directive("tgProjectMenu", ["$log", "$compile", "$tgAuth", "$rootScope", "$tgAuth", "$tgLocation", ProjectMenuDirective])
module.directive("tgProjectMenu", ["$log", "$compile", "$tgAuth", "$rootScope", "$tgAuth", "$tgLocation",
"$tgNavUrls", ProjectMenuDirective])

View File

@ -42,23 +42,15 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
return {link:link}
module.directive("tgLbCreateProject", [
"$rootScope",
"$tgRepo",
"$tgConfirm",
"$location",
"$tgNavUrls",
"$tgResources",
"$projectUrl",
"lightboxService",
CreateProject
])
module.directive("tgLbCreateProject", ["$rootScope", "$tgRepo", "$tgConfirm", "$location", "$tgNavUrls",
"$tgResources", "$projectUrl", "lightboxService", CreateProject])
#############################################################################
## Delete Project Lightbox Directive
#############################################################################
DeleteProjectDirective = ($repo, $rootscope, $auth, $location, lightboxService) ->
DeleteProjectDirective = ($repo, $rootscope, $auth, $location, $navUrls, lightboxService) ->
link = ($scope, $el, $attrs) ->
projectToDelete = null
$scope.$on "deletelightbox:new", (ctx, project)->
@ -73,7 +65,7 @@ DeleteProjectDirective = ($repo, $rootscope, $auth, $location, lightboxService)
promise.then (data) ->
lightboxService.close($el)
$location.path("/")
$location.path($navUrls.resolve("home"))
# FIXME: error handling?
promise.then null, ->
@ -89,5 +81,5 @@ DeleteProjectDirective = ($repo, $rootscope, $auth, $location, lightboxService)
return {link:link}
module.directive("tgLbDeleteProject", ["$tgRepo", "$rootScope", "$tgAuth", "$tgLocation", "lightboxService", DeleteProjectDirective])
module.directive("tgLbDeleteProject", ["$tgRepo", "$rootScope", "$tgAuth", "$tgLocation", "$tgNavUrls",
"lightboxService", DeleteProjectDirective])

View File

@ -2,20 +2,31 @@ taiga = @.taiga
module = angular.module("taigaProject")
bindOnce = @.taiga.bindOnce
class ProjectsController extends taiga.Controller
@.$inject = ["$scope", "$tgResources", "$rootScope", "$tgNavUrls", "$tgAuth", "$tgLocation", "$appTitle", "$projectUrl", "tgLoader"]
@.$inject = [
"$scope",
"$tgResources",
"$rootScope",
"$tgNavUrls",
"$tgAuth",
"$tgLocation",
"$appTitle",
"$projectUrl",
"tgLoader"
]
constructor: (@scope, @rs, @rootscope, @navurls, $auth, $location, appTitle, @projectUrl, tgLoader) ->
appTitle.set("Projects")
constructor: (@scope, @rs, @rootscope, @navurls, @auth, @location, @appTitle, @projectUrl, @tgLoader) ->
@appTitle.set("Projects")
if !$auth.isAuthenticated()
$location.path("/login")
if !@auth.isAuthenticated()
@location.path(@navurls.resolve("login"))
@.projects = []
@.loadInitialData()
.then () =>
@scope.$emit("projects:loaded")
tgLoader.pageLoaded()
@tgLoader.pageLoaded()
loadInitialData: ->
return @rs.projects.list().then (projects) =>
@ -29,8 +40,18 @@ class ProjectsController extends taiga.Controller
module.controller("ProjectsController", ProjectsController)
class ProjectController extends taiga.Controller
@.$inject = ["$scope", "$tgResources", "$tgRepo", "$routeParams", "$q", "$rootScope", "$appTitle", "$tgLocation"]
@.$inject = [
"$scope",
"$tgResources",
"$tgRepo",
"$routeParams",
"$q",
"$rootScope",
"$appTitle",
"$tgLocation"
]
constructor: (@scope, @rs, @repo, @params, @q, @rootscope, @appTitle, @location) ->
@.loadInitialData()
@ -66,9 +87,9 @@ class ProjectController extends taiga.Controller
@scope.stats = stats
return stats
module.controller("ProjectController", ProjectController)
ProjectsPaginationDirective = ($timeout) ->
link = ($scope, $el, $attrs) ->
bindOnce $scope, "projects", (projects) ->
@ -151,8 +172,6 @@ ProjectsPaginationDirective = ($timeout) ->
renderNextAndPrev()
return {
link: link,
scope: {

View File

@ -29,6 +29,7 @@ trim = @.taiga.trim
module = angular.module("taigaSearch", [])
#############################################################################
## Search Controller
#############################################################################
@ -121,13 +122,12 @@ SearchBoxDirective = ($lightboxService, $navurls, $location, $route)->
text = $el.find("#search-text").val()
url = $navurls.resolve("project-search")
url = $navurls.formatUrl(url, {'project': project.slug})
url = $navurls.resolve("project-search", {project: project.slug})
$lightboxService.close($el)
$scope.$apply ->
$location.path(url)
$location.search("text",text).path(url)
$location.search("text", text).path(url)
$route.reload()
$scope.$on "search-box:show", (ctx, newProject)->
@ -144,7 +144,6 @@ SearchBoxDirective = ($lightboxService, $navurls, $location, $route)->
return {link:link}
module.directive("tgSearchBox", ["lightboxService", "$tgNavUrls", "$tgLocation", "$route", SearchBoxDirective])
@ -153,7 +152,6 @@ module.directive("tgSearchBox", ["lightboxService", "$tgNavUrls", "$tgLocation",
#############################################################################
SearchDirective = ($log, $compile, $templatecache, $routeparams, $location) ->
# linkFilters = ($scope, $el, $attrs, $ctrl) ->
linkTable = ($scope, $el, $attrs, $ctrl) ->
tabsDom = $el.find("section.search-filter")
lastSeatchResults = null
@ -235,7 +233,6 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams, $location) ->
link = ($scope, $el, $attrs) ->
$ctrl = $el.controller()
# linkFilters($scope, $el, $attrs, $ctrl)
linkTable($scope, $el, $attrs, $ctrl)
searchText = $routeparams.text
@ -244,5 +241,5 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams, $location) ->
return {link:link}
module.directive("tgSearch", ["$log", "$compile", "$templateCache", "$routeParams", "$tgLocation", SearchDirective])
module.directive("tgSearch", ["$log", "$compile", "$templateCache", "$routeParams", "$tgLocation",
SearchDirective])

View File

@ -24,11 +24,12 @@ bindOnce = @.taiga.bindOnce
module = angular.module("taigaUserSettings")
#############################################################################
## Delete User Lightbox Directive
#############################################################################
DeleteUserDirective = ($repo, $rootscope, $auth, $location, lightboxService) ->
DeleteUserDirective = ($repo, $rootscope, $auth, $location, $navUrls, lightboxService) ->
link = ($scope, $el, $attrs) ->
$scope.$on "deletelightbox:new", (ctx, user)->
lightboxService.open($el)
@ -42,7 +43,7 @@ DeleteUserDirective = ($repo, $rootscope, $auth, $location, lightboxService) ->
promise.then (data) ->
lightboxService.close($el)
$auth.logout()
$location.path("/login")
$location.path($navUrls.resolve("login"))
# FIXME: error handling?
promise.then null, ->
@ -58,5 +59,5 @@ DeleteUserDirective = ($repo, $rootscope, $auth, $location, lightboxService) ->
return {link:link}
module.directive("tgLbDeleteUser", ["$tgRepo", "$rootScope", "$tgAuth", "$tgLocation", "lightboxService", DeleteUserDirective])
module.directive("tgLbDeleteUser", ["$tgRepo", "$rootScope", "$tgAuth", "$tgLocation", "$tgNavUrls",
"lightboxService", DeleteUserDirective])

View File

@ -44,10 +44,12 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin, taig
"$tgLocation",
"$filter",
"$log",
"$appTitle"
"$appTitle",
"$tgNavUrls"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @filter, @log, @appTitle) ->
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @filter, @log, @appTitle,
@navUrls) ->
@.attachmentsUrlName = "wiki/attachments"
@scope.projectSlug = @params.pslug
@ -79,9 +81,12 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin, taig
@scope.wikiId = data.wikipage
@scope.projectId = data.project
return data
promise.then null, =>
@location.path("/project/#{@params.pslug}/wiki/#{@params.slug}/edit")
ctx = {
project: @params.pslug
slug: @params.slug
}
@location.path(@navUrls.resolve("project-wiki-page-edit", ctx))
loadWiki: ->
if @scope.wikiId
@ -114,19 +119,28 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin, taig
.then(=> @.loadAttachments(@scope.wikiId))
edit: ->
@location.path("/project/#{@scope.projectSlug}/wiki/#{@scope.wikiSlug}/edit")
ctx = {
project: @scope.projectSlug
slug: @scope.wikiSlug
}
@location.path(@navUrls.resolve("project-wiki-page-edit", ctx))
cancel: ->
@location.path("/project/#{@scope.projectSlug}/wiki/#{@scope.wikiSlug}")
ctx = {
project: @scope.projectSlug
slug: @scope.wikiSlug
}
@location.path(@navUrls.resolve("project-wiki-page", ctx))
delete: ->
onSuccess = =>
ctx = {project: @scope.projectSlug}
@location.path(@navUrls.resolve("project-wiki", ctx))
@confirm.notify("success")
@location.path("/project/#{@scope.projectSlug}/wiki")
onError = =>
@confirm.notify("error")
# TODO: i18n
title = "Delete Wiki Page"
subtitle = unslugify(@scope.wiki.slug)
@ -143,12 +157,15 @@ module.controller("WikiDetailController", WikiDetailController)
class WikiEditController extends WikiDetailController
save: ->
onSuccess = =>
ctx = {
project: @scope.projectSlug
slug: @scope.wiki.slug
}
@location.path(@navUrls.resolve("project-wiki-page", ctx))
@confirm.notify("success")
@location.path("/project/#{@scope.projectSlug}/wiki/#{@scope.wiki.slug}")
onError = =>
@confirm.notify("error")
@location.path("/project/#{@scope.projectSlug}/wiki/#{@scope.wiki.slug}")
if @scope.wiki.id
@repo.save(@scope.wiki).then onSuccess, onError
@ -157,9 +174,9 @@ class WikiEditController extends WikiDetailController
@scope.wiki.slug = @scope.wikiSlug
@repo.create("wiki", @scope.wiki).then onSuccess, onError
module.controller("WikiEditController", WikiEditController)
#############################################################################
## Wiki Main Directive
#############################################################################
@ -172,6 +189,7 @@ WikiDirective = ($tgrepo, $log, $location, $confirm) ->
module.directive("tgWikiDetail", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", WikiDirective])
#############################################################################
## Wiki Edit Main Directive
#############################################################################
@ -184,6 +202,7 @@ WikiEditDirective = ($tgrepo, $log, $location, $confirm) ->
module.directive("tgWikiEdit", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", WikiEditDirective])
#############################################################################
## Wiki User Info Directive
#############################################################################
@ -207,7 +226,7 @@ WikiUserInfoDirective = ($log) ->
else
user = $scope.usersById[wiki.last_modifier]
if user is undefined
ctx = {name: "Unassigned", imgurl: "/images/unnamed.png"}
ctx = {name: "unknown", imgurl: "/images/unnamed.png"}
else
ctx = {name: user.full_name_display, imgurl: user.photo}

View File

@ -29,11 +29,12 @@ unslugify = @.taiga.slugify
module = angular.module("taigaWiki")
#############################################################################
## Wiki Main Directive
#############################################################################
WikiNavDirective = ($tgrepo, $log, $location, $confirm) ->
WikiNavDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
template = _.template("""
<header>
<h1>Links</h1>
@ -86,7 +87,11 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm) ->
linkId = target.parents('.wiki-link').data('id')
linkSlug = $scope.wikiLinks[linkId].href
$scope.$apply ->
$location.path("/project/#{$scope.projectSlug}/wiki/#{linkSlug}")
ctx = {
project: $scope.projectSlug
slug: linkSlug
}
$location.path($navUrls.resolve("project-wiki-page", ctx))
$el.on "click", ".add-button", (event) ->
event.preventDefault()
@ -134,4 +139,4 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm) ->
return {link:link}
module.directive("tgWikiNav", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", WikiNavDirective])
module.directive("tgWikiNav", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", "$tgNavUrls", WikiNavDirective])