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", []) module = angular.module("taigaFeedback", [])
FeedbackDirective = ($lightboxService, $repo, $confirm, $loading)-> FeedbackDirective = ($lightboxService, $repo, $confirm, $loading, feedbackService)->
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
form = $el.find("form").checksley() form = $el.find("form").checksley()
@ -56,14 +56,18 @@ FeedbackDirective = ($lightboxService, $repo, $confirm, $loading)->
$el.on "submit", "form", submit $el.on "submit", "form", submit
$scope.$on "feedback:show", -> sendFeedbackCallback = ->
$scope.feedback = {} $scope.feedback = {}
$lightboxService.open($el) $lightboxService.open($el)
$el.find("textarea").focus() $el.find("textarea").focus()
feedbackService.emiter.on "send", sendFeedbackCallback
$scope.$on "$destroy", -> $scope.$on "$destroy", ->
emitter.off(feedbackService.emiter, sendFeedbackCallback)
$el.off() $el.off()
return {link:link} 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 = { directive = {
templateUrl: "navigation-bar/dropdown-user/dropdown-user.html" templateUrl: "navigation-bar/dropdown-user/dropdown-user.html"
controller: "ProjectsController"
scope: {} scope: {}
bindToController: true link: link
controllerAs: "vm"
} }
return directive return directive
angular.module("taigaNavigationBar").directive("tgDropdownUser", 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}}", title="{{'PROJECT.NAVIGATION.NOTIFICATIONS_TITLE' | translate}}",
translate="PROJECT.NAVIGATION.NOTIFICATIONS") translate="PROJECT.NAVIGATION.NOTIFICATIONS")
li(ng-show="vm.isFeedbackEnabled()") li(ng-show="vm.isFeedbackEnabled")
a( a(
href="#", href="#",
ng-click="vm.sendFeedback()", 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 = { directive = {
templateUrl: "navigation-bar/navigation-bar.html" templateUrl: "navigation-bar/navigation-bar.html"
scope: {}
link: link
} }
return directive return directive
angular.module("taigaNavigationBar").directive("tgNavigationBar", angular.module("taigaNavigationBar").directive("tgNavigationBar",
NavigationBarDirective) ["tgProjects", NavigationBarDirective])

View File

@ -26,7 +26,7 @@ nav.navbar
include ../../svg/dashboard.svg 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-organization-list)
div.topnav-dropdown-wrapper(tg-dropdown-user) div.topnav-dropdown-wrapper(tg-dropdown-user)

View File

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