Skip to content

Commit 3e11414

Browse files
authored
Merge pull request #867 from eikek/fix/842-bool-custom-field
Fix/842 bool custom field
2 parents 363cd59 + 7ec0668 commit 3e11414

3 files changed

Lines changed: 26 additions & 11 deletions

File tree

modules/webapp/src/main/elm/Comp/CustomFieldInput.elm

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Html.Attributes exposing (..)
2424
import Html.Events exposing (onClick, onInput)
2525
import Messages.Comp.CustomFieldInput exposing (Texts)
2626
import Styles as S
27+
import Util.CustomField
2728
import Util.Maybe
2829

2930

@@ -267,18 +268,11 @@ update1 forSearch msg model =
267268

268269
( ToggleBool, BoolField b ) ->
269270
let
270-
notb =
271-
not b
272-
273271
model_ =
274-
{ model | fieldModel = BoolField notb }
272+
{ model | fieldModel = BoolField (not b) }
275273

276274
value =
277-
if notb then
278-
"true"
279-
280-
else
281-
"false"
275+
Util.CustomField.boolValue (not b)
282276
in
283277
UpdateResult model_ Cmd.none (Value value)
284278

modules/webapp/src/main/elm/Comp/CustomFieldMultiInput.elm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Api.Model.ItemFieldValue exposing (ItemFieldValue)
2222
import Comp.CustomFieldInput
2323
import Comp.FixedDropdown
2424
import Data.CustomFieldChange exposing (CustomFieldChange(..))
25+
import Data.CustomFieldType
2526
import Data.DropdownStyle as DS
2627
import Data.Flags exposing (Flags)
2728
import Dict exposing (Dict)
@@ -217,8 +218,16 @@ update1 forSearch flags msg model =
217218

218219
cmd_ =
219220
Cmd.map (CustomFieldInputMsg f) fc
221+
222+
change =
223+
case Data.CustomFieldType.fromString f.ftype of
224+
Just Data.CustomFieldType.Boolean ->
225+
FieldValueChange f (Util.CustomField.boolValue False)
226+
227+
_ ->
228+
NoFieldChange
220229
in
221-
UpdateResult model_ cmd_ NoFieldChange
230+
UpdateResult model_ cmd_ change
222231

223232
RemoveField f ->
224233
let

modules/webapp/src/main/elm/Util/CustomField.elm

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Util.CustomField exposing
2-
( nameOrLabel
2+
( boolValue
3+
, nameOrLabel
34
, renderValue
45
, renderValue2
56
)
@@ -12,6 +13,17 @@ import Html.Attributes exposing (..)
1213
import Html.Events exposing (onClick)
1314

1415

16+
{-| This is how the server wants the value to a bool custom field
17+
-}
18+
boolValue : Bool -> String
19+
boolValue b =
20+
if b then
21+
"true"
22+
23+
else
24+
"false"
25+
26+
1527
nameOrLabel : { r | name : String, label : Maybe String } -> String
1628
nameOrLabel fv =
1729
Maybe.withDefault fv.name fv.label

0 commit comments

Comments
 (0)