diff options
Diffstat (limited to 'views.rkt')
| -rw-r--r-- | views.rkt | 36 |
1 files changed, 30 insertions, 6 deletions
@@ -14,6 +14,9 @@ show-measurement-page show-rotation-page show-fertilizer-page + show-crop-requirement-page + new-crop-requirement-page + edit-crop-requirement-page fallback-page) (require gregor @@ -206,6 +209,9 @@ (define (new-fertilizer-page) (form-page-template "Nouvel intrant" "/ferti/fertilizers/create" (fertilizer-formlet))) +(define (new-crop-requirement-page) + (form-page-template "Nouveau profil" "/ferti/crop-requirements/create" (crop-requirements-formlet))) + ;; Edit (define (edit-measurement-page nm) @@ -216,12 +222,12 @@ (define (edit-fertilizer-page fp) (form-page-template "Modifier intrant" "/ferti/fertilizers/update" (fertilizer-formlet #:value fp))) -;; (define (new-crop-requirement-page) -;; (page-template "Nouveau profil" -;; `((h1 ((class "display-1 mb-3")) "Nouveau profil") -;; (div ((class "mb-3") [style "max-width: 30em"]) -;; (form ([action "/ferti/crop-requirements/create"] [method "POST"]) -;; ,@(formlet-display (crop-requirement-formlet))))))) +(define (edit-crop-requirement-page cr) + (form-page-template "Modifier profil" + "/ferti/crop-requirements/update" + (crop-requirements-formlet #:value cr))) + +;; Show (define (show-measurement-page nm) (define title (format "Relevé du ~a" (normal-date (nutrient-measurement-date nm)))) @@ -285,6 +291,24 @@ ,button-group ,table))) +(define (show-crop-requirement-page cr) + (define id (crop-requirement-id cr)) + (define title (string-titlecase (crop-requirement-profile cr))) + (define table + `(table ((class "table") (style "max-width: 30em")) + (thead (tr (th "Nutriment") (th ((class "text-end")) "Concentration (mg/L)"))) + (tbody ,@(for/list ([n (get-nutrients)]) + (define nutrient-value (hash-ref (crop-requirement-values cr) n 0)) + `(tr (td ,(nutrient-french-name n)) + (td ((class "text-end font-monospace")) ,(round 2 nutrient-value))))))) + (define button-group + `(div ((class "btn-group")) + (a ((class "btn btn-primary") [href ,(format "/ferti/crop-requirements/~a/edit" id)]) + "Modifier") + (a ((class "btn btn-danger") [href ,(format "/ferti/crop-requirements/~a/destroy" id)]) + "Supprimer"))) + (page-template title `((h1 ((class "display-1 mb-3")) ,title) ,button-group ,table))) + (define (index-page user) (page-template "Bienvenue à la FAPG" |