diff --git a/productMods/css/visualization/mapofscience/layout.css b/productMods/css/visualization/mapofscience/layout.css index 1cf098fa..787468f4 100644 --- a/productMods/css/visualization/mapofscience/layout.css +++ b/productMods/css/visualization/mapofscience/layout.css @@ -232,4 +232,9 @@ a.map-of-science-links { #noPublications-span a { color: #84a655; font-size:16px; +} + +ul.error-list li { + font-size: 0.81em; + list-style: disc inside none; } \ No newline at end of file diff --git a/productMods/js/visualization/mapofscience/ErrorDisplayWidget.js b/productMods/js/visualization/mapofscience/ErrorDisplayWidget.js new file mode 100644 index 00000000..1959505e --- /dev/null +++ b/productMods/js/visualization/mapofscience/ErrorDisplayWidget.js @@ -0,0 +1,100 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +var ErrorDisplayWidget = Class.extend({ + + container: '', + body: '', + bodyID: 'error-body', + messagePlaceholderID: 'variable-error-text', + + init: function(opts) { + + this.container = $("#" + opts.containerID); + this.body = this.container.find("#" + this.bodyID); + }, + + isErrorConditionTriggered: function(responseData) { + + if (responseData.error) { + return true; + } + + if (responseData[0].pubsMapped === 0) { + return true; + } + + return false; + }, + + show: function(errorForType, responseData) { + + var isZeroPublicationsCase = responseData.error ? true : false; + var newErrorMessage = ""; + + /* + * This means that the organization or person has zero publications. + * */ + if (isZeroPublicationsCase) { + + newErrorMessage += "No publications in the system have been attributed to this " + errorForType.toLowerCase() + "."; + + } else { + /* + * This means that the organization or person has publications but none of them are mapped. + * Change the default text. + * */ + newErrorMessage += this._getUnScienceLocatedErrorMessage(errorForType, responseData[0]); + } + + /* + * Now replace the error message with the newly created one. + * */ + this.body.find("#" + this.messagePlaceholderID).html(newErrorMessage); + + this.container.show(); + }, + + _getUnScienceLocatedErrorMessage: function(errorForType, responseData) { + + var totalPublications = responseData.pubsWithNoJournals + responseData.pubsWithInvalidJournals; + var newErrorMessage = ""; + + if (totalPublications > 1) { + newErrorMessage = "None of the " + totalPublications + " publications attributed to this " + + errorForType.toLowerCase() + " have been 'science-located'."; + + } else { + newErrorMessage = "The publication attributed to this " + + errorForType.toLowerCase() + " has not been 'science-located'."; + } + + + newErrorMessage += "
This organization has neither sub-organizations nor people with publications in the system. - Please visit the full ${entityLabel} profile page for a more complete overview.
+No publications in the system have been attributed to this organization.