Commit 2b2c447e authored by Dave Griffiths's avatar Dave Griffiths
Browse files

added households and individual entities

parent 598d9cc2
...@@ -59,7 +59,9 @@ ...@@ -59,7 +59,9 @@
(list 'three (list "three")) (list 'three (list "three"))
(list 'village (list "Village")) (list 'village (list "Village"))
(list 'household (list "Household")) (list 'household (list "Household"))
(list 'households (list "Households"))
(list 'individual (list "Individual")) (list 'individual (list "Individual"))
(list 'individuals (list "Individuals"))
(list 'add-item (list "+")) (list 'add-item (list "+"))
(list 'default-village-name (list "New village")) (list 'default-village-name (list "New village"))
...@@ -540,11 +542,11 @@ ...@@ -540,11 +542,11 @@
;; a standard builder for list widgets of entities and a ;; a standard builder for list widgets of entities and a
;; make new button, to add defaults to the list ;; make new button, to add defaults to the list
(define (build-list-widget db table entity-type edit-activity ktv-default) (define (build-list-widget db table title entity-type edit-activity ktv-default)
(vert-colour (vert-colour
colour-two colour-two
(horiz (horiz
(mtitle-scale 'villages) (mtitle-scale title)
(mbutton-scale (mbutton-scale
'add-item 'add-item
(lambda () (lambda ()
...@@ -627,7 +629,7 @@ ...@@ -627,7 +629,7 @@
'())) '()))
)))) ))))
(build-list-widget (build-list-widget
db "sync" "village" "village" db "sync" 'villages "village" "village"
(list (list
(ktv "name" "varchar" (mtext-lookup 'default-village-name)) (ktv "name" "varchar" (mtext-lookup 'default-village-name))
(ktv "block" "varchar" "") (ktv "block" "varchar" "")
...@@ -686,7 +688,6 @@ ...@@ -686,7 +688,6 @@
))) )))
(mbutton 'household-list (lambda () (list (start-activity "household-list" 0 "")))) (mbutton 'household-list (lambda () (list (start-activity "household-list" 0 ""))))
(mtitle 'amenities) (mtitle 'amenities)
(place-widgets 'school #t) (place-widgets 'school #t)
...@@ -703,10 +704,8 @@ ...@@ -703,10 +704,8 @@
(set-current! 'activity-title "Village") (set-current! 'activity-title "Village")
(activity-layout activity)) (activity-layout activity))
(lambda (activity arg) (lambda (activity arg)
(msg "on start")
(msg "activity start - entity init")
(entity-init! db "sync" "village" (get-entity-by-unique db "sync" arg)) (entity-init! db "sync" "village" (get-entity-by-unique db "sync" arg))
(msg "activity start - entity init done") (set-current! 'village arg)
(list (list
(mupdate 'edit-text 'village-name "name") (mupdate 'edit-text 'village-name "name")
(mupdate 'edit-text 'block "block") (mupdate 'edit-text 'block "block")
...@@ -736,16 +735,21 @@ ...@@ -736,16 +735,21 @@
(activity (activity
"household-list" "household-list"
(build-activity (build-activity
(mbutton 'household (lambda () (list (start-activity "household" 0 "")))) (build-list-widget
(mbutton 'household (lambda () (list (start-activity "household" 0 "")))) db "sync" 'households "household" "household"
(mbutton 'household (lambda () (list (start-activity "household" 0 "")))) (list
(mbutton 'household (lambda () (list (start-activity "household" 0 "")))) (ktv "name" "varchar" (mtext-lookup 'default-household-name))
(mbutton 'household (lambda () (list (start-activity "household" 0 "")))) (ktv "num-pots" "int" 0)
) (ktv "house-lat" "real" 0) ;; get from current location?
(ktv "house-lon" "real" 0)
(ktv "toilet-lat" "real" 0)
(ktv "toilet-lon" "real" 0)
(ktv "parent" "varchar" (get-current 'village "error no village set")))))
(lambda (activity arg) (lambda (activity arg)
(set-current! 'activity-title "Household List") (set-current! 'activity-title "Household List")
(activity-layout activity)) (activity-layout activity))
(lambda (activity arg) '()) (lambda (activity arg)
(list (update-list-widget db "sync" "household" "household")))
(lambda (activity) '()) (lambda (activity) '())
(lambda (activity) '()) (lambda (activity) '())
(lambda (activity) '()) (lambda (activity) '())
...@@ -755,6 +759,9 @@ ...@@ -755,6 +759,9 @@
(activity (activity
"household" "household"
(build-activity (build-activity
(horiz
(medit-text 'household-name "normal" (lambda (v) '()))
(medit-text 'num-pots "numeric" (lambda (v) '())))
(horiz (horiz
(mtext 'location) (mtext 'location)
(vert (vert
...@@ -769,26 +776,25 @@ ...@@ -769,26 +776,25 @@
(mtext-small 'test-num) (mtext-small 'test-num)
(mtext-small 'test-num)) (mtext-small 'test-num))
(medit-text 'elevation "numeric" (lambda (v) '()))) (medit-text 'elevation "numeric" (lambda (v) '())))
(horiz
(medit-text 'num-pots "numeric" (lambda (v) '()))
(vert
(mtext 'children)
(horiz
(medit-text 'male "numeric" (lambda (v) '()))
(medit-text 'female "numeric" (lambda (v) '())))))
(mtitle 'adults)
(mbutton 'individual (lambda () (list (start-activity "individual" 0 ""))))
(mbutton 'individual (lambda () (list (start-activity "individual" 0 ""))))
(mbutton 'individual (lambda () (list (start-activity "individual" 0 ""))))
(mbutton 'individual (lambda () (list (start-activity "individual" 0 ""))))
(mbutton 'individual (lambda () (list (start-activity "individual" 0 ""))))
(mbutton 'individual (lambda () (list (start-activity "individual" 0 ""))))
) (build-list-widget
db "sync" 'individuals "individual" "individual"
(list
(ktv "name" "varchar" (mtext-lookup 'default-household-name))
(ktv "family" "varchar" (mtext-lookup 'default-family-name))
(ktv "photo-id" "varchar" (mtext-lookup 'default-photo-id))
(ktv "parent" "varchar" (get-current 'household "error no household set")))))
(lambda (activity arg) (lambda (activity arg)
(set-current! 'activity-title "Household") (set-current! 'activity-title "Household")
(activity-layout activity)) (activity-layout activity))
(lambda (activity arg) '()) (lambda (activity arg)
(entity-init! db "sync" "household" (get-entity-by-unique db "sync" arg))
(set-current! 'household arg)
(list
(update-list-widget db "sync" "household" "household")
(mupdate 'edit-text 'household-name "name")
(mupdate 'edit-text 'num-pots "num-pots")))
(lambda (activity) '()) (lambda (activity) '())
(lambda (activity) '()) (lambda (activity) '())
(lambda (activity) '()) (lambda (activity) '())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment