Commit fc8ee1e4 authored by Dave Griffiths's avatar Dave Griffiths

id selectors for spouse, mother, father

parent 7a96f055
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
<application android:label="@string/app_name"
......@@ -519,6 +519,11 @@
r (cons (update-widget 'toggle-button (get-id id) 'checked 0) r)))
'() 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
;; dispatches based on widget type
(define (mupdate widget-type id-symbol key)
......@@ -179,6 +179,7 @@
;; family
(list 'spouse (list "Spouse"))
(list 'change-id (list "Update ID"))
(list 'head-of-house (list "Head of house"))
(list 'marital-status (list "Marital status"))
(list 'ever-married (list "Ever married"))
......@@ -441,6 +442,7 @@
(define button-size (list (inexact->exact (round (* 192 0.9)))
(inexact->exact (round (* 256 0.9)))))
(define (update-individual-filter)
'linear-layout (get-id "choose-pics") 'contents
......@@ -449,9 +451,7 @@
(lambda (e)
(let* ((id (ktv-get e "unique_id"))
(image-name (ktv-get e "photo"))
(image (if (or (null? image-name)
(not image-name)
(equal? image-name "none"))
(image (if (image-invalid? image-name)
"face" (string-append "/sdcard/symbai/files/" image-name))))
(if (equal? image "face")
......@@ -469,11 +469,49 @@
(db-filter db "sync" "individual" (filter-get)))
(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)
(mtitle id)
(image-view (make-id (string-append (symbol->string id) "-image"))
"face" (layout 240 320 -1 'centre 0))
(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
(define photo-code 999)
(define choose-code 998)
(define spouse-request-code 997)
(define mother-request-code 996)
(define father-request-code 995)
......@@ -799,10 +837,9 @@
(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) '()))
(medit-text 'times-married "numeric" (lambda (v) (entity-add-value! "times-married" "int" v) '())))
(mtitle 'spouse)
(image-view (make-id "spouse-image") "face" (layout 240 320 -1 'centre 0))
(mbutton 'change-spouse (lambda () '()))))
(build-person-selector 'spouse "id-spouse" (list) spouse-request-code)
(mtitle 'children)
......@@ -819,6 +856,7 @@
(activity-layout activity))
(lambda (activity arg)
(update-person-selector db "sync" 'spouse "id-spouse")
(mupdate-spinner 'head-of-house "head-of-house" '(male female))
(mupdate-spinner 'marital-status "marital-status" married-list)
(mupdate 'edit-text 'times-married "times-married")
......@@ -834,7 +872,9 @@
(lambda (activity) '())
(lambda (activity) '())
(lambda (activity) '())
(lambda (activity requestcode resultcode) '()))
(lambda (activity requestcode resultcode)
(person-selector-return requestcode "id-spouse" spouse-request-code)
......@@ -919,14 +959,8 @@
(mtitle 'mother)
(image-view (make-id "image") "face" (layout 240 320 -1 'centre 0))
(mbutton 'change-mother (lambda () '())))
(mtitle 'father)
(image-view (make-id "image") "face" (layout 240 320 -1 'centre 0))
(mbutton 'change-father (lambda () '()))))
(build-person-selector 'mother "id-mother" (list) mother-request-code)
(build-person-selector 'father "id-father" (list) father-request-code))
(mtitle 'children)
(medit-text 'name "normal" (lambda (v) '()))
......@@ -937,12 +971,19 @@
(lambda (activity arg)
(set-current! 'activity-title "Individual geneaology")
(activity-layout activity))
(lambda (activity arg) '())
(lambda (activity arg)
(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 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)
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