Fix bug #747 and fix some typos in the code too
parent
94193ea3cb
commit
738e66d333
|
@ -136,17 +136,17 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, tgLoade
|
||||||
$httpProvider.defaults.headers.get = {}
|
$httpProvider.defaults.headers.get = {}
|
||||||
|
|
||||||
# Add next param when user try to access to a secction need auth permissions.
|
# 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) ->
|
||||||
return promise.then null, (response) ->
|
return promise.then null, (response) ->
|
||||||
if response.status == 0
|
if response.status == 0
|
||||||
$location.path("/error")
|
$location.path($navUrls.resolve("error"))
|
||||||
else if response.status == 401
|
else if response.status == 401
|
||||||
nextPath = $location.path()
|
nextPath = $location.path()
|
||||||
$location.url("/login").search("next=#{nextPath}")
|
$location.url($navUrls.resolve("login")).search("next=#{nextPath}")
|
||||||
return $q.reject(response)
|
return $q.reject(response)
|
||||||
|
|
||||||
$provide.factory("authHttpIntercept", ["$q", "$location", "$tgConfirm", authHttpIntercept])
|
$provide.factory("authHttpIntercept", ["$q", "$location", "$tgConfirm", "$tgNavUrls", authHttpIntercept])
|
||||||
$httpProvider.responseInterceptors.push('authHttpIntercept')
|
$httpProvider.responseInterceptors.push('authHttpIntercept')
|
||||||
$httpProvider.interceptors.push('loaderInterceptor')
|
$httpProvider.interceptors.push('loaderInterceptor')
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ bindOnce = @.taiga.bindOnce
|
||||||
|
|
||||||
module = angular.module("taigaAdmin")
|
module = angular.module("taigaAdmin")
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Project Profile Controller
|
## Project Profile Controller
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
@ -85,14 +86,14 @@ class ProjectProfileController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
openDeleteLightbox: ->
|
openDeleteLightbox: ->
|
||||||
@rootscope.$broadcast("deletelightbox:new", @scope.project)
|
@rootscope.$broadcast("deletelightbox:new", @scope.project)
|
||||||
|
|
||||||
|
|
||||||
module.controller("ProjectProfileController", ProjectProfileController)
|
module.controller("ProjectProfileController", ProjectProfileController)
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Project Profile Directive
|
## Project Profile Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
ProjectProfileDirective = ($rootscope, $log, $repo, $confirm, $location) ->
|
ProjectProfileDirective = ($rootscope, $log, $repo, $confirm) ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
form = $el.find("form").checksley({"onlyOneErrorElement": true})
|
form = $el.find("form").checksley({"onlyOneErrorElement": true})
|
||||||
submit = =>
|
submit = =>
|
||||||
|
@ -101,7 +102,6 @@ ProjectProfileDirective = ($rootscope, $log, $repo, $confirm, $location) ->
|
||||||
promise = $repo.save($scope.project)
|
promise = $repo.save($scope.project)
|
||||||
promise.then ->
|
promise.then ->
|
||||||
$confirm.notify("success")
|
$confirm.notify("success")
|
||||||
$location.path("/project/#{$scope.project.slug}/admin/project-profile/details")
|
|
||||||
$scope.$emit("project:loaded", $scope.project)
|
$scope.$emit("project:loaded", $scope.project)
|
||||||
|
|
||||||
promise.then null, (data) ->
|
promise.then null, (data) ->
|
||||||
|
@ -119,6 +119,9 @@ ProjectProfileDirective = ($rootscope, $log, $repo, $confirm, $location) ->
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
|
module.directive("tgProjectProfile", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", ProjectProfileDirective])
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Project Features Directive
|
## Project Features Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
@ -161,5 +164,4 @@ ProjectFeaturesDirective = ($rootscope, $log, $repo, $confirm) ->
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
module.directive("tgProjectProfile", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", "$tgLocation", ProjectProfileDirective])
|
|
||||||
module.directive("tgProjectFeatures", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", ProjectFeaturesDirective])
|
module.directive("tgProjectFeatures", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", ProjectFeaturesDirective])
|
||||||
|
|
|
@ -403,7 +403,7 @@ ChangeEmailDirective = ($repo, $model, $auth, $confirm, $location, $params, $nav
|
||||||
onSuccessSubmit = (response) ->
|
onSuccessSubmit = (response) ->
|
||||||
$repo.queryOne("users", $auth.getUser().id).then (data) =>
|
$repo.queryOne("users", $auth.getUser().id).then (data) =>
|
||||||
$auth.setUser(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
|
$confirm.success("Our Oompa Loompas updated your email") #TODO: i18n
|
||||||
|
|
||||||
onErrorSubmit = (response) ->
|
onErrorSubmit = (response) ->
|
||||||
|
|
|
@ -72,6 +72,7 @@ urls = {
|
||||||
|
|
||||||
"project-wiki": "/project/:project/wiki",
|
"project-wiki": "/project/:project/wiki",
|
||||||
"project-wiki-page": "/project/:project/wiki/:slug",
|
"project-wiki-page": "/project/:project/wiki/:slug",
|
||||||
|
"project-wiki-page-edit": "/project/:project/wiki/:slug/edit",
|
||||||
|
|
||||||
# Admin
|
# Admin
|
||||||
"project-admin-home": "/project/:project/admin/project-profile/details"
|
"project-admin-home": "/project/:project/admin/project-profile/details"
|
||||||
|
|
|
@ -25,9 +25,11 @@ bindOnce = @.taiga.bindOnce
|
||||||
|
|
||||||
module = angular.module("taigaNavMenu", [])
|
module = angular.module("taigaNavMenu", [])
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Projects Navigation
|
## Projects Navigation
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
class ProjectsNavigationController extends taiga.Controller
|
class ProjectsNavigationController extends taiga.Controller
|
||||||
@.$inject = ["$scope", "$rootScope", "$tgResources", "$tgNavUrls", "$projectUrl"]
|
@.$inject = ["$scope", "$rootScope", "$tgResources", "$tgNavUrls", "$projectUrl"]
|
||||||
|
|
||||||
|
@ -59,7 +61,9 @@ class ProjectsNavigationController extends taiga.Controller
|
||||||
@rootscope.$broadcast("projects:create")
|
@rootscope.$broadcast("projects:create")
|
||||||
|
|
||||||
filterProjects: (text) ->
|
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
|
@scope.filterText = text
|
||||||
@rootscope.$broadcast("projects:filtered")
|
@rootscope.$broadcast("projects:filtered")
|
||||||
|
|
||||||
|
@ -193,7 +197,7 @@ module.directive("tgProjectsNav", ["$rootScope", "animationFrame", "$timeout", "
|
||||||
## Project
|
## Project
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location) ->
|
ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $navUrls) ->
|
||||||
menuEntriesTemplate = _.template("""
|
menuEntriesTemplate = _.template("""
|
||||||
<div class="menu-container">
|
<div class="menu-container">
|
||||||
<ul class="main-nav">
|
<ul class="main-nav">
|
||||||
|
@ -322,7 +326,7 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location) -
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
$auth.logout()
|
$auth.logout()
|
||||||
$scope.$apply ->
|
$scope.$apply ->
|
||||||
$location.path("/login")
|
$location.path($navUrls.resolve("login"))
|
||||||
|
|
||||||
$el.on "click", "#nav-search > a", (event) ->
|
$el.on "click", "#nav-search > a", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -342,5 +346,5 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location) -
|
||||||
|
|
||||||
return {link: link}
|
return {link: link}
|
||||||
|
|
||||||
|
module.directive("tgProjectMenu", ["$log", "$compile", "$tgAuth", "$rootScope", "$tgAuth", "$tgLocation",
|
||||||
module.directive("tgProjectMenu", ["$log", "$compile", "$tgAuth", "$rootScope", "$tgAuth", "$tgLocation", ProjectMenuDirective])
|
"$tgNavUrls", ProjectMenuDirective])
|
||||||
|
|
|
@ -42,23 +42,15 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
module.directive("tgLbCreateProject", [
|
module.directive("tgLbCreateProject", ["$rootScope", "$tgRepo", "$tgConfirm", "$location", "$tgNavUrls",
|
||||||
"$rootScope",
|
"$tgResources", "$projectUrl", "lightboxService", CreateProject])
|
||||||
"$tgRepo",
|
|
||||||
"$tgConfirm",
|
|
||||||
"$location",
|
|
||||||
"$tgNavUrls",
|
|
||||||
"$tgResources",
|
|
||||||
"$projectUrl",
|
|
||||||
"lightboxService",
|
|
||||||
CreateProject
|
|
||||||
])
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Delete Project Lightbox Directive
|
## Delete Project Lightbox Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
DeleteProjectDirective = ($repo, $rootscope, $auth, $location, lightboxService) ->
|
DeleteProjectDirective = ($repo, $rootscope, $auth, $location, $navUrls, lightboxService) ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
projectToDelete = null
|
projectToDelete = null
|
||||||
$scope.$on "deletelightbox:new", (ctx, project)->
|
$scope.$on "deletelightbox:new", (ctx, project)->
|
||||||
|
@ -73,7 +65,7 @@ DeleteProjectDirective = ($repo, $rootscope, $auth, $location, lightboxService)
|
||||||
|
|
||||||
promise.then (data) ->
|
promise.then (data) ->
|
||||||
lightboxService.close($el)
|
lightboxService.close($el)
|
||||||
$location.path("/")
|
$location.path($navUrls.resolve("home"))
|
||||||
|
|
||||||
# FIXME: error handling?
|
# FIXME: error handling?
|
||||||
promise.then null, ->
|
promise.then null, ->
|
||||||
|
@ -89,5 +81,5 @@ DeleteProjectDirective = ($repo, $rootscope, $auth, $location, lightboxService)
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
|
module.directive("tgLbDeleteProject", ["$tgRepo", "$rootScope", "$tgAuth", "$tgLocation", "$tgNavUrls",
|
||||||
module.directive("tgLbDeleteProject", ["$tgRepo", "$rootScope", "$tgAuth", "$tgLocation", "lightboxService", DeleteProjectDirective])
|
"lightboxService", DeleteProjectDirective])
|
||||||
|
|
|
@ -2,20 +2,31 @@ taiga = @.taiga
|
||||||
module = angular.module("taigaProject")
|
module = angular.module("taigaProject")
|
||||||
bindOnce = @.taiga.bindOnce
|
bindOnce = @.taiga.bindOnce
|
||||||
|
|
||||||
|
|
||||||
class ProjectsController extends taiga.Controller
|
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) ->
|
constructor: (@scope, @rs, @rootscope, @navurls, @auth, @location, @appTitle, @projectUrl, @tgLoader) ->
|
||||||
appTitle.set("Projects")
|
@appTitle.set("Projects")
|
||||||
|
|
||||||
if !$auth.isAuthenticated()
|
if !@auth.isAuthenticated()
|
||||||
$location.path("/login")
|
@location.path(@navurls.resolve("login"))
|
||||||
|
|
||||||
@.projects = []
|
@.projects = []
|
||||||
@.loadInitialData()
|
@.loadInitialData()
|
||||||
.then () =>
|
.then () =>
|
||||||
@scope.$emit("projects:loaded")
|
@scope.$emit("projects:loaded")
|
||||||
tgLoader.pageLoaded()
|
@tgLoader.pageLoaded()
|
||||||
|
|
||||||
loadInitialData: ->
|
loadInitialData: ->
|
||||||
return @rs.projects.list().then (projects) =>
|
return @rs.projects.list().then (projects) =>
|
||||||
|
@ -29,8 +40,18 @@ class ProjectsController extends taiga.Controller
|
||||||
|
|
||||||
module.controller("ProjectsController", ProjectsController)
|
module.controller("ProjectsController", ProjectsController)
|
||||||
|
|
||||||
|
|
||||||
class ProjectController extends taiga.Controller
|
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) ->
|
constructor: (@scope, @rs, @repo, @params, @q, @rootscope, @appTitle, @location) ->
|
||||||
@.loadInitialData()
|
@.loadInitialData()
|
||||||
|
@ -66,9 +87,9 @@ class ProjectController extends taiga.Controller
|
||||||
@scope.stats = stats
|
@scope.stats = stats
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
|
|
||||||
module.controller("ProjectController", ProjectController)
|
module.controller("ProjectController", ProjectController)
|
||||||
|
|
||||||
|
|
||||||
ProjectsPaginationDirective = ($timeout) ->
|
ProjectsPaginationDirective = ($timeout) ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
bindOnce $scope, "projects", (projects) ->
|
bindOnce $scope, "projects", (projects) ->
|
||||||
|
@ -151,8 +172,6 @@ ProjectsPaginationDirective = ($timeout) ->
|
||||||
|
|
||||||
renderNextAndPrev()
|
renderNextAndPrev()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
link: link,
|
link: link,
|
||||||
scope: {
|
scope: {
|
||||||
|
|
|
@ -29,6 +29,7 @@ trim = @.taiga.trim
|
||||||
|
|
||||||
module = angular.module("taigaSearch", [])
|
module = angular.module("taigaSearch", [])
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Search Controller
|
## Search Controller
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
@ -121,13 +122,12 @@ SearchBoxDirective = ($lightboxService, $navurls, $location, $route)->
|
||||||
|
|
||||||
text = $el.find("#search-text").val()
|
text = $el.find("#search-text").val()
|
||||||
|
|
||||||
url = $navurls.resolve("project-search")
|
url = $navurls.resolve("project-search", {project: project.slug})
|
||||||
url = $navurls.formatUrl(url, {'project': project.slug})
|
|
||||||
|
|
||||||
$lightboxService.close($el)
|
$lightboxService.close($el)
|
||||||
$scope.$apply ->
|
$scope.$apply ->
|
||||||
$location.path(url)
|
$location.path(url)
|
||||||
$location.search("text",text).path(url)
|
$location.search("text", text).path(url)
|
||||||
$route.reload()
|
$route.reload()
|
||||||
|
|
||||||
$scope.$on "search-box:show", (ctx, newProject)->
|
$scope.$on "search-box:show", (ctx, newProject)->
|
||||||
|
@ -144,7 +144,6 @@ SearchBoxDirective = ($lightboxService, $navurls, $location, $route)->
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
|
|
||||||
module.directive("tgSearchBox", ["lightboxService", "$tgNavUrls", "$tgLocation", "$route", SearchBoxDirective])
|
module.directive("tgSearchBox", ["lightboxService", "$tgNavUrls", "$tgLocation", "$route", SearchBoxDirective])
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,7 +152,6 @@ module.directive("tgSearchBox", ["lightboxService", "$tgNavUrls", "$tgLocation",
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
SearchDirective = ($log, $compile, $templatecache, $routeparams, $location) ->
|
SearchDirective = ($log, $compile, $templatecache, $routeparams, $location) ->
|
||||||
# linkFilters = ($scope, $el, $attrs, $ctrl) ->
|
|
||||||
linkTable = ($scope, $el, $attrs, $ctrl) ->
|
linkTable = ($scope, $el, $attrs, $ctrl) ->
|
||||||
tabsDom = $el.find("section.search-filter")
|
tabsDom = $el.find("section.search-filter")
|
||||||
lastSeatchResults = null
|
lastSeatchResults = null
|
||||||
|
@ -235,7 +233,6 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams, $location) ->
|
||||||
|
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
$ctrl = $el.controller()
|
$ctrl = $el.controller()
|
||||||
# linkFilters($scope, $el, $attrs, $ctrl)
|
|
||||||
linkTable($scope, $el, $attrs, $ctrl)
|
linkTable($scope, $el, $attrs, $ctrl)
|
||||||
|
|
||||||
searchText = $routeparams.text
|
searchText = $routeparams.text
|
||||||
|
@ -244,5 +241,5 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams, $location) ->
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
|
module.directive("tgSearch", ["$log", "$compile", "$templateCache", "$routeParams", "$tgLocation",
|
||||||
module.directive("tgSearch", ["$log", "$compile", "$templateCache", "$routeParams", "$tgLocation", SearchDirective])
|
SearchDirective])
|
||||||
|
|
|
@ -24,11 +24,12 @@ bindOnce = @.taiga.bindOnce
|
||||||
|
|
||||||
module = angular.module("taigaUserSettings")
|
module = angular.module("taigaUserSettings")
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Delete User Lightbox Directive
|
## Delete User Lightbox Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
DeleteUserDirective = ($repo, $rootscope, $auth, $location, lightboxService) ->
|
DeleteUserDirective = ($repo, $rootscope, $auth, $location, $navUrls, lightboxService) ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
$scope.$on "deletelightbox:new", (ctx, user)->
|
$scope.$on "deletelightbox:new", (ctx, user)->
|
||||||
lightboxService.open($el)
|
lightboxService.open($el)
|
||||||
|
@ -42,7 +43,7 @@ DeleteUserDirective = ($repo, $rootscope, $auth, $location, lightboxService) ->
|
||||||
promise.then (data) ->
|
promise.then (data) ->
|
||||||
lightboxService.close($el)
|
lightboxService.close($el)
|
||||||
$auth.logout()
|
$auth.logout()
|
||||||
$location.path("/login")
|
$location.path($navUrls.resolve("login"))
|
||||||
|
|
||||||
# FIXME: error handling?
|
# FIXME: error handling?
|
||||||
promise.then null, ->
|
promise.then null, ->
|
||||||
|
@ -58,5 +59,5 @@ DeleteUserDirective = ($repo, $rootscope, $auth, $location, lightboxService) ->
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
|
module.directive("tgLbDeleteUser", ["$tgRepo", "$rootScope", "$tgAuth", "$tgLocation", "$tgNavUrls",
|
||||||
module.directive("tgLbDeleteUser", ["$tgRepo", "$rootScope", "$tgAuth", "$tgLocation", "lightboxService", DeleteUserDirective])
|
"lightboxService", DeleteUserDirective])
|
||||||
|
|
|
@ -44,10 +44,12 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin, taig
|
||||||
"$tgLocation",
|
"$tgLocation",
|
||||||
"$filter",
|
"$filter",
|
||||||
"$log",
|
"$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"
|
@.attachmentsUrlName = "wiki/attachments"
|
||||||
|
|
||||||
@scope.projectSlug = @params.pslug
|
@scope.projectSlug = @params.pslug
|
||||||
|
@ -79,9 +81,12 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin, taig
|
||||||
@scope.wikiId = data.wikipage
|
@scope.wikiId = data.wikipage
|
||||||
@scope.projectId = data.project
|
@scope.projectId = data.project
|
||||||
return data
|
return data
|
||||||
|
|
||||||
promise.then null, =>
|
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: ->
|
loadWiki: ->
|
||||||
if @scope.wikiId
|
if @scope.wikiId
|
||||||
|
@ -114,19 +119,28 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin, taig
|
||||||
.then(=> @.loadAttachments(@scope.wikiId))
|
.then(=> @.loadAttachments(@scope.wikiId))
|
||||||
|
|
||||||
edit: ->
|
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: ->
|
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: ->
|
delete: ->
|
||||||
onSuccess = =>
|
onSuccess = =>
|
||||||
|
ctx = {project: @scope.projectSlug}
|
||||||
|
@location.path(@navUrls.resolve("project-wiki", ctx))
|
||||||
@confirm.notify("success")
|
@confirm.notify("success")
|
||||||
@location.path("/project/#{@scope.projectSlug}/wiki")
|
|
||||||
onError = =>
|
onError = =>
|
||||||
@confirm.notify("error")
|
@confirm.notify("error")
|
||||||
|
|
||||||
|
|
||||||
# TODO: i18n
|
# TODO: i18n
|
||||||
title = "Delete Wiki Page"
|
title = "Delete Wiki Page"
|
||||||
subtitle = unslugify(@scope.wiki.slug)
|
subtitle = unslugify(@scope.wiki.slug)
|
||||||
|
@ -143,12 +157,15 @@ module.controller("WikiDetailController", WikiDetailController)
|
||||||
class WikiEditController extends WikiDetailController
|
class WikiEditController extends WikiDetailController
|
||||||
save: ->
|
save: ->
|
||||||
onSuccess = =>
|
onSuccess = =>
|
||||||
|
ctx = {
|
||||||
|
project: @scope.projectSlug
|
||||||
|
slug: @scope.wiki.slug
|
||||||
|
}
|
||||||
|
@location.path(@navUrls.resolve("project-wiki-page", ctx))
|
||||||
@confirm.notify("success")
|
@confirm.notify("success")
|
||||||
@location.path("/project/#{@scope.projectSlug}/wiki/#{@scope.wiki.slug}")
|
|
||||||
|
|
||||||
onError = =>
|
onError = =>
|
||||||
@confirm.notify("error")
|
@confirm.notify("error")
|
||||||
@location.path("/project/#{@scope.projectSlug}/wiki/#{@scope.wiki.slug}")
|
|
||||||
|
|
||||||
if @scope.wiki.id
|
if @scope.wiki.id
|
||||||
@repo.save(@scope.wiki).then onSuccess, onError
|
@repo.save(@scope.wiki).then onSuccess, onError
|
||||||
|
@ -157,9 +174,9 @@ class WikiEditController extends WikiDetailController
|
||||||
@scope.wiki.slug = @scope.wikiSlug
|
@scope.wiki.slug = @scope.wikiSlug
|
||||||
@repo.create("wiki", @scope.wiki).then onSuccess, onError
|
@repo.create("wiki", @scope.wiki).then onSuccess, onError
|
||||||
|
|
||||||
|
|
||||||
module.controller("WikiEditController", WikiEditController)
|
module.controller("WikiEditController", WikiEditController)
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Wiki Main Directive
|
## Wiki Main Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
@ -172,6 +189,7 @@ WikiDirective = ($tgrepo, $log, $location, $confirm) ->
|
||||||
|
|
||||||
module.directive("tgWikiDetail", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", WikiDirective])
|
module.directive("tgWikiDetail", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", WikiDirective])
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Wiki Edit Main Directive
|
## Wiki Edit Main Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
@ -184,6 +202,7 @@ WikiEditDirective = ($tgrepo, $log, $location, $confirm) ->
|
||||||
|
|
||||||
module.directive("tgWikiEdit", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", WikiEditDirective])
|
module.directive("tgWikiEdit", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", WikiEditDirective])
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Wiki User Info Directive
|
## Wiki User Info Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
@ -207,7 +226,7 @@ WikiUserInfoDirective = ($log) ->
|
||||||
else
|
else
|
||||||
user = $scope.usersById[wiki.last_modifier]
|
user = $scope.usersById[wiki.last_modifier]
|
||||||
if user is undefined
|
if user is undefined
|
||||||
ctx = {name: "Unassigned", imgurl: "/images/unnamed.png"}
|
ctx = {name: "unknown", imgurl: "/images/unnamed.png"}
|
||||||
else
|
else
|
||||||
ctx = {name: user.full_name_display, imgurl: user.photo}
|
ctx = {name: user.full_name_display, imgurl: user.photo}
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,12 @@ unslugify = @.taiga.slugify
|
||||||
|
|
||||||
module = angular.module("taigaWiki")
|
module = angular.module("taigaWiki")
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Wiki Main Directive
|
## Wiki Main Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
WikiNavDirective = ($tgrepo, $log, $location, $confirm) ->
|
WikiNavDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
||||||
template = _.template("""
|
template = _.template("""
|
||||||
<header>
|
<header>
|
||||||
<h1>Links</h1>
|
<h1>Links</h1>
|
||||||
|
@ -86,7 +87,11 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm) ->
|
||||||
linkId = target.parents('.wiki-link').data('id')
|
linkId = target.parents('.wiki-link').data('id')
|
||||||
linkSlug = $scope.wikiLinks[linkId].href
|
linkSlug = $scope.wikiLinks[linkId].href
|
||||||
$scope.$apply ->
|
$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) ->
|
$el.on "click", ".add-button", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -134,4 +139,4 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm) ->
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
module.directive("tgWikiNav", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", WikiNavDirective])
|
module.directive("tgWikiNav", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", "$tgNavUrls", WikiNavDirective])
|
||||||
|
|
Loading…
Reference in New Issue