close panel if already open #75
This commit is contained in:
parent
4da2e3f0ed
commit
35c8a8fee5
|
@ -1,16 +1,18 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { faTimes } from "@fortawesome/free-solid-svg-icons";
|
||||
|
||||
import { NavigationService, LeftPanelType } from '../../services/navigation.service';
|
||||
import { AccountWrapper } from '../../models/account.models';
|
||||
import { OpenThreadEvent } from '../../services/tools.service';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-floating-column',
|
||||
templateUrl: './floating-column.component.html',
|
||||
styleUrls: ['./floating-column.component.scss']
|
||||
})
|
||||
export class FloatingColumnComponent implements OnInit {
|
||||
export class FloatingColumnComponent implements OnInit, OnDestroy {
|
||||
|
||||
faTimes = faTimes;
|
||||
overlayActive: boolean;
|
||||
overlayAccountToBrowse: string;
|
||||
|
@ -19,31 +21,58 @@ export class FloatingColumnComponent implements OnInit {
|
|||
|
||||
userAccountUsed: AccountWrapper;
|
||||
|
||||
openPanel: string;
|
||||
openPanel: string = '';
|
||||
|
||||
private activatedPanelSub: Subscription;
|
||||
|
||||
constructor(private readonly navigationService: NavigationService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.navigationService.activatedPanelSubject.subscribe((type: LeftPanelType) => {
|
||||
this.activatedPanelSub = this.navigationService.activatedPanelSubject.subscribe((type: LeftPanelType) => {
|
||||
switch (type) {
|
||||
case LeftPanelType.Closed:
|
||||
this.openPanel = '';
|
||||
break;
|
||||
case LeftPanelType.AddNewAccount:
|
||||
if (this.openPanel === 'addNewAccount') {
|
||||
this.closePanel();
|
||||
} else {
|
||||
this.openPanel = 'addNewAccount';
|
||||
}
|
||||
break;
|
||||
case LeftPanelType.CreateNewStatus:
|
||||
if (this.openPanel === 'createNewStatus') {
|
||||
this.closePanel();
|
||||
} else {
|
||||
this.openPanel = 'createNewStatus';
|
||||
}
|
||||
break;
|
||||
case LeftPanelType.ManageAccount:
|
||||
let lastUserAccountId = '';
|
||||
if (this.userAccountUsed && this.userAccountUsed.info) {
|
||||
lastUserAccountId = this.userAccountUsed.info.id;
|
||||
}
|
||||
this.userAccountUsed = this.navigationService.getAccountToManage();
|
||||
|
||||
if (this.openPanel === 'manageAccount' && this.userAccountUsed.info.id === lastUserAccountId) {
|
||||
this.closePanel();
|
||||
} else {
|
||||
this.openPanel = 'manageAccount';
|
||||
}
|
||||
break;
|
||||
case LeftPanelType.Search:
|
||||
if (this.openPanel === 'search') {
|
||||
this.closePanel();
|
||||
} else {
|
||||
this.openPanel = 'search';
|
||||
}
|
||||
break;
|
||||
case LeftPanelType.Settings:
|
||||
if (this.openPanel === 'settings') {
|
||||
this.closePanel();
|
||||
} else {
|
||||
this.openPanel = 'settings';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
this.openPanel = '';
|
||||
|
@ -51,6 +80,12 @@ export class FloatingColumnComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if(this.activatedPanelSub) {
|
||||
this.activatedPanelSub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
closePanel(): boolean {
|
||||
this.navigationService.closePanel();
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue