Fix sort warning
This commit is contained in:
parent
13e949a1cd
commit
b0cd6f3a09
2 changed files with 45 additions and 47 deletions
|
@ -4,9 +4,7 @@ import MapControlButton from "../MapControlButton";
|
||||||
import GeoLocationHandler from "../../Logic/Actors/GeoLocationHandler";
|
import GeoLocationHandler from "../../Logic/Actors/GeoLocationHandler";
|
||||||
import Svg from "../../Svg";
|
import Svg from "../../Svg";
|
||||||
import MapState from "../../Logic/State/MapState";
|
import MapState from "../../Logic/State/MapState";
|
||||||
import {VariableUiElement} from "../Base/VariableUIElement";
|
|
||||||
import LevelSelector from "../Input/LevelSelector";
|
import LevelSelector from "../Input/LevelSelector";
|
||||||
import {UIEventSource} from "../../Logic/UIEventSource";
|
|
||||||
import FeaturePipeline from "../../Logic/FeatureSource/FeaturePipeline";
|
import FeaturePipeline from "../../Logic/FeatureSource/FeaturePipeline";
|
||||||
import {Utils} from "../../Utils";
|
import {Utils} from "../../Utils";
|
||||||
|
|
||||||
|
@ -50,6 +48,7 @@ export default class RightControls extends Combine {
|
||||||
const allElements = state.featurePipeline.GetAllFeaturesAndMetaWithin(bbox);
|
const allElements = state.featurePipeline.GetAllFeaturesAndMetaWithin(bbox);
|
||||||
const allLevelsRaw: string[] = [].concat(...allElements.map(allElements => allElements.features.map(f => <string>f.properties["level"])))
|
const allLevelsRaw: string[] = [].concat(...allElements.map(allElements => allElements.features.map(f => <string>f.properties["level"])))
|
||||||
const allLevels = [].concat(...allLevelsRaw.map(l => LevelSelector.LevelsParser(l)))
|
const allLevels = [].concat(...allLevelsRaw.map(l => LevelSelector.LevelsParser(l)))
|
||||||
|
allLevels.sort((a,b) => a < b ? -1 : 1)
|
||||||
return Utils.Dedup(allLevels)
|
return Utils.Dedup(allLevels)
|
||||||
})
|
})
|
||||||
const levelSelect = new LevelSelector(levelsInView)
|
const levelSelect = new LevelSelector(levelsInView)
|
||||||
|
|
|
@ -1,24 +1,25 @@
|
||||||
import {InputElement} from "./InputElement";
|
import {InputElement} from "./InputElement";
|
||||||
import {Store, UIEventSource} from "../../Logic/UIEventSource";
|
import {Store, Stores, UIEventSource} from "../../Logic/UIEventSource";
|
||||||
import Combine from "../Base/Combine";
|
import Combine from "../Base/Combine";
|
||||||
import Slider from "./Slider";
|
import Slider from "./Slider";
|
||||||
import {ClickableToggle} from "./Toggle";
|
import {ClickableToggle} from "./Toggle";
|
||||||
import {FixedUiElement} from "../Base/FixedUiElement";
|
import {FixedUiElement} from "../Base/FixedUiElement";
|
||||||
import {Utils} from "../../Utils";
|
import {Utils} from "../../Utils";
|
||||||
|
import {VariableUiElement} from "../Base/VariableUIElement";
|
||||||
|
|
||||||
export default class LevelSelector extends Combine implements InputElement<string>{
|
export default class LevelSelector extends VariableUiElement implements InputElement<string> {
|
||||||
|
|
||||||
private readonly _value: UIEventSource<string>;
|
private readonly _value: UIEventSource<string>;
|
||||||
|
|
||||||
constructor(currentLevels: Store<string[]>, options?: {
|
constructor(currentLevels: Store<string[]>, options?: {
|
||||||
value?: UIEventSource<string>
|
value?: UIEventSource<string>
|
||||||
}) {
|
}) {
|
||||||
|
const value = options?.value ?? new UIEventSource<string>(undefined)
|
||||||
const testData = ["-1", "0", "0.5", "1", "1.5", "2"]
|
super(Stores.ListStabilized(currentLevels).map(levels => {
|
||||||
let slider = new Slider(0, testData.length - 1, {vertical: true});
|
let slider = new Slider(0, levels.length - 1, {vertical: true});
|
||||||
slider.SetClass("flex m-1 elevatorslider mb-0 mt-8").SetStyle("height: "+2.5*testData.length+"rem ")
|
slider.SetClass("flex m-1 elevatorslider mb-0 mt-8").SetStyle("height: " + 2.5 * levels.length + "rem ")
|
||||||
const toggleClass = "flex border-2 border-blue-500 w-10 h-10 place-content-center items-center"
|
const toggleClass = "flex border-2 border-blue-500 w-10 h-10 place-content-center items-center"
|
||||||
const values = testData.map((data, i) => new ClickableToggle(
|
const values = levels.map((data, i) => new ClickableToggle(
|
||||||
new FixedUiElement(data).SetClass("active bg-subtle " + toggleClass), new FixedUiElement(data).SetClass(toggleClass), slider.GetValue().sync(
|
new FixedUiElement(data).SetClass("active bg-subtle " + toggleClass), new FixedUiElement(data).SetClass(toggleClass), slider.GetValue().sync(
|
||||||
(sliderVal) => {
|
(sliderVal) => {
|
||||||
return sliderVal === i
|
return sliderVal === i
|
||||||
|
@ -31,10 +32,9 @@ export default class LevelSelector extends Combine implements InputElement<strin
|
||||||
.ToggleOnClick()
|
.ToggleOnClick()
|
||||||
.SetClass("flex flex-column ml-5 bg-slate-200 w-10 h-10 valuesContainer"))
|
.SetClass("flex flex-column ml-5 bg-slate-200 w-10 h-10 valuesContainer"))
|
||||||
|
|
||||||
super([new Combine(values.reverse()).SetClass("mt-8"), slider])
|
const combine = new Combine([new Combine(values).SetClass("mt-8"), slider])
|
||||||
this.SetClass("flex flex-row h-14");
|
combine.SetClass("flex flex-row h-14");
|
||||||
|
|
||||||
const value = this._value = options?.value ?? new UIEventSource<string>(undefined)
|
|
||||||
slider.GetValue().addCallbackAndRun(i => {
|
slider.GetValue().addCallbackAndRun(i => {
|
||||||
if (currentLevels?.data === undefined) {
|
if (currentLevels?.data === undefined) {
|
||||||
return
|
return
|
||||||
|
@ -45,16 +45,15 @@ export default class LevelSelector extends Combine implements InputElement<strin
|
||||||
const i = currentLevels?.data?.findIndex(l => l === level)
|
const i = currentLevels?.data?.findIndex(l => l === level)
|
||||||
slider.GetValue().setData(i)
|
slider.GetValue().setData(i)
|
||||||
})
|
})
|
||||||
|
return combine
|
||||||
|
}))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GetValue(): UIEventSource<string> {
|
GetValue(): UIEventSource<string> {
|
||||||
return this._value;
|
return this._value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected InnerConstructElement(): HTMLElement {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
IsValid(t: string): boolean {
|
IsValid(t: string): boolean {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue