Fix new macro selection

Closes #209
This commit is contained in:
Farkas József
2016-12-05 20:01:53 +01:00
parent 03ca90d558
commit cded85ed9c

View File

@@ -2,6 +2,8 @@ import { Component, Renderer, animate, state, style, transition, trigger } from
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { Keymap } from '../../config-serializer/config-items/Keymap'; import { Keymap } from '../../config-serializer/config-items/Keymap';
@@ -17,7 +19,7 @@ import { getKeymapEntities, getMacroEntities } from '../../store/reducers';
state('inactive', style({ state('inactive', style({
height: '0px' height: '0px'
})), })),
state('active', style({ state('active', style({
height: '*' height: '*'
})), })),
transition('inactive <=> active', animate('500ms ease-out')) transition('inactive <=> active', animate('500ms ease-out'))
@@ -30,7 +32,7 @@ import { getKeymapEntities, getMacroEntities } from '../../store/reducers';
export class SideMenuComponent { export class SideMenuComponent {
private keymaps$: Observable<Keymap[]>; private keymaps$: Observable<Keymap[]>;
private macros$: Observable<Macro[]>; private macros$: Observable<Macro[]>;
private animation: {[key: string]: 'active' | 'inactive'}; private animation: { [key: string]: 'active' | 'inactive' };
constructor(private store: Store<AppState>, private renderer: Renderer) { constructor(private store: Store<AppState>, private renderer: Renderer) {
this.animation = { this.animation = {
@@ -40,18 +42,20 @@ export class SideMenuComponent {
}; };
this.keymaps$ = store.let(getKeymapEntities()) this.keymaps$ = store.let(getKeymapEntities())
.map((keymaps: Keymap[]) => { .map(keymaps => keymaps.slice()) // Creating a new array reference, because the sort is working in place
return keymaps.sort((first: Keymap, second: Keymap) => first.name.localeCompare(second.name)); .do((keymaps: Keymap[]) => {
keymaps.sort((first: Keymap, second: Keymap) => first.name.localeCompare(second.name));
}); });
this.macros$ = store.let(getMacroEntities()) this.macros$ = store.let(getMacroEntities())
.map((macros: Macro[]) => { .map(macros => macros.slice()) // Creating a new array reference, because the sort is working in place
return macros.sort((first: Macro, second: Macro) => first.name.localeCompare(second.name)); .do((macros: Macro[]) => {
macros.sort((first: Macro, second: Macro) => first.name.localeCompare(second.name));
}); });
} }
toggleHide(event: Event, type: string) { toggleHide(event: Event, type: string) {
let header: DOMTokenList = (<Element> event.target).classList; let header: DOMTokenList = (<Element>event.target).classList;
let show = false; let show = false;
if (header.contains('fa-chevron-down')) { if (header.contains('fa-chevron-down')) {