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
1 change: 1 addition & 0 deletions graph/src/main/scala/wust/graph/GraphChanges.scala
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ object GraphChanges {

def addMarkdownMessage(string: String): GraphChanges = addNode(Node.MarkdownMessage(string))
def addMarkdownTask(string: String): GraphChanges = addNode(Node.MarkdownTask(string))
def addMarkdownTask(string: String, parentId:ParentId): GraphChanges = addNodeWithParent(Node.MarkdownTask(string), parentId)

def addNode(content: NodeData.Content, role: NodeRole) = GraphChanges(addNodes = Array(Node.Content(content, role)))
def addNode(node: Node) = GraphChanges(addNodes = Array(node))
Expand Down
80 changes: 77 additions & 3 deletions webApp/src/main/scala/wust/webApp/views/WelcomeView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import wust.css.Styles
import wust.facades.googleanalytics.Analytics
import wust.ids.View
import wust.util._
import wust.webApp.state.{GlobalState, ScreenSize}
import wust.webApp.state.{ GlobalState, ScreenSize }
import wust.webApp.views.Components._
import wust.webApp.views.SharedViewElements._
import wust.webUtil.outwatchHelpers._
import wust.graph.GraphChanges
import wust.ids._

object WelcomeView {

Expand Down Expand Up @@ -67,7 +69,79 @@ object WelcomeView {
onClick.preventDefault foreach { Analytics.sendEvent("topbar", "signup") }), ".")
)
)
}
},
div(
cls := "ui segment",
maxWidth := "80ex",
marginTop := "50px",
marginBottom := "50px",
h3("Find out what's so great about Woost"),
p(
"You can explore Woost yourself, be guided by a tutorial.",
),
button(cls := "ui primary button", "Create example content to play with",
onClick.stopPropagation.foreach { _ =>
var changes = GraphChanges.empty
def addGraphChange(newChanges: GraphChanges): Unit = {
changes = changes merge newChanges
}

sealed trait Node {
def name: String
val children: List[Node]
val views: Option[List[View.Visible]]
}
case class Project(name: String, views: Option[List[View.Visible]] = None, children: List[Node] = Nil) extends Node
case class Task(name: String, views: Option[List[View.Visible]] = None, children: List[Node] = Nil) extends Node

def addChange(node: Node, parentId: Option[NodeId] = None): NodeId = {
println(s"adding $node, parent: $parentId")
val nodeId = NodeId.fresh()
node match {
case Project(name, views, _) => addGraphChange(GraphChanges.newProject(nodeId, GlobalState.userId.now, name, views = views))
case Task(name, views, _) =>
println(GraphChanges.addNodeWithParent(wust.graph.Node.MarkdownTask(name), parentId.map(ParentId(_))))
addGraphChange(GraphChanges.addNodeWithParent(wust.graph.Node.MarkdownTask(name), parentId.map(ParentId(_))))
}
node.children.reverse.foreach(node => addChange(node, Some(ParentId(nodeId))))
nodeId
}

val checklistId = addChange(
Project(
"Click me to rename",
views = Some(List(View.List)),
children = List(
Task("check me"),
Task("drag me to change order"),
Task(
"click the + on the right or the progress-bar to expand this task",
children = List(
Task("check this subtask"),
)
),
)
)
)

// val newProjectId = NodeId.fresh()
// addChange(GraphChanges.newProject(newProjectId, GlobalState.userId.now, "Click me to rename", views = Some(List(View.List))))
// // checklist items are added in reverse order

// val expanded = GraphChanges.addMarkdownTask("click the + on the right or the progress-bar to expand this task", ParentId(newProjectId))
// val expandedId = expanded.addNodes.head.id
// addChange(expanded)
// addChange(GraphChanges.addMarkdownTask("create a new sub-subtask (expand a subtask first). Tasks can be nested as you want.", ParentId(expandedId)))
// addChange(GraphChanges.addMarkdownTask("create a new subtask", ParentId(expandedId)))
// addChange(GraphChanges.addMarkdownTask("check this subtask", ParentId(expandedId)))

// addChange(GraphChanges.addMarkdownTask("drag me to change order", ParentId(newProjectId)))
// addChange(GraphChanges.addMarkdownTask("check me", ParentId(newProjectId)))

GlobalState.submitChanges(changes)
GlobalState.focus(checklistId, needsGet = false)
})
)
)
),
Rx {
Expand All @@ -78,7 +152,7 @@ object WelcomeView {
Styles.flex,
alignItems.center,
justifyContent.spaceAround,
AuthControls.authStatus( buttonStyleLoggedIn = "basic", buttonStyleLoggedOut = "primary")
AuthControls.authStatus(buttonStyleLoggedIn = "basic", buttonStyleLoggedOut = "primary")
)
)
)
Expand Down
Loading