Skip to content
Snippets Groups Projects
Commit c8204f83 authored by David Dorchies's avatar David Dorchies
Browse files

Closes #83

parent e804e8dd
No related branches found
No related tags found
No related merge requests found
<div class="btn-group" dropdown (click)="onSelect($event)">
<div class="btn-group" dropdown (selected)="onSelect($event)">
<button dropdownToggle class="btn btn-primary dropdown-toggle waves-light my-1" type="button" mdbRippleRadius>
{{currentLabel}}
</button>
......
......@@ -15,12 +15,14 @@ import { BaseComponent } from "../base/base.component";
*/
export abstract class GenericSelectComponent<T> {
private get currentLabel(): string {
for (let e of this.entries)
if (e == this.selectedValue)
return this.entryLabel(e);
return "<no selection>";
private _currentLabel: string;
private get currentLabel(): string {
if (this._currentLabel === undefined) {
this._currentLabel = this.selectedLabel;
}
return this._currentLabel;
}
/**
......@@ -28,8 +30,18 @@ export abstract class GenericSelectComponent<T> {
*/
private onSelect(event: any) {
const val = event.target.value;
if (val != undefined)
if (val !== undefined && val !== "") {
this.selectedValue = val;
this._currentLabel = this.selectedLabel;
}
}
private get selectedLabel(): string {
for (const e of this.entries) {
if (e === this.selectedValue) {
return this.entryLabel(e);
}
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment