Skip to content

Commit

Permalink
implemented workflows for projects
Browse files Browse the repository at this point in the history
  • Loading branch information
vextorspace committed Jul 15, 2024
1 parent f142d7f commit 90978ab
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composeApp/src/commonMain/kotlin/model/ActionType.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package model

enum class ActionType {
Copy,
COPY,
MOVE;
}
4 changes: 2 additions & 2 deletions composeApp/src/commonMain/kotlin/model/ItemWorkflow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import viewmodel.DewItViewModel
data class ItemWorkflow(
val source: String,
val destination: String,
val actionType: ActionType = ActionType.Copy
val actionType: ActionType = ActionType.COPY
) {
fun execute(item: Item, model: DewItViewModel) {
when(actionType) {
ActionType.Copy -> {
ActionType.COPY -> {
if(destination == item.id)
return
model.findItemById(destination)?.add(item)
Expand Down
4 changes: 4 additions & 0 deletions composeApp/src/commonMain/kotlin/viewmodel/GtdModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ object GtdModel {
inbox.addWorkflow(ItemWorkflow(inbox.id, someday.id, ActionType.MOVE))
inbox.addWorkflow(ItemWorkflow(inbox.id, references.id, ActionType.MOVE))

projects.addWorkflow(ItemWorkflow(projects.id, someday.id, ActionType.MOVE))
projects.addWorkflow(ItemWorkflow(projects.id, waiting.id, ActionType.MOVE))
projects.addWorkflow(ItemWorkflow(projects.id, todo.id, ActionType.COPY))

val root = Item("Root")
root.subItems.addAll(itemList)

Expand Down
8 changes: 4 additions & 4 deletions composeApp/src/commonTest/kotlin/model/ItemWorkflowTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ItemWorkflowTest {

// Then
actionType.shouldBeInstanceOf<ActionType>()
.shouldBe(ActionType.Copy)
.shouldBe(ActionType.COPY)
}

@Test
Expand All @@ -36,7 +36,7 @@ class ItemWorkflowTest {
val itemWorkflow = ItemWorkflow(
source = parent.id,
destination = copyToParent.id,
actionType = ActionType.Copy
actionType = ActionType.COPY
)

// When
Expand All @@ -55,7 +55,7 @@ class ItemWorkflowTest {
parent.add(child)
val model = DewItViewModel(listOf(parent))

val itemWorkflow = ItemWorkflow(parent.id, child.id, ActionType.Copy,)
val itemWorkflow = ItemWorkflow(parent.id, child.id, ActionType.COPY,)

// When
itemWorkflow.execute(child, model)
Expand All @@ -72,7 +72,7 @@ class ItemWorkflowTest {
parent.add(child)
val model = DewItViewModel(listOf(parent))

val itemWorkflow = ItemWorkflow(parent.id, parent.id, ActionType.Copy,)
val itemWorkflow = ItemWorkflow(parent.id, parent.id, ActionType.COPY,)

// When
itemWorkflow.execute(child, model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class GtdModelHasWorkflowsTest {
row("Inbox","todo", ActionType.MOVE),
row("Inbox","projects", ActionType.MOVE),
row("Inbox", "someday maybe", ActionType.MOVE),
row("Inbox", "references", ActionType.MOVE)
row("Inbox", "references", ActionType.MOVE),
row("Projects", "todo", ActionType.COPY),
row("Projects", "someday maybe", ActionType.MOVE),
row("Projects", "waiting on", ActionType.MOVE)
)

// Then
Expand Down

0 comments on commit 90978ab

Please sign in to comment.