Skip to content

Commit

Permalink
Merge pull request #1263 from ds-wizard/release/4.12.0
Browse files Browse the repository at this point in the history
Release 4.12.0
  • Loading branch information
janslifka authored Nov 7, 2024
2 parents 6d64050 + eaf9ca1 commit 0f0ae3c
Show file tree
Hide file tree
Showing 92 changed files with 3,194 additions and 223 deletions.
2 changes: 1 addition & 1 deletion engine-registry/elm/Registry/Pages/Signup.elm
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ successView appState =
Page.illustratedMessage
{ image = Undraw.confirmation
, heading = gettext "Sign up was successful!" appState.locale
, msg = gettext "Check your email address for the activation link." appState.locale
, msg = gettext "Check your email for the activation link." appState.locale
}


Expand Down
34 changes: 34 additions & 0 deletions engine-shared/elm/Shared/Api.elm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ module Shared.Api exposing
, jwtFetchString
, jwtGet
, jwtGetString
, jwtOrHttpDelete
, jwtOrHttpFetch
, jwtOrHttpFetchFileWithData
, jwtOrHttpGet
, jwtOrHttpPut
, jwtPost
Expand Down Expand Up @@ -56,6 +58,16 @@ jwtOrHttpFetch url decoder body appState =
jwtOrHttp appState jwtFetch httpFetch url decoder body appState


jwtOrHttpFetchFileWithData : String -> List Http.Part -> Decoder a -> File -> AbstractAppState b -> ToMsg a msg -> Cmd msg
jwtOrHttpFetchFileWithData url data decoder file appState =
jwtOrHttp appState jwtFetchFileWithData httpFetchFileWithData url data decoder file appState


jwtOrHttpDelete : String -> AbstractAppState b -> ToMsg () msg -> Cmd msg
jwtOrHttpDelete url appState =
jwtOrHttp appState jwtDelete httpDelete url appState


jwtGet : String -> Decoder a -> AbstractAppState b -> ToMsg a msg -> Cmd msg
jwtGet url decoder appState toMsg =
Jwt.Http.get appState.session.token.token
Expand Down Expand Up @@ -205,6 +217,15 @@ httpFetch url decoder body appState toMsg =
}


httpFetchFileWithData : String -> List Http.Part -> Decoder a -> File -> AbstractAppState b -> ToMsg a msg -> Cmd msg
httpFetchFileWithData url data decoder file appState toMsg =
Http.post
{ url = appState.apiUrl ++ url
, body = Http.multipartBody (Http.filePart "file" file :: data)
, expect = expectJson toMsg decoder
}


httpPut : String -> E.Value -> AbstractAppState b -> ToMsg () msg -> Cmd msg
httpPut url body appState toMsg =
Http.request
Expand All @@ -218,6 +239,19 @@ httpPut url body appState toMsg =
}


httpDelete : String -> AbstractAppState b -> ToMsg () msg -> Cmd msg
httpDelete url appState toMsg =
Http.request
{ method = "DELETE"
, headers = []
, url = appState.apiUrl ++ url
, body = Http.emptyBody
, expect = expectWhatever toMsg
, timeout = Nothing
, tracker = Nothing
}


wsUrl : String -> AbstractAppState b -> String
wsUrl url appState =
String.replace "http" "ws" <| authorizedUrl url appState
Expand Down
48 changes: 48 additions & 0 deletions engine-shared/elm/Shared/Api/QuestionnaireFiles.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module Shared.Api.QuestionnaireFiles exposing (deleteFile, fileUrl, getFileUrl, getQuestionnaireFiles, postFile)

import File exposing (File)
import Http
import Shared.AbstractAppState exposing (AbstractAppState)
import Shared.Api exposing (ToMsg, jwtGet, jwtOrHttpDelete, jwtOrHttpFetchFileWithData, jwtOrHttpGet)
import Shared.Data.Pagination as Pagination exposing (Pagination)
import Shared.Data.PaginationQueryFilters exposing (PaginationQueryFilters)
import Shared.Data.PaginationQueryString as PaginationQueryString exposing (PaginationQueryString)
import Shared.Data.QuestionnaireFile as QuestionnaireFile exposing (QuestionnaireFile)
import Shared.Data.QuestionnaireFileSimple as QuestionnaireFileSimple exposing (QuestionnaireFileSimple)
import Shared.Data.UrlResponse as UrlResponse exposing (UrlResponse)
import Uuid exposing (Uuid)


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

url =
"/questionnaire-files" ++ queryString
in
jwtGet url (Pagination.decoder "questionnaireFiles" QuestionnaireFile.decoder)


postFile : Uuid -> String -> File -> AbstractAppState a -> ToMsg QuestionnaireFileSimple msg -> Cmd msg
postFile questionnaireUuid questionUuidString file =
jwtOrHttpFetchFileWithData ("/questionnaires/" ++ Uuid.toString questionnaireUuid ++ "/files/" ++ questionUuidString)
[ Http.stringPart "fileName" (File.name file) ]
QuestionnaireFileSimple.decoder
file


deleteFile : Uuid -> Uuid -> AbstractAppState a -> ToMsg () msg -> Cmd msg
deleteFile questionnaireUuid fileUuid =
jwtOrHttpDelete ("/questionnaires/" ++ Uuid.toString questionnaireUuid ++ "/files/" ++ Uuid.toString fileUuid)


getFileUrl : Uuid -> Uuid -> AbstractAppState a -> ToMsg UrlResponse msg -> Cmd msg
getFileUrl projectUuid fileUuid =
jwtOrHttpGet ("/questionnaires/" ++ Uuid.toString projectUuid ++ "/files/" ++ Uuid.toString fileUuid) UrlResponse.decoder


fileUrl : Uuid -> Uuid -> AbstractAppState a -> String
fileUrl questionnaireUuid fileUuid appState =
appState.apiUrl ++ "/questionnaires/" ++ Uuid.toString questionnaireUuid ++ "/files/" ++ Uuid.toString fileUuid
14 changes: 14 additions & 0 deletions engine-shared/elm/Shared/Api/Questionnaires.elm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Shared.Api.Questionnaires exposing
, fetchQuestionnaireMigration
, getDocumentPreview
, getDocuments
, getFiles
, getProjectTagsSuggestions
, getQuestionnaire
, getQuestionnaireComments
Expand Down Expand Up @@ -51,6 +52,7 @@ import Shared.Data.QuestionnaireContent as QuestionnaireContent exposing (Questi
import Shared.Data.QuestionnaireDetail.CommentThread as CommentThread exposing (CommentThread)
import Shared.Data.QuestionnaireDetail.QuestionnaireEvent as QuestionnaireEvent exposing (QuestionnaireEvent)
import Shared.Data.QuestionnaireDetailWrapper as QuestionnaireDetailWrapper exposing (QuestionnaireDetailWrapper)
import Shared.Data.QuestionnaireFile as QuestionnaireFile exposing (QuestionnaireFile)
import Shared.Data.QuestionnaireMigration as QuestionnaireMigration exposing (QuestionnaireMigration)
import Shared.Data.QuestionnairePreview as QuestionnairePreview exposing (QuestionnairePreview)
import Shared.Data.QuestionnaireQuestionnaire as QuestionnaireDetail exposing (QuestionnaireQuestionnaire)
Expand Down Expand Up @@ -276,6 +278,18 @@ getDocuments questionnaireUuid _ qs =
jwtOrHttpGet url (Pagination.decoder "documents" Document.decoder)


getFiles : Uuid -> PaginationQueryFilters -> PaginationQueryString -> AbstractAppState a -> ToMsg (Pagination QuestionnaireFile) msg -> Cmd msg
getFiles questionnaireUuid _ qs =
let
queryString =
PaginationQueryString.toApiUrl qs

url =
"/questionnaires/" ++ Uuid.toString questionnaireUuid ++ "/files" ++ queryString
in
jwtOrHttpGet url (Pagination.decoder "questionnaireFiles" QuestionnaireFile.decoder)


postVersion : Uuid -> Value -> AbstractAppState a -> ToMsg QuestionnaireVersion msg -> Cmd msg
postVersion questionnaireUuid data =
jwtFetch ("/questionnaires/" ++ Uuid.toString questionnaireUuid ++ "/versions") QuestionnaireVersion.decoder data
Expand Down
18 changes: 16 additions & 2 deletions engine-shared/elm/Shared/Data/Event/AddQuestionEventData.elm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Shared.Data.Event.AddQuestionEventData exposing

import Json.Decode as D exposing (Decoder)
import Json.Encode as E
import Shared.Data.Event.AddQuestionFileEventData as AddQuestionFileEventData exposing (AddQuestionFileEventData)
import Shared.Data.Event.AddQuestionIntegrationEventData as AddQuestionIntegrationEventData exposing (AddQuestionIntegrationEventData)
import Shared.Data.Event.AddQuestionItemSelectEventData as AddQuestionItemSelectEventData exposing (AddQuestionItemSelectEventData)
import Shared.Data.Event.AddQuestionListEventData as AddQuestionListEventData exposing (AddQuestionListEventData)
Expand All @@ -27,6 +28,7 @@ type AddQuestionEventData
| AddQuestionIntegrationEvent AddQuestionIntegrationEventData
| AddQuestionMultiChoiceEvent AddQuestionMultiChoiceEventData
| AddQuestionItemSelectEvent AddQuestionItemSelectEventData
| AddQuestionFileEvent AddQuestionFileEventData


decoder : Decoder AddQuestionEventData
Expand All @@ -53,6 +55,9 @@ decoder =
"ItemSelectQuestion" ->
D.map AddQuestionItemSelectEvent AddQuestionItemSelectEventData.decoder

"FileQuestion" ->
D.map AddQuestionFileEvent AddQuestionFileEventData.decoder

_ ->
D.fail <| "Unknown question type: " ++ questionType
)
Expand All @@ -69,6 +74,7 @@ encode data =
AddQuestionIntegrationEventData.encode
AddQuestionMultiChoiceEventData.encode
AddQuestionItemSelectEventData.encode
AddQuestionFileEventData.encode
data
in
( "eventType", E.string "AddQuestionEvent" ) :: eventData
Expand Down Expand Up @@ -100,6 +106,9 @@ toQuestion questionUuid data =
AddQuestionItemSelectEvent eventData ->
AddQuestionItemSelectEventData.toQuestion questionUuid eventData

AddQuestionFileEvent eventData ->
AddQuestionFileEventData.toQuestion questionUuid eventData


getTypeString : AddQuestionEventData -> String
getTypeString =
Expand All @@ -110,11 +119,12 @@ getTypeString =
(always "Integration")
(always "MultiChoice")
(always "ItemSelect")
(always "File")


getEntityVisibleName : AddQuestionEventData -> Maybe String
getEntityVisibleName =
Just << map .title .title .title .title .title .title
Just << map .title .title .title .title .title .title .title


map :
Expand All @@ -124,9 +134,10 @@ map :
-> (AddQuestionIntegrationEventData -> a)
-> (AddQuestionMultiChoiceEventData -> a)
-> (AddQuestionItemSelectEventData -> a)
-> (AddQuestionFileEventData -> a)
-> AddQuestionEventData
-> a
map optionsQuestion listQuestion valueQuestion integrationQuestion multiChoiceQuestion itemSelectQuestion question =
map optionsQuestion listQuestion valueQuestion integrationQuestion multiChoiceQuestion itemSelectQuestion fileQuestion question =
case question of
AddQuestionOptionsEvent data ->
optionsQuestion data
Expand All @@ -145,3 +156,6 @@ map optionsQuestion listQuestion valueQuestion integrationQuestion multiChoiceQu

AddQuestionItemSelectEvent data ->
itemSelectQuestion data

AddQuestionFileEvent data ->
fileQuestion data
66 changes: 66 additions & 0 deletions engine-shared/elm/Shared/Data/Event/AddQuestionFileEventData.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
module Shared.Data.Event.AddQuestionFileEventData exposing
( AddQuestionFileEventData
, decoder
, encode
, toQuestion
)

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 Shared.Data.KnowledgeModel.Annotation as Annotation exposing (Annotation)
import Shared.Data.KnowledgeModel.Question exposing (Question(..))


type alias AddQuestionFileEventData =
{ title : String
, text : Maybe String
, requiredPhaseUuid : Maybe String
, maxSize : Maybe Int
, fileTypes : Maybe String
, tagUuids : List String
, annotations : List Annotation
}


decoder : Decoder AddQuestionFileEventData
decoder =
D.succeed AddQuestionFileEventData
|> D.required "title" D.string
|> D.required "text" (D.nullable D.string)
|> D.required "requiredPhaseUuid" (D.nullable D.string)
|> D.required "maxSize" (D.maybe D.int)
|> D.required "fileTypes" (D.maybe D.string)
|> D.required "tagUuids" (D.list D.string)
|> D.required "annotations" (D.list Annotation.decoder)


encode : AddQuestionFileEventData -> List ( String, E.Value )
encode data =
[ ( "questionType", E.string "FileQuestion" )
, ( "title", E.string data.title )
, ( "text", E.maybe E.string data.text )
, ( "requiredPhaseUuid", E.maybe E.string data.requiredPhaseUuid )
, ( "maxSize", E.maybe E.int data.maxSize )
, ( "fileTypes", E.maybe E.string data.fileTypes )
, ( "tagUuids", E.list E.string data.tagUuids )
, ( "annotations", E.list Annotation.encode data.annotations )
]


toQuestion : String -> AddQuestionFileEventData -> Question
toQuestion uuid data =
FileQuestion
{ uuid = uuid
, title = data.title
, text = data.text
, requiredPhaseUuid = data.requiredPhaseUuid
, tagUuids = data.tagUuids
, referenceUuids = []
, expertUuids = []
, annotations = data.annotations
}
{ maxSize = data.maxSize
, fileTypes = data.fileTypes
}
12 changes: 12 additions & 0 deletions engine-shared/elm/Shared/Data/Event/EditEventSetters.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Shared.Data.Event.EditEventSetters exposing
, setDescription
, setEmail
, setExpertUuids
, setFileTypes
, setFollowUpUuids
, setId
, setIntegrationUuid
Expand All @@ -19,6 +20,7 @@ module Shared.Data.Event.EditEventSetters exposing
, setLabel
, setListQuestionUuid
, setLogo
, setMaxSize
, setMetricMeasures
, setMetricUuids
, setName
Expand Down Expand Up @@ -104,6 +106,11 @@ setExpertUuids value data =
{ data | expertUuids = EventField.create value True }


setFileTypes : a -> { b | fileTypes : EventField a } -> { b | fileTypes : EventField a }
setFileTypes value data =
{ data | fileTypes = EventField.create value True }


setFollowUpUuids : a -> { b | followUpUuids : EventField a } -> { b | followUpUuids : EventField a }
setFollowUpUuids value data =
{ data | followUpUuids = EventField.create value True }
Expand Down Expand Up @@ -149,6 +156,11 @@ setLogo value data =
{ data | logo = EventField.create value True }


setMaxSize : a -> { b | maxSize : EventField a } -> { b | maxSize : EventField a }
setMaxSize value data =
{ data | maxSize = EventField.create value True }


setMetricMeasures : a -> { b | metricMeasures : EventField a } -> { b | metricMeasures : EventField a }
setMetricMeasures value data =
{ data | metricMeasures = EventField.create value True }
Expand Down
Loading

0 comments on commit 0f0ae3c

Please sign in to comment.