Aaron E Krohn

Fixed text summary report page

@@ -98,6 +98,7 @@ @@ -98,6 +98,7 @@
98 (let ((uri-params) 98 (let ((uri-params)
99 (c-item-id) 99 (c-item-id)
100 (item-list)) 100 (item-list))
  101 +
101 (setf uri-params (parse-uri-params (request-uri* *REQUEST*))) 102 (setf uri-params (parse-uri-params (request-uri* *REQUEST*)))
102 103
103 (handler-case (setf c-item-id (parse-integer (nth 2 uri-params))) 104 (handler-case (setf c-item-id (parse-integer (nth 2 uri-params)))
@@ -115,15 +116,19 @@ @@ -115,15 +116,19 @@
115 116
116 (setf uri-params (parse-uri-params (request-uri* *REQUEST*))) 117 (setf uri-params (parse-uri-params (request-uri* *REQUEST*)))
117 118
  119 + ;; Ensure argument ID is an integer
118 (handler-case (setf item-id (parse-integer (nth 1 uri-params))) 120 (handler-case (setf item-id (parse-integer (nth 1 uri-params)))
119 (error () (smart-redirect (referer *REQUEST*) "/objectives"))) 121 (error () (smart-redirect (referer *REQUEST*) "/objectives")))
120 122
  123 + ;; Ensure that new priority is an integer
121 (handler-case (setf new-priority (parse-integer (nth 3 uri-params))) 124 (handler-case (setf new-priority (parse-integer (nth 3 uri-params)))
122 (error () (smart-redirect (referer *REQUEST*) "/objectives"))) 125 (error () (smart-redirect (referer *REQUEST*) "/objectives")))
123 126
  127 + ;; Ensure the provided objective ID is valid
124 (handler-case (setf item-obj (action-item-get-by-id item-id)) 128 (handler-case (setf item-obj (action-item-get-by-id item-id))
125 (error () (smart-redirect (referer *REQUEST*) "/objectives"))) 129 (error () (smart-redirect (referer *REQUEST*) "/objectives")))
126 130
  131 + ;; 0 < new-priority < max-priority
127 (if (or 132 (if (or
128 (< new-priority 1) 133 (< new-priority 1)
129 (> new-priority (get-max-priority (parent-id item-obj)))) 134 (> new-priority (get-max-priority (parent-id item-obj))))
@@ -131,13 +136,15 @@ @@ -131,13 +136,15 @@
131 136
132 (setf old-priority (priority item-obj)) 137 (setf old-priority (priority item-obj))
133 138
  139 + ;; Do nothing if old-priority == new-priority
134 (if (equal new-priority old-priority) 140 (if (equal new-priority old-priority)
135 (smart-redirect (referer *REQUEST*) "/objectives")) 141 (smart-redirect (referer *REQUEST*) "/objectives"))
136 142
  143 + ;; I don't know why this is a handler-case
137 (handler-case (setf (priority item-obj) new-priority) 144 (handler-case (setf (priority item-obj) new-priority)
138 (error () (smart-redirect (referer *REQUEST*) "/objectives"))) 145 (error () (smart-redirect (referer *REQUEST*) "/objectives")))
139 146
140 - ;; Set session message for successs/failure 147 + ;; TODO: Set session message for successs/failure
141 (action-item-set-priority item-obj old-priority) 148 (action-item-set-priority item-obj old-priority)
142 (smart-redirect (referer *REQUEST*) "/objectives"))) 149 (smart-redirect (referer *REQUEST*) "/objectives")))
143 150
@@ -155,6 +162,9 @@ Param 1+: Any parameter that is an integer will be selected as @@ -155,6 +162,9 @@ Param 1+: Any parameter that is an integer will be selected as
155 (in-status-types '()) 162 (in-status-types '())
156 (ex-status-types '()) 163 (ex-status-types '())
157 (h-title "Filtered Objectives List")) 164 (h-title "Filtered Objectives List"))
  165 +
  166 + (no-cache)
  167 +
158 (setf uri-params (parse-uri-params (request-uri* *REQUEST*))) 168 (setf uri-params (parse-uri-params (request-uri* *REQUEST*)))
159 (setf status-types (action-item-status-types-list-all)) 169 (setf status-types (action-item-status-types-list-all))
160 (dolist (sti status-types) 170 (dolist (sti status-types)
@@ -300,10 +310,9 @@ Param 1+: Any parameter that is an integer will be selected as @@ -300,10 +310,9 @@ Param 1+: Any parameter that is an integer will be selected as
300 310
301 (redirect (format nil "/objective/~A/view" item-id)))) 311 (redirect (format nil "/objective/~A/view" item-id))))
302 312
303 -(defun project-text-summary-page () 313 +(defun action-items-text-summary-page ()
304 (let ((item-list)) 314 (let ((item-list))
305 -  
306 - (setf item-list (action-items-build-select nil nil '("complete"))) 315 + (setf item-list (action-items-list-tree-by-root 0))
307 (action-items-list-text-view item-list))) 316 (action-items-list-text-view item-list)))
308 317
309 (defun action-item-set-status-data () 318 (defun action-item-set-status-data ()
@@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
44 (create-regex-dispatcher "/objectives/.*" 'action-items-list-filter-page) 44 (create-regex-dispatcher "/objectives/.*" 'action-items-list-filter-page)
45 (create-prefix-dispatcher "/objective/new" 'action-item-create-page) 45 (create-prefix-dispatcher "/objective/new" 'action-item-create-page)
46 (create-prefix-dispatcher "/objective/add" 'action-item-create-data) 46 (create-prefix-dispatcher "/objective/add" 'action-item-create-data)
47 - (create-prefix-dispatcher "/objectives/report" 'action-item-text-summary-page) 47 + (create-prefix-dispatcher "/objectives/report" 'action-items-text-summary-page)
48 48
49 ;; Regex dispatchers 49 ;; Regex dispatchers
50 (create-regex-dispatcher "/objective/(-?\\d+)" 'action-item-view-redirect) 50 (create-regex-dispatcher "/objective/(-?\\d+)" 'action-item-view-redirect)
@@ -39,18 +39,33 @@ @@ -39,18 +39,33 @@
39 (if (eq status :custom) 39 (if (eq status :custom)
40 (htm (:li (:strong "Filtered"))))))) 40 (htm (:li (:strong "Filtered")))))))
41 41
42 -(defun action-items-list-nested-text-view (item-list &optional (root 0) (depth 0)) 42 +(defun action-items-list-nested-text-view (the-list &optional (root 0) (depth 0))
43 (let ((this-list '()) 43 (let ((this-list '())
44 - (the-list-new '())))) 44 + (the-list-new '()))
  45 +
  46 + (dolist (item the-list)
  47 + (if (eq root (parent-id item))
  48 + (push item this-list)
  49 + (push item the-list-new)))
  50 +
  51 + ;; This would be obsolete if I could get the query's ORDER BY correct
  52 + (setf this-list (sort this-list #'< :key 'priority))
  53 +
  54 + (with-html-output-to-string (*standard-output* nil :indent t)
  55 + (htm
  56 + (dolist (item this-list)
  57 + (fmt "~v@{~A~:*~}~A~A. ~A~&" depth " " (priority item) (name item))
  58 + (fmt "~A"
  59 + (action-items-list-nested-text-view
  60 + the-list-new
  61 + (id item)
  62 + (1+ depth))))))))
45 63
46 (defun action-items-list-text-view (item-list) 64 (defun action-items-list-text-view (item-list)
47 (standard-page 65 (standard-page
48 (:title "Activity summary") 66 (:title "Activity summary")
49 (:pre 67 (:pre
50 - (dolist (project proj-list)  
51 - (fmt "~%~A. ~A~%" (priority project) (name project))  
52 - (dolist (task (tasks project))  
53 - (fmt " - ~A~%" (name task))))))) 68 + (fmt "~A" (action-items-list-nested-text-view item-list)))))
54 69
55 (defun action-items-list-nested-view (the-list status-list &optional (root 0)) 70 (defun action-items-list-nested-view (the-list status-list &optional (root 0))
56 (let ((this-list '()) 71 (let ((this-list '())