From c08b0f589a0deb3fd2ef59086879eabaef7a9e56 Mon Sep 17 00:00:00 2001 From: Jacky Date: Sun, 5 Nov 2017 09:49:58 -0500 Subject: [PATCH 1/4] add isoDateParser to sort the date --- .../com/google/refine/io/FileProjectManager.java | 16 ++++++++++++++++ .../core/scripts/index/open-project-ui.js | 12 +++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/main/src/com/google/refine/io/FileProjectManager.java b/main/src/com/google/refine/io/FileProjectManager.java index beccf4c5a..e56c0f97f 100644 --- a/main/src/com/google/refine/io/FileProjectManager.java +++ b/main/src/com/google/refine/io/FileProjectManager.java @@ -430,6 +430,11 @@ public class FileProjectManager extends ProjectManager { try { 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); @@ -452,6 +457,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; diff --git a/main/webapp/modules/core/scripts/index/open-project-ui.js b/main/webapp/modules/core/scripts/index/open-project-ui.js index 8bb616bdc..c14a3a313 100644 --- a/main/webapp/modules/core/scripts/index/open-project-ui.js +++ b/main/webapp/modules/core/scripts/index/open-project-ui.js @@ -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" } } }); From 9a93ab091d41201c09abc191863b5157e75c6db5 Mon Sep 17 00:00:00 2001 From: Jacky Date: Sun, 5 Nov 2017 10:01:44 -0500 Subject: [PATCH 2/4] prevent overflow of the project index --- .../webapp/modules/core/styles/index/open-project-ui.less | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main/webapp/modules/core/styles/index/open-project-ui.less b/main/webapp/modules/core/styles/index/open-project-ui.less index 170cdc5a8..1244c984f 100644 --- a/main/webapp/modules/core/styles/index/open-project-ui.less +++ b/main/webapp/modules/core/styles/index/open-project-ui.less @@ -87,6 +87,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. opacity: 0.2; } +#projects-container > table { + table-layout: fixed +} + +#projects-container > table > tbody > tr > td { + word-wrap: break-word; +} + #metadata-body tr:nth-child(even) {background: #CCC} #metadata-body tr:nth-child(odd) {background: #FFF} From facffdca3745c31a27ec1016c709062804bdfc8f Mon Sep 17 00:00:00 2001 From: Jacky Date: Sun, 5 Nov 2017 10:20:15 -0500 Subject: [PATCH 3/4] remove sorter arrow for action columns --- main/webapp/modules/core/scripts/index/open-project-ui.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main/webapp/modules/core/scripts/index/open-project-ui.js b/main/webapp/modules/core/scripts/index/open-project-ui.js index c14a3a313..97c95740c 100644 --- a/main/webapp/modules/core/scripts/index/open-project-ui.js +++ b/main/webapp/modules/core/scripts/index/open-project-ui.js @@ -277,6 +277,9 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) { $(table).tablesorter({ headers : { + 0: { sorter: false }, + 1: { sorter: false }, + 2: { sorter: false }, 3 : { sorter : "isoDateParser" } From e958dfc4c25e1de9b6b458acb09842fb23069f73 Mon Sep 17 00:00:00 2001 From: Jacky Date: Sun, 5 Nov 2017 10:41:17 -0500 Subject: [PATCH 4/4] disable editing the internal metadata --- .../scripts/index/edit-metadata-dialog.js | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/main/webapp/modules/core/scripts/index/edit-metadata-dialog.js b/main/webapp/modules/core/scripts/index/edit-metadata-dialog.js index 29aac1fc5..2f85cf1cc 100644 --- a/main/webapp/modules/core/scripts/index/edit-metadata-dialog.js +++ b/main/webapp/modules/core/scripts/index/edit-metadata-dialog.js @@ -14,29 +14,31 @@ function EditMetadataDialog(metaData, targetRowElem) { var td2 = tr.insertCell(2); - $('