diff --git a/AlgebraicDataflowArchitectureModel/models/Citrus.model b/AlgebraicDataflowArchitectureModel/models/Citrus.model index 3730a7d..700e4dd 100644 --- a/AlgebraicDataflowArchitectureModel/models/Citrus.model +++ b/AlgebraicDataflowArchitectureModel/models/Citrus.model @@ -3,7 +3,7 @@ } channel CreateBook(aid:Str) { - out accounts.{aid}.books(bookList:List, createBook(title:Str)) = append(bookList, {"title": title, "todos":nil, "favorited": nil}) + out accounts.{aid}.books(bookList:List, createBook(title:Str)) = append(bookList, {"title": title, "todos": nil, "favorited": nil}) } channel DeleteAccount { @@ -11,7 +11,7 @@ } channel ChangeAccountName { - out accounts(accDB:Map, changeAccountId(aid:Str, newAid:Str)) = insert(delete(accDB, aid), newAid, lookup(accDB, aid)) + out accounts(accDB:Map, changeAccountId(aid:Str, newAid:Str)) = if(aid == newAid, accDB, delete(insert(accDB, newAid, lookup(accDB, aid)), aid)) } channel ChangeBookName(aid:Str, bid:Int) { @@ -23,7 +23,7 @@ } channel CreateToDo(aid:Str, bid:Int) { - out accounts.{aid}.books.{bid}.todos(toDoDB:Map, createtodo(title:Str, year:Str, month:Str, day:Str)) = insert(toDoDB, year, + out accounts.{aid}.books.{bid}.todos(toDoDB:Map, createtodo(year:Str, month:Str, day:Str, title:Str)) = insert(toDoDB, year, insert(lookup(toDoDB, year), month, insert(lookup(lookup(toDoDB, year), month), day, append(lookup(lookup(lookup(toDoDB, year), month), day), {"title": title, "check": false})))) @@ -37,8 +37,15 @@ out accounts.{aid}.books.{bid}.todos.{year}.{month}.{day}.{tid}.check(check:Bool, changeCheck(newCheck)) = newCheck } -channel DeleteToDo(aid:Str, bid:Int, year:Str, month:Str, day:Str, tid:Int) { - out accounts.{aid}.books.{bid}.todos.{year}.{month}.{day}(todoList:List, deleteToDo(tid:int)) = if(tid < length(todoList), remove(todoList, tid), todoList) +channel DeleteToDo(aid:Str, bid:Int) { + out accounts.{aid}.books.{bid}.todos(toDoDB:Map, deleteToDo(year:Str, month:Str, day:Str, tid:int)) = insert(toDoDB, + year, + insert(lookup(toDoDB, year), + month, + insert(lookup(lookup(toDoDB, year), month), + day, + remove(lookup(lookup(lookup(toDoDB, year), month), day), + tid)))) } channel AddFavorited(aid:Str, bid:Int) {