Merge pull request #46 from taigaio/feedback

Create a feedback form for registered users
stable
Andrey Antukh 2014-10-05 20:18:10 +02:00
commit 5b8f0663b9
8 changed files with 106 additions and 3 deletions

View File

@ -220,6 +220,7 @@ modules = [
"taigaNavMenu", "taigaNavMenu",
"taigaProject", "taigaProject",
"taigaUserSettings", "taigaUserSettings",
"taigaFeedback",
"taigaPlugins", "taigaPlugins",
# Vendor modules # Vendor modules

View File

@ -38,6 +38,8 @@ class ConfigService extends taiga.Service
termsOfServiceUrl: null termsOfServiceUrl: null
privacyPolicyUrl: null privacyPolicyUrl: null
feedbackEnabled: true
} }
initialize: (localconfig) -> initialize: (localconfig) ->

View File

@ -0,0 +1,68 @@
###
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
# Copyright (C) 2014 Jesús Espino Garcia <jespinog@gmail.com>
# Copyright (C) 2014 David Barragán Merino <bameda@dbarragan.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
# 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])

View File

@ -200,7 +200,7 @@ module.directive("tgProjectsNav", ["$rootScope", "animationFrame", "$timeout", "
## Project ## Project
############################################################################# #############################################################################
ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $navUrls) -> ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $navUrls, $config) ->
menuEntriesTemplate = _.template(""" menuEntriesTemplate = _.template("""
<div class="menu-container"> <div class="menu-container">
<ul class="main-nav"> <ul class="main-nav">
@ -262,6 +262,9 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $
<li><a href="" title="User Profile", tg-nav="user-settings-user-profile:project=project.slug">User Profile</a></li> <li><a href="" title="User Profile", tg-nav="user-settings-user-profile:project=project.slug">User Profile</a></li>
<li><a href="" title="Change Password", tg-nav="user-settings-user-change-password:project=project.slug">Change Password</a></li> <li><a href="" title="Change Password", tg-nav="user-settings-user-change-password:project=project.slug">Change Password</a></li>
<li><a href="" title="Notifications", tg-nav="user-settings-mail-notifications:project=project.slug">Notifications</a></li> <li><a href="" title="Notifications", tg-nav="user-settings-mail-notifications:project=project.slug">Notifications</a></li>
<% if (feedbackEnabled) { %>
<li><a href="" class="feedback" title="Feedback"">Feedback</a></li>
<% } %>
<li><a href="" title="Logout" class="logout">Logout</a></li> <li><a href="" title="Logout" class="logout">Logout</a></li>
</ul> </ul>
<a href="" title="User preferences" class="avatar" id="nav-user-settings"> <a href="" title="User preferences" class="avatar" id="nav-user-settings">
@ -325,7 +328,14 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $
renderMenuEntries = ($el, targetScope, project={}) -> renderMenuEntries = ($el, targetScope, project={}) ->
container = $el.find(".menu-container") container = $el.find(".menu-container")
sectionName = targetScope.section sectionName = targetScope.section
dom = $compile(menuEntriesTemplate({user: $auth.getUser(), project: project}))(targetScope)
ctx = {
user: $auth.getUser(),
project: project,
feedbackEnabled: $config.get("feedbackEnabled")
}
dom = $compile(menuEntriesTemplate(ctx))(targetScope)
dom.find("a.active").removeClass("active") dom.find("a.active").removeClass("active")
dom.find("#nav-#{sectionName} > a").addClass("active") dom.find("#nav-#{sectionName} > a").addClass("active")
@ -371,6 +381,10 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $
event.preventDefault() event.preventDefault()
$rootscope.$broadcast("search-box:show", project) $rootscope.$broadcast("search-box:show", project)
$el.on "click", ".feedback", (event) ->
event.preventDefault()
$rootscope.$broadcast("feedback:show")
$scope.$on "projects:loaded", (listener) -> $scope.$on "projects:loaded", (listener) ->
$el.addClass("hidden") $el.addClass("hidden")
listener.stopPropagation() listener.stopPropagation()
@ -386,4 +400,4 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $
return {link: link} return {link: link}
module.directive("tgProjectMenu", ["$log", "$compile", "$tgAuth", "$rootScope", "$tgAuth", "$tgLocation", module.directive("tgProjectMenu", ["$log", "$compile", "$tgAuth", "$rootScope", "$tgAuth", "$tgLocation",
"$tgNavUrls", ProjectMenuDirective]) "$tgNavUrls", "$tgConfig", ProjectMenuDirective])

View File

@ -94,6 +94,9 @@ urls = {
"attachments/issue": "/api/v1/issues/attachments" "attachments/issue": "/api/v1/issues/attachments"
"attachments/task": "/api/v1/tasks/attachments" "attachments/task": "/api/v1/tasks/attachments"
"attachments/wiki_page": "/api/v1/wiki/attachments" "attachments/wiki_page": "/api/v1/wiki/attachments"
# Feedback
"feedback": "/api/v1/feedback"
} }
# Initialize api urls service # Initialize api urls service

View File

@ -12,6 +12,8 @@ config = {
publicRegisterEnabled: true publicRegisterEnabled: true
privacyPolicyUrl: null privacyPolicyUrl: null
termsOfServiceUrl: null termsOfServiceUrl: null
feedbackEnabled: true
} }
angular.module("taigaLocalConfig", []).value("localconfig", config) angular.module("taigaLocalConfig", []).value("localconfig", config)

View File

@ -31,6 +31,8 @@ html(lang="en", ng-app="taiga")
include partials/views/modules/lightbox-generic-error include partials/views/modules/lightbox-generic-error
div.lightbox.lightbox-search(tg-search-box) div.lightbox.lightbox-search(tg-search-box)
include partials/views/modules/lightbox-search 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 include partials/views/modules/loader

View File

@ -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