You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by jo...@apache.org on 2021/05/10 07:11:44 UTC
[isis] 07/12: allow an icon menu with dialogs
This is an automated email from the ASF dual-hosted git repository.
joergrade pushed a commit to branch ISIS-2505_Catch_Up_With_Demo_Examples
in repository https://gitbox.apache.org/repos/asf/isis.git
commit f5ae1e871aa92a198dd87d80212eda6eaedb4901
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Fri Apr 30 16:43:04 2021 +0200
allow an icon menu with dialogs
---
.../apache/isis/client/kroviz/ui/DiagramDialog.kt | 16 +++--
.../apache/isis/client/kroviz/ui/kv/Constants.kt | 1 +
.../apache/isis/client/kroviz/ui/kv/MenuFactory.kt | 2 +-
.../apache/isis/client/kroviz/ui/kv/RoWindow.kt | 72 ++++++++++++++++++----
.../apache/isis/client/kroviz/utils/XmlHelper.kt | 9 +--
5 files changed, 76 insertions(+), 24 deletions(-)
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/DiagramDialog.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/DiagramDialog.kt
index d5ce68e..6428dcf 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/DiagramDialog.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/DiagramDialog.kt
@@ -18,11 +18,10 @@
*/
package org.apache.isis.client.kroviz.ui
+import org.apache.isis.client.kroviz.core.aggregator.SvgDispatcher
import org.apache.isis.client.kroviz.core.event.EventStore
import org.apache.isis.client.kroviz.to.ValueType
-import org.apache.isis.client.kroviz.ui.kv.FormPanelFactory
-import org.apache.isis.client.kroviz.ui.kv.RoDialog
-import org.apache.isis.client.kroviz.ui.kv.UiManager
+import org.apache.isis.client.kroviz.ui.kv.*
import org.apache.isis.client.kroviz.utils.*
class DiagramDialog(
@@ -58,9 +57,14 @@ class DiagramDialog(
}
private fun pin() {
- val newImage = getDiagram()
- val newCallBack = buildNewPanel()
- DomUtil.replaceWith(newCallBack, newImage)
+// val newImage = getDiagram()
+// val newCallBack = buildNewPanel()
+// DomUtil.replaceWith(newCallBack, newImage)
+ val logEntry = EventStore.findBy(callBack as UUID)
+ val svgStr = logEntry.getResponse()
+ val panel = SvgPanel()
+ panel.renderSvg(svgStr)
+ UiManager.add("Diagram", panel)
}
private fun getDiagram(): ScalableVectorGraphic {
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/Constants.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/Constants.kt
index 42f6764..e94a8e0 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/Constants.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/Constants.kt
@@ -22,6 +22,7 @@ object Constants {
const val stdMimeType = "text/plain"
const val svgMimeType = "image/svg+xml"
+ const val xmlMimeType = "application/xml"
const val calcHeight = "calc(100vh - 88px)"
const val actionSeparator = "\n"
const val subTypeJson = "json"
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/MenuFactory.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/MenuFactory.kt
index 3356b32..99a49a4 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/MenuFactory.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/MenuFactory.kt
@@ -132,7 +132,7 @@ object MenuFactory {
return null
}
- private fun buildActionLink(
+ fun buildActionLink(
label: String,
menuTitle: String): KvisionHtmlLink {
val actionTitle = Utils.deCamel(label)
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoWindow.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoWindow.kt
index 1a1dc51..f8d1ba8 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoWindow.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoWindow.kt
@@ -18,21 +18,24 @@
*/
package org.apache.isis.client.kroviz.ui.kv
-/* (!) copied from io.kvision.window.Window in order to make Dialogs transparent on move */
+/* (!) copied from io.kvision.window.Window in order to make
+* Dialogs transparent on move
+* add a dd menu to the icon
+* */
import com.github.snabbdom.VNode
-import org.w3c.dom.events.Event
-import org.w3c.dom.events.MouseEvent
import io.kvision.core.*
-import io.kvision.html.Icon
-import io.kvision.html.TAG
-import io.kvision.html.Tag
+import io.kvision.dropdown.DropDown
+import io.kvision.dropdown.separator
+import io.kvision.html.*
import io.kvision.modal.CloseIcon
import io.kvision.panel.SimplePanel
import io.kvision.utils.obj
import io.kvision.utils.px
import io.kvision.window.MaximizeIcon
import io.kvision.window.MinimizeIcon
+import org.w3c.dom.events.Event
+import org.w3c.dom.events.MouseEvent
internal const val DEFAULT_Z_INDEX = 900
internal const val WINDOW_HEADER_HEIGHT = 40
@@ -78,6 +81,7 @@ open class RoWindow(
captionTag.content = value
checkHeaderVisibility()
}
+
/**
* Window content width.
*/
@@ -86,6 +90,7 @@ open class RoWindow(
set(value) {
width = value
}
+
/**
* Window content height.
*/
@@ -94,6 +99,7 @@ open class RoWindow(
set(value) {
content.height = value
}
+
/**
* Window content height.
*/
@@ -102,14 +108,17 @@ open class RoWindow(
set(value) {
content.overflow = value
}
+
/**
* Determines if the window is resizable.
*/
var isResizable by refreshOnUpdate(isResizable) { checkIsResizable() }
+
/**
* Determines if the window is draggable.
*/
var isDraggable by refreshOnUpdate(isDraggable) { checkIsDraggable(); checkHeaderVisibility() }
+
/**
* Determines if Close button is visible.
*/
@@ -119,6 +128,7 @@ open class RoWindow(
closeIcon.visible = value
checkHeaderVisibility()
}
+
/**
* Determines if Maximize button is visible.
*/
@@ -128,6 +138,7 @@ open class RoWindow(
maximizeIcon.visible = value
checkHeaderVisibility()
}
+
/**
* Determines if Maximize button is visible.
*/
@@ -137,6 +148,7 @@ open class RoWindow(
minimizeIcon.visible = value
checkHeaderVisibility()
}
+
/**
* Window icon.
*/
@@ -160,13 +172,25 @@ open class RoWindow(
private val closeIcon = CloseIcon()
private val maximizeIcon = MaximizeIcon()
private val minimizeIcon = MinimizeIcon()
- private val captionTag = Tag(TAG.H5, caption, classes = setOf("modal-title"))
+ private val captionTag = Tag(TAG.H5, caption, classes = setOf("modal-title")).apply {
+ alignSelf = AlignItems.START
+ }
private val iconsContainer = SimplePanel(setOf("kv-window-icons-container"))
- private val windowIcon = Icon(icon ?: "").apply {
- addCssClass("window-icon")
- visible = (icon != null && icon != "")
+
+ /* private val windowIcon = Icon(icon ?: "").apply {
+ addCssClass("window-icon")
+ visible = (icon != null && icon != "")
+ } */
+ private val windowIcon = DropDown(
+ text = "",
+ icon = icon,
+ style = ButtonStyle.LIGHT).apply {
+ marginLeft = CssSize(-16, UNIT.px)
+ marginTop = CssSize(-1, UNIT.px)
+ background = Background(color = Color.name(Col.WHITE))
}
+
private var isResizeEvent = false
init {
@@ -179,8 +203,17 @@ open class RoWindow(
width = contentWidth
@Suppress("LeakingThis")
zIndex = ++zIndexCounter
+ amendMenu(windowIcon)
+ header.add(windowIcon)
+ windowIcon.setEventListener<Icon> {
+ click = { _ ->
+ console.log("[RoWindow.windowIcon.click]")
+ }
+ mousedown = { e ->
+ e.stopPropagation()
+ }
+ }
header.add(captionTag)
- captionTag.add(windowIcon)
header.add(iconsContainer)
minimizeIcon.visible = minimizeButton
minimizeIcon.setEventListener<MinimizeIcon> {
@@ -410,9 +443,26 @@ open class RoWindow(
open fun toggleMinimize() {
}
+ //TODO pass in menu in constructor?
+ fun amendMenu(
+ dd: DropDown) {
+ dd.separator()
+
+// val saveLink = tObject.links.first()
+ val saveAction = MenuFactory.buildActionLink(
+ label = "save",
+ menuTitle = "save")
+ saveAction.onClick {
+// RoXmlHttpRequest().invoke(saveLink)
+ }
+ dd.add(saveAction)
+ }
+
+
companion object {
internal var counter = 0
internal var zIndexCounter = DEFAULT_Z_INDEX
}
+
}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/XmlHelper.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/XmlHelper.kt
index 122a35d..712c778 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/XmlHelper.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/XmlHelper.kt
@@ -18,6 +18,7 @@
*/
package org.apache.isis.client.kroviz.utils
+import org.apache.isis.client.kroviz.ui.kv.Constants
import org.w3c.dom.Document
import org.w3c.dom.Node
import org.w3c.dom.asList
@@ -44,7 +45,7 @@ object XmlHelper {
fun parseXml(xmlStr: String): Document {
val p = DOMParser()
- return p.parseFromString(xmlStr, "application/xml")
+ return p.parseFromString(xmlStr, Constants.xmlMimeType)
}
// Adopted from @link https://stackoverflow.com/questions/376373/pretty-printing-xml-with-javascript
@@ -73,12 +74,8 @@ object XmlHelper {
}
fun xml2json(xml: String): String {
- console.log("[XmlHelper.xml2json]")
val json = XmlToJson.parseString(xml)
- console.log(json)
- val jsonStr = JSON.stringify(json)
- console.log(jsonStr)
- return jsonStr
+ return JSON.stringify(json)
}
}