blob: be32fb7450e0bf45d6102245c5189c65238b51a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
module LoggedIn.Home.Model exposing
( Model
, Search
, init
, searchInitial
)
import Form exposing (Form)
import Form.Validate as Validate exposing (Validation)
import Form.Field as Field exposing (Field)
import Model.User exposing (Users, UserId)
import Model.Payment as Payment exposing (PaymentId, Payments, Frequency(..))
import Model.Payer exposing (Payers)
type alias Model =
{ paymentEdition : Maybe PaymentId
, currentPage : Int
, search : Form String Search
}
type alias Search =
{ name : Maybe String
, frequency : Frequency
}
init : Model
init =
{ paymentEdition = Nothing
, currentPage = 1
, search = Form.initial (searchInitial Punctual) searchValidation
}
searchInitial : Frequency -> List (String, Field)
searchInitial frequency = [ ("frequency", Field.Radio (toString frequency)) ]
searchValidation : Validation String Search
searchValidation =
Validate.form2 Search
(Validate.get "name" (Validate.maybe Validate.string))
(Validate.get "frequency" Payment.validateFrequency)
|