Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion webApp/src/main/scala/wust/webApp/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import wust.facades.jquery.JQuery
import wust.facades.marked.{Marked, MarkedOptions, Renderer}
import wust.facades.wdtEmojiBundle._
import wust.graph.Node
import wust.ids.NodeData
import wust.webApp.dragdrop.SortableEvents
import wust.webApp.state.{GlobalState, GlobalStateFactory}
import wust.webApp.views.{GenericSidebar, MainView, Modal}
Expand Down Expand Up @@ -66,7 +67,14 @@ object Main {
cls := "result", //we need this class for semantic ui to work,
div(cls := "title", display.none, result.title), // needed for semantic ui to map the html element back to the SearchSourceEntry
padding := "4px",
views.Components.nodeCardAsOneLineText( node, projectWithIcon = true)(Ctx.Owner.Unsafe).prepend(
if(result.placeholder.getOrElse(false)) {
views.Components.renderNodeCard(node,
contentInject = node =>
views.Components.displayPlaceholder(node.data.asInstanceOf[NodeData.Placeholder])
.apply(s" of ${result.text}", cls := "oneline")
)(Ctx.Owner.Unsafe)
}
else views.Components.nodeCardAsOneLineText( node, projectWithIcon = true)(Ctx.Owner.Unsafe).prepend(
cursor.pointer,
Styles.flex,
alignItems.center
Expand Down
54 changes: 42 additions & 12 deletions webApp/src/main/scala/wust/webApp/views/Components.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ object Components {
// 4. crop via overflow ellipsis
cls := "oneline"
)

}

def nodeCardAsOneLineText(node: Node, projectWithIcon: Boolean = true)(implicit ctx: Ctx.Owner): VNode = {
Expand Down Expand Up @@ -652,7 +653,7 @@ object Components {
def searchAndSelectNodeApplied[F[_] : Sink : Source](current: F[Option[NodeId]], filter: Node => Boolean)(implicit ctx: Ctx.Owner): VNode = searchAndSelectNode(current, filter) --> current
def searchAndSelectNode[F[_] : Source](observable: F[Option[NodeId]], filter: Node => Boolean)(implicit ctx: Ctx.Owner): EmitterBuilder[Option[NodeId], VNode] =
Components.searchInGraph(GlobalState.rawGraph, "Search", filter = {
case n: Node.Content => InlineList.contains[NodeRole](NodeRole.Message, NodeRole.Task, NodeRole.Project)(n.role) && filter(n)
case n: Node.Content => filter(n)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you check whether other usages depends on this?

case _ => false
}, innerElementModifier = width := "100%", inputModifiers = width := "100%").mapResult[VNode] { search =>
div(
Expand Down Expand Up @@ -689,18 +690,47 @@ object Components {
minCharacters = 0
showNoResults = showNotFound

source = graph.now.nodes.collect { case node: Node if filter(node) =>
val str = node match {
case user: Node.User => Components.displayUserName(user.data)
case _ => node.str
}
source = {
val g: Graph = graph.now
val res1 = (g.nodes.collect { case node: Node if filter(node) && node.role == NodeRole.Neutral =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about other noderoles than neutral?


new SearchSourceEntry {
title = node.id.toCuidString
description = trimToMaxLength(str, 36)
data = node.asInstanceOf[js.Any]
}
}(breakOut): js.Array[SearchSourceEntry]
val probEdgesRev = g.propertiesEdgeReverseIdx(g.idToIdxOrThrow(node.id))

val probData = probEdgesRev.map{ idx =>
val keyString = g.edges(idx).as[Edge.LabeledProperty].data.key
val propertyValue = g.nodes(g.edgesIdx.b(idx))
val propertySource = g.nodes(g.edgesIdx.a(idx))
(keyString, propertyValue, propertySource)
}

probData.collect {
case p: (String, Node, Node) if p._2.data.isInstanceOf[NodeData.Placeholder] =>
new SearchSourceEntry {
title = p._2.id.toCuidString
placeholder = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to store this placeholder var separately? It is already encoded in the data property (that is the node itself).

text = s"${p._1} of ${p._3.str}"
description = trimToMaxLength(s"missing ${p._1} of ${p._3.str}", 36)
data = node.asInstanceOf[js.Any]
}
}(breakOut): js.Array[SearchSourceEntry]
}(breakOut): js.Array[js.Array[SearchSourceEntry]]).flatten

val res2 = g.nodes.collect { case node: Node if filter(node) && node.role != NodeRole.Neutral =>
val str = node match {
case user: Node.User => Components.displayUserName(user.data)
case n: Node.Content => node.str
}

new SearchSourceEntry {
title = node.id.toCuidString
placeholder = false
description = trimToMaxLength(str, 36)
data = node.asInstanceOf[js.Any]
}
}(breakOut): js.Array[SearchSourceEntry]

res2 ++ res1
}

searchFields = js.Array("description")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ trait SearchSourceEntry extends js.Object {
var description: js.UndefOr[String] = js.undefined
var category: js.UndefOr[String] = js.undefined

var placeholder: js.UndefOr[Boolean] = js.undefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not really belong into the fomantic ui facade, as it is our state, right?

var text: js.UndefOr[String] = js.undefined

var data: js.UndefOr[js.Any] = js.undefined
}

Expand Down