diff --git a/lib/common/rules.js b/lib/common/rules.js index d7ee6db..218fc6b 100644 --- a/lib/common/rules.js +++ b/lib/common/rules.js @@ -26,6 +26,11 @@ var NEXA_RULES = { } return false; }, + explanation: { + 1.0: "one of: acceptance, publication", + 2.0: "embargo ok for both HUSS and STEM", + false: "not one of acceptance, publication or embargo too long", + }, guidelines: 3.14, gmga: "29.2.2.b", }, @@ -70,6 +75,9 @@ var NEXA_RULES = { }, guidelines: [3.5, 3.13, 3.15], gmga: "29.2.2.b", + explanation: { + true: "any value is ok", + }, normalize: function (v) { return ( ((v === "reccomended") ? "recommended" : @@ -112,6 +120,11 @@ var NEXA_RULES = { }, guidelines: 3.14, gmga: "29.2.2.b", + explanation: { + true: "one of: no, not_specified", + 0.25: "is yes (but see caveats)", + false: "not one of: no, not_specified, yes", + }, fuzzyLabels: { 0.25: "Please note that European Commission does not " + "expressly state that maximal embargo cannot be " + @@ -129,6 +142,11 @@ var NEXA_RULES = { (v === "no") ? 0.75 : (v === "yes") ? 0.25 : false ); }, + explanation: { + 0.75: "is 'no'", + 0.25: "is 'yes'", + false: "is neither 'no' nor 'yes'", + }, gmga: ["29.1.1", "29.1.2"], fuzzyLabels: { 0.75: "However, please note that Open Access must be " + @@ -154,6 +172,10 @@ var NEXA_RULES = { value.indexOf("not_specified") < 0 ); }, + explanation: { + true: "not 'not_specified'", + false: "'not_specified'", + }, guidelines: [3.1, 3.3, 3.4, 3.11], gmga: ["29.2.1", "29.2.2.a.2"], }, @@ -162,16 +184,27 @@ var NEXA_RULES = { var evaluateRule = function (rule, record, key, value) { var compliantValues = rule.compliantValues, initialExpr = compliantValues; - var compliant = ((typeof compliantValues === "string" && - value === compliantValues) || - (compliantValues instanceof Array && - compliantValues.indexOf(value) >= 0) || - (compliantValues instanceof Function && - compliantValues(value, record, key))); + var compliant; + var reason; + if (typeof compliantValues === "string") { + compliant = (value === compliantValues); + reason = ((!compliant) ? "not " : "") + "equal to " + + "'" + compliantValues + "'"; + } else if (compliantValues instanceof Array) { + compliant = (compliantValues.indexOf(value) >= 0); + reason = ((!compliant) ? "not " : "") + "one of: " + + compliantValues.join(", "); + } else if (compliantValues instanceof Function) { + compliant = compliantValues(value, record, key); + reason = rule.explanation[compliant]; + } else { + throw "Programmer error"; + } return { clause: compliantValues, expr: initialExpr, fuzzyLabel: (rule.fuzzyLabels && rule.fuzzyLabels[compliant]), + reason: reason, value: compliant }; }; @@ -186,6 +219,7 @@ var apply = exports.apply = function (record) { newRecord.push({ field_id: rule.field_id, field: key, + reason: compliantRec.reason, value: (function () { return (rule.normalize && rule.normalize(value)); })() || value, diff --git a/static/app.css b/static/app.css index bdeea83..6e67a26 100644 --- a/static/app.css +++ b/static/app.css @@ -11,3 +11,11 @@ tr:nth-child(even) { tr:hover { background-color: #f3f781 } + +td.compliant-true { + color: #228B22 +} + +td.compliant-false { + color: #FF0000 +} diff --git a/static/partials/institution.html b/static/partials/institution.html index 1c0e3d7..84c1d5a 100644 --- a/static/partials/institution.html +++ b/static/partials/institution.html @@ -9,25 +9,40 @@ (roarmap url) (policy maker url) (repository url) - (policy url)

+ (policy url)
+ compliance: {{g.selected.percentage|number:2}}%

- + + + + + + + + + + + + + + + + + + + + + + +
#fieldvalueis-compliantreasoncaveatsguidelinesgmga
{{entry.field_id}}{{entry.field}}{{entry.value}}{{entry.is_compliant}}{{entry.reason}}{{entry.fuzzy_label}} + + [{{ref}}] + + + + [{{ref}}] + +