From 0d3e7c87bf74948f83ce006a1d340b0f3f5e68b0 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Mon, 8 Oct 2018 13:40:04 +0200 Subject: Refactoring to modules --- kvision-modules/kvision-base/build.gradle | 7 + kvision-modules/kvision-bootstrap/build.gradle | 13 + .../kvision-bootstrap/package.json.d/project.info | 3 + .../pl/treksoft/kvision/KVManagerBootstrap.kt | 53 +++ .../src/main/resources/css/paper.css | 12 + .../src/main/resources/js/bootstrap.config.js | 64 ++++ .../src/main/resources/js/bootstrap.config.less | 0 kvision-modules/kvision-common/build.gradle | 10 + .../kotlin/pl/treksoft/kvision/remote/Jooby.kt | 37 +++ .../kotlin/pl/treksoft/kvision/remote/JsonRpc.kt | 37 +++ .../pl/treksoft/kvision/remote/ServiceManager.kt | 139 ++++++++ .../main/kotlin/pl/treksoft/kvision/types/KDate.kt | 49 +++ .../main/kotlin/pl/treksoft/kvision/types/KFile.kt | 34 ++ kvision-modules/kvision-datetime/build.gradle | 9 + .../kvision-datetime/package.json.d/project.info | 3 + .../pl/treksoft/kvision/KVManagerDatetime.kt | 81 +++++ .../pl/treksoft/kvision/form/time/DateTime.kt | 246 ++++++++++++++ .../pl/treksoft/kvision/form/time/DateTimeInput.kt | 291 ++++++++++++++++ .../bootstrap-datetimepicker.ar.js | 18 + .../bootstrap-datetimepicker.az.js | 17 + .../bootstrap-datetimepicker.bg.js | 17 + .../bootstrap-datetimepicker.bn.js | 17 + .../bootstrap-datetimepicker.ca.js | 17 + .../bootstrap-datetimepicker.cs.js | 20 ++ .../bootstrap-datetimepicker.da.js | 17 + .../bootstrap-datetimepicker.de.js | 19 ++ .../bootstrap-datetimepicker.ee.js | 19 ++ .../bootstrap-datetimepicker.el.js | 16 + .../bootstrap-datetimepicker.es.js | 17 + .../bootstrap-datetimepicker.fi.js | 17 + .../bootstrap-datetimepicker.fr.js | 19 ++ .../bootstrap-datetimepicker.he.js | 18 + .../bootstrap-datetimepicker.hr.js | 16 + .../bootstrap-datetimepicker.hu.js | 18 + .../bootstrap-datetimepicker.hy.js | 17 + .../bootstrap-datetimepicker.id.js | 20 ++ .../bootstrap-datetimepicker.is.js | 17 + .../bootstrap-datetimepicker.it.js | 19 ++ .../bootstrap-datetimepicker.ja.js | 17 + .../bootstrap-datetimepicker.ka.js | 17 + .../bootstrap-datetimepicker.ko.js | 18 + .../bootstrap-datetimepicker.lt.js | 19 ++ .../bootstrap-datetimepicker.lv.js | 19 ++ .../bootstrap-datetimepicker.ms.js | 17 + .../bootstrap-datetimepicker.nb.js | 17 + .../bootstrap-datetimepicker.nl.js | 17 + .../bootstrap-datetimepicker.no.js | 17 + .../bootstrap-datetimepicker.pl.js | 18 + .../bootstrap-datetimepicker.pt-BR.js | 18 + .../bootstrap-datetimepicker.pt.js | 18 + .../bootstrap-datetimepicker.ro.js | 18 + .../bootstrap-datetimepicker.rs-latin.js | 17 + .../bootstrap-datetimepicker.rs.js | 17 + .../bootstrap-datetimepicker.ru.js | 17 + .../bootstrap-datetimepicker.sk.js | 20 ++ .../bootstrap-datetimepicker.sl.js | 17 + .../bootstrap-datetimepicker.sv.js | 17 + .../bootstrap-datetimepicker.sw.js | 18 + .../bootstrap-datetimepicker.th.js | 17 + .../bootstrap-datetimepicker.tr.js | 18 + .../bootstrap-datetimepicker.ua.js | 16 + .../bootstrap-datetimepicker.uk.js | 17 + .../bootstrap-datetimepicker.zh-TW.js | 17 + .../bootstrap-datetimepicker.zh.js | 17 + .../kotlin/test/pl/treksoft/kvision/TestUtil.kt | 99 ++++++ .../kvision/form/time/DateTimeInputSpec.kt | 53 +++ .../pl/treksoft/kvision/form/time/DateTimeSpec.kt | 62 ++++ kvision-modules/kvision-handlebars/build.gradle | 10 + .../kvision-handlebars/package.json.d/project.info | 3 + .../pl/treksoft/kvision/KVManagerHandlebars.kt | 41 +++ kvision-modules/kvision-i18n/build.gradle | 9 + .../kvision-i18n/package.json.d/project.info | 3 + .../kotlin/pl/treksoft/kvision/KVManagerI18n.kt | 41 +++ .../pl/treksoft/kvision/i18n/DefaultI18nManager.kt | 44 +++ kvision-modules/kvision-richtext/build.gradle | 9 + .../kvision-richtext/package.json.d/project.info | 3 + .../pl/treksoft/kvision/KVManagerRichText.kt | 64 ++++ .../pl/treksoft/kvision/form/text/RichText.kt | 79 +++++ .../pl/treksoft/kvision/form/text/RichTextInput.kt | 133 ++++++++ .../src/main/resources/js/locales/trix/trix.pl.js | 28 ++ .../kotlin/test/pl/treksoft/kvision/TestUtil.kt | 99 ++++++ .../kvision/form/text/RichTextInputSpec.kt | 51 +++ .../pl/treksoft/kvision/form/text/RichTextSpec.kt | 58 ++++ kvision-modules/kvision-select/build.gradle | 10 + .../kvision-select/package.json.d/project.info | 3 + .../kotlin/pl/treksoft/kvision/KVManagerSelect.kt | 65 ++++ .../pl/treksoft/kvision/form/select/AjaxOptions.kt | 128 ++++++++ .../pl/treksoft/kvision/form/select/Select.kt | 285 ++++++++++++++++ .../pl/treksoft/kvision/form/select/SelectInput.kt | 363 ++++++++++++++++++++ .../treksoft/kvision/form/select/SelectOptGroup.kt | 91 ++++++ .../treksoft/kvision/form/select/SelectOption.kt | 103 ++++++ .../ajax-bootstrap-select.de-DE.min.js | 22 ++ .../ajax-bootstrap-select.en-US.min.js | 22 ++ .../ajax-bootstrap-select.es-ES.min.js | 22 ++ .../ajax-bootstrap-select.fr-FR.min.js | 22 ++ .../ajax-bootstrap-select.it-IT.min.js | 22 ++ .../ajax-bootstrap-select.ja-JP.min.js | 22 ++ .../ajax-bootstrap-select.ko-KR.min.js | 22 ++ .../ajax-bootstrap-select.nl-NL.min.js | 22 ++ .../ajax-bootstrap-select.pl-PL.min.js | 22 ++ .../ajax-bootstrap-select.pt-BR.min.js | 22 ++ .../ajax-bootstrap-select.ru-RU.min.js | 22 ++ .../ajax-bootstrap-select.tr-TR.min.js | 22 ++ .../bootstrap-select/bootstrap-select-i18n.min.js | 1 + .../kotlin/test/pl/treksoft/kvision/TestUtil.kt | 99 ++++++ .../kvision/form/select/SelectInputSpec.kt | 53 +++ .../kvision/form/select/SelectOptGroupSpec.kt | 54 +++ .../kvision/form/select/SelectOptionSpec.kt | 59 ++++ .../pl/treksoft/kvision/form/select/SelectSpec.kt | 58 ++++ kvision-modules/kvision-server-jooby/build.gradle | 31 ++ .../kotlin/pl/treksoft/kvision/remote/Jooby.kt | 91 ++++++ .../pl/treksoft/kvision/remote/ServiceManager.kt | 338 +++++++++++++++++++ .../main/kotlin/pl/treksoft/kvision/types/KDate.kt | 58 ++++ kvision-modules/kvision-spinner/build.gradle | 9 + .../kvision-spinner/package.json.d/project.info | 3 + .../kotlin/pl/treksoft/kvision/KVManagerSpinner.kt | 42 +++ .../pl/treksoft/kvision/form/spinner/Spinner.kt | 263 +++++++++++++++ .../treksoft/kvision/form/spinner/SpinnerInput.kt | 323 ++++++++++++++++++ .../kotlin/test/pl/treksoft/kvision/TestUtil.kt | 99 ++++++ .../kvision/form/spinner/SpinnerInputSpec.kt | 75 +++++ .../treksoft/kvision/form/spinner/SpinnerSpec.kt | 82 +++++ kvision-modules/kvision-upload/build.gradle | 9 + .../kvision-upload/package.json.d/project.info | 3 + .../kotlin/pl/treksoft/kvision/KVManagerUpload.kt | 86 +++++ .../pl/treksoft/kvision/form/upload/Upload.kt | 333 +++++++++++++++++++ .../pl/treksoft/kvision/form/upload/UploadInput.kt | 364 +++++++++++++++++++++ .../resources/js/locales/bootstrap-fileinput/ar.js | 101 ++++++ .../resources/js/locales/bootstrap-fileinput/az.js | 101 ++++++ .../resources/js/locales/bootstrap-fileinput/bg.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/ca.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/cr.js | 101 ++++++ .../resources/js/locales/bootstrap-fileinput/cs.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/da.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/de.js | 98 ++++++ .../resources/js/locales/bootstrap-fileinput/el.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/es.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/et.js | 99 ++++++ .../resources/js/locales/bootstrap-fileinput/fa.js | 101 ++++++ .../resources/js/locales/bootstrap-fileinput/fi.js | 91 ++++++ .../resources/js/locales/bootstrap-fileinput/fr.js | 99 ++++++ .../resources/js/locales/bootstrap-fileinput/gl.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/hu.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/id.js | 101 ++++++ .../resources/js/locales/bootstrap-fileinput/it.js | 102 ++++++ .../resources/js/locales/bootstrap-fileinput/ja.js | 109 ++++++ .../resources/js/locales/bootstrap-fileinput/ka.js | 101 ++++++ .../resources/js/locales/bootstrap-fileinput/ko.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/kz.js | 88 +++++ .../resources/js/locales/bootstrap-fileinput/lt.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/nl.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/no.js | 99 ++++++ .../resources/js/locales/bootstrap-fileinput/pl.js | 90 +++++ .../js/locales/bootstrap-fileinput/pt-BR.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/pt.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/ro.js | 101 ++++++ .../resources/js/locales/bootstrap-fileinput/ru.js | 101 ++++++ .../resources/js/locales/bootstrap-fileinput/sk.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/sl.js | 98 ++++++ .../resources/js/locales/bootstrap-fileinput/sv.js | 99 ++++++ .../resources/js/locales/bootstrap-fileinput/th.js | 100 ++++++ .../resources/js/locales/bootstrap-fileinput/tr.js | 99 ++++++ .../resources/js/locales/bootstrap-fileinput/uk.js | 101 ++++++ .../resources/js/locales/bootstrap-fileinput/vi.js | 101 ++++++ .../js/locales/bootstrap-fileinput/zh-TW.js | 102 ++++++ .../resources/js/locales/bootstrap-fileinput/zh.js | 100 ++++++ .../kotlin/test/pl/treksoft/kvision/TestUtil.kt | 99 ++++++ .../kvision/form/upload/UploadInputSpec.kt | 57 ++++ .../pl/treksoft/kvision/form/upload/UploadSpec.kt | 56 ++++ kvision-modules/shared.gradle | 65 ++++ 169 files changed, 10792 insertions(+) create mode 100644 kvision-modules/kvision-base/build.gradle create mode 100644 kvision-modules/kvision-bootstrap/build.gradle create mode 100644 kvision-modules/kvision-bootstrap/package.json.d/project.info create mode 100644 kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/KVManagerBootstrap.kt create mode 100644 kvision-modules/kvision-bootstrap/src/main/resources/css/paper.css create mode 100644 kvision-modules/kvision-bootstrap/src/main/resources/js/bootstrap.config.js create mode 100644 kvision-modules/kvision-bootstrap/src/main/resources/js/bootstrap.config.less create mode 100644 kvision-modules/kvision-common/build.gradle create mode 100644 kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt create mode 100644 kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/JsonRpc.kt create mode 100644 kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt create mode 100644 kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt create mode 100644 kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/KFile.kt create mode 100644 kvision-modules/kvision-datetime/build.gradle create mode 100644 kvision-modules/kvision-datetime/package.json.d/project.info create mode 100644 kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/KVManagerDatetime.kt create mode 100644 kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt create mode 100644 kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ar.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.az.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.bg.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.bn.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ca.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.cs.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.da.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.de.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ee.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.el.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.es.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.fi.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.fr.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.he.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.hr.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.hu.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.hy.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.id.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.is.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.it.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ja.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ka.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ko.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.lt.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.lv.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ms.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.nb.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.nl.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.no.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.pl.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.pt-BR.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.pt.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ro.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.rs-latin.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.rs.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ru.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.sk.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.sl.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.sv.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.sw.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.th.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.tr.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ua.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.uk.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.zh-TW.js create mode 100644 kvision-modules/kvision-datetime/src/main/resources/js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.zh.js create mode 100644 kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt create mode 100644 kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt create mode 100644 kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt create mode 100644 kvision-modules/kvision-handlebars/build.gradle create mode 100644 kvision-modules/kvision-handlebars/package.json.d/project.info create mode 100644 kvision-modules/kvision-handlebars/src/main/kotlin/pl/treksoft/kvision/KVManagerHandlebars.kt create mode 100644 kvision-modules/kvision-i18n/build.gradle create mode 100644 kvision-modules/kvision-i18n/package.json.d/project.info create mode 100644 kvision-modules/kvision-i18n/src/main/kotlin/pl/treksoft/kvision/KVManagerI18n.kt create mode 100644 kvision-modules/kvision-i18n/src/main/kotlin/pl/treksoft/kvision/i18n/DefaultI18nManager.kt create mode 100644 kvision-modules/kvision-richtext/build.gradle create mode 100644 kvision-modules/kvision-richtext/package.json.d/project.info create mode 100644 kvision-modules/kvision-richtext/src/main/kotlin/pl/treksoft/kvision/KVManagerRichText.kt create mode 100644 kvision-modules/kvision-richtext/src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt create mode 100644 kvision-modules/kvision-richtext/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt create mode 100644 kvision-modules/kvision-richtext/src/main/resources/js/locales/trix/trix.pl.js create mode 100644 kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt create mode 100644 kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt create mode 100644 kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt create mode 100644 kvision-modules/kvision-select/build.gradle create mode 100644 kvision-modules/kvision-select/package.json.d/project.info create mode 100644 kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/KVManagerSelect.kt create mode 100644 kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt create mode 100644 kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt create mode 100644 kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt create mode 100644 kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt create mode 100644 kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt create mode 100644 kvision-modules/kvision-select/src/main/resources/js/locales/ajax-bootstrap-select/ajax-bootstrap-select.de-DE.min.js create mode 100644 kvision-modules/kvision-select/src/main/resources/js/locales/ajax-bootstrap-select/ajax-bootstrap-select.en-US.min.js create mode 100644 kvision-modules/kvision-select/src/main/resources/js/locales/ajax-bootstrap-select/ajax-bootstrap-select.es-ES.min.js create mode 100644 kvision-modules/kvision-select/src/main/resources/js/locales/ajax-bootstrap-select/ajax-bootstrap-select.fr-FR.min.js create mode 100644 kvision-modules/kvision-select/src/main/resources/js/locales/ajax-bootstrap-select/ajax-bootstrap-select.it-IT.min.js create mode 100644 kvision-modules/kvision-select/src/main/resources/js/locales/ajax-bootstrap-select/ajax-bootstrap-select.ja-JP.min.js create mode 100644 kvision-modules/kvision-select/src/main/resources/js/locales/ajax-bootstrap-select/ajax-bootstrap-select.ko-KR.min.js create mode 100644 kvision-modules/kvision-select/src/main/resources/js/locales/ajax-bootstrap-select/ajax-bootstrap-select.nl-NL.min.js create mode 100644 kvision-modules/kvision-select/src/main/resources/js/locales/ajax-bootstrap-select/ajax-bootstrap-select.pl-PL.min.js create mode 100644 kvision-modules/kvision-select/src/main/resources/js/locales/ajax-bootstrap-select/ajax-bootstrap-select.pt-BR.min.js create mode 100644 kvision-modules/kvision-select/src/main/resources/js/locales/ajax-bootstrap-select/ajax-bootstrap-select.ru-RU.min.js create mode 100644 kvision-modules/kvision-select/src/main/resources/js/locales/ajax-bootstrap-select/ajax-bootstrap-select.tr-TR.min.js create mode 100644 kvision-modules/kvision-select/src/main/resources/js/locales/bootstrap-select/bootstrap-select-i18n.min.js create mode 100644 kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt create mode 100644 kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt create mode 100644 kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt create mode 100644 kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt create mode 100644 kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt create mode 100644 kvision-modules/kvision-server-jooby/build.gradle create mode 100644 kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt create mode 100644 kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt create mode 100644 kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt create mode 100644 kvision-modules/kvision-spinner/build.gradle create mode 100644 kvision-modules/kvision-spinner/package.json.d/project.info create mode 100644 kvision-modules/kvision-spinner/src/main/kotlin/pl/treksoft/kvision/KVManagerSpinner.kt create mode 100644 kvision-modules/kvision-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt create mode 100644 kvision-modules/kvision-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt create mode 100644 kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt create mode 100644 kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerInputSpec.kt create mode 100644 kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt create mode 100644 kvision-modules/kvision-upload/build.gradle create mode 100644 kvision-modules/kvision-upload/package.json.d/project.info create mode 100644 kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/KVManagerUpload.kt create mode 100644 kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt create mode 100644 kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/ar.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/az.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/bg.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/ca.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/cr.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/cs.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/da.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/de.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/el.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/es.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/et.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/fa.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/fi.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/fr.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/gl.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/hu.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/id.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/it.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/ja.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/ka.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/ko.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/kz.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/lt.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/nl.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/no.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/pl.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/pt-BR.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/pt.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/ro.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/ru.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/sk.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/sl.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/sv.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/th.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/tr.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/uk.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/vi.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/zh-TW.js create mode 100644 kvision-modules/kvision-upload/src/main/resources/js/locales/bootstrap-fileinput/zh.js create mode 100644 kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt create mode 100644 kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadInputSpec.kt create mode 100644 kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadSpec.kt create mode 100644 kvision-modules/shared.gradle (limited to 'kvision-modules') diff --git a/kvision-modules/kvision-base/build.gradle b/kvision-modules/kvision-base/build.gradle new file mode 100644 index 00000000..51970a40 --- /dev/null +++ b/kvision-modules/kvision-base/build.gradle @@ -0,0 +1,7 @@ +apply plugin: 'kotlin-platform-js' + +dependencies { + compile rootProject + compile project(path: ":", configuration: "tests") + testCompile rootProject +} diff --git a/kvision-modules/kvision-bootstrap/build.gradle b/kvision-modules/kvision-bootstrap/build.gradle new file mode 100644 index 00000000..9dc6953c --- /dev/null +++ b/kvision-modules/kvision-bootstrap/build.gradle @@ -0,0 +1,13 @@ +apply from: "../shared.gradle" + +kotlinFrontend { + + npm { + dependency("bootstrap", "3.3.7") + dependency("bootstrap-webpack", "0.0.6") + dependency("font-awesome", "4.7.0") + dependency("font-awesome-webpack", "github:jarecsni/font-awesome-webpack") + dependency("awesome-bootstrap-checkbox", "0.3.7") + } + +} diff --git a/kvision-modules/kvision-bootstrap/package.json.d/project.info b/kvision-modules/kvision-bootstrap/package.json.d/project.info new file mode 100644 index 00000000..e77a0f47 --- /dev/null +++ b/kvision-modules/kvision-bootstrap/package.json.d/project.info @@ -0,0 +1,3 @@ +{ + "description": "KVision Bootstrap module" +} diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/KVManagerBootstrap.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/KVManagerBootstrap.kt new file mode 100644 index 00000000..552f8d42 --- /dev/null +++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/KVManagerBootstrap.kt @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package pl.treksoft.kvision + +import org.w3c.dom.asList +import kotlin.browser.document + +/** + * Internal singleton object which initializes and configures KVision Bootstrap module. + */ +@Suppress("EmptyCatchBlock", "TooGenericExceptionCaught") +internal object KVManagerBootstrap { + private val links = document.getElementsByTagName("link") + private val bootstrapWebpack = try { + val bootswatch = links.asList().find { it.getAttribute("href")?.contains("bootstrap.min.css") ?: false } + if (bootswatch != null) { + if (bootswatch.getAttribute("href")?.contains("/paper/") == true) { + require("./css/paper.css") + } + require("bootstrap-webpack!./js/bootstrap.config.js") + } else { + require("bootstrap-webpack") + } + } catch (e: Throwable) { + } + private val fontAwesomeWebpack = try { + require("font-awesome-webpack") + } catch (e: Throwable) { + } + private val awesomeBootstrapCheckbox = try { + require("awesome-bootstrap-checkbox") + } catch (e: Throwable) { + } +} diff --git a/kvision-modules/kvision-bootstrap/src/main/resources/css/paper.css b/kvision-modules/kvision-bootstrap/src/main/resources/css/paper.css new file mode 100644 index 00000000..6e923117 --- /dev/null +++ b/kvision-modules/kvision-bootstrap/src/main/resources/css/paper.css @@ -0,0 +1,12 @@ +body { + font-size: 14px; + line-height: 1.42857143; +} + +.kv-radio-checkbox { + padding-left: 20px !important; +} + +.radio label, .checkbox label { + white-space: nowrap; +} diff --git a/kvision-modules/kvision-bootstrap/src/main/resources/js/bootstrap.config.js b/kvision-modules/kvision-bootstrap/src/main/resources/js/bootstrap.config.js new file mode 100644 index 00000000..906942d1 --- /dev/null +++ b/kvision-modules/kvision-bootstrap/src/main/resources/js/bootstrap.config.js @@ -0,0 +1,64 @@ +module.exports = { + + // Default for the style loading + styleLoader: 'style-loader!css-loader!less-loader', + + scripts: { + 'transition': true, + 'alert': true, + 'button': true, + 'carousel': true, + 'collapse': true, + 'dropdown': true, + 'modal': true, + 'tooltip': true, + 'popover': true, + 'scrollspy': true, + 'tab': true, + 'affix': true + }, + styles: { + "mixins": false, + + "normalize": false, + "print": false, + + "scaffolding": false, + "type": false, + "code": false, + "grid": false, + "tables": false, + "forms": false, + "buttons": false, + + "component-animations": false, + "glyphicons": false, + "dropdowns": false, + "button-groups": false, + "input-groups": false, + "navs": false, + "navbar": false, + "breadcrumbs": false, + "pagination": false, + "pager": false, + "labels": false, + "badges": false, + "jumbotron": false, + "thumbnails": false, + "alerts": false, + "progress-bars": false, + "media": false, + "list-group": false, + "panels": false, + "wells": false, + "close": false, + + "modals": false, + "tooltip": false, + "popovers": false, + "carousel": false, + + "utilities": false, + "responsive-utilities": false + } +}; diff --git a/kvision-modules/kvision-bootstrap/src/main/resources/js/bootstrap.config.less b/kvision-modules/kvision-bootstrap/src/main/resources/js/bootstrap.config.less new file mode 100644 index 00000000..e69de29b diff --git a/kvision-modules/kvision-common/build.gradle b/kvision-modules/kvision-common/build.gradle new file mode 100644 index 00000000..af3703e6 --- /dev/null +++ b/kvision-modules/kvision-common/build.gradle @@ -0,0 +1,10 @@ +apply plugin: 'kotlin-platform-common' +apply plugin: 'kotlinx-serialization' + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion" + compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serializationVersion" + compile "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutinesVersion" + testCompile "org.jetbrains.kotlin:kotlin-test-common:$kotlinVersion" + testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlinVersion" +} diff --git a/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt b/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt new file mode 100644 index 00000000..ec348a25 --- /dev/null +++ b/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package pl.treksoft.kvision.remote + +/** + * A Jooby based server. + */ +expect open class JoobyServer + +/** + * A server request. + */ +expect interface Request + +/** + * A user profile. + */ +expect class Profile diff --git a/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/JsonRpc.kt b/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/JsonRpc.kt new file mode 100644 index 00000000..7953ea01 --- /dev/null +++ b/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/JsonRpc.kt @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package pl.treksoft.kvision.remote + +import kotlinx.serialization.Serializable + +@Serializable +data class JsonRpcRequest(val id: Int, val method: String, val params: List, val jsonrpc: String = "2.0") { + constructor() : this(0, "", listOf()) +} + +@Serializable +data class JsonRpcResponse( + val id: Int? = null, + val result: String? = null, + val error: String? = null, + val jsonrpc: String = "2.0" +) diff --git a/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt b/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt new file mode 100644 index 00000000..8225a785 --- /dev/null +++ b/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package pl.treksoft.kvision.remote + +import kotlinx.coroutines.Deferred + +enum class RpcHttpMethod { + POST, + PUT, + DELETE, + OPTIONS +} + +enum class HttpMethod { + GET, + POST, + PUT, + DELETE, + OPTIONS +} + +/** + * Multiplatform service manager. + */ +expect open class ServiceManager(service: T) { + /** + * Binds a given route with a function of the receiver. + * @param function a function of the receiver + * @param route a route + * @param method a HTTP method + * @param prefix an URL address prefix + */ + protected inline fun bind( + noinline function: T.(Request?) -> Deferred, + route: String? = null, + method: RpcHttpMethod = RpcHttpMethod.POST, + prefix: String = "/" + ) + + /** + * Binds a given route with a function of the receiver. + * @param function a function of the receiver + * @param route a route + * @param method a HTTP method + * @param prefix an URL address prefix + */ + protected inline fun bind( + noinline function: T.(PAR, Request?) -> Deferred, + route: String? = null, + method: RpcHttpMethod = RpcHttpMethod.POST, + prefix: String = "/" + ) + + /** + * Binds a given route with a function of the receiver. + * @param function a function of the receiver + * @param route a route + * @param method a HTTP method + * @param prefix an URL address prefix + */ + protected inline fun bind( + noinline function: T.(PAR1, PAR2, Request?) -> Deferred, + route: String? = null, + method: RpcHttpMethod = RpcHttpMethod.POST, + prefix: String = "/" + ) + + /** + * Binds a given route with a function of the receiver. + * @param function a function of the receiver + * @param route a route + * @param method a HTTP method + * @param prefix an URL address prefix + */ + protected inline fun bind( + noinline function: T.(PAR1, PAR2, PAR3, Request?) -> Deferred, + route: String? = null, + method: RpcHttpMethod = RpcHttpMethod.POST, + prefix: String = "/" + ) + + /** + * Binds a given route with a function of the receiver. + * @param function a function of the receiver + * @param route a route + * @param method a HTTP method + * @param prefix an URL address prefix + */ + protected inline fun bind( + noinline function: T.(PAR1, PAR2, PAR3, PAR4, Request?) -> Deferred, + route: String? = null, + method: RpcHttpMethod = RpcHttpMethod.POST, + prefix: String = "/" + ) + + /** + * Binds a given route with a function of the receiver. + * @param function a function of the receiver + * @param route a route + * @param method a HTTP method + * @param prefix an URL address prefix + */ + protected inline fun bind( + noinline function: T.(PAR1, PAR2, PAR3, PAR4, PAR5, Request?) -> Deferred, + route: String? = null, + method: RpcHttpMethod = RpcHttpMethod.POST, + prefix: String = "/" + ) + + /** + * Applies all defined routes to the given server. + * @param k a Jooby server + */ + fun applyRoutes(k: JoobyServer) + + /** + * Returns the map of defined paths. + */ + fun getCalls(): Map> +} diff --git a/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt b/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt new file mode 100644 index 00000000..0cb1a1f1 --- /dev/null +++ b/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package pl.treksoft.kvision.types + +import kotlinx.serialization.Serializable + +expect val KDATE_FORMAT: String + +/** + * A serializable wrapper for a multiplatform Date type. + */ +@Serializable +data class KDate(val time: Long) { + constructor() : this(now().time) + constructor(str: String) : this(str.toKDateF(KDATE_FORMAT).time) + + override fun toString(): String { + return this.toStringF(KDATE_FORMAT) + } + + companion object { + fun now() = nowDate() + } +} + +expect fun nowDate(): KDate + +expect fun String.toKDateF(format: String): KDate + +expect fun KDate.toStringF(format: String): String diff --git a/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/KFile.kt b/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/KFile.kt new file mode 100644 index 00000000..ce4adca4 --- /dev/null +++ b/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/KFile.kt @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package pl.treksoft.kvision.types + +import kotlinx.serialization.Serializable + +/** + * A serializable class for a multiplatform File type. + */ +@Serializable +data class KFile( + val name: String, + val size: Int, + val content: String? = null +) diff --git a/kvision-modules/kvision-datetime/build.gradle b/kvision-modules/kvision-datetime/build.gradle new file mode 100644 index 00000000..b853d2f4 --- /dev/null +++ b/kvision-modules/kvision-datetime/build.gradle @@ -0,0 +1,9 @@ +apply from: "../shared.gradle" + +kotlinFrontend { + + npm { + dependency("bootstrap-datetime-picker", "2.4.4") + } + +} diff --git a/kvision-modules/kvision-datetime/package.json.d/project.info b/kvision-modules/kvision-datetime/package.json.d/project.info new file mode 100644 index 00000000..3d332806 --- /dev/null +++ b/kvision-modules/kvision-datetime/package.json.d/project.info @@ -0,0 +1,3 @@ +{ + "description": "KVision Datetime module" +} diff --git a/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/KVManagerDatetime.kt b/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/KVManagerDatetime.kt new file mode 100644 index 00000000..cde55b1e --- /dev/null +++ b/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/KVManagerDatetime.kt @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package pl.treksoft.kvision + +internal val KVManagerDatetimeInit = KVManagerDatetime.init() + +/** + * Internal singleton object which initializes and configures KVision datetime module. + */ +@Suppress("EmptyCatchBlock", "TooGenericExceptionCaught") +internal object KVManagerDatetime { + fun init() {} + + private val bootstrapDateTimePickerCss = try { + require("bootstrap-datetime-picker/css/bootstrap-datetimepicker.min.css") + } catch (e: Throwable) { + } + private val bootstrapDateTimePicker = try { + require("bootstrap-datetime-picker/js/bootstrap-datetimepicker.min.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ar.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.az.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.bg.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.bn.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ca.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.cs.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.da.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.de.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ee.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.el.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.es.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.fi.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.fr.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.he.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.hr.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.hu.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.hy.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.id.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.is.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.it.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ja.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ko.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.lt.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.lv.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.nl.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.no.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.pl.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.pt.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ro.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.rs.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ru.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.sk.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.sl.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.sv.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.th.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.tr.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.ua.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.uk.js") + require("./js/locales/bootstrap-datetime-picker/bootstrap-datetimepicker.zh.js") + } catch (e: Throwable) { + } + +} diff --git a/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt b/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt new file mode 100644 index 00000000..9cdd0369 --- /dev/null +++ b/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package pl.treksoft.kvision.form.time + +import pl.treksoft.kvision.core.Container +import pl.treksoft.kvision.core.StringBoolPair +import pl.treksoft.kvision.core.Widget +import pl.treksoft.kvision.form.FieldLabel +import pl.treksoft.kvision.form.HelpBlock +import pl.treksoft.kvision.form.KDateFormControl +import pl.treksoft.kvision.panel.SimplePanel +import pl.treksoft.kvision.types.KDate +import pl.treksoft.kvision.utils.SnOn + +/** + * Form field date/time chooser component. + * + * @constructor + * @param value date/time input value + * @param name the name attribute of the generated HTML input element + * @param format date/time format (default YYYY-MM-DD HH:mm) + * @param label label text bound to the input element + * @param rich determines if [label] can contain HTML code + */ +open class DateTime( + value: KDate? = null, name: String? = null, format: String = "YYYY-MM-DD HH:mm", label: String? = null, + rich: Boolean = false +) : SimplePanel(setOf("form-group")), KDateFormControl { + + /** + * Date/time input value. + */ + override var value + get() = input.value + set(value) { + input.value = value + } + /** + * Date/time format. + */ + var format + get() = input.format + set(value) { + input.format = value + } + /** + * The placeholder for the date/time input. + */ + var placeholder + get() = input.placeholder + set(value) { + input.placeholder = value + } + /** + * Determines if the date/time input is automatically focused. + */ + var autofocus + get() = input.autofocus + set(value) { + input.autofocus = value + } + /** + * Determines if the date/time input is read-only. + */ + var readonly + get() = input.readonly + set(value) { + input.readonly = value + } + /** + * Day of the week start. 0 (Sunday) to 6 (Saturday). + */ + var weekStart + get() = input.weekStart + set(value) { + input.weekStart = value + } + /** + * Days of the week that should be disabled. Multiple values should be comma separated. + */ + var daysOfWeekDisabled + get() = input.daysOfWeekDisabled + set(value) { + input.daysOfWeekDisabled = value + } + /** + * Determines if *Clear* button should be visible. + */ + var clearBtn + get() = input.clearBtn + set(value) { + input.clearBtn = value + } + /** + * Determines if *Today* button should be visible. + */ + var todayBtn + get() = input.todayBtn + set(value) { + input.todayBtn = value + } + /** + * Determines if the current day should be highlighted. + */ + var todayHighlight + get() = input.todayHighlight + set(value) { + input.todayHighlight = value + } + /** + * The increment used to build the hour view. + */ + var minuteStep + get() = input.minuteStep + set(value) { + input.minuteStep = value + } + /** + * Determines if meridian views are visible in day and hour views. + */ + var showMeridian + get() = input.showMeridian + set(value) { + input.showMeridian = value + } + /** + * The label text bound to the input element. + */ + var label + get() = flabel.content + set(value) { + flabel.content = value + } + /** + * Determines if [label] can contain HTML code. + */ + var rich + get() = flabel.rich + set(value) { + flabel.rich = value + } + + private val idc = "kv_form_time_$counter" + final override val input: DateTimeInput = DateTimeInput(value, format).apply { + this.id = idc + this.name = name + } + final override val flabel: FieldLabel = FieldLabel(idc, label, rich) + final override val validationInfo: HelpBlock = HelpBlock().apply { visible = false } + + init { + @Suppress("LeakingThis") + input.eventTarget = this + this.addInternal(flabel) + this.addInternal(input) + this.addInternal(validationInfo) + counter++ + } + + override fun getSnClass(): List { + val cl = super.getSnClass().toMutableList() + if (validatorError != null) { + cl.add("has-error" to true) + } + return cl + } + + @Suppress("UNCHECKED_CAST") + override fun setEventListener(block: SnOn.() -> Unit): Widget { + input.setEventListener(block) + return this + } + + override fun setEventListener(block: SnOn.() -> Unit): Widget { + input.setEventListener(block) + return this + } + + override fun removeEventListeners(): Widget { + input.removeEventListeners() + return this + } + + /** + * Open date/time chooser popup. + */ + open fun showPopup() { + input.showPopup() + } + + /** + * Hides date/time chooser popup. + */ + open fun hidePopup() { + input.hidePopup() + } + + override fun getValueAsString(): String? { + return input.getValueAsString() + } + + override fun focus() { + input.focus() + } + + override fun blur() { + input.blur() + } + + companion object { + internal var counter = 0 + + /** + * DSL builder extension function. + * + * It takes the same parameters as the constructor of the built component. + */ + fun Container.dateTime( + value: KDate? = null, name: String? = null, format: String = "YYYY-MM-DD HH:mm", label: String? = null, + rich: Boolean = false, init: (DateTime.() -> Unit)? = null + ): DateTime { + val dateTime = DateTime(value, name, format, label, rich).apply { init?.invoke(this) } + this.add(dateTime) + return dateTime + } + } +} diff --git a/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt b/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt new file mode 100644 index 00000000..1df8a082 --- /dev/null +++ b/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt @@ -0,0 +1,291 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notic