Add user terms directive
parent
b48748b25d
commit
aa10d7b1ed
|
@ -792,7 +792,7 @@ init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $na
|
|||
# Load user
|
||||
if $auth.isAuthenticated()
|
||||
user = $auth.getUser()
|
||||
|
||||
$auth.showTerms()
|
||||
# Analytics
|
||||
$analytics.initialize()
|
||||
|
||||
|
|
|
@ -68,10 +68,11 @@ class AuthService extends taiga.Service
|
|||
"$translate",
|
||||
"tgCurrentUserService",
|
||||
"tgThemeService",
|
||||
"$tgAnalytics"]
|
||||
"$tgAnalytics",
|
||||
"tgTermsAnnouncementService"]
|
||||
|
||||
constructor: (@rootscope, @storage, @model, @rs, @http, @urls, @config, @translate, @currentUserService,
|
||||
@themeService, @analytics) ->
|
||||
@themeService, @analytics, @termsAnnouncementService) ->
|
||||
super()
|
||||
|
||||
userModel = @.getUser()
|
||||
|
@ -238,6 +239,12 @@ class AuthService extends taiga.Service
|
|||
url = @urls.resolve("users-export")
|
||||
return @http.post(url)
|
||||
|
||||
showTerms: (data) ->
|
||||
user = @.getUser()
|
||||
if not user or user.read_new_terms
|
||||
return
|
||||
@termsAnnouncementService.show('GDPR', 'General Data Protection Regulation - Read more!')
|
||||
|
||||
module.service("$tgAuth", AuthService)
|
||||
|
||||
|
||||
|
@ -290,6 +297,8 @@ LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls, $
|
|||
$events.setupConnection()
|
||||
$analytics.trackEvent("auth", "login", "user login", 1)
|
||||
|
||||
$auth.showTerms()
|
||||
|
||||
if $scope.nextUrl.indexOf('http') == 0
|
||||
$window.location.href = $scope.nextUrl
|
||||
else
|
||||
|
|
|
@ -45,6 +45,7 @@ html(lang="en")
|
|||
|
||||
div(tg-joy-ride)
|
||||
div(tg-live-announcement)
|
||||
div(tg-terms-announcement)
|
||||
|
||||
script(src="/#{v}/js/libs.js")
|
||||
script(src="/#{v}/js/templates.js")
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
###
|
||||
# Copyright (C) 2014-2015 Andrey Antukh <niwi@niwi.nz>
|
||||
# Copyright (C) 2014-2015 Jesús Espino Garcia <jespinog@gmail.com>
|
||||
# Copyright (C) 2014-2015 David Barragán Merino <bameda@dbarragan.com>
|
||||
# Copyright (C) 2014-2017 Alejandro Alonso <alejandro.alonso@kaleidos.net>
|
||||
# Copyright (C) 2014-2017 Juan Francisco Alcántara <juanfran.alcantara@kaleidos.net>
|
||||
# Copyright (C) 2014-2017 Xavi Julian <xavier.julian@kaleidos.net>
|
||||
#
|
||||
# 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: terms-announcement.directive.coffee
|
||||
###
|
||||
|
||||
|
||||
TermsAnnouncementDirective = (TermsAnnouncementService, $repo, $auth) ->
|
||||
link = (scope, el, attrs) ->
|
||||
|
||||
return {
|
||||
restrict: "AE",
|
||||
scope: {},
|
||||
controllerAs: 'vm',
|
||||
controller: () ->
|
||||
this.close = () ->
|
||||
TermsAnnouncementService.open = false
|
||||
user = $auth.getUser()
|
||||
|
||||
onSuccess = (data) =>
|
||||
$auth.setUser(data)
|
||||
|
||||
user.read_new_terms = true
|
||||
$repo.save(user).then(onSuccess)
|
||||
|
||||
Object.defineProperties(this, {
|
||||
open: {
|
||||
get: () -> return TermsAnnouncementService.open
|
||||
},
|
||||
title: {
|
||||
get: () -> return TermsAnnouncementService.title
|
||||
},
|
||||
desc: {
|
||||
get: () -> return TermsAnnouncementService.desc
|
||||
}
|
||||
})
|
||||
link: link,
|
||||
templateUrl: "components/terms-announcement/terms-announcement.html"
|
||||
}
|
||||
|
||||
TermsAnnouncementDirective.$inject = [
|
||||
"tgTermsAnnouncementService",
|
||||
"$tgRepo",
|
||||
"$tgAuth"
|
||||
]
|
||||
|
||||
angular.module("taigaComponents")
|
||||
.directive("tgTermsAnnouncement", TermsAnnouncementDirective)
|
|
@ -0,0 +1,12 @@
|
|||
.terms-announcement(ng-class="{visible: vm.open}")
|
||||
.terms-announcement-inner
|
||||
img.anouncement-decoration(src="/#{v}/images/notification-decoration.png", alt="Loading...")
|
||||
.text
|
||||
h2.title {{vm.title}}
|
||||
p.warning(ng-bind-html="vm.desc")
|
||||
a.close(
|
||||
ng-click="vm.close()"
|
||||
href=""
|
||||
ng-title="COMMON.CLOSE | translate"
|
||||
)
|
||||
tg-svg(svg-icon="icon-close")
|
|
@ -0,0 +1,73 @@
|
|||
.terms-announcement {
|
||||
$animation-steps-duration: .5s;
|
||||
align-content: center;
|
||||
background: $tribe-primary;
|
||||
display: flex;
|
||||
height: 0;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
transition: width $animation-steps-duration, height $animation-steps-duration;
|
||||
transition-delay: $animation-steps-duration;
|
||||
width: 0;
|
||||
z-index: 99;
|
||||
.terms-announcement-inner {
|
||||
opacity: 0;
|
||||
transition: opacity $animation-steps-duration;
|
||||
width: 100%;
|
||||
}
|
||||
&.visible {
|
||||
height: 146px;
|
||||
pointer-events: auto;
|
||||
transition-delay: 0s;
|
||||
width: 100%;
|
||||
.terms-announcement-inner {
|
||||
opacity: 1;
|
||||
transition: opacity $animation-steps-duration $animation-steps-duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.terms-announcement-inner {
|
||||
display: flex;
|
||||
max-width: 1200px;
|
||||
.announcement-decoration {
|
||||
align-self: flex-end;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
.text {
|
||||
padding: 1.25rem 3rem 1.25rem 2rem;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
.title {
|
||||
@include font-type(bold);
|
||||
@include font-size(larger);
|
||||
color: $tribe-secondary;
|
||||
margin-bottom: .5rem;
|
||||
}
|
||||
.warning {
|
||||
color: $tribe-secondary;
|
||||
a {
|
||||
@include font-type(bold);
|
||||
color: $tribe-secondary;
|
||||
}
|
||||
}
|
||||
.close {
|
||||
display: block;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 1rem;
|
||||
svg {
|
||||
@include svg-size(2rem);
|
||||
fill: lighten($tribe-secondary, 15%);
|
||||
pointer-events: none;
|
||||
transition: fill .2s;
|
||||
&:hover {
|
||||
fill: $tribe-secondary;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
###
|
||||
# Copyright (C) 2014-2015 Taiga Agile LLC <taiga@taiga.io>
|
||||
#
|
||||
# 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: notification.service.coffee
|
||||
###
|
||||
|
||||
class TermsAnnouncementService extends taiga.Service
|
||||
constructor: () ->
|
||||
@.open = false
|
||||
@.title = ""
|
||||
@.desc = ""
|
||||
|
||||
show: (title, desc) ->
|
||||
@.open = true
|
||||
@.title = title
|
||||
@.desc = desc
|
||||
|
||||
angular.module("taigaComponents").service("tgTermsAnnouncementService", TermsAnnouncementService)
|
Loading…
Reference in New Issue