add create project in the project nav

stable
Juanfran 2014-08-01 13:56:48 +02:00
parent c6179e4a06
commit 0db30f2894
7 changed files with 31 additions and 45 deletions

View File

@ -9,6 +9,8 @@ CreateProject = ($repo, $confirm, $location, $navurls) ->
form = $el.find("form").checksley()
onSuccessSubmit = (response) ->
$el.addClass("hidden")
$confirm.notify("success", "Success") #TODO: i18n
url = $navurls.resolve('project')
@ -27,6 +29,7 @@ CreateProject = ($repo, $confirm, $location, $navurls) ->
promise.then(onSuccessSubmit, onErrorSubmit)
$scope.$on "projects:create", ->
$scope.data = {}
$el.removeClass("hidden")
$el.on "click", ".close", (event) ->

View File

@ -1,6 +1,16 @@
taiga = @.taiga
module = angular.module("taigaProject")
class ProjectNavController extends taiga.Controller
@.$inject = ["$rootScope"]
constructor: (@rootscope) ->
newProject: ->
@rootscope.$broadcast("projects:create")
module.controller("ProjectNavController", ProjectNavController)
class ProjectsController extends taiga.Controller
@.$inject = ["$scope", "$tgResources", "$rootScope"]
@ -53,42 +63,6 @@ class ProjectController extends taiga.Controller
module.controller("ProjectController", ProjectController)
CreateProjectDirective = ($repo, $confirm, $location, $navurls) ->
link = ($scope, $el, $attrs) ->
$scope.data = {}
form = $el.find("form").checksley()
onSuccessSubmit = (response) ->
$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
already in use.") #TODO: i18n
submit = ->
if not form.validate()
return
promise = $repo.create("projects", $scope.data)
promise.then(onSuccessSubmit, onErrorSubmit)
$el.on "submit", (event) ->
event.preventDefault()
submit()
$el.on "click", "a.button-create", (event) ->
event.preventDefault()
submit()
return {link:link}
module.directive("tgCreateProject", ["$tgRepo", "$tgConfirm", "$location", "$tgNavUrls", CreateProjectDirective])
ProjectsPaginationDirective = ($timeout) ->
nextPage = (element, pageSize, callback) ->
top = parseInt(element.css('top'), 10)

View File

@ -23,6 +23,3 @@ block content
.create-project-button-wrapper
a.button.button-green(href="", ng-click="ctrl.newProject()") Create project
div.lightbox.lightbox_create-project.hidden(tg-lb-create-project)
include views/modules/lightbox_create-project

View File

@ -3,13 +3,19 @@
img(src="/images/logo.png", alt="TAIGA")
p Loading project...
nav.projects-nav(tg-projects-nav)
div.lightbox.lightbox_create-project.hidden(tg-lb-create-project)
include lightbox_create-project
nav.projects-nav(ng-controller="ProjectNavController as ctrl", tg-projects-nav)
h1 Your projects
form
fieldset
input(type="text" placeholder="Search in...", ng-model="projectsSearch.$")
a.icon.icon-search
.create-project-button
a.button.button-green(href="", ng-click="ctrl.newProject()") Create project
div.projects-pagination(tg-projects-pagination, active="projects.length && !projectsSearch.$.length")
ul.projects-list
li(ng-repeat="project in projects|filter:projectsSearch:strict track by project.id")

View File

@ -8,7 +8,7 @@
position: absolute;
top: 0;
width: 100%;
z-index: 9999;
z-index: 99920;
&.active {
@include transform(translateY(0));
@include transition (all .6s ease-in-out);

View File

@ -6,7 +6,7 @@
position: fixed;
right: 0;
top: 0;
z-index: 999;
z-index: 99910;
.close {
@extend %large;
position: absolute;
@ -374,4 +374,3 @@
width: 600px;
}
}

View File

@ -42,6 +42,13 @@
flex-direction: column;
margin-top: 1rem;
}
.create-project-button {
margin-top: 1rem;
a {
text-align: center;
width: 100%;
}
}
.v-pagination-previous,
.v-pagination-next {
flex-shrink: 0;
@ -88,7 +95,7 @@
right: 0;
top: 0;
width: 100%;
z-index: 99999;
z-index: 99900;
div {
margin: 10% auto;
opacity: 0;