parent
3d687576eb
commit
cde5b7040e
|
@ -38,6 +38,8 @@ class ConfigService extends taiga.Service
|
|||
|
||||
termsOfServiceUrl: null
|
||||
privacyPolicyUrl: null
|
||||
|
||||
feedbackEnabled: true
|
||||
}
|
||||
|
||||
initialize: (localconfig) ->
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
###
|
||||
# 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
|
||||
|
@ -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])
|
||||
|
|
|
@ -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("""
|
||||
<div class="menu-container">
|
||||
<ul class="main-nav">
|
||||
|
@ -262,7 +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="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>
|
||||
<% if (feedbackEnabled) { %>
|
||||
<li><a href="" class="feedback" title="Feedback"">Feedback</a></li>
|
||||
<% } %>
|
||||
<li><a href="" title="Logout" class="logout">Logout</a></li>
|
||||
</ul>
|
||||
<a href="" title="User preferences" class="avatar" id="nav-user-settings">
|
||||
|
@ -326,7 +328,14 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $
|
|||
renderMenuEntries = ($el, targetScope, project={}) ->
|
||||
container = $el.find(".menu-container")
|
||||
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("#nav-#{sectionName} > a").addClass("active")
|
||||
|
||||
|
@ -374,7 +383,7 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $
|
|||
|
||||
$el.on "click", ".feedback", (event) ->
|
||||
event.preventDefault()
|
||||
$rootscope.$broadcast("feedback:show", project)
|
||||
$rootscope.$broadcast("feedback:show")
|
||||
|
||||
$scope.$on "projects:loaded", (listener) ->
|
||||
$el.addClass("hidden")
|
||||
|
@ -391,4 +400,4 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $
|
|||
return {link: link}
|
||||
|
||||
module.directive("tgProjectMenu", ["$log", "$compile", "$tgAuth", "$rootScope", "$tgAuth", "$tgLocation",
|
||||
"$tgNavUrls", ProjectMenuDirective])
|
||||
"$tgNavUrls", "$tgConfig", ProjectMenuDirective])
|
||||
|
|
|
@ -94,6 +94,9 @@ urls = {
|
|||
"attachments/issue": "/api/v1/issues/attachments"
|
||||
"attachments/task": "/api/v1/tasks/attachments"
|
||||
"attachments/wiki_page": "/api/v1/wiki/attachments"
|
||||
|
||||
# Feedback
|
||||
"feedback": "/api/v1/feedback"
|
||||
}
|
||||
|
||||
# Initialize api urls service
|
||||
|
|
|
@ -12,6 +12,8 @@ config = {
|
|||
publicRegisterEnabled: true
|
||||
privacyPolicyUrl: null
|
||||
termsOfServiceUrl: null
|
||||
|
||||
feedbackEnabled: true
|
||||
}
|
||||
|
||||
angular.module("taigaLocalConfig", []).value("localconfig", config)
|
||||
|
|
Loading…
Reference in New Issue