forked from MapComplete/MapComplete
Add separate 'save' button to slope input
This commit is contained in:
parent
32606856f9
commit
de5d10ffa7
1 changed files with 19 additions and 2 deletions
|
@ -8,7 +8,14 @@
|
||||||
import If from "../../Base/If.svelte"
|
import If from "../../Base/If.svelte"
|
||||||
import type { SpecialVisualizationState } from "../../SpecialVisualization"
|
import type { SpecialVisualizationState } from "../../SpecialVisualization"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value exported to outside, saved only when the button is pressed
|
||||||
|
*/
|
||||||
export let value: UIEventSource<string> = new UIEventSource<string>(undefined)
|
export let value: UIEventSource<string> = new UIEventSource<string>(undefined)
|
||||||
|
/**
|
||||||
|
* The continuously updated value
|
||||||
|
*/
|
||||||
|
let _value: UIEventSource<string> = new UIEventSource<string>(undefined)
|
||||||
export let mode: "degrees" | "percentage" = "percentage"
|
export let mode: "degrees" | "percentage" = "percentage"
|
||||||
|
|
||||||
export let feature: Feature = undefined
|
export let feature: Feature = undefined
|
||||||
|
@ -62,9 +69,9 @@
|
||||||
let valueSign = valuesign.data
|
let valueSign = valuesign.data
|
||||||
|
|
||||||
if (mode === "degrees") {
|
if (mode === "degrees") {
|
||||||
value.setData(valueSign * beta + "°")
|
_value.setData(valueSign * beta + "°")
|
||||||
} else {
|
} else {
|
||||||
value.setData(degreesToPercentage(valueSign * beta))
|
_value.setData(degreesToPercentage(valueSign * beta))
|
||||||
}
|
}
|
||||||
|
|
||||||
previewDegrees.setData(beta + "°")
|
previewDegrees.setData(beta + "°")
|
||||||
|
@ -72,6 +79,12 @@
|
||||||
},
|
},
|
||||||
[valuesign, beta]
|
[valuesign, beta]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
function onSave(){
|
||||||
|
if(_value.data){
|
||||||
|
value.setData(_value.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $gotMeasurement}
|
{#if $gotMeasurement}
|
||||||
|
@ -87,6 +100,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<button class="primary" on:click={() => onSave()}>
|
||||||
|
Select this incline
|
||||||
|
</button>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Tr t={Translations.t.validation.slope.inputExplanation} />
|
<Tr t={Translations.t.validation.slope.inputExplanation} />
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue