Skip to content

Commit

Permalink
Merge pull request #886 from ds-wizard/hotfix/3.25.2
Browse files Browse the repository at this point in the history
Hotfix 3.25.2
  • Loading branch information
janslifka authored Jul 18, 2023
2 parents 1fd4798 + 7638819 commit 51756fe
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 38 deletions.
10 changes: 6 additions & 4 deletions engine-wizard/elm/Wizard/KMEditor/Editor/Components/Preview.elm
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,28 @@ setPackageId appState packageId model =
{ model | questionnaireModel = questionnaireModel }


generateReplies : AppState -> String -> KnowledgeModel -> Model -> Model
generateReplies : AppState -> String -> KnowledgeModel -> Model -> ( Seed, Model )
generateReplies appState questionUuid knowledgeModel model =
let
questionnaireModel =
model.questionnaireModel

( _, mbChapterUuid, questionnaireDetail ) =
( newSeed, mbChapterUuid, questionnaireDetail ) =
questionnaireModel.questionnaire
|> QuestionnaireDetail.generateReplies appState.currentTime appState.seed questionUuid knowledgeModel

activePage =
Maybe.unwrap questionnaireModel.activePage PageChapter mbChapterUuid
in
{ model
( newSeed
, { model
| questionnaireModel =
{ questionnaireModel
| activePage = activePage
, questionnaire = questionnaireDetail
}
}
}
)


createQuestionnaireDetail : String -> KnowledgeModel -> QuestionnaireDetail
Expand Down
19 changes: 11 additions & 8 deletions engine-wizard/elm/Wizard/KMEditor/Editor/Models.elm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Wizard.KMEditor.Editor.Models exposing
)

import ActionResult exposing (ActionResult)
import Random exposing (Seed)
import Shared.Api.Branches as BranchesApi
import Shared.Data.KnowledgeModel.Integration exposing (Integration)
import Shared.Data.OnlineUserInfo exposing (OnlineUserInfo)
Expand Down Expand Up @@ -66,11 +67,13 @@ init appState uuid mbEditorUuid =
}


initPageModel : AppState -> KMEditorRoute -> Model -> Model
initPageModel : AppState -> KMEditorRoute -> Model -> ( Seed, Model )
initPageModel appState route model =
case route of
KMEditorRoute.Edit mbEditorUuid ->
{ model | branchModel = ActionResult.map (EditorBranch.setActiveEditor (Maybe.map Uuid.toString mbEditorUuid)) model.branchModel }
( appState.seed
, { model | branchModel = ActionResult.map (EditorBranch.setActiveEditor (Maybe.map Uuid.toString mbEditorUuid)) model.branchModel }
)

KMEditorRoute.Preview ->
case model.branchModel of
Expand Down Expand Up @@ -101,20 +104,20 @@ initPageModel appState route model =
List.head editorBranch.branch.knowledgeModel.phaseUuids
|> Maybe.andThen Uuid.fromString

previewModel =
( newSeed, previewModel ) =
model.previewModel
|> Preview.setPackageId appState packageId
|> Preview.generateReplies appState currentQuestionUuid editorBranch.branch.knowledgeModel
|> Preview.setActiveChapterIfNot selectedChapterUuid
|> Preview.setPhase defaultPhaseUuid
|> Tuple.mapSecond (Preview.setActiveChapterIfNot selectedChapterUuid)
|> Tuple.mapSecond (Preview.setPhase defaultPhaseUuid)
in
{ model | previewModel = previewModel }
( newSeed, { model | previewModel = previewModel } )

_ ->
model
( appState.seed, model )

_ ->
model
( appState.seed, model )


addSavingActionUuid : Uuid -> Model -> Model
Expand Down
25 changes: 13 additions & 12 deletions engine-wizard/elm/Wizard/KMEditor/Editor/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,21 @@ fetchSubrouteData appState model =
Cmd.none


fetchSubrouteDataFromAfter : (Msg -> Wizard.Msgs.Msg) -> AppState -> Model -> ( Model, Cmd Wizard.Msgs.Msg )
fetchSubrouteDataFromAfter : (Msg -> Wizard.Msgs.Msg) -> AppState -> Model -> ( Seed, Model, Cmd Wizard.Msgs.Msg )
fetchSubrouteDataFromAfter wrapMsg appState model =
case ( model.branchModel, appState.route ) of
( Success _, KMEditorRoute (EditorRoute _ route) ) ->
let
newModel =
( newSeed, newModel ) =
initPageModel appState route model
in
( newModel
( newSeed
, newModel
, Cmd.map wrapMsg <| fetchSubrouteData appState newModel
)

_ ->
( model, Cmd.none )
( appState.seed, model, Cmd.none )


isGuarded : AppState -> Routes.Route -> Model -> Maybe String
Expand Down Expand Up @@ -177,21 +178,21 @@ update wrapMsg msg appState model =
Ok branch ->
if BranchState.isEditable branch.state then
let
( newModel, fetchCmd ) =
( newSeed, newModel, fetchCmd ) =
fetchSubrouteDataFromAfter wrapMsg
appState
{ model
| branchModel = Success (EditorBranch.init appState branch model.mbEditorUuid)
, settingsModel = Settings.setBranchDetail branch model.settingsModel
}
in
withSeed
( newModel
, Cmd.batch
[ WebSocket.open model.websocket
, fetchCmd
]
)
( newSeed
, newModel
, Cmd.batch
[ WebSocket.open model.websocket
, fetchCmd
]
)

else
withSeed ( model, cmdNavigate appState (Routes.kmEditorMigration model.uuid) )
Expand Down
30 changes: 23 additions & 7 deletions engine-wizard/elm/Wizard/KMEditor/Models.elm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Wizard.KMEditor.Models exposing (Model, initLocalModel, initialModel)

import Random exposing (Seed)
import Shared.Data.PaginationQueryString as PaginationQueryString
import Uuid
import Wizard.Common.AppState exposing (AppState)
Expand Down Expand Up @@ -31,15 +32,25 @@ initialModel appState =
}


initLocalModel : AppState -> Route -> Model -> Model
initLocalModel : AppState -> Route -> Model -> ( Seed, Model )
initLocalModel appState route model =
let
withSeed m =
( appState.seed, m )
in
case route of
CreateRoute selectedPackage edit ->
{ model | createModel = Wizard.KMEditor.Create.Models.initialModel selectedPackage edit }
withSeed { model | createModel = Wizard.KMEditor.Create.Models.initialModel selectedPackage edit }

EditorRoute uuid subroute ->
if uuid == model.editorModel.uuid then
{ model | editorModel = Editor.initPageModel appState subroute model.editorModel }
let
( newSeed, editorModel ) =
Editor.initPageModel appState subroute model.editorModel
in
( newSeed
, { model | editorModel = editorModel }
)

else
let
Expand All @@ -50,14 +61,19 @@ initLocalModel appState route model =

_ ->
Nothing

( newSeed, editorModel ) =
Editor.initPageModel appState subroute <| Editor.init appState uuid mbEditorUuid
in
{ model | editorModel = Editor.initPageModel appState subroute <| Editor.init appState uuid mbEditorUuid }
( newSeed
, { model | editorModel = editorModel }
)

IndexRoute paginationQueryString ->
{ model | indexModel = Wizard.KMEditor.Index.Models.initialModel paginationQueryString }
withSeed { model | indexModel = Wizard.KMEditor.Index.Models.initialModel paginationQueryString }

MigrationRoute uuid ->
{ model | migrationModel = Wizard.KMEditor.Migration.Models.initialModel uuid }
withSeed { model | migrationModel = Wizard.KMEditor.Migration.Models.initialModel uuid }

PublishRoute _ ->
{ model | publishModel = Wizard.KMEditor.Publish.Models.initialModel }
withSeed { model | publishModel = Wizard.KMEditor.Publish.Models.initialModel }
9 changes: 8 additions & 1 deletion engine-wizard/elm/Wizard/Models.elm
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,14 @@ initLocalModel model =
{ model | documentTemplateEditorsModel = Wizard.DocumentTemplateEditors.Models.initLocalModel route model.documentTemplateEditorsModel }

Routes.KMEditorRoute route ->
{ model | kmEditorModel = Wizard.KMEditor.Models.initLocalModel model.appState route model.kmEditorModel }
let
( newSeed, kmEditorModel ) =
Wizard.KMEditor.Models.initLocalModel model.appState route model.kmEditorModel
in
setSeed newSeed
{ model
| kmEditorModel = kmEditorModel
}

Routes.KnowledgeModelsRoute route ->
{ model | kmPackagesModel = Wizard.KnowledgeModels.Models.initLocalModel route model.appState model.kmPackagesModel }
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "engine-frontend",
"version": "3.25.1",
"version": "3.25.2",
"repository": "https://github.com/ds-wizard/engine-frontend",
"license": "Apache-2.0",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions wizard-style-builder/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wizard-style-builder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wizard-style-builder",
"version": "3.25.1",
"version": "3.25.2",
"description": "",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 51756fe

Please sign in to comment.