aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft
diff options
context:
space:
mode:
Diffstat (limited to 'kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft')
-rw-r--r--kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt2
-rw-r--r--kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt40
2 files changed, 24 insertions, 18 deletions
diff --git a/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt b/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt
index 314c9904..971ce186 100644
--- a/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt
+++ b/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt
@@ -252,7 +252,7 @@ open class Upload(
* @param kFile KFile object
* @return File object
*/
- fun getNativeFile(kFile: KFile): File? {
+ override fun getNativeFile(kFile: KFile): File? {
return input.getNativeFile(kFile)
}
diff --git a/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt b/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt
index 2af7b3f7..ee17949e 100644
--- a/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt
+++ b/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt
@@ -173,23 +173,25 @@ open class UploadInput(uploadUrl: String? = null, multiple: Boolean = false, cla
@Suppress("UnsafeCastFromDynamic")
override fun afterInsert(node: VNode) {
getElementJQueryD()?.fileinput(getSettingsObj())
- this.getElementJQuery()?.on("fileselect") { e, _ ->
- this.dispatchEvent("fileSelectUpload", obj { detail = e })
- }
- this.getElementJQuery()?.on("fileclear") { e, _ ->
- this.dispatchEvent("fileClearUpload", obj { detail = e })
- }
- this.getElementJQuery()?.on("filereset") { e, _ ->
- this.dispatchEvent("fileResetUpload", obj { detail = e })
- }
- this.getElementJQuery()?.on("filebrowse") { e, _ ->
- this.dispatchEvent("fileBrowseUpload", obj { detail = e })
- }
- this.getElementJQueryD()?.on("filepreupload") lambda@{ _, data, previewId, index ->
- data["previewId"] = previewId
- data["index"] = index
- this.dispatchEvent("filePreUpload", obj { detail = data })
- return@lambda null
+ if (uploadUrl != null) {
+ this.getElementJQuery()?.on("fileselect") { e, _ ->
+ this.dispatchEvent("fileSelectUpload", obj { detail = e })
+ }
+ this.getElementJQuery()?.on("fileclear") { e, _ ->
+ this.dispatchEvent("fileClearUpload", obj { detail = e })
+ }
+ this.getElementJQuery()?.on("filereset") { e, _ ->
+ this.dispatchEvent("fileResetUpload", obj { detail = e })
+ }
+ this.getElementJQuery()?.on("filebrowse") { e, _ ->
+ this.dispatchEvent("fileBrowseUpload", obj { detail = e })
+ }
+ this.getElementJQueryD()?.on("filepreupload") lambda@{ _, data, previewId, index ->
+ data["previewId"] = previewId
+ data["index"] = index
+ this.dispatchEvent("filePreUpload", obj { detail = data })
+ return@lambda null
+ }
}
}
@@ -301,6 +303,10 @@ open class UploadInput(uploadUrl: String? = null, multiple: Boolean = false, cla
this.allowedFileTypes = allowedFileTypes?.toTypedArray()
this.allowedFileExtensions = allowedFileExtensions?.toTypedArray()
this.dropZoneEnabled = dropZoneEnabled
+ this.fileActionSettings = obj {
+ this.showUpload = showUpload
+ this.showRemove = showRemove
+ }
this.language = language
}
}