Merge pull request #1333 from jackyq2015/feature/metadata
check if the project has the userMetadata
This commit is contained in:
commit
43b6cb8001
@ -414,7 +414,7 @@ public class WikitextImporter extends TabularImportingParserBase {
|
||||
} else if ("name".equals(currentXmlAttr)) {
|
||||
currentReferenceName = xmlAttrStringBuilder.toString();
|
||||
}
|
||||
} catch (NumberFormatException _) {
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
currentXmlAttr = null;
|
||||
xmlAttrStringBuilder = null;
|
||||
@ -425,7 +425,7 @@ public class WikitextImporter extends TabularImportingParserBase {
|
||||
try {
|
||||
currentXmlAttr = e.getAsString();
|
||||
|
||||
} catch (UnsupportedOperationException _) {
|
||||
} catch (UnsupportedOperationException soe) {
|
||||
currentXmlAttr = null;
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ public class StandardReconConfig extends ReconConfig {
|
||||
job.text = query;
|
||||
job.code = stringWriter.toString();
|
||||
return job;
|
||||
} catch (JSONException _) {
|
||||
} catch (JSONException je) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -508,6 +508,7 @@ function init() {
|
||||
"externals/imgareaselect/jquery.imgareaselect.js",
|
||||
"externals/date.js",
|
||||
"externals/jquery.i18n.js",
|
||||
"externals/underscore-min.js",
|
||||
"scripts/preferences.js",
|
||||
]
|
||||
);
|
||||
|
@ -108,19 +108,22 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
|
||||
var project = data.projects[n];
|
||||
project.id = n;
|
||||
project.date = moment(project.modified).format('YYYY-MM-DD HH:mm A');
|
||||
for (var n in data.customMetadataColumns) {
|
||||
var found = false;
|
||||
for(var i = 0; i < project.userMetadata.length; i++) {
|
||||
if (project.userMetadata[i].name === data.customMetadataColumns[n].name) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if (!found) {
|
||||
project.userMetadata.push({
|
||||
name: data.customMetadataColumns[n].name,
|
||||
dispay: data.customMetadataColumns[n].display,
|
||||
value: ""
|
||||
});
|
||||
|
||||
if (typeof project.userMetadata !== "undefined") {
|
||||
for (var n in data.customMetadataColumns) {
|
||||
var found = false;
|
||||
for(var i = 0; i < project.userMetadata.length; i++) {
|
||||
if (project.userMetadata[i].name === data.customMetadataColumns[n].name) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if (!found) {
|
||||
project.userMetadata.push({
|
||||
name: data.customMetadataColumns[n].name,
|
||||
dispay: data.customMetadataColumns[n].display,
|
||||
value: ""
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,13 @@ dictionary = data;
|
||||
$.i18n.setDictionary(dictionary);
|
||||
//End internationalization
|
||||
|
||||
function deDupUserMetaData(arrObj) {
|
||||
var result = _.uniq(JSON.parse(arrObj), function(x){
|
||||
return x.name;
|
||||
});
|
||||
|
||||
return JSON.stringify(result).replace(/"/g, '\"');
|
||||
}
|
||||
|
||||
function PreferenceUI(tr, key, value) {
|
||||
var self = this;
|
||||
@ -65,7 +72,11 @@ function PreferenceUI(tr, key, value) {
|
||||
$('<button class="button">').text($.i18n._('core-index')["edit"]).appendTo(td2).click(function() {
|
||||
var newValue = window.prompt($.i18n._('core-index')["change-value"]+" " + key, value);
|
||||
if (newValue !== null) {
|
||||
if (key === "userMetadata") {
|
||||
newValue = deDupUserMetaData(newValue);
|
||||
}
|
||||
$(td1).text(newValue);
|
||||
|
||||
$.post(
|
||||
"command/core/set-preference",
|
||||
{
|
||||
@ -137,7 +148,11 @@ function populatePreferences(prefs) {
|
||||
if (value !== null) {
|
||||
var tr = table.insertRow(table.rows.length - 1);
|
||||
preferenceUIs.push(new PreferenceUI(tr, key, value));
|
||||
|
||||
|
||||
if (key === "userMetadata") {
|
||||
value = deDupUserMetaData(value);
|
||||
}
|
||||
|
||||
$.post(
|
||||
"command/core/set-preference",
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
}
|
||||
|
||||
#metadata-body td {
|
||||
padding: 8px
|
||||
padding: 1px
|
||||
}
|
||||
|
||||
#metadata-body tr:nth-child(even) {background: #f2f2f2}
|
||||
|
Loading…
Reference in New Issue
Block a user