This commit is contained in:
Eugene Pankov
2017-04-16 23:04:29 +02:00
parent 125ec2b81c
commit acc13087bf
18 changed files with 91 additions and 33 deletions

View File

@@ -40,7 +40,7 @@ import { AppService, IToolbarButton, ToolbarButtonProvider } from '../api'
})
export class AppRootComponent {
toasterConfig: ToasterConfig
logger: Logger
private logger: Logger
constructor(
private docking: DockingService,

View File

@@ -1,5 +1,5 @@
import { BehaviorSubject } from 'rxjs'
import { EventEmitter, ViewRef } from '@angular/core'
import { Subject, BehaviorSubject } from 'rxjs'
import { ViewRef } from '@angular/core'
export abstract class BaseTabComponent {
@@ -7,13 +7,20 @@ export abstract class BaseTabComponent {
title$ = new BehaviorSubject<string>(null)
scrollable: boolean
hasActivity = false
focused = new EventEmitter<any>()
blurred = new EventEmitter<any>()
focused$ = new Subject<void>()
blurred$ = new Subject<void>()
hasFocus = false
hostView: ViewRef
private static lastTabID = 0
constructor () {
this.id = BaseTabComponent.lastTabID++
this.focused$.subscribe(() => {
this.hasFocus = true
})
this.blurred$.subscribe(() => {
this.hasFocus = false
})
}
displayActivity (): void {
@@ -25,5 +32,8 @@ export abstract class BaseTabComponent {
}
destroy (): void {
this.focused$.complete()
this.blurred$.complete()
this.title$.complete()
}
}

View File

@@ -4,9 +4,10 @@ import { BaseTabComponent } from '../components/baseTab.component'
@Component({
selector: 'tab-body',
template: `
<perfect-scrollbar [config]="{ suppressScrollX: true, suppressScrollY: !scrollable}">
<ng-template #placeholder></ng-template>
<perfect-scrollbar [config]="{ suppressScrollX: true }" *ngIf="scrollable">
<ng-template #scrollablePlaceholder></ng-template>
</perfect-scrollbar>
<template #nonScrollablePlaceholder [ngIf]="!scrollable"></template>
`,
styles: [
require('./tabBody.component.scss'),
@@ -17,11 +18,12 @@ export class TabBodyComponent {
@Input() @HostBinding('class.active') active: boolean
@Input() tab: BaseTabComponent
@Input() scrollable: boolean
@ViewChild('placeholder', {read: ViewContainerRef}) placeholder: ViewContainerRef
@ViewChild('scrollablePlaceholder', {read: ViewContainerRef}) scrollablePlaceholder: ViewContainerRef
@ViewChild('nonScrollablePlaceholder', {read: ViewContainerRef}) nonScrollablePlaceholder: ViewContainerRef
ngAfterViewInit () {
setImmediate(() => {
this.placeholder.insert(this.tab.hostView)
(this.scrollable ? this.scrollablePlaceholder : this.nonScrollablePlaceholder).insert(this.tab.hostView)
})
}
}

View File

@@ -51,11 +51,11 @@ export class AppService {
}
if (this.activeTab) {
this.activeTab.hasActivity = false
this.activeTab.blurred.emit()
this.activeTab.blurred$.next()
}
this.activeTab = tab
if (this.activeTab) {
this.activeTab.focused.emit()
this.activeTab.focused$.next()
}
}