Skip to content

Commit

Permalink
Merge pull request #1301 from ds-wizard/release/4.14.0
Browse files Browse the repository at this point in the history
Release 4.14.0
  • Loading branch information
janslifka authored Jan 7, 2025
2 parents 63833c6 + c0e3351 commit c8d7a28
Show file tree
Hide file tree
Showing 52 changed files with 1,821 additions and 741 deletions.
19 changes: 12 additions & 7 deletions engine-registry/elm/Registry.elm
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,18 @@ init flags url key =
( appState, cmd ) =
case AppState.init flags key of
Just appStateWithoutRoute ->
let
originalRoute =
Routes.parse appStateWithoutRoute.config url
in
( { appStateWithoutRoute | route = routeIfAllowed appStateWithoutRoute originalRoute }
, dispatch (OnUrlChange url)
)
case Routes.redirect url of
Just redirectUrl ->
( appStateWithoutRoute, Navigation.pushUrl key (Url.toString redirectUrl) )

Nothing ->
let
originalRoute =
Routes.parse appStateWithoutRoute.config url
in
( { appStateWithoutRoute | route = routeIfAllowed appStateWithoutRoute originalRoute }
, dispatch (OnUrlChange url)
)

Nothing ->
( AppState.default key, Cmd.none )
Expand Down
13 changes: 13 additions & 0 deletions engine-registry/elm/Registry/Routes.elm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Registry.Routes exposing
, navigate
, organizationDetail
, parse
, redirect
, signup
, toUrl
)
Expand Down Expand Up @@ -135,6 +136,18 @@ navigate key =
Navigation.pushUrl key << toUrl


redirect : Url -> Maybe Url
redirect url =
if url.path == "/templates" then
Just { url | path = "/document-templates" }

else if String.startsWith "/templates/" url.path then
Just { url | path = "/document-templates/" ++ String.dropLeft 11 url.path }

else
Nothing



-- Route Helpers

Expand Down
14 changes: 14 additions & 0 deletions engine-shared/elm/Shared/Api/Branches.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Shared.Api.Branches exposing
( deleteBranch
, deleteMigration
, getBranch
, getBranchSuggestions
, getBranches
, getMigration
, postBranch
Expand All @@ -17,6 +18,7 @@ import Shared.AbstractAppState exposing (AbstractAppState)
import Shared.Api exposing (ToMsg, jwtDelete, jwtFetch, jwtGet, jwtPost, jwtPostEmpty, jwtPut, wsUrl)
import Shared.Data.Branch as Branch exposing (Branch)
import Shared.Data.BranchDetail as BranchDetail exposing (BranchDetail)
import Shared.Data.BranchSuggestion as BranchSuggestion exposing (BranchSuggestion)
import Shared.Data.Migration as Migration exposing (Migration)
import Shared.Data.Pagination as Pagination exposing (Pagination)
import Shared.Data.PaginationQueryFilters exposing (PaginationQueryFilters)
Expand All @@ -36,6 +38,18 @@ getBranches _ qs =
jwtGet url (Pagination.decoder "branches" Branch.decoder)


getBranchSuggestions : PaginationQueryFilters -> PaginationQueryString -> AbstractAppState a -> ToMsg (Pagination BranchSuggestion) msg -> Cmd msg
getBranchSuggestions _ qs =
let
queryString =
PaginationQueryString.toApiUrl qs

url =
"/branches/suggestions" ++ queryString
in
jwtGet url (Pagination.decoder "branches" BranchSuggestion.decoder)


getBranch : Uuid -> AbstractAppState a -> ToMsg BranchDetail msg -> Cmd msg
getBranch uuid =
jwtGet ("/branches/" ++ Uuid.toString uuid) BranchDetail.decoder
Expand Down
12 changes: 12 additions & 0 deletions engine-shared/elm/Shared/Api/DocumentTemplateDrafts.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Shared.Api.DocumentTemplateDrafts exposing
( deleteAsset
, deleteDraft
, deleteFile
, deleteFolder
, getAsset
, getAssets
, getDraft
Expand Down Expand Up @@ -157,3 +158,14 @@ moveFolder templateId currentPath newPath =
]
in
jwtPost ("/document-template-drafts/" ++ templateId ++ "/folders/move") body


deleteFolder : String -> String -> AbstractAppState a -> ToMsg () msg -> Cmd msg
deleteFolder templateId path =
let
body =
E.object
[ ( "path", E.string path )
]
in
jwtPost ("/document-template-drafts/" ++ templateId ++ "/folders/delete") body
7 changes: 7 additions & 0 deletions engine-shared/elm/Shared/Api/Documents.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Shared.Api.Documents exposing
( deleteDocument
, downloadDocumentUrl
, getDocumentUrl
, getDocuments
, getSubmissionServices
, postDocument
Expand All @@ -18,6 +19,7 @@ import Shared.Data.PaginationQueryFilters exposing (PaginationQueryFilters)
import Shared.Data.PaginationQueryString as PaginationQueryString exposing (PaginationQueryString)
import Shared.Data.Submission as Submission exposing (Submission)
import Shared.Data.SubmissionService as SubmissionService exposing (SubmissionService)
import Shared.Data.UrlResponse as UrlResponse exposing (UrlResponse)
import Uuid exposing (Uuid)


Expand Down Expand Up @@ -50,6 +52,11 @@ getSubmissionServices documentId =
jwtGet ("/documents/" ++ documentId ++ "/available-submission-services") (D.list SubmissionService.decoder)


getDocumentUrl : Uuid -> AbstractAppState a -> ToMsg UrlResponse msg -> Cmd msg
getDocumentUrl uuid =
jwtGet ("/documents/" ++ Uuid.toString uuid ++ "/download") UrlResponse.decoder


downloadDocumentUrl : Uuid -> AbstractAppState a -> String
downloadDocumentUrl uuid appState =
appState.apiUrl ++ "/documents/" ++ Uuid.toString uuid ++ "/download"
Expand Down
4 changes: 4 additions & 0 deletions engine-shared/elm/Shared/Data/BranchDetail.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ module Shared.Data.BranchDetail exposing
, decoder
)

import Dict exposing (Dict)
import Json.Decode as D exposing (Decoder)
import Json.Decode.Pipeline as D
import Shared.Data.Branch.BranchState as BranchState exposing (BranchState)
import Shared.Data.Event as Event exposing (Event)
import Shared.Data.KnowledgeModel as KnowledgeModel exposing (KnowledgeModel)
import Shared.Data.Package as Package exposing (Package)
import Shared.Data.QuestionnaireDetail.Reply as Reply exposing (Reply)
import Uuid exposing (Uuid)
import Version exposing (Version)

Expand All @@ -27,6 +29,7 @@ type alias BranchDetail =
, previousPackageId : Maybe String
, events : List Event
, state : BranchState
, replies : Dict String Reply
}


Expand All @@ -46,3 +49,4 @@ decoder =
|> D.required "previousPackageId" (D.nullable D.string)
|> D.required "events" (D.list Event.decoder)
|> D.required "state" BranchState.decoder
|> D.required "replies" (D.dict Reply.decoder)
21 changes: 21 additions & 0 deletions engine-shared/elm/Shared/Data/BranchSuggestion.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Shared.Data.BranchSuggestion exposing
( BranchSuggestion
, decoder
)

import Json.Decode as D exposing (Decoder)
import Json.Decode.Pipeline as D
import Uuid exposing (Uuid)


type alias BranchSuggestion =
{ uuid : Uuid
, name : String
}


decoder : Decoder BranchSuggestion
decoder =
D.succeed BranchSuggestion
|> D.required "uuid" Uuid.decoder
|> D.required "name" D.string
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module Shared.Data.DocumentTemplateDraft.DocumentTemplateDraftPreviewSettings exposing (DocumentTemplateDraftPreviewSettings, decoder, encode, init, isPreviewSet)
module Shared.Data.DocumentTemplateDraft.DocumentTemplateDraftPreviewSettings exposing (DocumentTemplateDraftPreviewSettings, clearQuestionnaireAndBranch, decoder, encode, init, isPreviewSet)

import Json.Decode as D exposing (Decoder)
import Json.Decode.Pipeline as D
import Json.Encode as E
import Json.Encode.Extra as E
import Maybe.Extra as Maybe
import Shared.Data.BranchSuggestion as BranchSuggestion exposing (BranchSuggestion)
import Shared.Data.QuestionnaireSuggestion as QuestionnaireSuggestion exposing (QuestionnaireSuggestion)
import Uuid exposing (Uuid)

Expand All @@ -13,6 +14,8 @@ type alias DocumentTemplateDraftPreviewSettings =
{ formatUuid : Maybe Uuid
, questionnaireUuid : Maybe Uuid
, questionnaire : Maybe QuestionnaireSuggestion
, branchUuid : Maybe Uuid
, branch : Maybe BranchSuggestion
}


Expand All @@ -21,25 +24,36 @@ init =
{ formatUuid = Nothing
, questionnaireUuid = Nothing
, questionnaire = Nothing
, branchUuid = Nothing
, branch = Nothing
}


clearQuestionnaireAndBranch : DocumentTemplateDraftPreviewSettings -> DocumentTemplateDraftPreviewSettings
clearQuestionnaireAndBranch settings =
{ settings | questionnaireUuid = Nothing, questionnaire = Nothing, branchUuid = Nothing, branch = Nothing }


decoder : Decoder DocumentTemplateDraftPreviewSettings
decoder =
D.succeed DocumentTemplateDraftPreviewSettings
|> D.required "formatUuid" (D.maybe Uuid.decoder)
|> D.required "questionnaireUuid" (D.maybe Uuid.decoder)
|> D.required "questionnaire" (D.maybe QuestionnaireSuggestion.decoder)
|> D.required "branchUuid" (D.maybe Uuid.decoder)
|> D.required "branch" (D.maybe BranchSuggestion.decoder)


encode : DocumentTemplateDraftPreviewSettings -> E.Value
encode settings =
E.object
[ ( "formatUuid", E.maybe Uuid.encode settings.formatUuid )
, ( "questionnaireUuid", E.maybe Uuid.encode settings.questionnaireUuid )
, ( "branchUuid", E.maybe Uuid.encode settings.branchUuid )
]


isPreviewSet : DocumentTemplateDraftPreviewSettings -> Bool
isPreviewSet settings =
Maybe.isJust settings.formatUuid && Maybe.isJust settings.questionnaireUuid
Maybe.isJust settings.formatUuid
&& (Maybe.isJust settings.questionnaireUuid || Maybe.isJust settings.branchUuid)
9 changes: 9 additions & 0 deletions engine-shared/elm/Shared/Data/DocumentTemplateDraftDetail.elm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Shared.Data.DocumentTemplateDraftDetail exposing
import Json.Decode as D exposing (Decoder)
import Json.Decode.Extra as D
import Json.Decode.Pipeline as D
import Shared.Data.BranchSuggestion as BranchSuggestion exposing (BranchSuggestion)
import Shared.Data.DocumentTemplate.DocumentTemplateAllowedPackage as AllowedPackage
import Shared.Data.DocumentTemplateDraft.DocumentTemplateDraftPreviewSettings as DocumentTemplateDraftPreviewSettings exposing (DocumentTemplateDraftPreviewSettings)
import Shared.Data.DocumentTemplateDraft.DocumentTemplateFormatDraft as DocumentTemplateFormatDraft exposing (DocumentTemplateFormatDraft)
Expand All @@ -33,6 +34,8 @@ type alias DocumentTemplateDraftDetail =
, formatUuid : Maybe Uuid
, questionnaireUuid : Maybe Uuid
, questionnaire : Maybe QuestionnaireSuggestion
, branchUuid : Maybe Uuid
, branch : Maybe BranchSuggestion
}


Expand All @@ -52,13 +55,17 @@ decoder =
|> D.optional "formatUuid" (D.maybe Uuid.decoder) Nothing
|> D.optional "questionnaireUuid" (D.maybe Uuid.decoder) Nothing
|> D.optional "questionnaire" (D.maybe QuestionnaireSuggestion.decoder) Nothing
|> D.optional "branchUuid" (D.maybe Uuid.decoder) Nothing
|> D.optional "branch" (D.maybe BranchSuggestion.decoder) Nothing


getPreviewSettings : DocumentTemplateDraftDetail -> DocumentTemplateDraftPreviewSettings
getPreviewSettings detail =
{ formatUuid = detail.formatUuid
, questionnaireUuid = detail.questionnaireUuid
, questionnaire = detail.questionnaire
, branchUuid = detail.branchUuid
, branch = detail.branch
}


Expand All @@ -68,6 +75,8 @@ updatePreviewSettings previewSettings detail =
| formatUuid = previewSettings.formatUuid
, questionnaireUuid = previewSettings.questionnaireUuid
, questionnaire = previewSettings.questionnaire
, branchUuid = previewSettings.branchUuid
, branch = previewSettings.branch
}


Expand Down
13 changes: 13 additions & 0 deletions engine-shared/elm/Shared/Data/QuestionnaireDetail/Reply.elm
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
module Shared.Data.QuestionnaireDetail.Reply exposing
( Reply
, decoder
, encode
)

import Iso8601
import Json.Decode as D exposing (Decoder)
import Json.Decode.Extra as D
import Json.Decode.Pipeline as D
import Json.Encode as E
import Json.Encode.Extra as E
import Shared.Data.QuestionnaireDetail.Reply.ReplyValue as ReplyValue exposing (ReplyValue)
import Shared.Data.UserSuggestion as UserSuggestion exposing (UserSuggestion)
import Time
Expand All @@ -24,3 +28,12 @@ decoder =
|> D.required "value" ReplyValue.decoder
|> D.required "createdAt" D.datetime
|> D.required "createdBy" (D.maybe UserSuggestion.decoder)


encode : Reply -> E.Value
encode reply =
E.object
[ ( "value", ReplyValue.encode reply.value )
, ( "createdAt", Iso8601.encode reply.createdAt )
, ( "createdBy", E.maybe UserSuggestion.encode reply.createdBy )
]
5 changes: 4 additions & 1 deletion engine-shared/elm/Shared/Data/QuestionnaireQuestionnaire.elm
Original file line number Diff line number Diff line change
Expand Up @@ -801,10 +801,13 @@ generateReplies currentTime seed questionUuid km questionnaireDetail =

( newSeed, mbChapterUuid, replies ) =
foldReplies currentTime km parentMap seed questionUuid Dict.empty

originalReplies =
questionnaireDetail.replies
in
( newSeed
, mbChapterUuid
, { questionnaireDetail | replies = replies }
, { questionnaireDetail | replies = Dict.union replies originalReplies }
)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Shared.Data.WebSockets.BranchAction.SetRepliesBranchAction exposing
( SetRepliesBranchAction
, decoder
, encode
)

import Dict exposing (Dict)
import Json.Decode as D exposing (Decoder)
import Json.Decode.Pipeline as D
import Json.Encode as E
import Shared.Data.QuestionnaireDetail.Reply as Reply exposing (Reply)
import Uuid exposing (Uuid)


type alias SetRepliesBranchAction =
{ uuid : Uuid
, replies : Dict String Reply
}


decoder : Decoder SetRepliesBranchAction
decoder =
D.succeed SetRepliesBranchAction
|> D.required "uuid" Uuid.decoder
|> D.required "replies" (D.dict Reply.decoder)


encode : SetRepliesBranchAction -> E.Value
encode action =
E.object
[ ( "uuid", Uuid.encode action.uuid )
, ( "replies", E.dict identity Reply.encode action.replies )
]
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ module Shared.Data.WebSockets.ClientBranchAction exposing

import Json.Encode as E
import Shared.Data.WebSockets.BranchAction.SetContentBranchAction as SetContentBranchAction exposing (SetContentBranchAction)
import Shared.Data.WebSockets.BranchAction.SetRepliesBranchAction as SetRepliesBranchAction exposing (SetRepliesBranchAction)


type ClientBranchAction
= SetContent SetContentBranchAction
| SetReplies SetRepliesBranchAction


encode : ClientBranchAction -> E.Value
Expand All @@ -17,6 +19,9 @@ encode action =
SetContent event ->
encodeActionData "SetContent_ClientBranchAction" (SetContentBranchAction.encode event)

SetReplies event ->
encodeActionData "SetReplies_ClientBranchAction" (SetRepliesBranchAction.encode event)


encodeActionData : String -> E.Value -> E.Value
encodeActionData actionType data =
Expand Down
Loading

0 comments on commit c8d7a28

Please sign in to comment.