WIP custom homepage

stable
Daniel García 2018-09-18 15:43:28 +02:00 committed by Alex Hermida
parent 37c7097c89
commit 2dc9835913
11 changed files with 289 additions and 0 deletions

View File

@ -172,6 +172,15 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven
# Project
$routeProvider.when("/project/:pslug/",
{
template: "",
loader: true,
controller: "ProjectRouter"
}
)
# Project
$routeProvider.when("/project/:pslug/timeline",
{
templateUrl: "projects/project/project.html",
loader: true,
@ -450,6 +459,8 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven
{templateUrl: "user/user-profile.html"})
$routeProvider.when("/user-settings/user-change-password",
{templateUrl: "user/user-change-password.html"})
$routeProvider.when("/user-settings/user-project-settings",
{templateUrl: "user/user-project-settings.html"})
$routeProvider.when("/user-settings/mail-notifications",
{templateUrl: "user/mail-notifications.html"})
$routeProvider.when("/user-settings/live-notifications",

View File

@ -119,6 +119,7 @@ urls = {
"user-settings-user-profile": "/user-settings/user-profile"
"user-settings-user-change-password": "/user-settings/user-change-password"
"user-settings-user-avatar": "/user-settings/user-avatar"
"user-settings-user-project-settings": "/user-settings/user-project-settings"
"user-settings-mail-notifications": "/user-settings/mail-notifications"
"user-settings-live-notifications": "/user-settings/live-notifications"
"user-settings-contrib": "/user-settings/contrib/:plugin"

View File

@ -0,0 +1,43 @@
###
# Copyright (C) 2014-2017 Andrey Antukh <niwi@niwi.nz>
# Copyright (C) 2014-2017 Jesús Espino Garcia <jespinog@gmail.com>
# Copyright (C) 2014-2017 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: modules/common/sections.coffee
###
module = angular.module("taigaCommon")
SECTIONS = {
1: {id: 1, title: 'TIMELINE', path:'timeline'}
2: {id: 2, title: 'SEARCH', path:'search'}
3: {id: 3, title: 'BACKLOG', path:'backlog'}
4: {id: 4, title: 'KANBAN', path:'kanban'}
5: {id: 5, title: 'ISSUES', path:'issues'}
6: {id: 6, title: 'WIKI', path:'wiki'}
7: {id: 7, title: 'TEAM', path:'team'}
8: {id: 8, title: 'MEETUP', path:'meetup'}
9: {id: 9, title: 'ADMIN', path:'admin'}
}
class SectionsService extends taiga.Service
list: () ->
return SECTIONS
module.service("$tgSections", SectionsService)

View File

@ -47,6 +47,9 @@ urls = {
"permissions": "/permissions"
"notify-policies": "/notify-policies"
# User Project Settings
"user-project-settings": "/user-project-settings"
# User - Storage
"user-storage": "/user-storage"
@ -261,6 +264,7 @@ module.run([
"$tgNotifyPoliciesResourcesProvider",
"$tgInvitationsResourcesProvider",
"$tgRolesResourcesProvider",
"$tgUserProjectSettingsResourcesProvider",
"$tgUserSettingsResourcesProvider",
"$tgSprintsResourcesProvider",
"$tgEpicsResourcesProvider",

View File

@ -0,0 +1,36 @@
###
#
# 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/resources/user-project-settings.coffee
###
taiga = @.taiga
resourceProvider = ($repo, $http, $urls) ->
service = {}
service.get = (id) ->
return $repo.queryOne("user-project-settings", id)
service.list = (filters) ->
params = _.extend({}, params, filters or {})
return $repo.queryMany("user-project-settings", params)
return (instance) ->
instance.userProjectSettings = service
module = angular.module("taigaResources")
module.factory("$tgUserProjectSettingsResourcesProvider", ["$tgRepo", "$tgHttp", "$tgUrls", resourceProvider])

View File

@ -0,0 +1,65 @@
###
# Copyright (C) 2014-2017 Andrey Antukh <niwi@niwi.nz>
# Copyright (C) 2014-2017 Jesús Espino Garcia <jespinog@gmail.com>
# Copyright (C) 2014-2017 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: modules/user-settings/user-project-settings.coffee
###
taiga = @.taiga
mixOf = @.taiga.mixOf
bindOnce = @.taiga.bindOnce
module = angular.module("taigaUserSettings")
#############################################################################
## Custom Homepage Controller
#############################################################################
class UserProjectSettingsController extends mixOf(taiga.Controller, taiga.PageMixin)
@.$inject = [
"$scope"
"$tgSections"
"$tgResources"
"$tgRepo"
"$tgConfirm"
]
constructor: (@scope, @tgSections, @rs, @repo, @confirm) ->
promise = @.loadInitialData()
promise.then null, @.onInitialDataError.bind(@)
@scope.sections = @tgSections.list()
loadInitialData: ->
return @rs.userProjectSettings.list().then (userProjectSettings) =>
@scope.userProjectSettings = userProjectSettings
return userProjectSettings
updateCustomHomePage: (project, customHomePage) ->
onSuccess = =>
@confirm.notify("success")
onError = =>
@confirm.notify("error")
# @repo.save(project).then(onSuccess, onError)
module.controller("UserProjectSettingsController", UserProjectSettingsController)

View File

@ -1561,6 +1561,12 @@
"OPTION_ALL": "All",
"OPTION_INVOLVED": "Involved",
"OPTION_NONE": "None"
},
"PROJECT_SETTINGS": {
"CUSTOM_HOMEPAGE": "Custom Homepage",
"COLUMN_PROJECT": "Project",
"COLUMN_HOMEPAGE": "Homepage",
"DEFAULT_VALUE": "Default"
}
},
"USER_PROFILE": {

View File

@ -0,0 +1,55 @@
###
# Copyright (C) 2014-2017 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: project-router.controller.coffee
###
class ProjectRouterController
@.$inject = [
"$routeParams",
"$location"
"tgProjectService"
"$tgResources"
"$tgSections"
]
constructor: (@routeParams, @location, @projectService, @rs, @tgSections) ->
@getProjectHomepage()
.then (section) =>
if section
@location.url("project/#{@routeParams.pslug}/#{section}")
else
gotoDefaultProjectHomepage()
.then null, ->
gotoDefaultProjectHomepage()
gotoDefaultProjectHomepage: () ->
@location.url("project/#{@routeParams.pslug}/timeline")
getProjectHomepage: () ->
sections = @tgSections.list()
project = @projectService.project.toJS()
@rs.userProjectSettings.list().then (userProjectSettings) ->
settings = _.find(userProjectSettings, {"project": project.id})
return if !settings
section = _.find(sections, {"id": settings.homepage})
return if !section
return section.path
angular.module("taigaProjects").controller("ProjectRouter", ProjectRouterController)

View File

@ -7,6 +7,9 @@ section.admin-menu
li#usersettingsmenu-change-password
a(href="" tg-nav="user-settings-user-change-password", title="{{ 'USER_SETTINGS.MENU.CHANGE_PASSWORD' | translate }}")
span.title(translate="USER_SETTINGS.MENU.CHANGE_PASSWORD")
li#usersettingsmenu-custom-homepage
a(href="", tg-nav="user-settings-user-project-settings", title="{{ 'USER_SETTINGS.PROJECT_SETTINGS.CUSTOM_HOMEPAGE' | translate }}")
span.title(translate="USER_SETTINGS.PROJECT_SETTINGS.CUSTOM_HOMEPAGE")
li#usersettingsmenu-mail-notifications
a(href="", tg-nav="user-settings-mail-notifications", title="{{ 'USER_SETTINGS.MENU.EMAIL_NOTIFICATIONS' | translate }}")
span.title(translate="USER_SETTINGS.MENU.EMAIL_NOTIFICATIONS")

View File

@ -0,0 +1,37 @@
doctype html
div.wrapper(
ng-controller="UserProjectSettingsController as ctrl",
ng-init="section='project-settings'"
)
sidebar.menu-secondary.sidebar.settings-nav(tg-user-settings-navigation="project-settings")
include ../includes/modules/user-settings-menu
section.main.admin-common
header
h1
span.green {{ 'USER_SETTINGS.PROJECT_SETTINGS.CUSTOM_HOMEPAGE' | translate }}
section.project-settings-table
div.custom-table-header
div.project-settings-table-row
div.project-settings-table-project
span(translate="USER_SETTINGS.PROJECT_SETTINGS.COLUMN_PROJECT")
div.project-settings-table-homepage
span(translate="USER_SETTINGS.PROJECT_SETTINGS.COLUMN_HOMEPAGE")
div.project-settings-table-body
.project-settings-table-row(ng-repeat="projectSettings in userProjectSettings")
.project-settings-table-project
span {{ projectSettings.project_name }}
.project-settings-table-homepage
select(
id="projects-settings-{{projectSettings.id}}-homepage-dropdown"
)
option(
ng-value="null"
) {{ 'USER_SETTINGS.PROJECT_SETTINGS.DEFAULT_VALUE' | translate }}
option(
ng-repeat="section in sections"
value="{{ section.id }}"
) {{ 'PROJECT.SECTION.' + section.title | translate }}

View File

@ -0,0 +1,28 @@
.project-settings-table {
.project-settings-table-row {
align-items: center;
border-bottom: 1px solid $whitish;
display: flex;
justify-content: center;
}
.project-settings-table-header {
@include font-type(bold);
border-bottom: 2px solid $gray-light;
}
.project-settings-table-project ,
.project-settings-table-homepage {
padding: 1rem;
}
.project-settings-table-project {
flex-basis: 0;
flex-grow: 3;
}
.project-settings-table-homepage {
flex-basis: 0;
flex-grow: 1;
}
}