Remove placeholder in macro-tab

This commit is contained in:
Farkas József
2016-11-20 21:58:07 +01:00
committed by József Farkas
parent 064d2eb29a
commit 8f930092df
3 changed files with 23 additions and 25 deletions
@@ -1,13 +1,16 @@
<div class="macro-selector"> <template [ngIf]="macroOptions.length === 0">
<b> Play macro: </b> <span> No macros are available to choose from. Create a macro first! </span>
<select2 [data]="macroOptions" [value]="macroOptions[selectedMacroIndex + 1].id" (valueChanged)="onChange($event)" [width]="'100%'"></select2> </template>
</div> <template [ngIf]="macroOptions.length > 0">
<div class="macro-action-container" [class.inactive]="selectedMacroIndex === -1"> <div class="macro-selector">
<template [ngIf]="selectedMacroIndex >= 0"> <b> Play macro: </b>
<div class="list-group"> <select2 [data]="macroOptions" [value]="macroOptions[selectedMacroIndex].id" (valueChanged)="onChange($event)" [width]="'100%'"></select2>
<macro-item *ngFor="let macroAction of macros[selectedMacroIndex].macroActions" </div>
[macroAction]="macroAction" [editable]="false"> <div class="macro-action-container">
</macro-item> <div class="list-group">
</div> <macro-item *ngFor="let macroAction of macros[selectedMacroIndex].macroActions"
</template> [macroAction]="macroAction" [editable]="false">
</div> </macro-item>
</div>
</div>
</template>
@@ -2,6 +2,10 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
> span {
text-align: center;
}
.macro-selector { .macro-selector {
display: flex; display: flex;
margin-top: 2px; margin-top: 2px;
@@ -28,10 +32,6 @@
border-radius: 4px; border-radius: 4px;
border: 1px solid #ddd; border: 1px solid #ddd;
&.inactive {
border: 0;
}
.list-group { .list-group {
margin-bottom: 0; margin-bottom: 0;
border: 0; border: 0;
@@ -31,21 +31,16 @@ export class MacroTabComponent implements OnInit, OnDestroy, Tab {
this.subscription = store.let(getMacroEntities()) this.subscription = store.let(getMacroEntities())
.subscribe((macros: Macro[]) => this.macros = macros); .subscribe((macros: Macro[]) => this.macros = macros);
this.macroOptions = []; this.macroOptions = [];
this.selectedMacroIndex = -1; this.selectedMacroIndex = 0;
} }
ngOnInit() { ngOnInit() {
this.macroOptions.push({ this.macroOptions = this.macros.map(function (macro: Macro): Select2OptionData {
id: '-1',
text: 'Select macro'
});
this.macroOptions = this.macroOptions.concat(this.macros.map(function (macro: Macro): Select2OptionData {
return { return {
id: macro.id.toString(), id: macro.id.toString(),
text: macro.name text: macro.name
}; };
})); });
this.fromKeyAction(this.defaultKeyAction); this.fromKeyAction(this.defaultKeyAction);
} }