Permalink
Browse files

section data for cubbies, sparks, tnt and misc section bug fixes

  • Loading branch information...
ThomasHintz committed Oct 1, 2011
1 parent d4be630 commit 59f632f626e69a474b0e56554ccc7cc941cc4960
Showing with 137 additions and 35 deletions.
  1. +36 −17 keep-the-records.scm
  2. +94 −18 section.data.scm
  3. +6 −0 sections.scm
  4. +1 −0 storage-funcs.scm
View
@@ -89,7 +89,7 @@
t))
'(("Dashboard") ("Attendance")
;("Awards")
- ("Find") ("Release")))) ;("Sections"))))
+ ("Find") ("Release") ("Sections"))))
((eq? tab 'leaders)
(folds* (lambda (t)
(<a> href: (++ "/" club "/leaders/" (string-downcase t))
@@ -1257,13 +1257,22 @@
(define (next-section club clubber club-level book chapter section)
(next-section-pruned (prune-till-section club clubber club-level book chapter section) club clubber club-level book))
+(define (->html-id s)
+ (string-fold
+ (lambda (c o)
+ (++ o
+ (cond ((char=? #\space c) "-")
+ ((char=? #\: c) "")
+ (#t (->string c)))))
+ "" s))
+
(define-awana-app-page (regexp "/[^/]*/clubbers/sections")
(lambda (path)
(let ((club (get-club path)))
(ajax "clubber-books" 'clubbers '(change keypress)
(lambda ()
(combo-box "change-book" (ad (club-level club ($ 'clubber)) 'book)
- selectedindex: (book club ($ 'clubber)) class: "change-book"
+ selectedindex: (book-index club ($ 'clubber)) class: "change-book"
default: (book club ($ 'clubber))))
; hack to fix apparent bug in combo-box
success: "$('#info-header').html(response); $('#change-book').attr('selectedIndex', $('#change-book').attr('selectedindex'));
@@ -1275,11 +1284,12 @@
(ajax "clubber-sections" 'change-book 'change
(lambda ()
(book club ($ 'clubber) ($ 'book-num))
+ (book-index club ($ 'clubber) ($ 'book-index))
(let* ((clubber ($ 'clubber))
(last (last-section club clubber))
(next (if last (next-section club clubber (first last) (second last) (third last) (fourth last)) #f))
- (chapter (if next (third next) (first (ad (club-level club clubber) (book club clubber) 'chapter))))
- (section (if next (fourth next) (caadar (ad (club-level club clubber) (book club clubber) 'chapter 'section)))))
+ (chapter (if next (if (> (length next) 2) (third next) #f) (first (ad (club-level club clubber) (book club clubber) 'chapter))))
+ (section (if next (if (> (length next) 2) (fourth next) #f) (caadar (ad (club-level club clubber) (book club clubber) 'chapter 'section)))))
`((sections .
,(fold (lambda (chapter/sections o)
(++ o (<span> class: "chapter" (first chapter/sections))
@@ -1290,22 +1300,25 @@
(++ o (<button> type: "button"
class: (++ "mark-section" (if (string=? c-section "") "" " done"))
value: (->string s)
- id: (space->dash (++ (first chapter/sections) "-" s))
- (if (string=? c-section "")
- (->string s)
- c-section)
+ id: (->html-id (++ (first chapter/sections) "-" s))
+ ; no dates for now
+ ;(if (string=? c-section "")
+ ; (->string s)
+ ; c-section)
+ s
(hidden-input 'chapter (first chapter/sections)))
" ")))
"" (second chapter/sections))
(<br>)))
""
(ad (club-level club ($ 'clubber)) ($ 'book) 'chapter 'section)))
- (mark-id . ,(space->dash (++ chapter "-" section)))
- (mark-text . ,(++ chapter " - " section)))))
+ (mark-id . ,(if (and chapter section) (->html-id (++ chapter "-" section)) ""))
+ (mark-text . ,(if (and chapter section) (++ chapter " - " section) "")))))
update-targets: #t
arguments: '((clubber . "$('#clubbers').val()[0]") (book . "$('#change-book').val()")
- (book-num . "$('#change-book').attr('selectedIndex')"))
- success: "$('#sections-container').html(response['sections']); $('#easy-mark').val(response['mark-text']);"
+ (book-num . "$('#change-book').val()") (book-index . "$('#change-book').attr('selected-index')"))
+ success: "$('#sections-container').html(response['sections']);
+ $('#easy-mark').unbind('click').bind('click', function () { $('#' + response['mark-id']).click(); }).val(response['mark-text']);"
method: 'GET
live: #t)
(ajax "mark-section" ".mark-section" 'click
@@ -1316,9 +1329,9 @@
(clubber-section club ($ 'clubber) (club-level club ($ 'clubber))
($ 'book) ($ 'chapter) ($ 'section) (if (string=? c-section "") (date->db (current-date)) ""))
(last-section club ($ 'clubber) (list (club-level club ($ 'clubber)) ($ 'book) ($ 'chapter) ($ 'section)))
- `((text . ,(if (string=? c-section "") (date->db (current-date)) ($ 'section)))
- (next-id . ,(space->dash (++ (third next) "-" (fourth next))))
- (next-title . ,(++ (third next) " - " (fourth next))))))
+ `((text . ,($ 'section)) ;,(if (string=? c-section "") (date->db (current-date)) ($ 'section))) - no date for now
+ (next-id . ,(if (> (length next) 2) (->html-id (++ (third next) "-" (fourth next))) ""))
+ (next-title . ,(if (> (length next) 2) (++ (third next) " - " (fourth next)) "")))))
update-targets: #t
method: 'PUT
live: #t
@@ -1346,9 +1359,15 @@
(<input> type: "text" class: "filter" id: "filter")
(<br>)
(<div> id: "clubbers-c"
+ (let ((c-out
+ (remove (lambda (e)
+ (not (any
+ (lambda (e2) (string=? (club-level club e) e2))
+ '("Cubbies" "Sparks" "TnT"))))
+ (db:list "clubs" club "clubbers"))))
(combo-box "clubbers"
- (zip (db:list "clubs" club "clubbers") (clubbers->names club (db:list "clubs" club "clubbers")))
- class: "clubbers" multiple: #t))))
+ (zip c-out (clubbers->names club c-out))
+ class: "clubbers" multiple: #t)))))
(<div> class: "grid_9" id: "info-container"
(<div> class: "padding column-header" id: "clubber-name" "Clubber Name")
(<div> class: "padding info-header" id: "info-header")
View
@@ -2,30 +2,106 @@
("Hopper Trail" ("1" "2"))
("Lamb Path 1" ("1" "2"))
("Elephant Walk 1" ("1" "2"))
- ("Lamb Path 2" ,(e->s (range 1 3)))
- ("Elephant Walk 2" ,(e->s (range 1 3)))
- ("Lamb Path 3" ,(e->s (range 1 3)))
- ("Elephant Walk 3" ,(e->s (range 1 3)))
- ("Lamb Path 4" ,(e->s (range 1 3)))
- ("Elephant Walk 4" ,(e->s (range 1 3)))
- ("Under the Apple Tree" ,(e->s (range 1 25)))
- ("Character Builder" ,(e->s (range 1 21)))))
- ("Jumper" (("asdf" ("1" "2"))
- ("qwerty" ("1" "2"))))))
- ("Sparks" (("sparks book 1" (("sc1" ("1" "2"))
- ("sc2" ("1" "2" "3"))))
- ("sparks book 2" (("sb1" ("1" "2"))
- ("sb2" ("1" "2"))))))
- ("TnT" ,(cons `("Start Zone" (("Start Zone" ,(e->s (range 1 8)))))
+ ("Lamb Path 2" ,(srange 1 4))
+ ("Elephant Walk 2" ,(srange 1 4))
+ ("Lamb Path 3" ,(srange 1 4))
+ ("Elephant Walk 3" ,(srange 1 4))
+ ("Lamb Path 4" ,(srange 1 4))
+ ("Elephant Walk 4" ,(srange 1 4))
+ ("Under the Apple Tree" ,(srange 1 25))
+ ("Character Builder" ,(srange 1 21))
+ ("Special Hugs" ,(srange 1 7))))
+ ("Jumper" (("Bear Hug Brochure" ("1" "2"))
+ ("Jumper Trail" ("1" "2"))
+ ("Lamb Path 1" ("1" "2"))
+ ("Elephant Walk 1" ("1" "2"))
+ ("Lamb Path 2" ,(srange 1 4))
+ ("Elephant Walk 2" ,(srange 1 4))
+ ("Lamb Path 3" ,(srange 1 4))
+ ("Elephant Walk 3" ,(srange 1 4))
+ ("Lamb Path 4" ,(srange 1 4))
+ ("Elephant Walk 4" ,(srange 1 4))
+ ("Under the Apple Tree" ,(srange 1 25))
+ ("Character Builder" ,(srange 1 21))
+ ("Special Hugs" ,(srange 1 7))))))
+ ("Sparks" (("Flight 3:16" (("Flight 3:16" ,(srange 1 7))))
+ ("HangGlider" (("HangGlider Rank" ,(srange 1 9))
+ ("Red Jewel 1" ,(srange 1 5))
+ ("Green Jewel 1" ,(srange 1 5))
+ ("Red Jewel 2" ,(srange 1 5))
+ ("Green Jewel 2" ,(srange 1 5))
+ ("Red Jewel 3" ,(srange 1 5))
+ ("Green Jewel 3" ,(srange 1 5))
+ ("Red Jewel 4" ,(srange 1 5))
+ ("Green Jewel 4" ,(srange 1 5))
+ ("Review HangGlider Rank" ("1" "3" "4" "5" "6" "7"))
+ ("Review Red Jewel 1" ("2" "3" "4"))
+ ("Review Green Jewel 1" ("2" "3" "4"))
+ ("Review Red Jewel 2" ("2" "3" "4"))
+ ("Review Green Jewel 2" ("4"))
+ ("Review Green Jewel 3" ("1"))
+ ("Review Red Jewel 4" ("2" "3" "4"))
+ ("Review Green Jewel 4" ("2"))
+ ("Return Flight" ,(srange 1 16))
+ ("Takeoff" ,(srange 1 6))
+ ("Passport" ,(srange 1 6))
+ ("Passenger List" ,(srange 1 6))
+ ("Landing Gear" ,(srange 1 6))))
+ ("WingRunner" (("WingRunner Rank" ,(srange 1 9))
+ ("Red Jewel 1" ,(srange 1 5))
+ ("Green Jewel 1" ,(srange 1 5))
+ ("Red Jewel 2" ,(srange 1 5))
+ ("Green Jewel 2" ,(srange 1 5))
+ ("Red Jewel 3" ,(srange 1 5))
+ ("Green Jewel 3" ,(srange 1 5))
+ ("Red Jewel 4" ,(srange 1 5))
+ ("Green Jewel 4" ,(srange 1 5))
+ ("Review WingRunner Rank" ,(append (srange 1 7)) '("8"))
+ ("Review Red Jewel 1" ("2" "3" "4"))
+ ("Review Green Jewel 1" ("1" "2" "3"))
+ ("Review Red Jewel 2" ("3"))
+ ("Review Green Jewel 2" ("3" "4"))
+ ("Review Green Jewel 3" ("4"))
+ ("Review Red Jewel 4" ,(srange 1 5))
+ ("Review Green Jewel 4" ("1" "2"))
+ ("Return Flight" ,(srange 1 16))
+ ("Takeoff" ,(srange 1 6))
+ ("Passport" ,(srange 1 6))
+ ("Passenger List" ,(srange 1 6))
+ ("Landing Gear" ,(srange 1 6))))
+ ("SkyStormer" (("SkyStormer Rank" ,(srange 1 9))
+ ("Red Jewel 1" ,(srange 1 5))
+ ("Green Jewel 1" ,(srange 1 5))
+ ("Red Jewel 2" ,(srange 1 5))
+ ("Green Jewel 2" ,(srange 1 5))
+ ("Red Jewel 3" ,(srange 1 5))
+ ("Green Jewel 3" ,(srange 1 5))
+ ("Red Jewel 4" ,(srange 1 5))
+ ("Green Jewel 4" ,(srange 1 5))
+ ("Review SkyStormer Rank" ,(srange 1 8))
+ ("Review Red Jewel 1" ,(srange 1 5))
+ ("Review Green Jewel 1" ,(srange 1 5))
+ ("Review Red Jewel 2" ,(srange 1 5))
+ ("Review Green Jewel 2" ,(srange 1 5))
+ ("Review Red Jewel 3" ,(srange 1 5))
+ ("Review Green Jewel 3" ,(srange 1 5))
+ ("Review Red Jewel 4" ,(srange 1 5))
+ ("Review Green Jewel 4" ,(srange 1 5))
+ ("Return Flight" ,(srange 1 16))
+ ("Takeoff" ,(srange 1 6))
+ ("Passport" ,(srange 1 6))
+ ("Passenger List" ,(srange 1 6))
+ ("Landing Gear" ,(srange 1 6))))))
+ ("TnT" ,(cons `("Start Zone" (("Start Zone" ,(srange 1 8))))
(map (lambda (book-n)
`(,(string-append "Book " (number->string book-n))
,(append (map (lambda (discovery-n)
`(,(string-append "Discovery " (number->string discovery-n)) ,(map (lambda (e) (number->string e)) (range 1 8))))
- (range 1 8))
+ (range 1 9))
(map (lambda (silver-n)
`(,(string-append "Silver " (number->string silver-n)) ("1")))
- (range 1 8))
+ (range 1 9))
(map (lambda (gold-n)
`(,(string-append "Gold " (number->string gold-n)) ("1" "2")))
- (range 1 8)))))
+ (range 1 9)))))
(range 1 5))))))
View
@@ -1,4 +1,10 @@
(define (e->s l)
(map (cut number->string <>) l))
+(define (srange from/to . to)
+ (e->s
+ (if (empty? to)
+ (range from/to)
+ (range from/to (car to)))))
+
(define section-data (make-parameter (with-input-from-file "section.data.scm" (lambda () (eval (read))))))
View
@@ -152,6 +152,7 @@
(db-club-clubber primary-parent "primary-parent" "")
(db-club-clubber total-points "total-points" 0)
(db-club-clubber book "book" 0)
+(db-club-clubber book-index "book-index" 0)
(db-club-clubber last-section "last-section" #f)
(db-club-clubber date-registered "date-registered" "09/01/10") ; mm/dd/yy
(db-club-clubber thank-you "thank-you" #f)

0 comments on commit 59f632f

Please sign in to comment.