Improving user settings
parent
9dbe70fed6
commit
8150653e31
|
@ -101,6 +101,9 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide) ->
|
||||||
$routeProvider.when("/project/:pslug/user-settings/user-profile",
|
$routeProvider.when("/project/:pslug/user-settings/user-profile",
|
||||||
{templateUrl: "/partials/user-profile.html"})
|
{templateUrl: "/partials/user-profile.html"})
|
||||||
|
|
||||||
|
$routeProvider.when("/project/:pslug/user-settings/user-avatar",
|
||||||
|
{templateUrl: "/partials/user-avatar.html"})
|
||||||
|
|
||||||
$routeProvider.when("/project/:pslug/user-settings/mail-notifications",
|
$routeProvider.when("/project/:pslug/user-settings/mail-notifications",
|
||||||
{templateUrl: "/partials/mail-notifications.html"})
|
{templateUrl: "/partials/mail-notifications.html"})
|
||||||
|
|
||||||
|
@ -171,6 +174,7 @@ modules = [
|
||||||
"taigaAdmin",
|
"taigaAdmin",
|
||||||
"taigaNavMenu",
|
"taigaNavMenu",
|
||||||
"taigaProject",
|
"taigaProject",
|
||||||
|
"taigaUserSettings",
|
||||||
|
|
||||||
# Vendor modules
|
# Vendor modules
|
||||||
"ngRoute",
|
"ngRoute",
|
||||||
|
|
|
@ -22,11 +22,12 @@
|
||||||
AdminNavigationDirective = ->
|
AdminNavigationDirective = ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
section = $attrs.tgAdminNavigation
|
section = $attrs.tgAdminNavigation
|
||||||
|
|
||||||
console.log "section:", section
|
|
||||||
$el.find(".active").removeClass("active")
|
$el.find(".active").removeClass("active")
|
||||||
$el.find("#adminmenu-#{section} a").addClass("active")
|
$el.find("#adminmenu-#{section} a").addClass("active")
|
||||||
|
|
||||||
|
$scope.$on "$destroy", ->
|
||||||
|
$el.off()
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
module = angular.module("taigaAdmin")
|
module = angular.module("taigaAdmin")
|
||||||
|
|
|
@ -91,6 +91,9 @@ class AuthService extends taiga.Service
|
||||||
@.setUser(user)
|
@.setUser(user)
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
logout: ->
|
||||||
|
@.removeToken()
|
||||||
|
|
||||||
register: (data, type, existing) ->
|
register: (data, type, existing) ->
|
||||||
url = @urls.resolve("auth-register")
|
url = @urls.resolve("auth-register")
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ urls = {
|
||||||
|
|
||||||
# User settings
|
# User settings
|
||||||
"user-settings-user-profile": "/project/:project/user-settings/user-profile"
|
"user-settings-user-profile": "/project/:project/user-settings/user-profile"
|
||||||
|
"user-settings-user-avatar": "/project/:project/user-settings/user-avatar"
|
||||||
"user-settings-mail-notifications": "/project/:project/user-settings/mail-notifications"
|
"user-settings-mail-notifications": "/project/:project/user-settings/mail-notifications"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ module.directive("tgProjectsNav", ProjectsNavigationDirective)
|
||||||
## Project
|
## Project
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
ProjectMenuDirective = ($log, $compile, $auth, $rootscope) ->
|
ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location) ->
|
||||||
menuEntriesTemplate = _.template("""
|
menuEntriesTemplate = _.template("""
|
||||||
<div class="menu-container">
|
<div class="menu-container">
|
||||||
<ul class="main-nav">
|
<ul class="main-nav">
|
||||||
|
@ -115,9 +115,10 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope) ->
|
||||||
<div class="user-settings">
|
<div class="user-settings">
|
||||||
<ul class="popover">
|
<ul class="popover">
|
||||||
<li><a href="" title="Account settings", tg-nav="user-settings-user-profile:project=project.slug">Account settings</a></li>
|
<li><a href="" title="Account settings", tg-nav="user-settings-user-profile:project=project.slug">Account settings</a></li>
|
||||||
<li><a href="" title="Logout">Logout</a></li>
|
<li><a href="" title="Change profile photo", tg-nav="user-settings-user-avatar:project=project.slug">Change profile photo</a></li>
|
||||||
|
<li><a href="" title="Logout" class="logout">Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<a href="" title="User preferences" class="avatar">
|
<a href="" title="User preferences" class="avatar" id="nav-user-settings">
|
||||||
<img src="<%- user.photo %>" alt="<%- user.full_name_display %>" />
|
<img src="<%- user.photo %>" alt="<%- user.full_name_display %>" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -151,7 +152,6 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope) ->
|
||||||
|
|
||||||
container.replaceWith(dom)
|
container.replaceWith(dom)
|
||||||
|
|
||||||
|
|
||||||
link = ($scope, $el, $attrs, $ctrl) ->
|
link = ($scope, $el, $attrs, $ctrl) ->
|
||||||
renderMainMenu($el)
|
renderMainMenu($el)
|
||||||
|
|
||||||
|
@ -169,6 +169,12 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope) ->
|
||||||
$el.find(".popover").hide()
|
$el.find(".popover").hide()
|
||||||
body.unbind("click")
|
body.unbind("click")
|
||||||
|
|
||||||
|
$el.on "click", ".logout", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
$auth.logout()
|
||||||
|
$scope.$apply ->
|
||||||
|
$location.path("/login")
|
||||||
|
|
||||||
$scope.$on "$viewContentLoaded", (ctx) ->
|
$scope.$on "$viewContentLoaded", (ctx) ->
|
||||||
if ctx.targetScope.$$childHead is null || ctx.targetScope.$$childHead.hideMenu
|
if ctx.targetScope.$$childHead is null || ctx.targetScope.$$childHead.hideMenu
|
||||||
$el.addClass("hidden")
|
$el.addClass("hidden")
|
||||||
|
@ -183,4 +189,4 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope) ->
|
||||||
return {link: link}
|
return {link: link}
|
||||||
|
|
||||||
|
|
||||||
module.directive("tgProjectMenu", ["$log", "$compile", "$tgAuth", "$rootScope", ProjectMenuDirective])
|
module.directive("tgProjectMenu", ["$log", "$compile", "$tgAuth", "$rootScope", "$tgAuth", "$tgLocation", ProjectMenuDirective])
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
###
|
||||||
|
# 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/user-settings.coffee
|
||||||
|
###
|
||||||
|
|
||||||
|
module = angular.module("taigaUserSettings", [])
|
|
@ -0,0 +1,82 @@
|
||||||
|
###
|
||||||
|
# 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/user-settings/main.coffee
|
||||||
|
###
|
||||||
|
|
||||||
|
taiga = @.taiga
|
||||||
|
|
||||||
|
mixOf = @.taiga.mixOf
|
||||||
|
|
||||||
|
module = angular.module("taigaUserSettings")
|
||||||
|
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
## User settings Controller
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
class UserSettingsController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
|
@.$inject = [
|
||||||
|
"$scope",
|
||||||
|
"$rootScope",
|
||||||
|
"$tgRepo",
|
||||||
|
"$tgConfirm",
|
||||||
|
"$tgResources",
|
||||||
|
"$routeParams",
|
||||||
|
"$q",
|
||||||
|
"$location",
|
||||||
|
"$tgAuth"
|
||||||
|
]
|
||||||
|
|
||||||
|
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @auth) ->
|
||||||
|
@scope.sectionName = "User Settings" #i18n
|
||||||
|
@scope.project = {}
|
||||||
|
@scope.user = @auth.getUser()
|
||||||
|
|
||||||
|
promise = @.loadInitialData()
|
||||||
|
promise.then null, ->
|
||||||
|
console.log "FAIL" #TODO
|
||||||
|
|
||||||
|
loadProject: ->
|
||||||
|
return @rs.projects.get(@scope.projectId).then (project) =>
|
||||||
|
@scope.project = project
|
||||||
|
return project
|
||||||
|
|
||||||
|
loadInitialData: ->
|
||||||
|
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
|
||||||
|
@scope.projectId = data.project
|
||||||
|
return data
|
||||||
|
|
||||||
|
return promise.then(=> @.loadProject())
|
||||||
|
|
||||||
|
|
||||||
|
module.controller("UserSettingsController", UserSettingsController)
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
## User Profile Directive
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
UserProfileDirective = () ->
|
||||||
|
link = ($scope, $el, $attrs) ->
|
||||||
|
|
||||||
|
$scope.$on "$destroy", ->
|
||||||
|
$el.off()
|
||||||
|
|
||||||
|
return {link:link}
|
||||||
|
|
||||||
|
module.directive("tgUserProfile", UserProfileDirective)
|
|
@ -0,0 +1,34 @@
|
||||||
|
###
|
||||||
|
# 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/user-settings/nav.coffee
|
||||||
|
###
|
||||||
|
|
||||||
|
UserSettingsNavigationDirective = ->
|
||||||
|
link = ($scope, $el, $attrs) ->
|
||||||
|
section = $attrs.tgUserSettingsNavigation
|
||||||
|
$el.find(".active").removeClass("active")
|
||||||
|
$el.find("#usersettingsmenu-#{section} a").addClass("active")
|
||||||
|
|
||||||
|
$scope.$on "$destroy", ->
|
||||||
|
$el.off()
|
||||||
|
|
||||||
|
return {link:link}
|
||||||
|
|
||||||
|
module = angular.module("taigaUserSettings")
|
||||||
|
module.directive("tgUserSettingsNavigation", UserSettingsNavigationDirective)
|
|
@ -1,13 +1,13 @@
|
||||||
extends layout
|
extends dummy-layout
|
||||||
|
|
||||||
block head
|
block head
|
||||||
title Taiga Project management web application with scrum in mind!
|
title Taiga Project management web application with scrum in mind!
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div.wrapper(tg-project-us-status, ng-controller="ProjectValuesController as ctrl",
|
div.wrapper(tg-user-profile, ng-controller="UserSettingsController as ctrl",
|
||||||
ng-init="section='admin'")
|
ng-init="section='mail-notifications'")
|
||||||
sidebar.menu-secondary.sidebar(tg-admin-navigation="project-values")
|
sidebar.menu-secondary.sidebar(tg-user-settings-navigation="mail-notifications")
|
||||||
include views/modules/admin-menu
|
include views/modules/user-settings-menu
|
||||||
|
|
||||||
section.main.admin-roles
|
section.main.admin-roles
|
||||||
header
|
header
|
||||||
|
|
|
@ -4,8 +4,9 @@ block head
|
||||||
title Taiga Project management web application with scrum in mind!
|
title Taiga Project management web application with scrum in mind!
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div.wrapper
|
div.wrapper(tg-user-profile, ng-controller="UserSettingsController as ctrl",
|
||||||
sidebar.menu-secondary.sidebar
|
ng-init="section='user-settings'")
|
||||||
|
sidebar.menu-secondary.sidebar(tg-user-settings-navigation="user-profile")
|
||||||
include views/modules/user-settings-menu
|
include views/modules/user-settings-menu
|
||||||
|
|
||||||
section.main.user-profile
|
section.main.user-profile
|
||||||
|
@ -15,7 +16,7 @@ block content
|
||||||
form
|
form
|
||||||
fieldset
|
fieldset
|
||||||
label(for="user-email") Email
|
label(for="user-email") Email
|
||||||
input(type="text", placeholder="Email", id="user-email")
|
input(type="text", placeholder="Email", id="user-email", ng-value="user.email")
|
||||||
fieldset
|
fieldset
|
||||||
label(for="current-password") Current Password
|
label(for="current-password") Current Password
|
||||||
input(type="password", placeholder="Password", id="current-password")
|
input(type="password", placeholder="Password", id="current-password")
|
||||||
|
|
|
@ -5,14 +5,14 @@ section.admin-menu
|
||||||
nav
|
nav
|
||||||
ul
|
ul
|
||||||
li#usersettingsmenu-user-profile
|
li#usersettingsmenu-user-profile
|
||||||
a(href="", tg-nav="project-admin-project-profile-details:project=project.slug")
|
a(href="", tg-nav="user-settings-user-profile:project=project.slug")
|
||||||
span.title User profile
|
span.title User profile
|
||||||
span.icon.icon-arrow-right
|
span.icon.icon-arrow-right
|
||||||
li#usersettingsmenu-avatar
|
li#usersettingsmenu-avatar
|
||||||
a(href="" tg-nav="project-admin-memberships:project=project.slug")
|
a(href="" tg-nav="user-settings-user-avatar:project=project.slug")
|
||||||
span.title User avatar
|
span.title User avatar
|
||||||
span.icon.icon-arrow-right
|
span.icon.icon-arrow-right
|
||||||
li#usersettingsmenu-mail-notifications
|
li#usersettingsmenu-mail-notifications
|
||||||
a(href="", tg-nav="project-admin-project-values-us-status:project=project.slug")
|
a(href="", tg-nav="user-settings-mail-notifications:project=project.slug")
|
||||||
span.title Email notificiations
|
span.title Email notificiations
|
||||||
span.icon.icon-arrow-right
|
span.icon.icon-arrow-right
|
||||||
|
|
|
@ -50,7 +50,8 @@ paths = {
|
||||||
"app/coffee/modules/admin/*.coffee",
|
"app/coffee/modules/admin/*.coffee",
|
||||||
"app/coffee/modules/locales/*.coffee",
|
"app/coffee/modules/locales/*.coffee",
|
||||||
"app/coffee/modules/base/*.coffee",
|
"app/coffee/modules/base/*.coffee",
|
||||||
"app/coffee/modules/resources/*.coffee"]
|
"app/coffee/modules/resources/*.coffee",
|
||||||
|
"app/coffee/modules/user-settings/*.coffee"]
|
||||||
vendorJsLibs: [
|
vendorJsLibs: [
|
||||||
"app/vendor/jquery/dist/jquery.js",
|
"app/vendor/jquery/dist/jquery.js",
|
||||||
"app/vendor/lodash/dist/lodash.js",
|
"app/vendor/lodash/dist/lodash.js",
|
||||||
|
|
Loading…
Reference in New Issue