From 3d687576ebfc57a051a09e909267d97b00819012 Mon Sep 17 00:00:00 2001 From: Juanfran Date: Wed, 1 Oct 2014 15:56:55 +0200 Subject: [PATCH 1/2] US #954: Tasks #1116 #1117: Create the Feedback form --- app/coffee/app.coffee | 1 + app/coffee/modules/feedback.coffee | 43 +++++++++++++++++++ app/coffee/modules/nav.coffee | 5 +++ app/index.jade | 2 + .../views/modules/lightbox-feedback.jade | 11 +++++ 5 files changed, 62 insertions(+) create mode 100644 app/coffee/modules/feedback.coffee create mode 100644 app/partials/views/modules/lightbox-feedback.jade 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/modules/feedback.coffee b/app/coffee/modules/feedback.coffee new file mode 100644 index 00000000..fe630cb7 --- /dev/null +++ b/app/coffee/modules/feedback.coffee @@ -0,0 +1,43 @@ +taiga = @.taiga + +groupBy = @.taiga.groupBy +bindOnce = @.taiga.bindOnce +mixOf = @.taiga.mixOf +debounce = @.taiga.debounce +trim = @.taiga.trim + +module = angular.module("taigaFeedback", []) + +FeedbackDirective = ($lightboxService, $navurls, $location, $route)-> + link = ($scope, $el, $attrs) -> + form = $el.find("form").checksley() + project = null + + submit = debounce 2000, -> + if not form.validate() + return + + $scope.$on "feedback:show", (ctx, newProject)-> + project = newProject + + $scope.$apply -> + $scope.issueTypes = _.sortBy(project.issue_types, "order") + + $scope.feedback = { + project: project.id + type: project.default_issue_type + } + + $lightboxService.open($el) + $el.find("textarea").focus() + + $el.on "submit", (event) -> + submit() + + $el.on "click", ".button-green", (event) -> + event.preventDefault() + submit() + + return {link:link} + +module.directive("tgFeedback", ["lightboxService", "$tgNavUrls", "$tgLocation", "$route", FeedbackDirective]) diff --git a/app/coffee/modules/nav.coffee b/app/coffee/modules/nav.coffee index 88a7a4e1..fd6f6b17 100644 --- a/app/coffee/modules/nav.coffee +++ b/app/coffee/modules/nav.coffee @@ -262,6 +262,7 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $
  • User Profile
  • Change Password
  • Notifications
  • +
  • Logout
  • @@ -371,6 +372,10 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $ event.preventDefault() $rootscope.$broadcast("search-box:show", project) + $el.on "click", ".feedback", (event) -> + event.preventDefault() + $rootscope.$broadcast("feedback:show", project) + $scope.$on "projects:loaded", (listener) -> $el.addClass("hidden") listener.stopPropagation() diff --git a/app/index.jade b/app/index.jade index 98ddf467..4d589b40 100644 --- a/app/index.jade +++ b/app/index.jade @@ -31,6 +31,8 @@ html(lang="en", ng-app="taiga") include partials/views/modules/lightbox-generic-error div.lightbox.lightbox-search(tg-search-box) include partials/views/modules/lightbox-search + div.lightbox.lightbox-feedback.lightbox-generic-form(tg-lb-feedback) + include partials/views/modules/lightbox-feedback include partials/views/modules/loader diff --git a/app/partials/views/modules/lightbox-feedback.jade b/app/partials/views/modules/lightbox-feedback.jade new file mode 100644 index 00000000..a59c4f56 --- /dev/null +++ b/app/partials/views/modules/lightbox-feedback.jade @@ -0,0 +1,11 @@ +a.close(href="", title="close") + span.icon.icon-delete +form + h2.title Tell us something... + fieldset + textarea(ng-model="feedback.comment", data-required="true", + placeholder="...a bug, some suggestions, something cool... or even your worst nightmare with Taiga") + fieldset + input.hidden(type="submit") + a.button.button-green(href="", title="Send feedback") + span Send feedback From cde5b7040e1c8e4f9e30c87917092765fb2b8b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Thu, 2 Oct 2014 13:25:20 +0200 Subject: [PATCH 2/2] US #954: Task #1118: Integrate the feedback form with the API endpoint --- app/coffee/config.coffee | 2 ++ app/coffee/modules/feedback.coffee | 53 +++++++++++++++++++++-------- app/coffee/modules/nav.coffee | 17 ++++++--- app/coffee/modules/resources.coffee | 3 ++ app/config/main.coffee.example | 2 ++ 5 files changed, 59 insertions(+), 18 deletions(-) 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 index fe630cb7..17add8e7 100644 --- a/app/coffee/modules/feedback.coffee +++ b/app/coffee/modules/feedback.coffee @@ -1,3 +1,24 @@ +### +# 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 @@ -8,28 +29,22 @@ trim = @.taiga.trim module = angular.module("taigaFeedback", []) -FeedbackDirective = ($lightboxService, $navurls, $location, $route)-> +FeedbackDirective = ($lightboxService, $repo, $confirm)-> link = ($scope, $el, $attrs) -> form = $el.find("form").checksley() - project = null submit = debounce 2000, -> if not form.validate() return - $scope.$on "feedback:show", (ctx, newProject)-> - project = newProject + promise = $repo.create("feedback", $scope.feedback) - $scope.$apply -> - $scope.issueTypes = _.sortBy(project.issue_types, "order") + promise.then (data) -> + $lightboxService.close($el) + $confirm.notify("success", "\\o/ we'll be happy to read your") - $scope.feedback = { - project: project.id - type: project.default_issue_type - } - - $lightboxService.open($el) - $el.find("textarea").focus() + promise.then null, -> + $confirm.notify("error") $el.on "submit", (event) -> submit() @@ -38,6 +53,16 @@ FeedbackDirective = ($lightboxService, $navurls, $location, $route)-> 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("tgFeedback", ["lightboxService", "$tgNavUrls", "$tgLocation", "$route", FeedbackDirective]) +module.directive("tgLbFeedback", ["lightboxService", "$tgRepo", "$tgConfirm", FeedbackDirective]) diff --git a/app/coffee/modules/nav.coffee b/app/coffee/modules/nav.coffee index fd6f6b17..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("""