David Barragán Merino 2014-08-29 15:47:20 +02:00
parent 67bc30e8f4
commit 08d28431f6
1 changed files with 16 additions and 50 deletions

View File

@ -28,7 +28,7 @@ module = angular.module("taigaIssues")
## Issue Create Lightbox Directive ## Issue Create Lightbox Directive
############################################################################# #############################################################################
CreateIssueDirective = ($repo, $model, $rs, $rootscope, lightboxService) -> CreateIssueDirective = ($repo, $confirm, $rootscope, lightboxService) ->
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
form = $el.find("form").checksley() form = $el.find("form").checksley()
$scope.issue = {} $scope.issue = {}
@ -55,13 +55,12 @@ CreateIssueDirective = ($repo, $model, $rs, $rootscope, lightboxService) ->
promise = $repo.create("issues", $scope.issue) promise = $repo.create("issues", $scope.issue)
promise.then (data) -> promise.then (data) ->
lightboxService.close($el)
console.log "succcess", data
$rootscope.$broadcast("issueform:new:success", data) $rootscope.$broadcast("issueform:new:success", data)
lightboxService.close($el)
$confirm.notify("success")
# FIXME: error handling?
promise.then null, -> promise.then null, ->
console.log "FAIL" $confirm.notify("error")
$el.on "click", ".button-green", (event) -> $el.on "click", ".button-green", (event) ->
event.preventDefault() event.preventDefault()
@ -73,8 +72,15 @@ CreateIssueDirective = ($repo, $model, $rs, $rootscope, lightboxService) ->
return {link:link} return {link:link}
module.directive("tgLbCreateIssue", ["$tgRepo", "$tgConfirm", "$rootScope", "lightboxService",
CreateIssueDirective])
CreateBulkIssuesDirective = ($repo, $rs, $rootscope, lightboxService) ->
#############################################################################
## Issue Bulk Create Lightbox Directive
#############################################################################
CreateBulkIssuesDirective = ($repo, $rs, $confirm, $rootscope, lightboxService) ->
link = ($scope, $el, attrs) -> link = ($scope, $el, attrs) ->
$scope.$on "issueform:bulk", (ctx, projectId, status)-> $scope.$on "issueform:bulk", (ctx, projectId, status)->
lightboxService.open($el) lightboxService.open($el)
@ -97,55 +103,15 @@ CreateBulkIssuesDirective = ($repo, $rs, $rootscope, lightboxService) ->
promise.then (result) -> promise.then (result) ->
$rootscope.$broadcast("issueform:new:success", result) $rootscope.$broadcast("issueform:new:success", result)
lightboxService.close($el) lightboxService.close($el)
$confirm.notify("success")
# TODO: error handling
promise.then null, -> promise.then null, ->
console.log "FAIL" $confirm.notify("error")
$scope.$on "$destroy", -> $scope.$on "$destroy", ->
$el.off() $el.off()
return {link: link} return {link: link}
module.directive("tgLbCreateIssue", [ module.directive("tgLbCreateBulkIssues", ["$tgRepo", "$tgResources", "$tgConfirm", "$rootScope",
"$tgRepo", "lightboxService", CreateBulkIssuesDirective])
"$tgModel",
"$tgResources",
"$rootScope",
"lightboxService",
CreateIssueDirective
])
module.directive("tgLbCreateBulkIssues", [
"$tgRepo",
"$tgResources",
"$rootScope",
"lightboxService",
CreateBulkIssuesDirective
])
#############################################################################
## Issue Create Lightbox Directive
#############################################################################
# BulkCreateIssuesDirective = ($repo, $model, $rs, $rootscope) ->
# link = ($scope, $el, $attrs) ->
# $scope.$on "issueform:new", ->
# $el.removeClass("hidden")
#
# $scope.$on "$destroy", ->
# $el.off()
#
# $el.on "click", ".close", (event) ->
# event.preventDefault()
# $el.addClass("hidden")
#
# return {link:link}
# module.directive("tgLbCreateIssue", [
# "$tgRepo",
# "$tgModel",
# "$tgResources",
# "$rootScope",
# CreateIssueDirective
# ])