mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 19:13:08 +00:00
68067: Fix adding/removing menu sections
This commit is contained in:
@@ -3,7 +3,7 @@ import { Observable } from 'rxjs/internal/Observable';
|
||||
import { MenuService } from '../../shared/menu/menu.service';
|
||||
import { MenuID } from '../../shared/menu/initial-menus-state';
|
||||
import { MenuSection } from '../../shared/menu/menu.reducer';
|
||||
import { first, map } from 'rxjs/operators';
|
||||
import { distinctUntilChanged, first, map } from 'rxjs/operators';
|
||||
import { GenericConstructor } from '../../core/shared/generic-constructor';
|
||||
import { hasValue } from '../empty.util';
|
||||
import { MenuSectionComponent } from './menu-section/menu-section.component';
|
||||
@@ -72,7 +72,7 @@ export class MenuComponent implements OnInit {
|
||||
this.menuCollapsed = this.menuService.isMenuCollapsed(this.menuID);
|
||||
this.menuPreviewCollapsed = this.menuService.isMenuPreviewCollapsed(this.menuID);
|
||||
this.menuVisible = this.menuService.isMenuVisible(this.menuID);
|
||||
this.sections = this.menuService.getMenuTopSections(this.menuID).pipe(first());
|
||||
this.sections = this.menuService.getMenuTopSections(this.menuID).pipe(distinctUntilChanged((x, y) => x.length === y.length));
|
||||
this.sections.subscribe((sections: MenuSection[]) => {
|
||||
sections.forEach((section: MenuSection) => {
|
||||
this.sectionInjectors.set(section.id, this.getSectionDataInjector(section));
|
||||
|
@@ -176,7 +176,9 @@ function removeSection(state: MenusState, action: RemoveMenuSectionAction) {
|
||||
const menuState: MenuState = state[action.menuID];
|
||||
const id = action.id;
|
||||
const newState = removeFromIndex(state, menuState.sections[action.id], action.menuID);
|
||||
const newMenuState = Object.assign({}, newState[action.menuID]);
|
||||
const newMenuState = Object.assign({}, newState[action.menuID], {
|
||||
sections: Object.assign({}, newState[action.menuID].sections)
|
||||
});
|
||||
delete newMenuState.sections[id];
|
||||
return Object.assign({}, newState, { [action.menuID]: newMenuState });
|
||||
}
|
||||
|
Reference in New Issue
Block a user