make field names in the generic detail view look nice
diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-util.js b/planetstack/core/xoslib/static/js/xoslib/xos-util.js
index c1f736e..638ba9a 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xos-util.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xos-util.js
@@ -14,6 +14,17 @@
return s.charAt(0).toUpperCase() + s.slice(1);
}
+function toTitleCase(str)
+{
+ return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
+}
+
+function fieldNameToHumanReadable(str)
+{
+ str = str.replace("_", " ");
+ return toTitleCase(str);
+}
+
// http://stackoverflow.com/questions/2117320/set-maximum-displayed-rows-count-for-html-table
function limitTableRows(tableSelector, maxRows) {
var table = $(tableSelector)[0] //document.getElementById(tableId);
diff --git a/planetstack/core/xoslib/templates/xosAdmin.html b/planetstack/core/xoslib/templates/xosAdmin.html
index c2bf202..8957e03 100644
--- a/planetstack/core/xoslib/templates/xosAdmin.html
+++ b/planetstack/core/xoslib/templates/xosAdmin.html
@@ -105,7 +105,7 @@
<form>
<table>
<% _.each(addFields, function(fieldName) { %>
- <tr><td><%= fieldName %>
+ <tr><td><%= fieldNameToHumanReadable(fieldName) %>:</td>
<% if (fieldName in foreignFields) { %>
<td><%= idToSelect(fieldName, window[fieldName], foreignFields[fieldName], "humanReadableName") %></td>
<% } else if (inputType[fieldName] == "checkbox") { %>
@@ -125,7 +125,7 @@
<form>
<table>
<% console.log(model); _.each(detailFields, function(fieldName) { %>
- <tr><td><%= fieldName %>
+ <tr><td><%= fieldNameToHumanReadable(fieldName) %>:</td>
<% if (fieldName in foreignFields) { %>
<td><%= idToSelect(fieldName, window[fieldName], foreignFields[fieldName], "humanReadableName") %></td>
<% } else if (inputType[fieldName] == "checkbox") { %>