mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
latest fixes
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
import { map } from 'rxjs/operators';
|
||||
import { first, map, switchMap } from 'rxjs/operators';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Actions, Effect, ofType } from '@ngrx/effects'
|
||||
import * as fromRouter from '@ngrx/router-store';
|
||||
|
||||
import { HostWindowActionTypes } from '../shared/host-window.actions';
|
||||
import { CollapseMenuAction } from '../shared/menu/menu.actions';
|
||||
import {
|
||||
CollapseMenuAction,
|
||||
ExpandMenuPreviewAction,
|
||||
MenuActionTypes
|
||||
} from '../shared/menu/menu.actions';
|
||||
import { MenuID } from '../shared/menu/initial-menus-state';
|
||||
import { MenuService } from '../shared/menu/menu.service';
|
||||
import { MenuState } from '../shared/menu/menu.reducer';
|
||||
|
||||
@Injectable()
|
||||
export class NavbarEffects {
|
||||
@@ -29,8 +35,27 @@ export class NavbarEffects {
|
||||
ofType(fromRouter.ROUTER_NAVIGATION),
|
||||
map(() => new CollapseMenuAction(this.menuID))
|
||||
);
|
||||
|
||||
constructor(private actions$: Actions) {
|
||||
/**
|
||||
* Effect that collapses the public menu when the admin sidebar opens
|
||||
* @type {Observable<CollapseMenuAction>}
|
||||
*/
|
||||
@Effect() openAdminSidebar$ = this.actions$
|
||||
.pipe(
|
||||
ofType(MenuActionTypes.EXPAND_MENU_PREVIEW),
|
||||
switchMap((action: ExpandMenuPreviewAction) => {
|
||||
return this.menuService.getMenu(action.menuID).pipe(
|
||||
first(),
|
||||
map((menu: MenuState) => {
|
||||
if (menu.id === MenuID.ADMIN) {
|
||||
if (!menu.previewCollapsed && menu.collapsed) {
|
||||
return new CollapseMenuAction(MenuID.PUBLIC)
|
||||
}
|
||||
}
|
||||
return { type: 'NO_ACTION' };
|
||||
}));
|
||||
})
|
||||
);
|
||||
constructor(private actions$: Actions, private menuService: MenuService) {
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user