Commit fc8ee1e4 authored by Dave Griffiths's avatar Dave Griffiths
Browse files

id selectors for spouse, mother, father

parent 7a96f055
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="foam.symbai" package="foam.symbai"
android:versionCode="2" android:versionCode="3"
android:versionName="1.0"> android:versionName="1.0">
<application android:label="@string/app_name" <application android:label="@string/app_name"
android:icon="@drawable/logo" android:icon="@drawable/logo"
......
...@@ -519,6 +519,11 @@ ...@@ -519,6 +519,11 @@
r (cons (update-widget 'toggle-button (get-id id) 'checked 0) r))) r (cons (update-widget 'toggle-button (get-id id) 'checked 0) r)))
'() id-list)) '() id-list))
(define (image-invalid? image-name)
(or (null? image-name)
(not image-name)
(equal? image-name "none")))
;; fill out the widget from the current entity in the memory store ;; fill out the widget from the current entity in the memory store
;; dispatches based on widget type ;; dispatches based on widget type
(define (mupdate widget-type id-symbol key) (define (mupdate widget-type id-symbol key)
......
...@@ -179,6 +179,7 @@ ...@@ -179,6 +179,7 @@
;; family ;; family
(list 'spouse (list "Spouse")) (list 'spouse (list "Spouse"))
(list 'change-id (list "Update ID"))
(list 'head-of-house (list "Head of house")) (list 'head-of-house (list "Head of house"))
(list 'marital-status (list "Marital status")) (list 'marital-status (list "Marital status"))
(list 'ever-married (list "Ever married")) (list 'ever-married (list "Ever married"))
...@@ -441,6 +442,7 @@ ...@@ -441,6 +442,7 @@
(define button-size (list (inexact->exact (round (* 192 0.9))) (define button-size (list (inexact->exact (round (* 192 0.9)))
(inexact->exact (round (* 256 0.9))))) (inexact->exact (round (* 256 0.9)))))
(define (update-individual-filter) (define (update-individual-filter)
(update-widget (update-widget
'linear-layout (get-id "choose-pics") 'contents 'linear-layout (get-id "choose-pics") 'contents
...@@ -449,9 +451,7 @@ ...@@ -449,9 +451,7 @@
(lambda (e) (lambda (e)
(let* ((id (ktv-get e "unique_id")) (let* ((id (ktv-get e "unique_id"))
(image-name (ktv-get e "photo")) (image-name (ktv-get e "photo"))
(image (if (or (null? image-name) (image (if (image-invalid? image-name)
(not image-name)
(equal? image-name "none"))
"face" (string-append "/sdcard/symbai/files/" image-name)))) "face" (string-append "/sdcard/symbai/files/" image-name))))
(if (equal? image "face") (if (equal? image "face")
(button (button
...@@ -469,11 +469,49 @@ ...@@ -469,11 +469,49 @@
(db-filter db "sync" "individual" (filter-get))) (db-filter db "sync" "individual" (filter-get)))
3))) 3)))
(define (image-from-unique-id db table unique-id)
(let ((e (get-entity-by-unique db table unique-id)))
(ktv-get e "photo")))
(define (build-person-selector id key filter request-code)
(vert
(mtitle id)
(image-view (make-id (string-append (symbol->string id) "-image"))
"face" (layout 240 320 -1 'centre 0))
(button
(make-id (string-append "change-" (symbol->string id)))
(mtext-lookup 'change-id)
40 (layout 'fill-parent 'wrap-content -1 'centre 5)
(lambda ()
(filter-set! filter)
(list (start-activity "individual-chooser" request-code ""))))))
;; from activity on result with request id: choose-code
;; todo determine *which* selector this came from...
(define (person-selector-return request-code key choose-code)
(when (eqv? request-code choose-code)
(entity-add-value! key "varchar" (get-current 'choose-result "not set"))))
;; need to load from across entities, so need db, table
(define (update-person-selector db table id key)
(msg "update-person-selector" key)
(let ((entity-id (entity-get-value key)))
(msg "entity-id is" entity-id)
(let ((image-name (image-from-unique-id db table entity-id))
(id (get-id (string-append (symbol->string id) "-image"))))
(msg "image-name is" image-name)
(if (image-invalid? image-name)
(update-widget 'image-view id 'image "face")
(update-widget 'image-view id 'external-image (string-append dirname "files/" image-name))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; activities ;; activities
(define photo-code 999) (define photo-code 999)
(define choose-code 998) (define choose-code 998)
(define spouse-request-code 997)
(define mother-request-code 996)
(define father-request-code 995)
(define-activity-list (define-activity-list
...@@ -799,10 +837,9 @@ ...@@ -799,10 +837,9 @@
(mspinner 'head-of-house '(male female) (lambda (v) (entity-add-value! "head-of-house" "varchar" v) '())) (mspinner 'head-of-house '(male female) (lambda (v) (entity-add-value! "head-of-house" "varchar" v) '()))
(mspinner 'marital-status married-list (lambda (v) (entity-add-value! "marital-status" "varchar" v) '())) (mspinner 'marital-status married-list (lambda (v) (entity-add-value! "marital-status" "varchar" v) '()))
(medit-text 'times-married "numeric" (lambda (v) (entity-add-value! "times-married" "int" v) '()))) (medit-text 'times-married "numeric" (lambda (v) (entity-add-value! "times-married" "int" v) '())))
(vert
(mtitle 'spouse) (build-person-selector 'spouse "id-spouse" (list) spouse-request-code)
(image-view (make-id "spouse-image") "face" (layout 240 320 -1 'centre 0)) )
(mbutton 'change-spouse (lambda () '()))))
(mtitle 'children) (mtitle 'children)
(horiz (horiz
...@@ -819,6 +856,7 @@ ...@@ -819,6 +856,7 @@
(activity-layout activity)) (activity-layout activity))
(lambda (activity arg) (lambda (activity arg)
(list (list
(update-person-selector db "sync" 'spouse "id-spouse")
(mupdate-spinner 'head-of-house "head-of-house" '(male female)) (mupdate-spinner 'head-of-house "head-of-house" '(male female))
(mupdate-spinner 'marital-status "marital-status" married-list) (mupdate-spinner 'marital-status "marital-status" married-list)
(mupdate 'edit-text 'times-married "times-married") (mupdate 'edit-text 'times-married "times-married")
...@@ -834,7 +872,9 @@ ...@@ -834,7 +872,9 @@
(lambda (activity) '()) (lambda (activity) '())
(lambda (activity) '()) (lambda (activity) '())
(lambda (activity) '()) (lambda (activity) '())
(lambda (activity requestcode resultcode) '())) (lambda (activity requestcode resultcode)
(person-selector-return requestcode "id-spouse" spouse-request-code)
'()))
(activity (activity
...@@ -919,14 +959,8 @@ ...@@ -919,14 +959,8 @@
"geneaology" "geneaology"
(build-activity (build-activity
(horiz (horiz
(vert (build-person-selector 'mother "id-mother" (list) mother-request-code)
(mtitle 'mother) (build-person-selector 'father "id-father" (list) father-request-code))
(image-view (make-id "image") "face" (layout 240 320 -1 'centre 0))
(mbutton 'change-mother (lambda () '())))
(vert
(mtitle 'father)
(image-view (make-id "image") "face" (layout 240 320 -1 'centre 0))
(mbutton 'change-father (lambda () '()))))
(mtitle 'children) (mtitle 'children)
(horiz (horiz
(medit-text 'name "normal" (lambda (v) '())) (medit-text 'name "normal" (lambda (v) '()))
...@@ -937,12 +971,19 @@ ...@@ -937,12 +971,19 @@
(lambda (activity arg) (lambda (activity arg)
(set-current! 'activity-title "Individual geneaology") (set-current! 'activity-title "Individual geneaology")
(activity-layout activity)) (activity-layout activity))
(lambda (activity arg) '()) (lambda (activity arg)
(list
(update-person-selector db "sync" 'mother "id-mother")
(update-person-selector db "sync" 'father "id-father")))
(lambda (activity) '()) (lambda (activity) '())
(lambda (activity) '()) (lambda (activity) '())
(lambda (activity) '()) (lambda (activity) '())
(lambda (activity) '()) (lambda (activity) '())
(lambda (activity requestcode resultcode) '())) (lambda (activity requestcode resultcode)
(msg requestcode)
(person-selector-return requestcode "id-mother" mother-request-code)
(person-selector-return requestcode "id-father" father-request-code)
'()))
(activity (activity
"social" "social"
......
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