Merge pull request #1311 from jackyq2015/master

some bug fix for #1221
This commit is contained in:
Jacky 2017-11-05 10:48:30 -05:00 committed by GitHub
commit 4c1ea97c92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 24 deletions

View File

@ -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;

View File

@ -14,29 +14,31 @@ function EditMetadataDialog(metaData, targetRowElem) {
var td2 = tr.insertCell(2);
$('<button class="button">').text($.i18n._('core-index')["edit"]).appendTo(td2).click(function() {
var newValue = window.prompt($.i18n._('core-index')["change-metadata-value"]+" " + key, value);
if (newValue !== null) {
$(td1).text(newValue);
metaData[key] = newValue;
$.post(
"command/core/set-metaData",
{
project : project,
name : key,
value : newValue
},
function(o) {
if (o.code === "error") {
alert(o.message);
}
},
"json"
);
}
Refine.OpenProjectUI.refreshProject(targetRowElem, metaData);
});
if (key !== "modified" && key !== "rowNumber" && key !== "importOptionMetaData" && key !== "id") {
$('<button class="button">').text($.i18n._('core-index')["edit"]).appendTo(td2).click(function() {
var newValue = window.prompt($.i18n._('core-index')["change-metadata-value"]+" " + key, value);
if (newValue !== null) {
$(td1).text(newValue);
metaData[key] = newValue;
$.post(
"command/core/set-metaData",
{
project : project,
name : key,
value : newValue
},
function(o) {
if (o.code === "error") {
alert(o.message);
}
},
"json"
);
}
Refine.OpenProjectUI.refreshProject(targetRowElem, metaData);
});
}
};
this._createDialog();

View File

@ -264,11 +264,24 @@ 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 : {
0: { sorter: false },
1: { sorter: false },
2: { sorter: false },
3 : {
sorter : "time"
sorter : "isoDateParser"
}
}
});

View File

@ -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}