Skip to content

Commit

Permalink
Fix saving preview values in KM Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
janslifka committed Dec 17, 2024
1 parent 8f55dad commit 72d5ceb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
13 changes: 12 additions & 1 deletion engine-wizard/elm/Wizard/KMEditor/Editor/Common/EditorBranch.elm
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ module Wizard.KMEditor.Editor.Common.EditorBranch exposing
, isQuestionDeletedInHierarchy
, isReachable
, setActiveEditor
, setReplies
, sortDeleted
, treeCollapseAll
, treeExpandAll
, treeIsNodeOpen
, treeSetNodeOpen
)

import Dict
import Dict exposing (Dict)
import Gettext exposing (gettext)
import List.Extra as List
import Maybe.Extra as Maybe
Expand Down Expand Up @@ -75,6 +76,7 @@ import Shared.Data.KnowledgeModel.Reference as Reference exposing (Reference)
import Shared.Data.KnowledgeModel.ResourceCollection exposing (ResourceCollection)
import Shared.Data.KnowledgeModel.ResourcePage exposing (ResourcePage)
import Shared.Data.KnowledgeModel.Tag exposing (Tag)
import Shared.Data.QuestionnaireDetail.Reply exposing (Reply)
import Shared.RegexPatterns as RegexPatterns
import Shared.Utils exposing (flip)
import String.Extra as String
Expand Down Expand Up @@ -124,6 +126,15 @@ init appState branch mbEditorUuid =
|> computeWarnings appState


setReplies : Dict String Reply -> EditorBranch -> EditorBranch
setReplies replies editorBranch =
let
branch =
editorBranch.branch
in
{ editorBranch | branch = { branch | replies = replies } }


getEditUuid : String -> EditorBranch -> Maybe Uuid
getEditUuid entityUuidString editorBranch =
let
Expand Down
8 changes: 7 additions & 1 deletion engine-wizard/elm/Wizard/KMEditor/Editor/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,13 @@ handleWebSocketMsg websocketMsg appState model =
( newModel, _ ) =
removeSavingActionUuid event.uuid model
in
( appState.seed, newModel, Cmd.none )
( appState.seed
, { newModel
| branchModel = ActionResult.map (EditorBranch.setReplies event.replies) newModel.branchModel
, previewModel = Preview.setReplies event.replies newModel.previewModel
}
, Cmd.none
)

WebSocketServerAction.Error _ ->
( appState.seed, { model | error = True }, Cmd.none )
Expand Down

0 comments on commit 72d5ceb

Please sign in to comment.