Commit 9c765ff7 authored by Emmanuel Raviart's avatar Emmanuel Raviart

Rating is now optional when posting a property.

parent a7053d92
......@@ -382,7 +382,7 @@ update msg model =
Debug.crash "Cards.Item.State update ValueUpserted: model.editedKeyId == Nothing"
in
( { model | data = mergeData data model.data }
, Requests.postProperty model.authentication model.cardId editedKeyId data.id 1
, Requests.postProperty model.authentication model.cardId editedKeyId data.id (Just 1)
|> Http.send (ForSelf << PropertyUpserted)
)
......
......@@ -111,7 +111,7 @@ update msg model =
ValueUpserted data ->
( { model | data = mergeData data model.data }
, Requests.postProperty model.authentication model.objectId model.keyId data.id 1
, Requests.postProperty model.authentication model.objectId model.keyId data.id (Just 1)
|> Http.send (ForSelf << Upserted)
)
......
......@@ -349,7 +349,7 @@ postCollection authentication collectionId collectionJson =
}
postProperty : Maybe Authentication -> String -> String -> String -> Int -> Http.Request DataIdBody
postProperty : Maybe Authentication -> String -> String -> String -> Maybe Int -> Http.Request DataIdBody
postProperty authentication objectId keyId valueId rating =
Http.request
{ method = "POST"
......@@ -357,11 +357,28 @@ postProperty authentication objectId keyId valueId rating =
, url = apiUrl ++ "properties?show=ballots&show=values&depth=3"
, body =
Encode.object
[ ( "keyId", Encode.string keyId )
, ( "objectId", Encode.string objectId )
, ( "rating", Encode.int rating )
, ( "valueId", Encode.string valueId )
]
([ ( "keyId", Just <| Encode.string keyId )
, ( "objectId", Just <| Encode.string objectId )
, ( "rating"
, case rating of
Just rating ->
Just <| Encode.int rating
Nothing ->
Nothing
)
, ( "valueId", Just <| Encode.string valueId )
]
|> List.filterMap
(\( key, value ) ->
case value of
Just value ->
Just ( key, value )
Nothing ->
Nothing
)
)
|> Http.jsonBody
, expect = Http.expectJson dataIdBodyDecoder
, timeout = Nothing
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment