Commit 40a5ffbf authored by Dave Griffiths's avatar Dave Griffiths
Browse files

removed save button - saving all the time

parent 1bbfac8d
...@@ -100,7 +100,10 @@ ...@@ -100,7 +100,10 @@
;; ;;
(begin (begin
(msg "entity-set-value! - adding new " key "of type" type "to entity") (msg "entity-set-value! - adding new " key "of type" type "to entity")
(entity-add-value-create! key type value))))) (entity-add-value-create! key type value)))
;; save straight to local db every time
(entity-update-single-value! (list key type value))
))
(define (date-time->string dt) (define (date-time->string dt)
...@@ -155,6 +158,17 @@ ...@@ -155,6 +158,17 @@
(else (else
(msg "no values or no id to update as entity:" unique-id "values:" values)))))) (msg "no values or no id to update as entity:" unique-id "values:" values))))))
(define (entity-update-single-value! ktv)
(let ((db (get-current 'db #f))
(table (get-current 'table #f))
(unique-id (ktv-get (get-current 'entity-values '()) "unique_id")))
(cond
(unique-id
(update-entity db table (entity-id-from-unique db table unique-id) (list ktv)))
(else
(msg "no values or no id to update as entity:" unique-id "values:" values)))))
(define (entity-reset!) (define (entity-reset!)
(set-current! 'entity-values '()) (set-current! 'entity-values '())
(set-current! 'db "reset") (set-current! 'db "reset")
......
...@@ -328,20 +328,20 @@ ...@@ -328,20 +328,20 @@
(layout 'fill-parent 'fill-parent 1 'centre 0) (layout 'fill-parent 'fill-parent 1 'centre 0)
(list 0 0 0 0) (list 0 0 0 0)
(list (list
(mbutton-scale ; (mbutton-scale
'save ; 'save
(lambda () ; (lambda ()
(list ; (list
(alert-dialog ; (alert-dialog
"ok-check" ; "ok-check"
(mtext-lookup 'save-are-you-sure) ; (mtext-lookup 'save-are-you-sure)
(lambda (v) ; (lambda (v)
(cond ; (cond
((eqv? v 1) ; ((eqv? v 1)
(entity-update-values!) ; (entity-update-values!)
(list)) ; (list))
(else ; (else
(list)))))))) ; (list))))))))
(mbutton-scale 'back (lambda () (list (finish-activity 1)))))) (mbutton-scale 'back (lambda () (list (finish-activity 1))))))
(lambda (fragment arg) (lambda (fragment arg)
(activity-layout fragment)) (activity-layout fragment))
......
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