-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport-page.ss
70 lines (49 loc) · 2.12 KB
/
report-page.ss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#lang scheme/base
(require "base.ss")
(require (unlib-in string)
"entity-report.ss"
"page-internal.ss")
; Variables --------------------------------------
; (parameter snooze-report%)
(define default-scaffolded-report-superclass
(make-parameter entity-report%))
; Mixins -----------------------------------------
(define entity-report-page-mixin
(mixin/cells (html-element<%> html-page<%>) ()
(inherit get-id)
; Fields ----------------------------
(super-new)
; entity
(init [entity #f])
; (listof attribute)
(init [attributes (and entity (entity-data-attributes entity))])
; snooze-report%
(init-field report
(or (and entity (new (default-scaffolded-report-superclass) [entity entity] [attributes attributes]))
(string-append "entity-report-page constructor: insufficient arguments"))
#:child)
; Methods ---------------------------
; -> entity
(define/public (get-entity)
(send report get-entity))
; -> string
(define/override (get-title)
(or (super get-title)
(string-sentencecase (entity-pretty-name-plural (get-entity)))))
; seed -> xml
(define/augment (render seed)
(send report render seed))))
; Procedures -------------------------------------
; entity [(subclassof html-page%)] [#:attributes (listof attribute)] -> html-page%
(define (scaffold-report-page entity
[page% (default-scaffolded-page-superclass)]
#:attributes [attributes (entity-data-attributes entity)])
(new (entity-report-page-mixin page%) [entity entity] [attributes attributes]))
; Provide statements -----------------------------
(provide entity-report-page-mixin)
(provide/contract
[default-scaffolded-report-superclass (parameter/c (subclass?/c entity-report%))]
[scaffold-report-page (->* (entity?)
((subclass?/c html-page%)
#:attributes (listof attribute?))
(is-a?/c html-page%))])