create project

stable
Juanfran 2014-07-25 14:46:29 +02:00
parent e0dffa0a32
commit 332dc5c433
2 changed files with 16 additions and 14 deletions

View File

@ -31,6 +31,12 @@ class NavigationUrlsService extends taiga.Service
update: (urls) -> update: (urls) ->
@.urls = _.merge({}, @.urls, urls or {}) @.urls = _.merge({}, @.urls, urls or {})
formatUrl: (url, ctx={}) ->
replacer = (match) ->
match = trim(match, ":")
return ctx[match] or "undefined"
return url.replace(/(:\w+)/g, replacer)
resolve: (name) -> resolve: (name) ->
return @.urls[name] return @.urls[name]
@ -63,12 +69,6 @@ NavigationUrlsDirective = ($navurls, $auth, $q, $location) ->
options[key] = $scope.$eval(value) options[key] = $scope.$eval(value)
return [name, options] return [name, options]
formatUrl = (url, ctx={}) ->
replacer = (match) ->
match = trim(match, ":")
return ctx[match] or "undefined"
return url.replace(/(:\w+)/g, replacer)
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
$el.on "click", (event) -> $el.on "click", (event) ->
event.preventDefault() event.preventDefault()
@ -80,7 +80,7 @@ NavigationUrlsDirective = ($navurls, $auth, $q, $location) ->
url = $navurls.resolve(name) url = $navurls.resolve(name)
fullUrl = formatUrl(url, options) fullUrl = $navurls.formatUrl(url, options)
$location.url(fullUrl) $location.url(fullUrl)
$scope.$on "$destroy", -> $scope.$on "$destroy", ->
@ -92,5 +92,3 @@ NavigationUrlsDirective = ($navurls, $auth, $q, $location) ->
module = angular.module("taigaBase") module = angular.module("taigaBase")
module.service("$tgNavUrls", NavigationUrlsService) module.service("$tgNavUrls", NavigationUrlsService)
module.directive("tgNav", ["$tgNavUrls", "$tgAuth", "$q", "$location", NavigationUrlsDirective]) module.directive("tgNav", ["$tgNavUrls", "$tgAuth", "$q", "$location", NavigationUrlsDirective])

View File

@ -11,7 +11,7 @@ class ProjectsController extends taiga.Controller
loadInitialData: -> loadInitialData: ->
return @rs.projects.list().then (projects) => return @rs.projects.list().then (projects) =>
@.projects = {'recents': projects.slice(0, 8), 'all': projects.slice(6)} @.projects = {'recents': projects.slice(0, 8), 'all': projects.slice(8)}
module.controller("ProjectsController", ProjectsController) module.controller("ProjectsController", ProjectsController)
@ -48,14 +48,18 @@ class ProjectController extends taiga.Controller
module.controller("ProjectController", ProjectController) module.controller("ProjectController", ProjectController)
CreateProjectDirective = ($repo, $confirm, $location) -> CreateProjectDirective = ($repo, $confirm, $location, $navurls) ->
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
$scope.data = {} $scope.data = {}
form = $el.find("form").checksley() form = $el.find("form").checksley()
onSuccessSubmit = (response) -> onSuccessSubmit = (response) ->
$confirm.notify("success", "Our Oompa Loompas are happy, wellcome to Taiga.") #TODO: i18n $confirm.notify("success", "Success") #TODO: i18n
$location.path("/")
url = $navurls.resolve('project-backlog')
fullUrl = $navurls.formatUrl(url, {'project': response.slug})
$location.url(fullUrl)
onErrorSubmit = (response) -> onErrorSubmit = (response) ->
$confirm.notify("light-error", "According to our Oompa Loompas, project name is $confirm.notify("light-error", "According to our Oompa Loompas, project name is
@ -78,7 +82,7 @@ CreateProjectDirective = ($repo, $confirm, $location) ->
return {link:link} return {link:link}
module.directive("tgCreateProject", ["$tgRepo", "$tgConfirm", "$location", CreateProjectDirective]) module.directive("tgCreateProject", ["$tgRepo", "$tgConfirm", "$location", "$tgNavUrls", CreateProjectDirective])
ProjectsPaginationDirective = ($timeout) -> ProjectsPaginationDirective = ($timeout) ->
nextPage = (element, pageSize, callback) -> nextPage = (element, pageSize, callback) ->