Redirect to specific URL of first macro

This commit is contained in:
NejcZdovc
2016-11-17 09:09:35 +01:00
committed by József Farkas
parent 646cb64a8a
commit 02db20e6c3
8 changed files with 15 additions and 23 deletions

View File

@@ -11,7 +11,7 @@ import { DragulaModule } from 'ng2-dragula/ng2-dragula';
import { Select2Module } from 'ng2-select2/ng2-select2';
import { AddOnComponent } from './components/add-on';
import { KeymapAddComponent, KeymapComponent, KeymapHeaderComponent } from './components/keymap';
import { KeymapAddComponent, KeymapEditComponent, KeymapHeaderComponent } from './components/keymap';
import { LayersComponent } from './components/layers';
import {
MacroActionEditorComponent,
@@ -79,7 +79,7 @@ const storeConfig = {
@NgModule({
declarations: [
MainAppComponent,
KeymapComponent,
KeymapEditComponent,
KeymapHeaderComponent,
NotificationComponent,
SvgIconTextKeyComponent,

View File

@@ -1,6 +1,6 @@
<template [ngIf]="keymap$ | async">
<keymap-header [keymap]="keymap$ | async" (deleted)="onKeymapDelete($event)"></keymap-header>
<svg-keyboard-wrap [keymap]="keymap$ | async" [deleted]="keymapDeleted"></svg-keyboard-wrap>
<keymap-header [keymap]="keymap$ | async"></keymap-header>
<svg-keyboard-wrap [keymap]="keymap$ | async"></svg-keyboard-wrap>
</template>
<div *ngIf="!(keymap$ | async)" class="not-found">

View File

@@ -15,13 +15,12 @@ import { AppState } from '../../../store';
import { getKeymap } from '../../../store/reducers/keymap';
@Component({
selector: 'keymap',
selector: 'keymap-edit',
template: require('./keymap-edit.component.html'),
styles: [require('./keymap-edit.component.scss')]
})
export class KeymapComponent {
export class KeymapEditComponent {
private keymap$: Observable<Keymap>;
private keymapDeleted: boolean = false;
constructor(
private store: Store<AppState>,
@@ -36,8 +35,4 @@ export class KeymapComponent {
this.keymap$ = keymapConnectable;
keymapConnectable.connect();
}
onKeymapDelete() {
this.keymapDeleted = true;
}
}

View File

@@ -1,4 +1,4 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Component, Input } from '@angular/core';
import { Store } from '@ngrx/store';
@@ -14,7 +14,6 @@ import { KeymapActions } from '../../../store/actions';
})
export class KeymapHeaderComponent {
@Input() keymap: Keymap;
@Output() deleted: EventEmitter<boolean> = new EventEmitter();
constructor(private store: Store<AppState>) { }
@@ -25,7 +24,6 @@ export class KeymapHeaderComponent {
}
removeKeymap() {
this.deleted.emit(false);
this.store.dispatch(KeymapActions.removeKeymap(this.keymap.abbreviation));
}

View File

@@ -1,7 +1,7 @@
import { Routes } from '@angular/router';
import { KeymapAddComponent } from './add/keymap-add.component';
import { KeymapComponent } from './edit/keymap-edit.component';
import { KeymapEditComponent } from './edit/keymap-edit.component';
export const keymapRoutes: Routes = [
{
@@ -11,7 +11,7 @@ export const keymapRoutes: Routes = [
},
{
path: 'keymap',
component: KeymapComponent
component: KeymapEditComponent
},
{
path: 'keymap/add',
@@ -19,6 +19,6 @@ export const keymapRoutes: Routes = [
},
{
path: 'keymap/:abbr',
component: KeymapComponent
component: KeymapEditComponent
}
];

View File

@@ -91,7 +91,6 @@ export class SvgKeyboardWrapComponent implements OnChanges {
@Input() keymap: Keymap;
@Input() popoverEnabled: boolean = true;
@Input() tooltipEnabled: boolean = false;
@Input() deleted: boolean = false;
private popoverShown: boolean;
private keyEditConfig: { keyActions: KeyAction[], keyId: number };

View File

@@ -33,7 +33,7 @@ export class KeymapEffects {
if (state.keymaps.entities.length === 0) {
this.router.navigate(['/keymap/add']);
} else {
let favourite: Keymap = state.keymaps.entities.find(keymap => keymap.isDefault);
const favourite: Keymap = state.keymaps.entities.find(keymap => keymap.isDefault);
this.router.navigate(['/keymap', favourite.abbreviation]);
}
});

View File

@@ -19,12 +19,12 @@ export class MacroEffects {
.ofType(MacroActions.REMOVE)
.withLatestFrom(this.store)
.do((latest) => {
let state: AppState = latest[1];
const state: AppState = latest[1];
if (state.macros.entities.length === 0) {
this.router.navigate(['/macro/add']);
} else {
this.router.navigate(['/macro']);
this.router.navigate(['/macro', '0']);
}
});
@@ -32,8 +32,8 @@ export class MacroEffects {
.ofType(MacroActions.ADD)
.withLatestFrom(this.store)
.do((latest) => {
let state: AppState = latest[1];
let macro: Macro = state.macros.entities[state.macros.entities.length - 1];
const state: AppState = latest[1];
const macro: Macro = state.macros.entities[state.macros.entities.length - 1];
this.router.navigate(['/macro', macro.id, 'new']);
});