Skip to content

Commit

Permalink
#42 Menu action and tab titles 'De Cameled'
Browse files Browse the repository at this point in the history
  • Loading branch information
joerg-rade committed Jan 25, 2020
1 parent 773d4d9 commit e8f2387
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/main/kotlin/org/ro/core/aggregator/ActionDispatcher.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ro.core.aggregator

import org.ro.core.Utils
import org.ro.core.event.LogEntry
import org.ro.core.event.RoXmlHttpRequest
import org.ro.to.Action
Expand Down Expand Up @@ -42,10 +43,11 @@ class ActionDispatcher(private val at: Point = Point(100,100)) : BaseAggregator(
private fun processPost(action: Action, link: Link) {
console.log("[ActionDispatcher.processPost] link.hasArguments: ${link.hasArguments()}")
console.log(link)
val title = Utils.deCamel(action.id)
if (link.hasArguments()) {
ActionPrompt(action).open(at)
} else {
RoXmlHttpRequest().invoke(link, ObjectAggregator(action.id))
RoXmlHttpRequest().invoke(link, ObjectAggregator(title))
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/org/ro/ui/IconManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ object IconManager {
"Error" to "bug",
"Find" to "search",
"Hsql" to "database",
"JEE/CDI" to "sword-light",
"List" to "list",
"Log" to "history",
"Manager" to "manager",
Expand Down
14 changes: 6 additions & 8 deletions src/main/kotlin/org/ro/ui/kv/MenuFactory.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ro.ui.kv

import org.ro.core.Utils
import org.ro.core.aggregator.ActionDispatcher
import org.ro.to.Link
import org.ro.to.Member
Expand Down Expand Up @@ -53,10 +54,12 @@ object MenuFactory {
}
return dd
}

private fun action(dd: DropDown, label: String, link: Link) {
val icon = IconManager.find(label)
val classes = IconManager.findStyleFor(label)
dd.ddLink(label, icon = icon, classes = classes).onClick {
val title = Utils.deCamel(label)
dd.ddLink(title, icon = icon, classes = classes).onClick {
ActionDispatcher().invoke(link)
}
}
Expand Down Expand Up @@ -97,18 +100,13 @@ object MenuFactory {
switchCssClass(undoItem, DISABLED, WARN)
}

private fun switchCssClass(menuItem: Component, from:String, to:String) {
private fun switchCssClass(menuItem: Component, from: String, to: String) {
menuItem.removeCssClass(from)
menuItem.addCssClass(to)
}

fun Member.getInvokeLink(): Link? {
for (l in links) {
if (l.rel.indexOf(id) > 0) {
return l
}
}
return null
return links.firstOrNull { it.rel.indexOf(id) > 0 }
}

}

0 comments on commit e8f2387

Please sign in to comment.