[Racket] Ferti hydroponic nutrient solver, redux.
Factor out number->string.
formlets.rkt
@@ -17,14 +17,14 @@
17
17
#:attributes '((class "form-control") [required "required"])))))
18
18
19
19
(define (nutrient-value-formlet nutrient)
20
Removed:
(define id (nutrient-id nutrient))
20
Added:
(define id (number->string (nutrient-id nutrient)))
21
21
(define number-input
22
22
(input #:type "number"
23
Removed:
#:attributes `((class "form-control") [id ,(number->string id)]
23
Added:
#:attributes `((class "form-control") [id ,id]
24
24
[step "0.1"]
25
25
[placeholder ,(nutrient-french-name nutrient)])))
26
26
(define input-label
27
Removed:
`(label ((for ,(number->string id)
27
Added:
`(label ((for ,id
28
28
))
29
29
,(nutrient-french-name nutrient)))
30
30
(formlet (#%# (div ((class "form-floating mb-3")) ,{=> number-input nutrient-value-b} ,input-label))
@@ -45,7 +45,7 @@
45
45
(values measured-on nutrient-values))))
46
46
47
47
(define (crop-requirement-formlet requirement)
48
Removed:
(define id (crop-requirement-id requirement))
48
Added:
(define id (number->string (crop-requirement-id requirement)))
49
49
(define profile (crop-requirement-profile requirement))
50
50
(define maybe-crop (crop-requirement-crop-id requirement))
51
51
(define crop
@@ -53,14 +53,12 @@
53
53
(crop-name (get-crop #:id maybe-crop))
54
54
#f))
55
55
(define number-input
56
Removed:
(input #:type "number"
57
Removed:
#:attributes `((class "form-control") [id ,(number->string id)]
58
Removed:
[min "0"]
59
Removed:
[max "100"]
60
Removed:
[step "1"]
61
Removed:
[placeholder ,profile])))
56
Added:
(input
57
Added:
#:type "number"
58
Added:
#:attributes
59
Added:
`((class "form-control") [id ,id] [min "0"] [max "100"] [step "1"] [placeholder ,profile])))
62
60
(define input-label
63
Removed:
`(label ((for ,(number->string id)
61
Added:
`(label ((for ,id
64
62
))
65
63
,(if crop
66
64
(format "~a (~a)" crop profile)