diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index 4316337a..bfdec816 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -220,6 +220,7 @@ modules = [ "taigaNavMenu", "taigaProject", "taigaUserSettings", + "taigaFeedback", "taigaPlugins", # Vendor modules diff --git a/app/coffee/config.coffee b/app/coffee/config.coffee index 14320253..43ea197b 100644 --- a/app/coffee/config.coffee +++ b/app/coffee/config.coffee @@ -38,6 +38,8 @@ class ConfigService extends taiga.Service termsOfServiceUrl: null privacyPolicyUrl: null + + feedbackEnabled: true } initialize: (localconfig) -> diff --git a/app/coffee/modules/feedback.coffee b/app/coffee/modules/feedback.coffee new file mode 100644 index 00000000..17add8e7 --- /dev/null +++ b/app/coffee/modules/feedback.coffee @@ -0,0 +1,68 @@ +### +# Copyright (C) 2014 Andrey Antukh +# Copyright (C) 2014 Jesús Espino Garcia +# Copyright (C) 2014 David Barragán Merino +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# File: modules/feedback.coffee +### + +taiga = @.taiga + +groupBy = @.taiga.groupBy +bindOnce = @.taiga.bindOnce +mixOf = @.taiga.mixOf +debounce = @.taiga.debounce +trim = @.taiga.trim + +module = angular.module("taigaFeedback", []) + +FeedbackDirective = ($lightboxService, $repo, $confirm)-> + link = ($scope, $el, $attrs) -> + form = $el.find("form").checksley() + + submit = debounce 2000, -> + if not form.validate() + return + + promise = $repo.create("feedback", $scope.feedback) + + promise.then (data) -> + $lightboxService.close($el) + $confirm.notify("success", "\\o/ we'll be happy to read your") + + promise.then null, -> + $confirm.notify("error") + + $el.on "submit", (event) -> + submit() + + $el.on "click", ".button-green", (event) -> + event.preventDefault() + submit() + + $scope.$on "feedback:show", -> + $scope.$apply -> + $scope.feedback = {} + + $lightboxService.open($el) + $el.find("textarea").focus() + + $scope.$on "$destroy", -> + $el.off() + + return {link:link} + +module.directive("tgLbFeedback", ["lightboxService", "$tgRepo", "$tgConfirm", FeedbackDirective]) diff --git a/app/coffee/modules/nav.coffee b/app/coffee/modules/nav.coffee index 88a7a4e1..2dd1764a 100644 --- a/app/coffee/modules/nav.coffee +++ b/app/coffee/modules/nav.coffee @@ -200,7 +200,7 @@ module.directive("tgProjectsNav", ["$rootScope", "animationFrame", "$timeout", " ## Project ############################################################################# -ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $navUrls) -> +ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $navUrls, $config) -> menuEntriesTemplate = _.template("""