Skip to content

Instantly share code, notes, and snippets.

@shafirov
Created September 6, 2013 19:05
Show Gist options
  • Save shafirov/6468439 to your computer and use it in GitHub Desktop.
Save shafirov/6468439 to your computer and use it in GitHub Desktop.
Somewhat boring part of business app's UI. Take note of handling optional order's date though
fun HtmlBodyTag.shortOrdersList(customer: CustomerProfile) {
val orders = customer.orders.toList().sortBy { -(it.date?.getMillis()?:0.toLong()) }
table(s("table table-striped table-condensed")) {
for (order in orders.take(5)) {
tr {
td {
order.date?.let {
small {
+DateTimeFormat.forPattern("dd/MM/yy").print(it)!!
}
}
}
td {
small {
+order.orderRef
}
}
td {
small(pull_right) {
+order.totalAmount.displayText()
}
}
}
}
}
if (orders.size() > 5) {
small {
a {
href=CustomerRoutes.ViewOrdersRoute(customer.id)
+"View"
}
+" all ${orders.size} orders"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment