1
1
package dev .sacode .flowrun
2
2
3
+ import java .time .Instant
4
+ import java .time .Duration
5
+ import java .time .temporal .TemporalUnit
6
+ import java .time .temporal .ChronoUnit
3
7
import scala .concurrent .ExecutionContext .Implicits .global
4
8
import scala .scalajs .js
5
9
import scala .scalajs .js .annotation .*
6
10
import org .scalajs .dom
11
+
7
12
import scalatags .JsDom .all .*
8
- import org .getshaka .nativeconverter .fromJson
9
13
import reactify .*
14
+ import ba .sake .tupson .*
10
15
import dev .sacode .flowrun .eval .Interpreter
11
16
import dev .sacode .flowrun .ast .*
12
17
import dev .sacode .flowrun .edit .FlowchartPresenter
@@ -19,10 +24,6 @@ import dev.sacode.flowrun.codegen.CodeGeneratorFactory
19
24
import dev .sacode .flowrun .codegen .Language
20
25
import dev .sacode .flowrun .toastify .*
21
26
import dev .sacode .flowrun .eval .Interpreter .State
22
- import java .time .Instant
23
- import java .time .Duration
24
- import java .time .temporal .TemporalUnit
25
- import java .time .temporal .ChronoUnit
26
27
import dev .sacode .flowrun .edit .CodeArea
27
28
28
29
@ JSExportTopLevel (" FlowRun" )
@@ -41,7 +42,7 @@ class FlowRun(
41
42
Option .when(mountElemText.nonEmpty)(mountElemText)
42
43
}
43
44
private val program = jsonSourceOpt match
44
- case Some (json) => json.fromJson [Program ]
45
+ case Some (json) => json.parseJson [Program ]
45
46
case None =>
46
47
Program (
47
48
AST .newId,
@@ -85,6 +86,8 @@ class FlowRun(
85
86
86
87
attachRunAndCopyListeners()
87
88
89
+ // fixed layout is when you force layout with a class
90
+ // meaning not-changeable with checkboxes
88
91
private val fixedLayout = flowRunElements.mountElem.classList.exists(_.startsWith(" flowrun-layout" ))
89
92
if fixedLayout then flowRunElements.configWidget.querySelector(" .flowrun-config-layout" ).remove()
90
93
else updateLayout()
@@ -315,19 +318,15 @@ class FlowRun(
315
318
316
319
flowRunElements.showFunctionsCheckbox.checked = programModel.ast.config.showFunctions
317
320
flowRunElements.showCodeCheckbox.checked = programModel.ast.config.showGenCode
321
+ flowRunElements.showDebugVarsCheckbox.checked = programModel.ast.config.showDebugVars
318
322
319
323
if ! fixedLayout then
320
324
flowRunElements.showFunctionsCheckbox.oninput = _ => setLayout()
321
325
flowRunElements.showCodeCheckbox.oninput = _ => setLayout()
322
326
323
- /*
324
- flowRunElements.drawArea.addEventListener(
325
- "dblclick",
326
- (event: dom.MouseEvent) => {
327
- Toastify(ToastifyOptions("Please right click on arrow to add more nodes. (Long press on touchscreen)"))
328
- .showToast()
329
- }
330
- )*/
327
+ flowRunElements.showDebugVarsCheckbox.oninput = _ => {
328
+ flowRunElements.debugVariables.classList.remove(" flowrun--hidden" )
329
+ }
331
330
}
332
331
333
332
private def doOnChange (): Unit =
@@ -337,6 +336,17 @@ class FlowRun(
337
336
private def doOnModelChange (): Unit =
338
337
Option (changeCallback).foreach(cb => cb(this ))
339
338
339
+ private def setLayout (): Unit = {
340
+ val oldConfig = programModel.ast.config
341
+ val newConfig = oldConfig.copy(
342
+ showFunctions = flowRunElements.showFunctionsCheckbox.checked,
343
+ showGenCode = flowRunElements.showCodeCheckbox.checked,
344
+ showDebugVars = flowRunElements.showDebugVarsCheckbox.checked
345
+ )
346
+ programModel.setConfig(newConfig)
347
+ updateLayout()
348
+ }
349
+
340
350
private def updateLayout (): Unit = {
341
351
val flowrunMount = flowRunElements.mountElem
342
352
flowrunMount.classList.remove(" flowrun-layout-f-d-o" )
@@ -348,16 +358,6 @@ class FlowRun(
348
358
if newLayout.nonEmpty then flowrunMount.classList.add(newLayout)
349
359
}
350
360
351
- private def setLayout (): Unit = {
352
- val oldConfig = programModel.ast.config
353
- val newConfig = oldConfig.copy(
354
- showFunctions = flowRunElements.showFunctionsCheckbox.checked,
355
- showGenCode = flowRunElements.showCodeCheckbox.checked
356
- )
357
- programModel.setConfig(newConfig)
358
- updateLayout()
359
- }
360
-
361
361
private def resolveLayout (showFunctions : Boolean , showCode : Boolean ): String = {
362
362
if showFunctions && showCode then " "
363
363
else if showFunctions && ! showCode then " flowrun-layout-f-d-o"
0 commit comments