diff options
Diffstat (limited to 'kvision-modules/kvision-bootstrap-upload/src')
2 files changed, 67 insertions, 70 deletions
diff --git a/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt b/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt index bd931127..67c660ea 100644 --- a/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt +++ b/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt @@ -308,26 +308,26 @@ open class Upload( companion object { internal var counter = 0 + } +} - /** - * DSL builder extension function. - * - * It takes the same parameters as the constructor of the built component. - */ - fun Container.upload( - uploadUrl: String? = null, - multiple: Boolean = false, - label: String? = null, - rich: Boolean = false, - init: (Upload.() -> Unit)? = null - ): Upload { - val upload = Upload(uploadUrl, multiple, label, rich).apply { - init?.invoke( - this - ) - } - this.add(upload) - return upload - } +/** + * DSL builder extension function. + * + * It takes the same parameters as the constructor of the built component. + */ +fun Container.upload( + uploadUrl: String? = null, + multiple: Boolean = false, + label: String? = null, + rich: Boolean = false, + init: (Upload.() -> Unit)? = null +): Upload { + val upload = Upload(uploadUrl, multiple, label, rich).apply { + init?.invoke( + this + ) } + this.add(upload) + return upload } diff --git a/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt b/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt index faae5274..da05b04c 100644 --- a/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt +++ b/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt @@ -320,58 +320,55 @@ open class UploadInput(uploadUrl: String? = null, multiple: Boolean = false, cla this.language = language } } +} - companion object { - - /** - * DSL builder extension function. - * - * It takes the same parameters as the constructor of the built component. - */ - fun Container.uploadInput( - uploadUrl: String? = null, - multiple: Boolean = false, - classes: Set<String> = setOf(), - init: (UploadInput.() -> Unit)? = null - ): UploadInput { - val uploadInput = UploadInput(uploadUrl, multiple, classes).apply { - init?.invoke( - this - ) - } - this.add(uploadInput) - return uploadInput - } +/** + * DSL builder extension function. + * + * It takes the same parameters as the constructor of the built component. + */ +fun Container.uploadInput( + uploadUrl: String? = null, + multiple: Boolean = false, + classes: Set<String> = setOf(), + init: (UploadInput.() -> Unit)? = null +): UploadInput { + val uploadInput = UploadInput(uploadUrl, multiple, classes).apply { + init?.invoke( + this + ) + } + this.add(uploadInput) + return uploadInput +} - /** - * Returns file with the content read. - * @param key key identifier of the control - * @param kFile object identifying the file - * @return KFile object - */ - suspend fun <K : Any> Form<K>.getContent( - key: KProperty1<K, List<KFile>?>, - kFile: KFile - ): KFile { - val control = getControl(key) as Upload - val content = control.getNativeFile(kFile)?.getContent() - return kFile.copy(content = content) - } +/** + * Returns file with the content read. + * @param key key identifier of the control + * @param kFile object identifying the file + * @return KFile object + */ +suspend fun <K : Any> Form<K>.getContent( + key: KProperty1<K, List<KFile>?>, + kFile: KFile +): KFile { + val control = getControl(key) as Upload + val content = control.getNativeFile(kFile)?.getContent() + return kFile.copy(content = content) +} - /** - * Returns file with the content read. - * @param key key identifier of the control - * @param kFile object identifying the file - * @return KFile object - */ - suspend fun <K : Any> FormPanel<K>.getContent( - key: KProperty1<K, List<KFile>?>, - kFile: KFile - ): KFile { - val control = getControl(key) as Upload - val content = control.getNativeFile(kFile)?.getContent() - return kFile.copy(content = content) - } - } +/** + * Returns file with the content read. + * @param key key identifier of the control + * @param kFile object identifying the file + * @return KFile object + */ +suspend fun <K : Any> FormPanel<K>.getContent( + key: KProperty1<K, List<KFile>?>, + kFile: KFile +): KFile { + val control = getControl(key) as Upload + val content = control.getNativeFile(kFile)?.getContent() + return kFile.copy(content = content) } |