mirror of
				https://github.com/TheAnachronism/docspell.git
				synced 2025-10-24 22:30:10 +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:
		| @@ -266,6 +266,13 @@ update1 forSearch msg model = | |||||||
|                         DatePicker.None -> |                         DatePicker.None -> | ||||||
|                             ( old, NoResult ) |                             ( old, NoResult ) | ||||||
|  |  | ||||||
|  |                         DatePicker.FailedInput (DatePicker.Invalid str) -> | ||||||
|  |                             if forSearch && hasWildCards str then | ||||||
|  |                                 ( Nothing, Value str ) | ||||||
|  |  | ||||||
|  |                             else | ||||||
|  |                                 ( old, NoResult ) | ||||||
|  |  | ||||||
|                         DatePicker.FailedInput _ -> |                         DatePicker.FailedInput _ -> | ||||||
|                             ( old, NoResult ) |                             ( old, NoResult ) | ||||||
|  |  | ||||||
| @@ -289,11 +296,7 @@ updateFloatModel : | |||||||
|     -> (String -> String) |     -> (String -> String) | ||||||
|     -> ( FloatModel, FieldResult ) |     -> ( FloatModel, FieldResult ) | ||||||
| updateFloatModel forSearch msg parse normalize = | updateFloatModel forSearch msg parse normalize = | ||||||
|     let |     if forSearch && hasWildCards msg then | ||||||
|         hasWildCards = |  | ||||||
|             String.startsWith "*" msg || String.endsWith "*" msg |  | ||||||
|     in |  | ||||||
|     if forSearch && hasWildCards then |  | ||||||
|         ( { input = normalize msg |         ( { input = normalize msg | ||||||
|           , result = Ok 0 |           , result = Ok 0 | ||||||
|           } |           } | ||||||
| @@ -317,6 +320,11 @@ updateFloatModel forSearch msg parse normalize = | |||||||
|                 ) |                 ) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | hasWildCards : String -> Bool | ||||||
|  | hasWildCards msg = | ||||||
|  |     String.startsWith "*" msg || String.endsWith "*" msg | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| --- View | --- View | ||||||
|  |  | ||||||
|   | |||||||
| @@ -39,7 +39,13 @@ defaultSettings = | |||||||
|         ds = |         ds = | ||||||
|             DatePicker.defaultSettings |             DatePicker.defaultSettings | ||||||
|     in |     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 ) | update : Settings -> Msg -> DatePicker -> ( DatePicker, DateEvent ) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user