Redirect to specific URL of first macro
This commit is contained in:
@@ -11,7 +11,7 @@ import { DragulaModule } from 'ng2-dragula/ng2-dragula';
|
|||||||
import { Select2Module } from 'ng2-select2/ng2-select2';
|
import { Select2Module } from 'ng2-select2/ng2-select2';
|
||||||
|
|
||||||
import { AddOnComponent } from './components/add-on';
|
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 { LayersComponent } from './components/layers';
|
||||||
import {
|
import {
|
||||||
MacroActionEditorComponent,
|
MacroActionEditorComponent,
|
||||||
@@ -79,7 +79,7 @@ const storeConfig = {
|
|||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
MainAppComponent,
|
MainAppComponent,
|
||||||
KeymapComponent,
|
KeymapEditComponent,
|
||||||
KeymapHeaderComponent,
|
KeymapHeaderComponent,
|
||||||
NotificationComponent,
|
NotificationComponent,
|
||||||
SvgIconTextKeyComponent,
|
SvgIconTextKeyComponent,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template [ngIf]="keymap$ | async">
|
<template [ngIf]="keymap$ | async">
|
||||||
<keymap-header [keymap]="keymap$ | async" (deleted)="onKeymapDelete($event)"></keymap-header>
|
<keymap-header [keymap]="keymap$ | async"></keymap-header>
|
||||||
<svg-keyboard-wrap [keymap]="keymap$ | async" [deleted]="keymapDeleted"></svg-keyboard-wrap>
|
<svg-keyboard-wrap [keymap]="keymap$ | async"></svg-keyboard-wrap>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div *ngIf="!(keymap$ | async)" class="not-found">
|
<div *ngIf="!(keymap$ | async)" class="not-found">
|
||||||
|
|||||||
@@ -15,13 +15,12 @@ import { AppState } from '../../../store';
|
|||||||
import { getKeymap } from '../../../store/reducers/keymap';
|
import { getKeymap } from '../../../store/reducers/keymap';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'keymap',
|
selector: 'keymap-edit',
|
||||||
template: require('./keymap-edit.component.html'),
|
template: require('./keymap-edit.component.html'),
|
||||||
styles: [require('./keymap-edit.component.scss')]
|
styles: [require('./keymap-edit.component.scss')]
|
||||||
})
|
})
|
||||||
export class KeymapComponent {
|
export class KeymapEditComponent {
|
||||||
private keymap$: Observable<Keymap>;
|
private keymap$: Observable<Keymap>;
|
||||||
private keymapDeleted: boolean = false;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private store: Store<AppState>,
|
private store: Store<AppState>,
|
||||||
@@ -36,8 +35,4 @@ export class KeymapComponent {
|
|||||||
this.keymap$ = keymapConnectable;
|
this.keymap$ = keymapConnectable;
|
||||||
keymapConnectable.connect();
|
keymapConnectable.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
onKeymapDelete() {
|
|
||||||
this.keymapDeleted = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
|
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
@@ -14,7 +14,6 @@ import { KeymapActions } from '../../../store/actions';
|
|||||||
})
|
})
|
||||||
export class KeymapHeaderComponent {
|
export class KeymapHeaderComponent {
|
||||||
@Input() keymap: Keymap;
|
@Input() keymap: Keymap;
|
||||||
@Output() deleted: EventEmitter<boolean> = new EventEmitter();
|
|
||||||
|
|
||||||
constructor(private store: Store<AppState>) { }
|
constructor(private store: Store<AppState>) { }
|
||||||
|
|
||||||
@@ -25,7 +24,6 @@ export class KeymapHeaderComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeKeymap() {
|
removeKeymap() {
|
||||||
this.deleted.emit(false);
|
|
||||||
this.store.dispatch(KeymapActions.removeKeymap(this.keymap.abbreviation));
|
this.store.dispatch(KeymapActions.removeKeymap(this.keymap.abbreviation));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Routes } from '@angular/router';
|
import { Routes } from '@angular/router';
|
||||||
|
|
||||||
import { KeymapAddComponent } from './add/keymap-add.component';
|
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 = [
|
export const keymapRoutes: Routes = [
|
||||||
{
|
{
|
||||||
@@ -11,7 +11,7 @@ export const keymapRoutes: Routes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'keymap',
|
path: 'keymap',
|
||||||
component: KeymapComponent
|
component: KeymapEditComponent
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'keymap/add',
|
path: 'keymap/add',
|
||||||
@@ -19,6 +19,6 @@ export const keymapRoutes: Routes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'keymap/:abbr',
|
path: 'keymap/:abbr',
|
||||||
component: KeymapComponent
|
component: KeymapEditComponent
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ export class SvgKeyboardWrapComponent implements OnChanges {
|
|||||||
@Input() keymap: Keymap;
|
@Input() keymap: Keymap;
|
||||||
@Input() popoverEnabled: boolean = true;
|
@Input() popoverEnabled: boolean = true;
|
||||||
@Input() tooltipEnabled: boolean = false;
|
@Input() tooltipEnabled: boolean = false;
|
||||||
@Input() deleted: boolean = false;
|
|
||||||
|
|
||||||
private popoverShown: boolean;
|
private popoverShown: boolean;
|
||||||
private keyEditConfig: { keyActions: KeyAction[], keyId: number };
|
private keyEditConfig: { keyActions: KeyAction[], keyId: number };
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export class KeymapEffects {
|
|||||||
if (state.keymaps.entities.length === 0) {
|
if (state.keymaps.entities.length === 0) {
|
||||||
this.router.navigate(['/keymap/add']);
|
this.router.navigate(['/keymap/add']);
|
||||||
} else {
|
} 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]);
|
this.router.navigate(['/keymap', favourite.abbreviation]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ export class MacroEffects {
|
|||||||
.ofType(MacroActions.REMOVE)
|
.ofType(MacroActions.REMOVE)
|
||||||
.withLatestFrom(this.store)
|
.withLatestFrom(this.store)
|
||||||
.do((latest) => {
|
.do((latest) => {
|
||||||
let state: AppState = latest[1];
|
const state: AppState = latest[1];
|
||||||
|
|
||||||
if (state.macros.entities.length === 0) {
|
if (state.macros.entities.length === 0) {
|
||||||
this.router.navigate(['/macro/add']);
|
this.router.navigate(['/macro/add']);
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate(['/macro']);
|
this.router.navigate(['/macro', '0']);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -32,8 +32,8 @@ export class MacroEffects {
|
|||||||
.ofType(MacroActions.ADD)
|
.ofType(MacroActions.ADD)
|
||||||
.withLatestFrom(this.store)
|
.withLatestFrom(this.store)
|
||||||
.do((latest) => {
|
.do((latest) => {
|
||||||
let state: AppState = latest[1];
|
const state: AppState = latest[1];
|
||||||
let macro: Macro = state.macros.entities[state.macros.entities.length - 1];
|
const macro: Macro = state.macros.entities[state.macros.entities.length - 1];
|
||||||
|
|
||||||
this.router.navigate(['/macro', macro.id, 'new']);
|
this.router.navigate(['/macro', macro.id, 'new']);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user