committed by
László Monda
parent
2735edb631
commit
49ec48c9e9
@@ -5,6 +5,9 @@ import { animate, keyframes, state, style, transition, trigger } from '@angular/
|
||||
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
import 'rxjs/add/operator/combineLatest';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import { ClientRect } from '../../dom';
|
||||
|
||||
@@ -90,11 +93,14 @@ export class PopoverComponent implements OnChanges {
|
||||
private leftPosition: number = 0;
|
||||
private animationState: string;
|
||||
|
||||
private readonly currentKeymap$ = new BehaviorSubject<Keymap>(undefined);
|
||||
|
||||
constructor(store: Store<AppState>) {
|
||||
this.animationState = 'closed';
|
||||
this.keymaps$ = store.let(getKeymaps())
|
||||
.map((keymaps: Keymap[]) =>
|
||||
keymaps.filter((keymap: Keymap) => this.currentKeymap.abbreviation !== keymap.abbreviation)
|
||||
.combineLatest(this.currentKeymap$)
|
||||
.map(([keymaps, currentKeymap]: [Keymap[], Keymap]) =>
|
||||
keymaps.filter((keymap: Keymap) => currentKeymap.abbreviation !== keymap.abbreviation)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -130,6 +136,10 @@ export class PopoverComponent implements OnChanges {
|
||||
this.animationState = 'closed';
|
||||
}
|
||||
}
|
||||
|
||||
if (change.currentKeymap) {
|
||||
this.currentKeymap$.next(this.currentKeymap);
|
||||
}
|
||||
}
|
||||
|
||||
onCancelClick(): void {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
|
||||
|
||||
import { Select2OptionData } from 'ng2-select2/ng2-select2';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { Tab } from '../tab';
|
||||
styleUrls: ['./keymap-tab.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class KeymapTabComponent extends Tab implements OnInit, OnChanges {
|
||||
export class KeymapTabComponent extends Tab implements OnChanges {
|
||||
@Input() defaultKeyAction: KeyAction;
|
||||
@Input() keymaps: Keymap[];
|
||||
|
||||
@@ -24,20 +24,20 @@ export class KeymapTabComponent extends Tab implements OnInit, OnChanges {
|
||||
this.keymapOptions = [];
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.keymapOptions = this.keymaps
|
||||
.map((keymap: Keymap): Select2OptionData => {
|
||||
return {
|
||||
id: keymap.abbreviation,
|
||||
text: keymap.name
|
||||
};
|
||||
});
|
||||
if (this.keymaps.length > 0) {
|
||||
this.selectedKeymap = this.keymaps[0];
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes.keymaps) {
|
||||
this.keymapOptions = this.keymaps
|
||||
.map((keymap: Keymap): Select2OptionData => {
|
||||
return {
|
||||
id: keymap.abbreviation,
|
||||
text: keymap.name
|
||||
};
|
||||
});
|
||||
if (this.keymaps.length > 0) {
|
||||
this.selectedKeymap = this.keymaps[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.fromKeyAction(this.defaultKeyAction);
|
||||
this.validAction.emit(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user