mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 18:39:33 +00:00
Allow to search for *
in custom date fields
This requires to pass the raw input through to the caller. Closes: #550
This commit is contained in:
parent
305f838239
commit
3c12e3678f
@ -266,6 +266,13 @@ update1 forSearch msg model =
|
||||
DatePicker.None ->
|
||||
( old, NoResult )
|
||||
|
||||
DatePicker.FailedInput (DatePicker.Invalid str) ->
|
||||
if forSearch && hasWildCards str then
|
||||
( Nothing, Value str )
|
||||
|
||||
else
|
||||
( old, NoResult )
|
||||
|
||||
DatePicker.FailedInput _ ->
|
||||
( old, NoResult )
|
||||
|
||||
@ -289,11 +296,7 @@ updateFloatModel :
|
||||
-> (String -> String)
|
||||
-> ( FloatModel, FieldResult )
|
||||
updateFloatModel forSearch msg parse normalize =
|
||||
let
|
||||
hasWildCards =
|
||||
String.startsWith "*" msg || String.endsWith "*" msg
|
||||
in
|
||||
if forSearch && hasWildCards then
|
||||
if forSearch && hasWildCards msg then
|
||||
( { input = normalize msg
|
||||
, result = Ok 0
|
||||
}
|
||||
@ -317,6 +320,11 @@ updateFloatModel forSearch msg parse normalize =
|
||||
)
|
||||
|
||||
|
||||
hasWildCards : String -> Bool
|
||||
hasWildCards msg =
|
||||
String.startsWith "*" msg || String.endsWith "*" msg
|
||||
|
||||
|
||||
|
||||
--- View
|
||||
|
||||
|
@ -39,7 +39,13 @@ defaultSettings =
|
||||
ds =
|
||||
DatePicker.defaultSettings
|
||||
in
|
||||
{ ds | changeYear = DatePicker.from 2010 }
|
||||
{ ds
|
||||
| changeYear = DatePicker.from 2010
|
||||
, parser =
|
||||
\str ->
|
||||
ds.parser str
|
||||
|> Result.mapError (\_ -> str)
|
||||
}
|
||||
|
||||
|
||||
update : Settings -> Msg -> DatePicker -> ( DatePicker, DateEvent )
|
||||
|
Loading…
x
Reference in New Issue
Block a user