compile & create new project lightbox

stable
Juanfran 2015-04-27 12:42:51 +02:00
parent c9d6fce6cd
commit 7829958548
5 changed files with 27 additions and 10 deletions

View File

@ -67,6 +67,9 @@ class LightboxService extends taiga.Service
$el.addClass('close')
if $el.hasClass("remove-on-close")
$el.remove()
closeAll: ->
docEl = angular.element(document)
for lightboxEl in docEl.find(".lightbox.open")

View File

@ -70,7 +70,7 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
promise = $repo.create("projects", $scope.data)
promise.then(onSuccessSubmit, onErrorSubmit)
createProjectCallback = ->
openLightbox = ->
$scope.data = {
total_story_points: 100
total_milestones: 5
@ -90,8 +90,6 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
timeout 600, ->
$el.find(".progress-bar").addClass('step1')
projects.emiter.on 'create', createProjectCallback
$el.on "click", ".button-next", (event) ->
event.preventDefault()
@ -129,9 +127,10 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
lightboxService.close($el)
$scope.$on "$destroy", ->
emitter.off(projects.emiter, createProjectCallback)
$el.off()
openLightbox()
directive = {
link: link,
templateUrl: "project/wizard-create-project.html"

View File

@ -29,5 +29,3 @@ nav.navbar
div.topnav-dropdown-wrapper(ng-show="vm.projects.size", tg-dropdown-project-list)
//div.topnav-dropdown-wrapper(tg-dropdown-organization-list)
div.topnav-dropdown-wrapper(tg-dropdown-user)
div.wizard-create-project(tg-lb-create-project)

View File

@ -1,12 +1,11 @@
class ProjectsService extends taiga.Service
@.$inject = ["$q", "$tgResources", "$rootScope", "$projectUrl"]
@.$inject = ["$q", "$tgResources", "$rootScope", "$projectUrl", "tgLightboxFactory"]
constructor: (@q, @rs, @rootScope, @projectUrl) ->
constructor: (@q, @rs, @rootScope, @projectUrl, @lightboxFactory) ->
@.projects = Immutable.Map()
@.inProgress = false
@.projectsPromise = null
@.fetchProjects()
@.emiter = new EventEmitter2()
fetchProjects: ->
if not @.inProgress
@ -28,7 +27,7 @@ class ProjectsService extends taiga.Service
return @.projectsPromise
newProject: ->
@.emiter.emit("create")
@lightboxFactory.create("tg-lb-create-project")
bulkUpdateProjectsOrder: (sortData) ->
@rs.projects.bulkUpdateOrder(sortData).then =>

View File

@ -0,0 +1,18 @@
class LightboxFactory
@.$inject = ["$rootScope", "$compile"]
constructor: (@rootScope, @compile) ->
create: (name) ->
elm = $("<div>")
.attr(name, true)
.addClass("wizard-create-project")
.addClass("remove-on-close")
scope = @rootScope.$new()
html = @compile(elm)(scope)
$(document.body).append(html)
return
angular.module("taigaCommon").service("tgLightboxFactory", LightboxFactory)