diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-01-19 00:18:58 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-01-19 00:18:58 +0100 |
commit | 76754fd65d195f418a8643a8e0213fc8b0b6ab31 (patch) | |
tree | b537707f6044a6598a9ef5bdfd514d72ad8d95d6 /kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft | |
parent | 69df5eb9d89f40d56ff7db0f7f30ead51ad0c2a1 (diff) | |
download | kvision-76754fd65d195f418a8643a8e0213fc8b0b6ab31.tar.gz kvision-76754fd65d195f418a8643a8e0213fc8b0b6ab31.tar.bz2 kvision-76754fd65d195f418a8643a8e0213fc8b0b6ab31.zip |
Upload component upgrade and enhancements.
Diffstat (limited to 'kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft')
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 } } |