Skip to content

Commit

Permalink
Add new poll shape attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpetri1 committed Sep 3, 2024
1 parent f5443d3 commit fbe9962
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ object JsonUtils {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,23 @@ object Polls {

private def pollResultToWhiteboardShape(result: SimplePollResultOutVO): scala.collection.immutable.Map[String, Object] = {
val shape = new scala.collection.mutable.HashMap[String, Object]()
shape += "numRespondents" -> Integer.valueOf(result.numRespondents)
shape += "numResponders" -> Integer.valueOf(result.numResponders)
shape += "questionType" -> result.questionType
shape += "questionText" -> result.questionText.getOrElse("")
val props = new scala.collection.mutable.HashMap[String, Object]()
val meta = new scala.collection.mutable.HashMap[String, Object]()

props += "answers" -> result.answers
props += "numRespondents" -> Integer.valueOf(result.numRespondents)
props += "numResponders" -> Integer.valueOf(result.numResponders)
props += "questionText" -> result.questionText.getOrElse("")
props += "questionType" -> result.questionType

shape += "typeName" -> "shape"
shape += "opacity" -> Integer.valueOf(1)
shape += "id" -> s"shape:poll-result-${result.id}"
shape += "answers" -> result.answers
shape += "type" -> "geo"
shape += "meta" -> meta.toMap
shape += "type" -> "poll"

shape += "props" -> props.toMap

shape.toMap
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ class AddTldrawShapeWhiteboardRecordEvent extends AbstractWhiteboardRecordEvent
case l: List[_] => listFormat[Any].write(l)
case b: Boolean if b == true => JsTrue
case b: Boolean if b == false => JsFalse
case _ => JsNull
case v: SimpleVoteOutVO => JsObject("id" -> JsNumber(v.id), "key" -> JsString(v.key), "numVotes" -> JsNumber(v.numVotes))
case arr: Array[_] => JsArray(arr.map(write).toVector)
case null => JsNull
case _ => throw new IllegalArgumentException(s"Unsupported type: ${x.getClass.getName}")
}

def read(value: JsValue) = {}
Expand Down

0 comments on commit fbe9962

Please sign in to comment.