Skip to content

Commit

Permalink
Datetime improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
schallis committed Oct 4, 2011
1 parent 22a21a3 commit 0b80e04
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 10 deletions.
3 changes: 2 additions & 1 deletion project.clj
@@ -1,6 +1,7 @@
(defproject house-the-homeless "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.2.1"]
[noir "1.1.1-SNAPSHOT"]]
[noir "1.1.1-SNAPSHOT"]
[clj-time "0.3.1"]]
:dev-dependencies [[appengine-magic "0.4.3"]]
:appengine-app-versions {"house-the-homeless" "1"})
23 changes: 17 additions & 6 deletions src/house_the_homeless/routes.clj
@@ -1,4 +1,5 @@
(ns house-the-homeless.routes
(:refer-clojure :exclude (extend))
(:use [noir.core :only [defpartial defpage render]]
[hiccup.core :only [html]]
[hiccup.page-helpers :only [link-to html5 include-css ordered-list
Expand All @@ -10,7 +11,9 @@
[house-the-homeless.utils]
[house-the-homeless.templates]
[house-the-homeless.clients]
[house-the-homeless.codes])
[house-the-homeless.codes]
[clj-time.core]
[clj-time.format])
(:require [noir.response :as resp]
[noir.validation :as vali]
[noir.session :as sess]
Expand All @@ -28,6 +31,14 @@
;; TEST client pages (non-valid inputs)q
;; TEST invalid codes (strings, integers, string-ints, symbols)

(def date-user (formatter "dd/MM/yy"))
(def date-storage (formatter "dd/MM/yy"))

(defn date-to-user [date]
(unparse date-user (parse date-storage date)))
(defn date-to-storage [date]
(unparse date-storage (parse date-user date)))

(ds/defentity Code [^:key content redeemed])
(ds/defentity Event [^:key content
date])
Expand Down Expand Up @@ -305,9 +316,9 @@
[:td (:client-id %)]])
stays)]])))))

(defpage "/stays/tonight" []
(defpage "/calendar" []
(admin-only
(layout "Staying Tonight"
(layout "Calendar"
(let [stays (get-stays)]
(html
[:table.tabular
Expand All @@ -331,7 +342,7 @@
(if client
(and
(ds/save! (Stay.
(:date form)
(unparse date-storage (parse date-user (:date form)))
(:status form)
(:notes form)
int-id))
Expand Down Expand Up @@ -378,7 +389,7 @@
[:tbody
(map
#(html [:tr
[:td (:date %)]
[:td (date-to-user (:date %))]
[:td (link-to "#" (:status %))]
]) stays)]])]
[:div#newstay
Expand Down Expand Up @@ -432,7 +443,7 @@
(:code form)
(:firstname form)
(:lastname form)
(:dob form)
(date-to-storage (:dob form))
(:ethnicity form)
(:nationality form)
(:notes form)
Expand Down
6 changes: 4 additions & 2 deletions src/house_the_homeless/templates.clj
Expand Up @@ -26,7 +26,7 @@
(html
[:li "Shelter log"
[:ul
[:li (link-to "/stays/tonight" "Tonight")]
[:li (link-to "/calendar" "Calendar")]
[:li (link-to "/stays" "All Stays")]
[:li (link-to "/reports" "Reports")]]]
[:li "Codes"
Expand Down Expand Up @@ -75,8 +75,10 @@
[:title (str title " - House the Homeless")]
(include-css "/css/reset.css")
(include-css "/css/main.css")
(include-css "/css/dark-hive/jquery-ui-1.8.16.custom.css")
(include-js "/js/jquery-1.4.2.min.js")
(include-js "/js/jquery-ui-1.8.1.custom.min.js")
(include-js "/js/jquery.ui.datepicker-en-GB.js")
(include-js "/js/jquery.address-1.3.min.js")
(include-js "/js/jquery.dataTables.min.js")
(include-js "/js/main.js")
Expand Down Expand Up @@ -117,7 +119,7 @@
[:div#main
[:h2 "Hi There"]
[:p "You must login with a Google or OpenID account to continue."]
[:p "If you are unable to login, please <a href="#">register</a> for a new account."]])]))
[:p "If you are unable to login, please <a href=\"https://accounts.google.com/NewAccount\">register</a> for a new account."]])]))

(defpartial error-item [[first-error]]
[:p.error first-error])
23 changes: 22 additions & 1 deletion war/css/main.css
Expand Up @@ -151,7 +151,6 @@ label {
}

form select {
font-size: 1.25em;
line-height: 4em;
vertical-align: middle;
width: 280px;
Expand Down Expand Up @@ -291,3 +290,25 @@ thead .sorting_asc, thead .sorting_desc {
.even > .sorting_1 {
background: #f0f0f0;
}

.dataTables_scrollHead {
clear: both;
}

.ui-datepicker {
background: #fff;
display: block;
border: 1px solid #ddd;
border-radius: 5px;
padding: 5px;
display: none;
}

.ui-datepicker-calendar tr td {
border: 1px solid #ddd;
padding: 3px;
}

.ui-datepicker-next {
float: right;
}
23 changes: 23 additions & 0 deletions war/js/jquery.ui.datepicker-en-GB.js
@@ -0,0 +1,23 @@
/* English/UK initialisation for the jQuery UI date picker plugin. */
/* Written by Stuart. */
jQuery(function($){
$.datepicker.regional['en-GB'] = {
closeText: 'Done',
prevText: 'Prev',
nextText: 'Next',
currentText: 'Today',
monthNames: ['January','February','March','April','May','June',
'July','August','September','October','November','December'],
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'],
weekHeader: 'Wk',
dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['en-GB']);
});
3 changes: 3 additions & 0 deletions war/js/main.js
Expand Up @@ -4,6 +4,9 @@ window.hth = {
this.setupBrowseTabs();
this.animateFlash();
this.setupDatatables();
$.datepicker.setDefaults( $.datepicker.regional[ "en-GB" ] );
$('#date').datepicker();
$('#dob').datepicker();
},
setupBrowseTabs: function(event) {
$('#uitabs').tabs({
Expand Down

0 comments on commit 0b80e04

Please sign in to comment.