Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(menu): Add an option to set skipLocationChange true or false for… #1043

Merged
merged 3 commits into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[routerLink]="menuItem.link"
[queryParams]="menuItem.queryParams"
[fragment]="menuItem.fragment"
[skipLocationChange]="menuItem.skipLocationChange"
[attr.target]="menuItem.target"
[attr.title]="menuItem.title"
[class.active]="menuItem.selected"
Expand Down
34 changes: 21 additions & 13 deletions src/framework/theme/components/menu/menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { Injectable } from '@angular/core';
import { Location } from '@angular/common';
import { Params } from '@angular/router';
import { Observable, BehaviorSubject, ReplaySubject, Subject } from 'rxjs';
import { share } from 'rxjs/operators';
import { isUrlPathContain, isUrlPathEqual } from './url-matching-helpers';

export interface NbMenuBag { tag: string; item: NbMenuItem }
import {Injectable} from '@angular/core';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we revert all unnecessary formatting changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nnixaa reverted unnecessary formatting changes.

import {Location} from '@angular/common';
import {Params} from '@angular/router';
import {Observable, BehaviorSubject, ReplaySubject, Subject} from 'rxjs';
import {share} from 'rxjs/operators';
import {isUrlPathContain, isUrlPathEqual} from './url-matching-helpers';

export interface NbMenuBag {
tag: string;
item: NbMenuItem
}

const itemClick$ = new Subject<NbMenuBag>();
const addItems$ = new ReplaySubject<{ tag: string; items: NbMenuItem[] }>(1);
Expand Down Expand Up @@ -83,6 +86,10 @@ export class NbMenuItem {
* @type {boolean}
*/
group?: boolean;
/** Whether the item skipLocationChange is true or false
*@type {boolean}
*/
skipLocationChange?: boolean;
/** Map of query parameters
*@type {Params}
*/
Expand Down Expand Up @@ -128,23 +135,23 @@ export class NbMenuService {
* @param {string} tag
*/
addItems(items: NbMenuItem[], tag?: string) {
addItems$.next({ tag, items });
addItems$.next({tag, items});
}

/**
* Collapses all menu items
* @param {string} tag
*/
collapseAll(tag?: string) {
collapseAll$.next({ tag });
collapseAll$.next({tag});
}

/**
* Navigate to the home menu item
* @param {string} tag
*/
navigateHome(tag?: string) {
navigateHome$.next({ tag });
navigateHome$.next({tag});
}

/**
Expand All @@ -155,7 +162,7 @@ export class NbMenuService {
getSelectedItem(tag?: string): Observable<NbMenuBag> {
const listener = new BehaviorSubject<NbMenuBag>(null);

getSelectedItem$.next({ tag, listener });
getSelectedItem$.next({tag, listener});

return listener.asObservable();
}
Expand All @@ -180,7 +187,8 @@ export class NbMenuService {
@Injectable()
export class NbMenuInternalService {

constructor(private location: Location) {}
constructor(private location: Location) {
}

prepareItems(items: NbMenuItem[]) {
const defaultItem = new NbMenuItem();
Expand Down