Refactoring feedback

stable
Alejandro Alonso 2015-04-23 12:53:26 +02:00 committed by Juanfran
parent 003499ce44
commit b2b823d47f
7 changed files with 43 additions and 15 deletions

View File

@ -29,7 +29,7 @@ trim = @.taiga.trim
module = angular.module("taigaFeedback", [])
FeedbackDirective = ($lightboxService, $repo, $confirm, $loading)->
FeedbackDirective = ($lightboxService, $repo, $confirm, $loading, feedbackService)->
link = ($scope, $el, $attrs) ->
form = $el.find("form").checksley()
@ -56,14 +56,18 @@ FeedbackDirective = ($lightboxService, $repo, $confirm, $loading)->
$el.on "submit", "form", submit
$scope.$on "feedback:show", ->
sendFeedbackCallback = ->
$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}
module.directive("tgLbFeedback", ["lightboxService", "$tgRepo", "$tgConfirm", "$tgLoading", FeedbackDirective])
module.directive("tgLbFeedback", ["lightboxService", "$tgRepo", "$tgConfirm",
"$tgLoading", "tgFeedback", FeedbackDirective])

View File

@ -0,0 +1,8 @@
class FeedbackService extends taiga.Service
constructor: ->
@.emiter = new EventEmitter2()
sendFeedback: ->
@.emiter.emit("send")
angular.module("taigaFeedback").service("tgFeedback", FeedbackService)

View File

@ -1,13 +1,26 @@
DropdownUserDirective = () ->
DropdownUserDirective = (authService, configService, locationService,
navUrlsService, feedbackService) ->
link = (scope, el, attrs, ctrl) ->
scope.vm = {}
scope.vm.user = authService.getUser()
scope.vm.isFeedbackEnabled = configService.get("feedbackEnabled")
scope.vm.logout = ->
authService.logout()
locationService.path(navUrlsService.resolve("login"))
scope.vm.sendFeedback = ->
feedbackService.sendFeedback()
directive = {
templateUrl: "navigation-bar/dropdown-user/dropdown-user.html"
controller: "ProjectsController"
scope: {}
bindToController: true
controllerAs: "vm"
link: link
}
return directive
angular.module("taigaNavigationBar").directive("tgDropdownUser",
DropdownUserDirective)
["$tgAuth", "$tgConfig", "$tgLocation", "$tgNavUrls", "tgFeedback",
DropdownUserDirective])

View File

@ -39,7 +39,7 @@ div.navbar-dropdown.dropdown-user
title="{{'PROJECT.NAVIGATION.NOTIFICATIONS_TITLE' | translate}}",
translate="PROJECT.NAVIGATION.NOTIFICATIONS")
li(ng-show="vm.isFeedbackEnabled()")
li(ng-show="vm.isFeedbackEnabled")
a(
href="#",
ng-click="vm.sendFeedback()",

View File

@ -1,10 +1,16 @@
NavigationBarDirective = () ->
NavigationBarDirective = (projectsService) ->
link = (scope, el, attrs, ctrl) ->
scope.vm = {}
scope.vm.projects = projectsService.projects
directive = {
templateUrl: "navigation-bar/navigation-bar.html"
scope: {}
link: link
}
return directive
angular.module("taigaNavigationBar").directive("tgNavigationBar",
NavigationBarDirective)
["tgProjects", NavigationBarDirective])

View File

@ -26,7 +26,7 @@ nav.navbar
include ../../svg/dashboard.svg
div.topnav-dropdown-wrapper(tg-dropdown-project-list)
div.topnav-dropdown-wrapper(ng-show="vm.projects.recents", tg-dropdown-project-list)
//div.topnav-dropdown-wrapper(tg-dropdown-organization-list)
div.topnav-dropdown-wrapper(tg-dropdown-user)

View File

@ -21,9 +21,6 @@ class ProjectsPageController extends taiga.Controller
if !@auth.isAuthenticated()
@location.path(@navUrls.resolve("login"))
#TODO:
@.user = @auth.getUser()
#Projects
promise = @projects.fetchProjects()