mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-2626] changed logic for preserving the sidenav component state
This commit is contained in:
@@ -1,26 +1,18 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Copyright (C) 2005 - 2018 Alfresco Software Limited
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
@@ -24,4 +24,3 @@ export * from './user-initial.pipe';
|
||||
export * from './app-config.pipe';
|
||||
|
||||
export * from './pipe.module';
|
||||
|
||||
|
@@ -15,16 +15,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, ContentChild, Input, OnInit, AfterViewInit, ViewChild, OnDestroy, TemplateRef } from '@angular/core';
|
||||
import { Component, ContentChild, Input, Output, OnInit, AfterViewInit, ViewChild, OnDestroy, TemplateRef, EventEmitter } from '@angular/core';
|
||||
import { MediaMatcher } from '@angular/cdk/layout';
|
||||
import { SidenavLayoutContentDirective } from '../../directives/sidenav-layout-content.directive';
|
||||
import { SidenavLayoutHeaderDirective } from '../../directives/sidenav-layout-header.directive';
|
||||
import { SidenavLayoutNavigationDirective } from '../../directives/sidenav-layout-navigation.directive';
|
||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { AppConfigService } from './../../../app-config/app-config.service';
|
||||
import { StorageService } from './../../../services/storage.service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'adf-sidenav-layout',
|
||||
@@ -41,6 +38,8 @@ export class SidenavLayoutComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
@Input() hideSidenav = false;
|
||||
@Input() expandedSidenav = true;
|
||||
|
||||
@Output() notify = new EventEmitter();
|
||||
|
||||
@ContentChild(SidenavLayoutHeaderDirective) headerDirective: SidenavLayoutHeaderDirective;
|
||||
@ContentChild(SidenavLayoutNavigationDirective) navigationDirective: SidenavLayoutNavigationDirective;
|
||||
@ContentChild(SidenavLayoutContentDirective) contentDirective: SidenavLayoutContentDirective;
|
||||
@@ -59,8 +58,7 @@ export class SidenavLayoutComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
isMenuMinimized: () => this.isMenuMinimized
|
||||
};
|
||||
|
||||
constructor(private mediaMatcher: MediaMatcher, private config: AppConfigService, private storage: StorageService) {
|
||||
|
||||
constructor(private mediaMatcher: MediaMatcher) {
|
||||
|
||||
this.onMediaQueryChange = this.onMediaQueryChange.bind(this);
|
||||
}
|
||||
@@ -86,9 +84,7 @@ export class SidenavLayoutComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
this.mediaQueryList.removeListener(this.onMediaQueryChange);
|
||||
}
|
||||
|
||||
toggleMenu() {
|
||||
const preserve = this.config.get<string>('sideNav.preserveState');
|
||||
|
||||
toggleMenu(expandedSidenav) {
|
||||
if (!this.mediaQueryList.matches) {
|
||||
this.isMenuMinimized = !this.isMenuMinimized;
|
||||
} else {
|
||||
@@ -96,10 +92,7 @@ export class SidenavLayoutComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
}
|
||||
|
||||
this.container.toggleMenu();
|
||||
|
||||
if (preserve) {
|
||||
this.storage.setItem('openedSidenav', <any> !this.isMenuMinimized);
|
||||
}
|
||||
this.notify.emit((!this.isMenuMinimized).toString());
|
||||
}
|
||||
|
||||
get isMenuMinimized() {
|
||||
|
Reference in New Issue
Block a user