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

social fixes and cycle social type

parent 55422843
...@@ -585,8 +585,12 @@ ...@@ -585,8 +585,12 @@
(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)
(update-widget 'spinner
(get-id (string-append (symbol->string id-symbol) "-spinner"))
'selection 0)
(let ((index (index-find (string->symbol val) choices)))
(if index (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"))
...@@ -595,19 +599,22 @@ ...@@ -595,19 +599,22 @@
(msg "spinner item in db " val " not found in list of items") (msg "spinner item in db " val " not found in list of items")
(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 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))) (update-widget 'spinner
(get-id (string-append (symbol->string id-symbol) "-spinner"))
'selection 0)
(let ((index (index-find (string->symbol val) choices)))
(if index (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 index)
(update-widget 'edit-text (update-widget 'edit-text
(get-id (string-append (symbol->string id-symbol) "-edit-text")) (get-id (string-append (symbol->string id-symbol) "-edit-text"))
'selection index)))) 'selection index))))))
;;;; ;;;;
;; (y m d h m s) ;; (y m d h m s)
......
...@@ -417,7 +417,11 @@ ...@@ -417,7 +417,11 @@
(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
0 'vertical
(layout 300 'wrap-content 1 'centre 10)
(list 0 0 0 0)
(list
(mtitle id) (mtitle id)
(image-view (make-id (string-append (symbol->string id) "-image")) (image-view (make-id (string-append (symbol->string id) "-image"))
"face" (layout 120 160 -1 'centre 0)) "face" (layout 120 160 -1 'centre 0))
...@@ -425,10 +429,10 @@ ...@@ -425,10 +429,10 @@
(button (button
(make-id (string-append "change-" (symbol->string id))) (make-id (string-append "change-" (symbol->string id)))
(mtext-lookup 'change-id) (mtext-lookup 'change-id)
40 (layout 'fill-parent 'wrap-content -1 'centre 5) 40 (layout 'wrap-content 'wrap-content -1 'centre 5)
(lambda () (lambda ()
(filter-set! filter) (filter-set! filter)
(list (start-activity "individual-chooser" request-code "")))))) (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,10 +460,16 @@ ...@@ -456,10 +460,16 @@
(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
0 'horizontal
(layout 'wrap-content 'wrap-content 1 'centre 20)
(if shade colour-one colour-two)
(list
(build-small-person-selector id key (list) request-code) (build-small-person-selector id key (list) request-code)
(vert
(horiz
(mspinner-other-vert (mspinner-other-vert
(string->symbol (string-append id-text "-relationship")) (string->symbol (string-append id-text "-relationship"))
'social-relationship 'social-relationship
...@@ -474,7 +484,7 @@ ...@@ -474,7 +484,7 @@
social-residence-list social-residence-list
(lambda (v) (lambda (v)
(entity-set-value! (string-append key "-residence") "varchar" (entity-set-value! (string-append key "-residence") "varchar"
(spinner-choice social-residence-list v)) '())) (spinner-choice social-residence-list v)) '())))
(vert (vert
(text-view 0 (mtext-lookup 'social-strength) (text-view 0 (mtext-lookup 'social-strength)
30 (layout 'wrap-content 'wrap-content 1 'centre 10)) 30 (layout 'wrap-content 'wrap-content 1 'centre 10))
...@@ -484,7 +494,7 @@ ...@@ -484,7 +494,7 @@
(layout 'wrap-content 'wrap-content 1 'centre 0) (layout 'wrap-content 'wrap-content 1 'centre 0)
(lambda (v) (lambda (v)
(entity-set-value! (string-append key "-strength") "varchar" (entity-set-value! (string-append key "-strength") "varchar"
(spinner-choice social-strength-list v)) '())))))) (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 ()
(let ((photo-id (get/inc-setting "photo-id")))
(ktvlist-merge (ktvlist-merge
individual-ktvlist individual-ktvlist
(list (ktv "photo-id" "varchar" (list
(ktv "photo-id" "varchar"
(string-append (string-append
(get-setting-value "user-id") (get-setting-value "user-id")
"-" "-"
(number->string (get/inc-setting "photo-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
(lambda (v) (entity-set-value!
"social-type" "varchar"
(spinner-choice social-types-list v)) '())) (spinner-choice social-types-list v)) '()))
(build-social-connection 'social-one "social-one" "friend" social-request-code-one) (build-social-connection 'social-one "social-one" "friend" social-request-code-one #t)
(build-social-connection 'social-two "social-two" "friend" social-request-code-two) (build-social-connection 'social-two "social-two" "friend" social-request-code-two #f)
(build-social-connection 'social-three "social-three" "friend" social-request-code-three) (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) (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) (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