-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
1,276 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Shared.Api.QuestionnaireFiles exposing (getQuestionnaireFiles, postFile) | ||
|
||
import File exposing (File) | ||
import Http | ||
import Shared.AbstractAppState exposing (AbstractAppState) | ||
import Shared.Api exposing (ToMsg, jwtFetchFileWithData, jwtGet) | ||
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 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 -> File -> AbstractAppState a -> ToMsg QuestionnaireFileSimple msg -> Cmd msg | ||
postFile questionnaireUuid file = | ||
jwtFetchFileWithData ("/questionnaires/" ++ Uuid.toString questionnaireUuid ++ "/files") | ||
[ Http.stringPart "fileName" (File.name file) ] | ||
QuestionnaireFileSimple.decoder | ||
file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
engine-shared/elm/Shared/Data/Event/AddQuestionFileEventData.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.