From 332dc5c4332e4fb3fec4c0c21ca1a75bbd7ea9ff Mon Sep 17 00:00:00 2001 From: Juanfran Date: Fri, 25 Jul 2014 14:46:29 +0200 Subject: [PATCH] create project --- app/coffee/modules/base/navurls.coffee | 16 +++++++--------- app/coffee/modules/project.coffee | 14 +++++++++----- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/coffee/modules/base/navurls.coffee b/app/coffee/modules/base/navurls.coffee index 2c5c5f9c..56c17989 100644 --- a/app/coffee/modules/base/navurls.coffee +++ b/app/coffee/modules/base/navurls.coffee @@ -31,6 +31,12 @@ class NavigationUrlsService extends taiga.Service update: (urls) -> @.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) -> return @.urls[name] @@ -63,12 +69,6 @@ NavigationUrlsDirective = ($navurls, $auth, $q, $location) -> options[key] = $scope.$eval(value) 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) -> $el.on "click", (event) -> event.preventDefault() @@ -80,7 +80,7 @@ NavigationUrlsDirective = ($navurls, $auth, $q, $location) -> url = $navurls.resolve(name) - fullUrl = formatUrl(url, options) + fullUrl = $navurls.formatUrl(url, options) $location.url(fullUrl) $scope.$on "$destroy", -> @@ -92,5 +92,3 @@ NavigationUrlsDirective = ($navurls, $auth, $q, $location) -> module = angular.module("taigaBase") module.service("$tgNavUrls", NavigationUrlsService) module.directive("tgNav", ["$tgNavUrls", "$tgAuth", "$q", "$location", NavigationUrlsDirective]) - - diff --git a/app/coffee/modules/project.coffee b/app/coffee/modules/project.coffee index 1b08f5bb..9aee68c3 100644 --- a/app/coffee/modules/project.coffee +++ b/app/coffee/modules/project.coffee @@ -11,7 +11,7 @@ class ProjectsController extends taiga.Controller loadInitialData: -> 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) @@ -48,14 +48,18 @@ class ProjectController extends taiga.Controller module.controller("ProjectController", ProjectController) -CreateProjectDirective = ($repo, $confirm, $location) -> +CreateProjectDirective = ($repo, $confirm, $location, $navurls) -> link = ($scope, $el, $attrs) -> $scope.data = {} form = $el.find("form").checksley() onSuccessSubmit = (response) -> - $confirm.notify("success", "Our Oompa Loompas are happy, wellcome to Taiga.") #TODO: i18n - $location.path("/") + $confirm.notify("success", "Success") #TODO: i18n + + url = $navurls.resolve('project-backlog') + fullUrl = $navurls.formatUrl(url, {'project': response.slug}) + + $location.url(fullUrl) onErrorSubmit = (response) -> $confirm.notify("light-error", "According to our Oompa Loompas, project name is @@ -78,7 +82,7 @@ CreateProjectDirective = ($repo, $confirm, $location) -> return {link:link} -module.directive("tgCreateProject", ["$tgRepo", "$tgConfirm", "$location", CreateProjectDirective]) +module.directive("tgCreateProject", ["$tgRepo", "$tgConfirm", "$location", "$tgNavUrls", CreateProjectDirective]) ProjectsPaginationDirective = ($timeout) -> nextPage = (element, pageSize, callback) ->