add isoDateParser to sort the date

This commit is contained in:
Jacky 2017-11-05 09:49:58 -05:00
parent a39ee108ac
commit c08b0f589a
2 changed files with 27 additions and 1 deletions

View File

@ -431,6 +431,11 @@ public class FileProjectManager extends ProjectManager {
boolean found = false;
JSONObject placeHolderJsonObj = userMetadataPreference.getJSONObject(index);
if (!isValidUserMetaDataDefinition(placeHolderJsonObj)) {
logger.warn("Skipped invalid user metadata definition" + placeHolderJsonObj.toString());
continue;
}
for (int i = 0; i < jsonObjArray.length(); i++) {
JSONObject jsonObj = jsonObjArray.getJSONObject(i);
if (jsonObj.getString("name").equals(placeHolderJsonObj.getString("name"))) {
@ -453,6 +458,17 @@ public class FileProjectManager extends ProjectManager {
}
}
/**
* A valid user meta data definition should have name and display property
* @param placeHolderJsonObj
* @return
*/
private boolean isValidUserMetaDataDefinition(JSONObject placeHolderJsonObj) {
return (placeHolderJsonObj != null &&
placeHolderJsonObj.has("name") &&
placeHolderJsonObj.has("display"));
}
protected void recover() {
boolean recovered = false;
for (File file : _workspaceDir.listFiles()) {

View File

@ -264,11 +264,21 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
renderProject(projects[i]);
}
$.tablesorter.addParser({
id: "isoDateParser",
is: function(s) {
return (/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}T\d{2}:\d{2}:\d{2}[\+,\-\.]\d{3}/).test(s);
},
format: function(s, table) {
return $.tablesorter.formatFloat((s !== "") ? (new Date(s).getTime() || "") : "", table);
},
type: "numeric"
});
$(table).tablesorter({
headers : {
3 : {
sorter : "time"
sorter : "isoDateParser"
}
}
});