Gray out trash at last keymap instead of not rendering
This commit is contained in:
committed by
József Farkas
parent
6bbcacfbe6
commit
55903e4869
@@ -21,12 +21,12 @@
|
|||||||
[title]="starTitle"
|
[title]="starTitle"
|
||||||
(click)="setDefault()"
|
(click)="setDefault()"
|
||||||
></i>
|
></i>
|
||||||
<i class="glyphicon glyphicon-trash keymap__remove pull-right" title=""
|
<i class="glyphicon glyphicon-trash keymap__remove pull-right" [title]="trashTitle"
|
||||||
*ngIf="deletable"
|
[class.disabled]="!deletable"
|
||||||
data-toggle="tooltip"
|
data-toggle="tooltip"
|
||||||
data-placement="left"
|
data-placement="left"
|
||||||
data-original-title="Remove keymap"
|
data-original-title="Remove keymap"
|
||||||
(click)="removeKeymap()"
|
(click)="removeKeymap()"
|
||||||
></i>
|
></i>
|
||||||
<i class="fa fa-files-o keymap__duplicate pull-right" title=""
|
<i class="fa fa-files-o keymap__duplicate pull-right" title=""
|
||||||
data-toggle="tooltip"
|
data-toggle="tooltip"
|
||||||
|
|||||||
@@ -16,10 +16,14 @@
|
|||||||
font-size: 0.75em;
|
font-size: 0.75em;
|
||||||
top: 8px;
|
top: 8px;
|
||||||
|
|
||||||
&:hover {
|
&:not(.disabled):hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: $icon-hover-delete;
|
color: $icon-hover-delete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.disabled {
|
||||||
|
opacity: 0.25;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__duplicate {
|
&__duplicate {
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
import { ChangeDetectionStrategy, Component, ElementRef, Input, OnChanges, Renderer, ViewChild } from '@angular/core';
|
import {
|
||||||
|
ChangeDetectionStrategy,
|
||||||
|
Component,
|
||||||
|
ElementRef,
|
||||||
|
Input,
|
||||||
|
OnChanges,
|
||||||
|
Renderer,
|
||||||
|
SimpleChanges,
|
||||||
|
ViewChild
|
||||||
|
} from '@angular/core';
|
||||||
|
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
@@ -21,11 +30,17 @@ export class KeymapHeaderComponent implements OnChanges {
|
|||||||
@ViewChild('abbr') keymapAbbr: ElementRef;
|
@ViewChild('abbr') keymapAbbr: ElementRef;
|
||||||
|
|
||||||
private starTitle: string;
|
private starTitle: string;
|
||||||
|
private trashTitle: string;
|
||||||
|
|
||||||
constructor(private store: Store<AppState>, private renderer: Renderer) { }
|
constructor(private store: Store<AppState>, private renderer: Renderer) { }
|
||||||
|
|
||||||
ngOnChanges() {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
this.setTitle();
|
if (changes['keymap']) {
|
||||||
|
this.setKeymapTitle();
|
||||||
|
}
|
||||||
|
if (changes['deletable']) {
|
||||||
|
this.setTrashTitle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setDefault() {
|
setDefault() {
|
||||||
@@ -35,7 +50,9 @@ export class KeymapHeaderComponent implements OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeKeymap() {
|
removeKeymap() {
|
||||||
this.store.dispatch(KeymapActions.removeKeymap(this.keymap.abbreviation));
|
if (this.deletable) {
|
||||||
|
this.store.dispatch(KeymapActions.removeKeymap(this.keymap.abbreviation));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
duplicateKeymap() {
|
duplicateKeymap() {
|
||||||
@@ -61,9 +78,13 @@ export class KeymapHeaderComponent implements OnChanges {
|
|||||||
this.store.dispatch(KeymapActions.editKeymapAbbr(this.keymap.abbreviation, newAbbr));
|
this.store.dispatch(KeymapActions.editKeymapAbbr(this.keymap.abbreviation, newAbbr));
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitle(): void {
|
setKeymapTitle(): void {
|
||||||
this.starTitle = this.keymap.isDefault
|
this.starTitle = this.keymap.isDefault
|
||||||
? 'This is the default keymap which gets activated when powering the keyboard.'
|
? 'This is the default keymap which gets activated when powering the keyboard.'
|
||||||
: 'Makes this keymap the default keymap which gets activated when powering the keyboard.';
|
: 'Makes this keymap the default keymap which gets activated when powering the keyboard.';
|
||||||
|
}
|
||||||
|
|
||||||
|
setTrashTitle(): void {
|
||||||
|
this.trashTitle = this.deletable ? '' : 'The last keymap cannot be deleted.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user