kvision / pl.treksoft.kvision.form.upload / Upload

Upload

open class Upload : SimplePanel, KFilesFormControl

The form field file upload component.

Constructors

<init>

Upload(uploadUrl: String? = null, multiple: Boolean = false, label: String? = null, rich: Boolean = false)

Properties

allowedFileExtensions

var allowedFileExtensions: Set<String>?

Allowed file extensions.

allowedFileTypes

var allowedFileTypes: Set<String>?

Allowed file types.

browseOnZoneClick

var browseOnZoneClick: Boolean

Determines if the click on the preview zone opens file browse window.

dropZoneEnabled

var dropZoneEnabled: Boolean

Determines if Drag&Drop zone is enabled.

explorerTheme

var explorerTheme: Boolean

Determines if the explorer theme is used.

flabel

val flabel: FieldLabel

Form field label.

idc

val idc: String

input

val input: UploadInput

The actual input component.

label

var label: String?

The label text bound to the spinner input element.

multiple

var multiple: Boolean

Determines if multiple file upload is supported.

preferIconicPreview

var preferIconicPreview: Boolean

Determines if the iconic preview is prefered.

required

var required: Boolean

Determines if the input selection is required.

rich

var rich: Boolean

Determines if label can contain HTML code.

showBrowse

var showBrowse: Boolean

Determines if the file browse button is shown.

showCancel

var showCancel: Boolean

Determines if the cancel button is shown.

showCaption

var showCaption: Boolean

Determines if the caption is shown.

showPreview

var showPreview: Boolean

Determines if the preview is shown.

showRemove

var showRemove: Boolean

Determines if the remove button is shown.

showUpload

var showUpload: Boolean

Determines if the upload button is shown.

uploadExtraData

var uploadExtraData: ((String, Int) -> dynamic)?

The extra data that will be passed as data to the AJAX server call via POST.

uploadUrl

var uploadUrl: String?

The optional URL for the upload processing action. If not set the upload button action will default to form submission.

validationInfo

val validationInfo: HelpBlock

Validation info component.

value

open var value: List<KFile>?

File input value.

Functions

blur

open fun blur(): Unit

Makes the input element blur.

cancel

open fun cancel(): Unit

Cancel an ongoing ajax upload (only for ajax mode).

clearInput

open fun clearInput(): Unit

Clears the file input control (including the native input).

focus

open fun focus(): Unit

Makes the input element focused.

getNativeFile

open fun getNativeFile(kFile: KFile): File?

Returns the native JavaScript File object.

getSnClass

open fun getSnClass(): List<StringBoolPair>

Returns list of CSS class names for current widget in the form of a List.

getValueAsString

open fun getValueAsString(): String?

Returns the value of the control as a String.

lock

open fun lock(): Unit

Locks the file input (disabling all buttons except a cancel button).

removeEventListeners

open fun removeEventListeners(): Widget

Removes all event listeners from current widget.

resetInput

open fun resetInput(): Unit

Resets the file input control.

setEventListener

open fun <T : Widget> setEventListener(block: SnOn<T>.() -> Unit): Widget

Sets an event listener for current widget, keeping the actual type of component.

open fun setEventListener(block: SnOn<Widget>.() -> Unit): Widget

Sets an event listener for current widget.

unlock

open fun unlock(): Unit

Unlocks the file input.

upload

open fun upload(): Unit

Trigger ajax upload (only for ajax mode).

Inherited Functions

add

open fun add(child: Component): SimplePanel

Adds given component to the current container.

addAll

open fun addAll(children: List<Component>): SimplePanel

Adds a list of components to the current container.

addInternal

fun addInternal(child: Component): SimplePanel

Protected and final method to add given component to the current container.

childrenVNodes

open fun childrenVNodes(): Array<VNode>

Returns the array of the children Snabbdom vnodes.

getChildren

open fun getChildren(): List<Component>

Returns a list of children of the current container.

getValue

open fun getValue(): List<KFile>?

Returns the value of the control.

remove

open fun remove(child: Component): SimplePanel

Removes given component from the current container.

removeAll

open fun removeAll(): SimplePanel

Removes all children from the current container.

render

open fun render(): VNode

Renders current component as a Snabbdom vnode.

setValue

open fun setValue(v: Any?): Unit

Sets the value of the control.

Companion Object Functions

upload

fun Container.upload(uploadUrl: String? = null, multiple: Boolean = false, label: String? = null, rich: Boolean = false, init: (Upload.() -> Unit)? = null): Upload

DSL builder extension function.

Extension Functions

createInstance

fun <T> Any?.createInstance(vararg args: dynamic): T

Helper function for creating JavaScript objects from dynamic constructors.