forked from kscience/visionforge
add builders for html field
This commit is contained in:
parent
c877fcbce3
commit
fbb402de90
@ -25,6 +25,11 @@ public inline fun VisionOfPlainHtml.content(block: TagConsumer<*>.() -> Unit) {
|
||||
content = createHTML().apply(block).finalize()
|
||||
}
|
||||
|
||||
@Suppress("UnusedReceiverParameter")
|
||||
public inline fun VisionOutput.html(
|
||||
block: VisionOfPlainHtml.() -> Unit,
|
||||
): VisionOfPlainHtml = VisionOfPlainHtml().apply(block)
|
||||
|
||||
@Serializable
|
||||
public enum class InputFeedbackMode {
|
||||
/**
|
||||
@ -47,13 +52,18 @@ public enum class InputFeedbackMode{
|
||||
@SerialName("html.input")
|
||||
public open class VisionOfHtmlInput(
|
||||
public val inputType: String,
|
||||
public val feedbackMode: InputFeedbackMode = InputFeedbackMode.ONCHANGE
|
||||
public val feedbackMode: InputFeedbackMode = InputFeedbackMode.ONCHANGE,
|
||||
) : VisionOfHtml() {
|
||||
public var value: Value? by properties.value()
|
||||
public var disabled: Boolean by properties.boolean { false }
|
||||
public var fieldName: String? by properties.string()
|
||||
}
|
||||
|
||||
@Suppress("UnusedReceiverParameter")
|
||||
public inline fun VisionOutput.htmlInput(
|
||||
inputType: String,
|
||||
block: VisionOfHtmlInput.() -> Unit = {},
|
||||
): VisionOfHtmlInput = VisionOfHtmlInput(inputType).apply(block)
|
||||
|
||||
@Serializable
|
||||
@SerialName("html.text")
|
||||
@ -61,18 +71,34 @@ public class VisionOfTextField : VisionOfHtmlInput(InputType.text.realValue) {
|
||||
public var text: String? by properties.string(key = VisionOfHtmlInput::value.name.asName())
|
||||
}
|
||||
|
||||
@Suppress("UnusedReceiverParameter")
|
||||
public inline fun VisionOutput.htmlTextField(
|
||||
block: VisionOfTextField.() -> Unit = {},
|
||||
): VisionOfTextField = VisionOfTextField().apply(block)
|
||||
|
||||
|
||||
@Serializable
|
||||
@SerialName("html.checkbox")
|
||||
public class VisionOfCheckbox : VisionOfHtmlInput(InputType.checkBox.realValue) {
|
||||
public var checked: Boolean? by properties.boolean(key = VisionOfHtmlInput::value.name.asName())
|
||||
}
|
||||
|
||||
@Suppress("UnusedReceiverParameter")
|
||||
public inline fun VisionOutput.htmlCheckBox(
|
||||
block: VisionOfCheckbox.() -> Unit = {},
|
||||
): VisionOfCheckbox = VisionOfCheckbox().apply(block)
|
||||
|
||||
@Serializable
|
||||
@SerialName("html.number")
|
||||
public class VisionOfNumberField : VisionOfHtmlInput(InputType.number.realValue) {
|
||||
public var number: Number? by properties.number(key = VisionOfHtmlInput::value.name.asName())
|
||||
}
|
||||
|
||||
@Suppress("UnusedReceiverParameter")
|
||||
public inline fun VisionOutput.htmlNumberField(
|
||||
block: VisionOfNumberField.() -> Unit = {},
|
||||
): VisionOfNumberField = VisionOfNumberField().apply(block)
|
||||
|
||||
@Serializable
|
||||
@SerialName("html.range")
|
||||
public class VisionOfRangeField(
|
||||
@ -83,3 +109,11 @@ public class VisionOfRangeField(
|
||||
public var number: Number? by properties.number(key = VisionOfHtmlInput::value.name.asName())
|
||||
}
|
||||
|
||||
@Suppress("UnusedReceiverParameter")
|
||||
public inline fun VisionOutput.htmlRangeField(
|
||||
min: Double,
|
||||
max: Double,
|
||||
step: Double = 1.0,
|
||||
block: VisionOfRangeField.() -> Unit = {},
|
||||
): VisionOfRangeField = VisionOfRangeField(min, max, step).apply(block)
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package space.kscience.visionforge.meta
|
||||
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.take
|
||||
@ -24,7 +23,6 @@ private class TestScheme : Scheme() {
|
||||
companion object : SchemeSpec<TestScheme>(::TestScheme)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
internal class VisionPropertyTest {
|
||||
|
||||
private val manager = Global.request(VisionManager)
|
||||
|
@ -194,7 +194,7 @@ internal fun FormData.toMeta(): Meta {
|
||||
}
|
||||
|
||||
internal val formVisionRenderer: ElementVisionRenderer =
|
||||
ElementVisionRenderer<VisionOfHtmlForm> { visionName, vision, _ ->
|
||||
ElementVisionRenderer<VisionOfHtmlForm> { _, vision, _ ->
|
||||
|
||||
val form = document.getElementById(vision.formId) as? HTMLFormElement
|
||||
?: error("An element with id = '${vision.formId} is not a form")
|
||||
|
Loading…
Reference in New Issue
Block a user