Commit 7783bb0a authored by Dave Griffiths's avatar Dave Griffiths
Browse files

social fixes and cycle social type

parent 55422843
...@@ -585,29 +585,36 @@ ...@@ -585,29 +585,36 @@
(symbol->string (list-ref l i))) (symbol->string (list-ref l i)))
(define (mupdate-spinner id-symbol key choices) (define (mupdate-spinner id-symbol key choices)
(let* ((val (entity-get-value key)) (let* ((val (entity-get-value key)))
(index (index-find (string->symbol val) choices))) (if (not val)
(if index
(update-widget 'spinner (update-widget 'spinner
(get-id (string-append (symbol->string id-symbol) "-spinner")) (get-id (string-append (symbol->string id-symbol) "-spinner"))
'selection index) 'selection 0)
(begin (let ((index (index-find (string->symbol val) choices)))
(msg "spinner item in db " val " not found in list of items") (if index
(update-widget 'spinner (update-widget 'spinner
(get-id (string-append (symbol->string id-symbol) "-spinner")) (get-id (string-append (symbol->string id-symbol) "-spinner"))
'selection 0))))) 'selection index)
(begin
(msg "spinner item in db " val " not found in list of items")
(update-widget 'spinner
(get-id (string-append (symbol->string id-symbol) "-spinner"))
'selection 0)))))))
(define (mupdate-spinner-other id-symbol key choices) (define (mupdate-spinner-other id-symbol key choices)
(msg "update spinner other...") (let* ((val (dbg (entity-get-value key))))
(let* ((val (entity-get-value key)) (if (not val)
(index (index-find (string->symbol val) choices)))
(if index
(update-widget 'spinner (update-widget 'spinner
(get-id (string-append (symbol->string id-symbol) "-spinner")) (get-id (string-append (symbol->string id-symbol) "-spinner"))
'selection index) 'selection 0)
(update-widget 'edit-text (let ((index (index-find (string->symbol val) choices)))
(get-id (string-append (symbol->string id-symbol) "-edit-text")) (if index
'selection index)))) (update-widget 'spinner
(get-id (string-append (symbol->string id-symbol) "-spinner"))
'selection index)
(update-widget 'edit-text
(get-id (string-append (symbol->string id-symbol) "-edit-text"))
'selection index))))))
;;;; ;;;;
;; (y m d h m s) ;; (y m d h m s)
......
...@@ -417,18 +417,22 @@ ...@@ -417,18 +417,22 @@
(list (start-activity "individual-chooser" request-code "")))))) (list (start-activity "individual-chooser" request-code ""))))))
(define (build-small-person-selector id key filter request-code) (define (build-small-person-selector id key filter request-code)
(vert (linear-layout
(mtitle id) 0 'vertical
(image-view (make-id (string-append (symbol->string id) "-image")) (layout 300 'wrap-content 1 'centre 10)
"face" (layout 120 160 -1 'centre 0)) (list 0 0 0 0)
(mtext-small (string->symbol (string-append (symbol->string id) "-text"))) (list
(button (mtitle id)
(make-id (string-append "change-" (symbol->string id))) (image-view (make-id (string-append (symbol->string id) "-image"))
(mtext-lookup 'change-id) "face" (layout 120 160 -1 'centre 0))
40 (layout 'fill-parent 'wrap-content -1 'centre 5) (mtext-small (string->symbol (string-append (symbol->string id) "-text")))
(lambda () (button
(filter-set! filter) (make-id (string-append "change-" (symbol->string id)))
(list (start-activity "individual-chooser" request-code "")))))) (mtext-lookup 'change-id)
40 (layout 'wrap-content '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 ;; from activity on result with request id: choose-code
...@@ -456,35 +460,41 @@ ...@@ -456,35 +460,41 @@
(update-widget 'image-view id 'external-image (update-widget 'image-view id 'external-image
(string-append dirname "files/" (cadr image-name)))))))) (string-append dirname "files/" (cadr image-name))))))))
(define (build-social-connection id key type request-code) (define (build-social-connection id key type request-code shade)
(let ((id-text (string-append (symbol->string id)))) (let ((id-text (string-append (symbol->string id))))
(horiz (linear-layout
(build-small-person-selector id key (list) request-code) 0 'horizontal
(mspinner-other-vert (layout 'wrap-content 'wrap-content 1 'centre 20)
(string->symbol (string-append id-text "-relationship")) (if shade colour-one colour-two)
'social-relationship (list
social-relationship-list (build-small-person-selector id key (list) request-code)
(lambda (v) (vert
(entity-set-value! (string-append key "-relationship") "varchar" (horiz
(spinner-choice social-relationship-list v)) (mspinner-other-vert
'())) (string->symbol (string-append id-text "-relationship"))
(mspinner-other-vert 'social-relationship
(string->symbol (string-append id-text "-residence")) social-relationship-list
'social-residence (lambda (v)
social-residence-list (entity-set-value! (string-append key "-relationship") "varchar"
(lambda (v) (spinner-choice social-relationship-list v))
(entity-set-value! (string-append key "-residence") "varchar" '()))
(spinner-choice social-residence-list v)) '())) (mspinner-other-vert
(vert (string->symbol (string-append id-text "-residence"))
(text-view 0 (mtext-lookup 'social-strength) 'social-residence
30 (layout 'wrap-content 'wrap-content 1 'centre 10)) social-residence-list
(spinner (lambda (v)
(make-id (dbg (string-append id-text "-strength-spinner"))) (entity-set-value! (string-append key "-residence") "varchar"
(map mtext-lookup social-strength-list) (spinner-choice social-residence-list v)) '())))
(layout 'wrap-content 'wrap-content 1 'centre 0) (vert
(lambda (v) (text-view 0 (mtext-lookup 'social-strength)
(entity-set-value! (string-append key "-strength") "varchar" 30 (layout 'wrap-content 'wrap-content 1 'centre 10))
(spinner-choice social-strength-list v)) '())))))) (spinner
(make-id (dbg (string-append id-text "-strength-spinner")))
(map mtext-lookup social-strength-list)
(layout 'wrap-content 'wrap-content 1 'centre 0)
(lambda (v)
(entity-set-value! (string-append key "-strength") "varchar"
(spinner-choice social-strength-list v)) '()))))))))
(define (social-connection-return request-code key choose-code) (define (social-connection-return request-code key choose-code)
(when (eqv? request-code choose-code) (when (eqv? request-code choose-code)
...@@ -724,13 +734,20 @@ ...@@ -724,13 +734,20 @@
db "sync" 'individuals "individual" "individual" db "sync" 'individuals "individual" "individual"
(lambda () (get-current 'household #f)) (lambda () (get-current 'household #f))
(lambda () (lambda ()
(ktvlist-merge (let ((photo-id (get/inc-setting "photo-id")))
individual-ktvlist (ktvlist-merge
(list (ktv "photo-id" "varchar" individual-ktvlist
(string-append (list
(get-setting-value "user-id") (ktv "photo-id" "varchar"
"-" (string-append
(number->string (get/inc-setting "photo-id")))))))) (get-setting-value "user-id")
"-"
(number->string photo-id)))
(ktv "social-type" "varchar"
(symbol->string
(list-ref social-types-list
(modulo photo-id (length social-types-list)))))
)))))
(delete-button)) (delete-button))
...@@ -1140,8 +1157,6 @@ ...@@ -1140,8 +1157,6 @@
(lambda (activity) '()) (lambda (activity) '())
(lambda (activity) '()) (lambda (activity) '())
(lambda (activity requestcode resultcode) (lambda (activity requestcode resultcode)
(msg "hello!!!")
(msg requestcode)
(person-selector-return requestcode "id-mother" mother-request-code) (person-selector-return requestcode "id-mother" mother-request-code)
(person-selector-return requestcode "id-father" father-request-code) (person-selector-return requestcode "id-father" father-request-code)
'())) '()))
...@@ -1149,18 +1164,21 @@ ...@@ -1149,18 +1164,21 @@
(activity (activity
"social" "social"
(build-activity (build-activity
(mspinner 'social-type social-types-list (lambda (v) (entity-set-value! "social-type" "varchar" (mspinner 'social-type social-types-list
(spinner-choice social-types-list v)) '())) (lambda (v) (entity-set-value!
(build-social-connection 'social-one "social-one" "friend" social-request-code-one) "social-type" "varchar"
(build-social-connection 'social-two "social-two" "friend" social-request-code-two) (spinner-choice social-types-list v)) '()))
(build-social-connection 'social-three "social-three" "friend" social-request-code-three) (build-social-connection 'social-one "social-one" "friend" social-request-code-one #t)
(build-social-connection 'social-four "social-four" "friend" social-request-code-four) (build-social-connection 'social-two "social-two" "friend" social-request-code-two #f)
(build-social-connection 'social-five "social-five" "friend" social-request-code-five) (build-social-connection 'social-three "social-three" "friend" social-request-code-three #t)
(build-social-connection 'social-four "social-four" "friend" social-request-code-four #f)
(build-social-connection 'social-five "social-five" "friend" social-request-code-five #t)
) )
(lambda (activity arg) (lambda (activity arg)
(set-current! 'activity-title "Individual social network") (set-current! 'activity-title "Individual social network")
(activity-layout activity)) (activity-layout activity))
(lambda (activity arg) (lambda (activity arg)
(msg "wooooop")
(append (append
(update-top-bar (entity-get-value "name") (entity-get-value "photo-id")) (update-top-bar (entity-get-value "name") (entity-get-value "photo-id"))
(list (list
......
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