new custom route page title
parent
4e41ea5015
commit
408fc1b8e3
|
@ -44,10 +44,10 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven
|
||||||
access: {
|
access: {
|
||||||
requiresLogin: true
|
requiresLogin: true
|
||||||
},
|
},
|
||||||
|
title: "PROJECT.WELCOME",
|
||||||
resolve: {
|
resolve: {
|
||||||
loader: tgLoaderProvider.add(true),
|
loader: tgLoaderProvider.add(true),
|
||||||
pageParams: -> {
|
pageParams: -> {
|
||||||
"title": "PROJECT.WELCOME"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,25 +59,24 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven
|
||||||
access: {
|
access: {
|
||||||
requiresLogin: true
|
requiresLogin: true
|
||||||
},
|
},
|
||||||
|
title: "PROJECT.SECTION_PROJECTS",
|
||||||
resolve: {
|
resolve: {
|
||||||
loader: tgLoaderProvider.add(true),
|
loader: tgLoaderProvider.add(true)
|
||||||
pageParams: -> {
|
}
|
||||||
"title": "PROJECT.SECTION_PROJECTS"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
controller: "Page"
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
$routeProvider.when("/project/:pslug/",
|
$routeProvider.when("/project/:pslug/",
|
||||||
{
|
{
|
||||||
templateUrl: "projects/project/project-page.html",
|
templateUrl: "projects/project/project.html",
|
||||||
access: {
|
access: {
|
||||||
requiresLogin: true
|
requiresLogin: true
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
loader: tgLoaderProvider.add(true)
|
loader: tgLoaderProvider.add(true)
|
||||||
}
|
},
|
||||||
|
controller: "Project",
|
||||||
|
controllerAs: "vm"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -354,7 +353,7 @@ i18nInit = (lang, $translate) ->
|
||||||
checksley.updateMessages('default', messages)
|
checksley.updateMessages('default', messages)
|
||||||
|
|
||||||
|
|
||||||
init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $navUrls) ->
|
init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $navUrls, $appTitle) ->
|
||||||
$log.debug("Initialize application")
|
$log.debug("Initialize application")
|
||||||
|
|
||||||
# Taiga Plugins
|
# Taiga Plugins
|
||||||
|
@ -378,6 +377,9 @@ init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $na
|
||||||
if !$auth.isAuthenticated()
|
if !$auth.isAuthenticated()
|
||||||
$location.path($navUrls.resolve("login"))
|
$location.path($navUrls.resolve("login"))
|
||||||
|
|
||||||
|
if next.title
|
||||||
|
$translate(next.title).then (text) => $appTitle.set(text)
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
# Main Global Modules
|
# Main Global Modules
|
||||||
"taigaBase",
|
"taigaBase",
|
||||||
|
@ -412,7 +414,6 @@ modules = [
|
||||||
# new modules
|
# new modules
|
||||||
"taigaProfile",
|
"taigaProfile",
|
||||||
"taigaHome",
|
"taigaHome",
|
||||||
"taigaPage",
|
|
||||||
"taigaUserTimeline",
|
"taigaUserTimeline",
|
||||||
|
|
||||||
# template cache
|
# template cache
|
||||||
|
@ -450,5 +451,6 @@ module.run([
|
||||||
"$translate",
|
"$translate",
|
||||||
"$tgLocation",
|
"$tgLocation",
|
||||||
"$tgNavUrls",
|
"$tgNavUrls",
|
||||||
|
"$appTitle",
|
||||||
init
|
init
|
||||||
])
|
])
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
class PageController extends taiga.Controller
|
|
||||||
@.$inject = [
|
|
||||||
"$appTitle",
|
|
||||||
"$translate",
|
|
||||||
"pageParams"
|
|
||||||
]
|
|
||||||
|
|
||||||
constructor: (@appTitle, @translate, @pageParams) ->
|
|
||||||
if @pageParams.title
|
|
||||||
@translate(@pageParams.title).then (text) => @appTitle.set(text)
|
|
||||||
|
|
||||||
angular.module("taigaPage").controller("Page", PageController)
|
|
|
@ -1,62 +0,0 @@
|
||||||
describe "PageController", ->
|
|
||||||
pageCtrl = null
|
|
||||||
provide = null
|
|
||||||
controller = null
|
|
||||||
mocks = {}
|
|
||||||
|
|
||||||
_mockPageParams = () ->
|
|
||||||
mocks.pageParams = {}
|
|
||||||
|
|
||||||
provide.value "pageParams", mocks.pageParams
|
|
||||||
|
|
||||||
_mockAppTitle = () ->
|
|
||||||
mocks.appTitle = {
|
|
||||||
set: sinon.spy()
|
|
||||||
}
|
|
||||||
|
|
||||||
provide.value "$appTitle", mocks.appTitle
|
|
||||||
|
|
||||||
_mockTranslate = () ->
|
|
||||||
mocks.translate = sinon.stub()
|
|
||||||
|
|
||||||
provide.value "$translate", mocks.translate
|
|
||||||
|
|
||||||
_mocks = () ->
|
|
||||||
module ($provide) ->
|
|
||||||
provide = $provide
|
|
||||||
_mockAppTitle()
|
|
||||||
_mockPageParams()
|
|
||||||
_mockTranslate()
|
|
||||||
|
|
||||||
return null
|
|
||||||
|
|
||||||
beforeEach ->
|
|
||||||
module "taigaPage"
|
|
||||||
|
|
||||||
_mocks()
|
|
||||||
|
|
||||||
inject ($controller) ->
|
|
||||||
controller = $controller
|
|
||||||
|
|
||||||
describe "page title", () ->
|
|
||||||
it "if title is defined set it", () ->
|
|
||||||
thenStub = sinon.stub()
|
|
||||||
|
|
||||||
mocks.pageParams.title = "TITLE"
|
|
||||||
mocks.translate.withArgs("TITLE").returns({
|
|
||||||
then: thenStub
|
|
||||||
})
|
|
||||||
|
|
||||||
pageCtrl = controller "Page",
|
|
||||||
$scope: {}
|
|
||||||
|
|
||||||
thenStub.callArg(0, "TITLE")
|
|
||||||
|
|
||||||
expect(mocks.appTitle.set.withArgs("TITLE")).have.been.calledOnce
|
|
||||||
|
|
||||||
it "if title is not defined not call appTitle", () ->
|
|
||||||
pageCtrl = controller "Page",
|
|
||||||
$scope: {}
|
|
||||||
|
|
||||||
expect(mocks.translate).have.callCount(0)
|
|
||||||
expect(mocks.appTitle.set.withArgs("TITLE")).have.callCount(0)
|
|
|
@ -1 +0,0 @@
|
||||||
module = angular.module("taigaPage", [])
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
class ProfilePageController extends taiga.Controller
|
||||||
|
@.$inject = [
|
||||||
|
"$appTitle",
|
||||||
|
"$tgAuth"
|
||||||
|
]
|
||||||
|
|
||||||
|
constructor: (@appTitle, @auth) ->
|
||||||
|
user = @auth.getUser()
|
||||||
|
|
||||||
|
@appTitle.set(user.username)
|
||||||
|
|
||||||
|
angular.module("taigaProfile").controller("ProfilePage", ProfilePageController)
|
|
@ -0,0 +1,47 @@
|
||||||
|
describe "PageController", ->
|
||||||
|
pageCtrl = null
|
||||||
|
provide = null
|
||||||
|
controller = null
|
||||||
|
mocks = {}
|
||||||
|
|
||||||
|
_mockAuth = () ->
|
||||||
|
mocks.authService = {
|
||||||
|
getUser: sinon.stub()
|
||||||
|
}
|
||||||
|
|
||||||
|
provide.value "$tgAuth", mocks.authService
|
||||||
|
|
||||||
|
_mockAppTitle = () ->
|
||||||
|
mocks.appTitle = {
|
||||||
|
set: sinon.spy()
|
||||||
|
}
|
||||||
|
|
||||||
|
provide.value "$appTitle", mocks.appTitle
|
||||||
|
|
||||||
|
_mocks = () ->
|
||||||
|
module ($provide) ->
|
||||||
|
provide = $provide
|
||||||
|
_mockAppTitle()
|
||||||
|
_mockAuth()
|
||||||
|
|
||||||
|
return null
|
||||||
|
|
||||||
|
beforeEach ->
|
||||||
|
module "taigaProfile"
|
||||||
|
|
||||||
|
_mocks()
|
||||||
|
|
||||||
|
inject ($controller) ->
|
||||||
|
controller = $controller
|
||||||
|
|
||||||
|
it "set the username as title", () ->
|
||||||
|
user = {
|
||||||
|
username: 'UserName'
|
||||||
|
}
|
||||||
|
|
||||||
|
mocks.authService.getUser.returns(user)
|
||||||
|
|
||||||
|
pageCtrl = controller "ProfilePage",
|
||||||
|
$scope: {}
|
||||||
|
|
||||||
|
expect(mocks.appTitle.set.withArgs(user.username)).have.been.calledOnce
|
|
@ -11,7 +11,7 @@ div.wrapper
|
||||||
|
|
||||||
div.project-data
|
div.project-data
|
||||||
section.timeline
|
section.timeline
|
||||||
span TODO. Missing the amazing timeline around!!dfdfdf
|
div(tg-user-timeline)
|
||||||
section.involved-data
|
section.involved-data
|
||||||
h2.title Team
|
h2.title Team
|
||||||
ul.involved-team
|
ul.involved-team
|
||||||
|
|
Loading…
Reference in New Issue