open lightbox feedback with the lightboxFactory service

stable
Juanfran 2015-04-28 10:03:56 +02:00
parent 43501892ee
commit d6a4f790c9
6 changed files with 24 additions and 13 deletions

View File

@ -56,18 +56,23 @@ FeedbackDirective = ($lightboxService, $repo, $confirm, $loading, feedbackServic
$el.on "submit", "form", submit
sendFeedbackCallback = ->
openLightbox = ->
$scope.feedback = {}
$lightboxService.open($el)
$el.find("textarea").focus()
feedbackService.emiter.on "send", sendFeedbackCallback
$scope.$on "$destroy", ->
emitter.off(feedbackService.emiter, sendFeedbackCallback)
$el.off()
return {link:link}
openLightbox()
directive = {
link: link,
templateUrl: "common/lightbox-feedback.html"
scope: {}
}
return directive
module.directive("tgLbFeedback", ["lightboxService", "$tgRepo", "$tgConfirm",
"$tgLoading", "tgFeedback", FeedbackDirective])

View File

@ -30,8 +30,6 @@ html(lang="en")
include partials/includes/modules/lightbox-generic-loading
div.lightbox.lightbox-search(tg-search-box)
include partials/includes/modules/lightbox-search
div.lightbox.lightbox-feedback.lightbox-generic-form(tg-lb-feedback)
include partials/includes/modules/lightbox-feedback
include partials/includes/modules/loader

View File

@ -1,8 +1,12 @@
class FeedbackService extends taiga.Service
constructor: ->
@.emiter = new EventEmitter2()
@.$inject = ["tgLightboxFactory"]
constructor: (@lightboxFactory) ->
sendFeedback: ->
@.emiter.emit("send")
@lightboxFactory.create("tg-lb-feedback", {
"class": "lightbox lightbox-feedback lightbox-generic-form"
})
angular.module("taigaFeedback").service("tgFeedback", FeedbackService)

View File

@ -33,7 +33,9 @@ class ProjectsService extends taiga.Service
return @.projectsPromise
newProject: ->
@lightboxFactory.create("tg-lb-create-project")
@lightboxFactory.create("tg-lb-create-project", {
"class": "wizard-create-project"
})
bulkUpdateProjectsOrder: (sortData) ->
@rs.projects.bulkUpdateOrder(sortData).then =>

View File

@ -2,15 +2,17 @@ class LightboxFactory
@.$inject = ["$rootScope", "$compile"]
constructor: (@rootScope, @compile) ->
create: (name) ->
create: (name, attrs) ->
scope = @rootScope.$new()
elm = $("<div>")
.attr(name, true)
.attr("tg-bind-scope", true)
.addClass("wizard-create-project")
.addClass("remove-on-close")
if attrs
elm.attr(attrs)
html = @compile(elm)(scope)
$(document.body).append(html)