Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 802f81a1
authored
Apr 02, 2018
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
now menu works
1 parent
16d94af2
Pipeline
#55
failed
in 0 seconds
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
24 deletions
code/moya-angular/src/app/app-routing.module.ts
code/moya-angular/src/app/menu/defines/menu.ts
code/moya-angular/src/app/menu/left-menu/left-menu.component.ts
code/moya-angular/src/app/menu/top-menu/top-menu.component.html
code/moya-angular/src/app/app-routing.module.ts
View file @
802f81a
...
...
@@ -10,10 +10,8 @@ const APP_ROUTES: Routes = [
/*{ path: 'viplist', loadChildren: 'app/modules/viplist/viplist.module#ViplistModule' },*/
{
path
:
'viplist'
,
component
:
InfoViplistPageComponent
},
{
path
:
'old'
,
loadChildren
:
'app/modules/old-moya/old-moya.module#OldMoyaModule'
},
{
path
:
'user'
,
pathMatch
:
'full'
,
component
:
FrontpageComponent
},
{
path
:
'info'
,
pathMatch
:
'full'
,
component
:
FrontpageComponent
},
{
path
:
'admin'
,
pathMatch
:
'full'
,
component
:
FrontpageComponent
},
{
path
:
''
,
pathMatch
:
'full'
,
component
:
FrontpageComponent
}
{
path
:
'index'
,
component
:
FrontpageComponent
},
{
path
:
''
,
pathMatch
:
'full'
,
redirectTo
:
'/index'
,
}
];
@
NgModule
({
...
...
code/moya-angular/src/app/menu/defines/menu.ts
View file @
802f81a
...
...
@@ -27,6 +27,11 @@ export class MENU {
static
USER
:
MenuGroup
[]
=
[
{
'name'
:
''
,
'items'
:
[
{
'path'
:
'/index'
,
'name'
:
'Frontpage'
},
]},
{
'name'
:
'Event'
,
'items'
:
[
{
'path'
:
'/old/user'
,
'name'
:
'Poll'
,
'params'
:
{
p
:
'poll/index.jsf'
}
},
...
...
code/moya-angular/src/app/menu/left-menu/left-menu.component.ts
View file @
802f81a
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
MenuGroup
}
from
'../models/menu-group.model'
;
import
{
MENU
}
from
"../defines/menu"
;
import
{
ActivatedRoute
,
UrlSegment
}
from
"@angular/router"
;
import
{
ActivatedRoute
,
Router
,
RouterEvent
,
UrlSegment
}
from
"@angular/router"
;
@
Component
({
selector
:
'left-menu'
,
...
...
@@ -16,13 +16,14 @@ export class LeftMenuComponent implements OnInit {
searchPath
(
path
:
string
,
menu
:
MenuGroup
[]):
boolean
{
menu
.
forEach
(
group
=>
{
group
.
items
.
forEach
(
item
=>
{
for
(
let
i
in
menu
)
{
for
(
let
n
in
menu
[
i
].
items
)
{
let
item
=
menu
[
i
].
items
[
n
];
if
(
path
.
startsWith
(
item
.
path
))
{
return
true
;
}
}
);
}
);
}
}
return
false
;
}
...
...
@@ -30,29 +31,29 @@ export class LeftMenuComponent implements OnInit {
constructor
(
private
route
:
ActivatedRoute
)
{
constructor
(
private
route
:
Router
)
{
this
.
route
.
url
.
subscribe
(
segments
=>
{
let
path
:
string
=
segments
.
map
(
segment
=>
segment
.
path
).
join
(
"/"
);
route
.
events
.
filter
(
e
=>
e
instanceof
RouterEvent
).
subscribe
(
event
=>
{
cons
ole
.
log
(
path
)
;
cons
t
revent
=
event
as
RouterEvent
;
if
(
this
.
searchPath
(
path
,
MENU
.
USER
))
{
if
(
this
.
searchPath
(
revent
.
url
,
MENU
.
USER
))
{
this
.
activateUser
();
return
;
}
if
(
this
.
searchPath
(
path
,
MENU
.
INFO
))
{
if
(
this
.
searchPath
(
revent
.
url
,
MENU
.
INFO
))
{
this
.
activateInfo
();
return
;
}
if
(
this
.
searchPath
(
path
,
MENU
.
ADMIN
))
{
if
(
this
.
searchPath
(
revent
.
url
,
MENU
.
ADMIN
))
{
this
.
activateAdmin
();
return
;
}
});
}
...
...
@@ -63,22 +64,17 @@ export class LeftMenuComponent implements OnInit {
activateInfo
()
{
console
.
log
(
"activating info"
);
this
.
menu
=
MENU
.
INFO
;
this
.
styleClass
=
"infoMenu"
;
}
activateUser
()
{
console
.
log
(
"activating user"
);
this
.
menu
=
MENU
.
USER
;
this
.
styleClass
=
"userMenu"
;
}
activateAdmin
()
{
console
.
log
(
"activating admin"
);
this
.
menu
=
MENU
.
ADMIN
;
this
.
styleClass
=
"adminMenu"
;
}
...
...
code/moya-angular/src/app/menu/top-menu/top-menu.component.html
View file @
802f81a
<nav
id=
"topNav"
>
<a
class=
"topNavItem"
id=
"userTopNav"
routerLink=
"/
user
"
routerLinkActive=
"active"
i18n
>
Kävijänäkymä
</a>
<a
class=
"topNavItem"
id=
"infoTopNav"
routerLink=
"/info"
routerLinkActive=
"active"
[
queryParams
]="{
p:
'
useradmin
/
list
.
jsf
'}"
i18n
>
Infonäkymä
</a>
<a
class=
"topNavItem"
id=
"adminTopNav"
routerLink=
"/
admin"
routerLinkActive=
"active
"
i18n
>
Ylläpitonäkymä
</a>
<a
class=
"topNavItem"
id=
"userTopNav"
routerLink=
"/
index
"
routerLinkActive=
"active"
i18n
>
Kävijänäkymä
</a>
<a
class=
"topNavItem"
id=
"infoTopNav"
routerLink=
"/
old/
info"
routerLinkActive=
"active"
[
queryParams
]="{
p:
'
useradmin
/
list
.
jsf
'}"
i18n
>
Infonäkymä
</a>
<a
class=
"topNavItem"
id=
"adminTopNav"
routerLink=
"/
old/admin"
routerLinkActive=
"active"
[
queryParams
]="{
p:
'
product
/
list
.
jsf
'}
"
i18n
>
Ylläpitonäkymä
</a>
</nav>
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment