diff --git a/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js b/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js index 2e3f3e6b30009722acb4ff6c8ed1c840475a702b..7c0aa87ea1931b6fed39e5f8e8535866bad17437 100644 --- a/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js +++ b/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js @@ -436,6 +436,56 @@ GuiUtils.prototype.createAnnotationList = function (annotations, options) { return result; }; +/** + * + * @param {Author[]} authors + * @returns {HTMLElement} + */ +GuiUtils.prototype.createAuthorsList = function (authors) { + var self = this; + var result = Functions.createElement({type: "div", className: "minerva-annotation-group"}); + + for (var i = 0; i < authors.length; i++) { + var author = authors[i]; + var row = document.createElement("div"); + if (i % 2 === 0) { + row.className = "minerva-annotation-row-odd"; + } else { + row.className = "minerva-annotation-row-even"; + } + + row.appendChild(Functions.createElement({ + type: "div", + className: "minerva-annotation-counter", + content: "[" + (i + 1) + "]" + })); + + var body = Functions.createElement({ + type: "div", + className: "minerva-annotation-body" + }); + + var desc = author.firstName + " " + author.lastName; + + var link; + if (author.email !== undefined) { + link = Functions.createElement({type: "a", href: "mailto:" + author.email, content: desc}); + } else { + link = Functions.createElement({type: "span", content: desc}); + } + body.appendChild(link); + + if (author.organisation !== undefined) { + body.appendChild(Functions.createElement({type: "span", content: ", " + author.organisation})); + } + + row.appendChild(body); + result.appendChild(row); + } + + return result; +}; + /** * * @param {string} [value] diff --git a/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js b/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js index 2f40e5d36b8938aa586bdc7c3c86d3add0b7de53..4c61b833f0c665c2eaba220ceb8477ab2db4ba1c 100644 --- a/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js @@ -221,6 +221,20 @@ ProjectInfoPanel.prototype._createInfoPanelGui = function () { referencesTab.appendChild(guiUtils.createAnnotationList(self.getProject().getModels()[0].getReferences(), {groupAnnotations: false})); } + if (self.getProject().getModels()[0].getAuthors().length > 0) { + var authorsTab = Functions.createElement({ + type: "div" + }); + infoDiv.appendChild(authorsTab); + + var authors = Functions.createElement({ + type: "h4", + content: 'Authors:' + }); + authorsTab.appendChild(authors); + authorsTab.appendChild(guiUtils.createAuthorsList(self.getProject().getModels()[0].getAuthors())); + } + }; diff --git a/frontend-js/src/main/js/gui/leftPanel/SubmapPanel.js b/frontend-js/src/main/js/gui/leftPanel/SubmapPanel.js index 1518437ae5ee06c7b36a3d445df6da8b0845358e..150c09f77133a1f6aebb220e8b1dfdf941203590 100644 --- a/frontend-js/src/main/js/gui/leftPanel/SubmapPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/SubmapPanel.js @@ -64,19 +64,30 @@ SubmapPanel.prototype.createRow = function (model) { var nameTd = Functions.createElement({type: "td", content: model.getName(), style: "position:relative"}); - if (model.getReferences().length > 0) { + if (model.getReferences().length > 0 || model.getAuthors().length > 0) { var referencesTab = Functions.createElement({ type: "div", className: "minerva-search-data-hidden" }); nameTd.appendChild(referencesTab); - var references = Functions.createElement({ - type: "div", - content: 'References:' - }); - referencesTab.appendChild(references); - referencesTab.appendChild(guiUtils.createAnnotationList(self.getProject().getModels()[0].getReferences(), {groupAnnotations: false})); + if (model.getReferences().length > 0) { + var references = Functions.createElement({ + type: "div", + content: 'References:' + }); + referencesTab.appendChild(references); + referencesTab.appendChild(guiUtils.createAnnotationList(model.getReferences(), {groupAnnotations: false})); + } + + if (model.getAuthors().length > 0) { + var authors = Functions.createElement({ + type: "div", + content: 'Authors:' + }); + referencesTab.appendChild(authors); + referencesTab.appendChild(guiUtils.createAuthorsList(model.getAuthors())); + } var expandButton = Functions.createElement({ type: "button", @@ -108,7 +119,8 @@ SubmapPanel.prototype.createRow = function (model) { result.appendChild(openTd); return result; -}; +} +; /** * diff --git a/frontend-js/src/test/js/gui/leftPanel/ProjectInfoPanel-test.js b/frontend-js/src/test/js/gui/leftPanel/ProjectInfoPanel-test.js index 91df01227443189b687bad1959eb9aeaa0f49309..d293005b216cd89ff41a5bf504b78b3484bbc7c7 100644 --- a/frontend-js/src/test/js/gui/leftPanel/ProjectInfoPanel-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/ProjectInfoPanel-test.js @@ -87,4 +87,20 @@ describe('ProjectInfoPanel', function () { panel.destroy(); }); + it('list authors', function () { + var map = helper.createCustomMap(); + map.getModel().getAuthors().push({firstName: "Piotr", lastName: "G", organisation: "LCSB", email: "a@a.lu"}); + map.getModel().getAuthors().push({firstName: "Joe", lastName: "G", organisation: "LCSB", email: "a@a.lu"}); + + var panel = new ProjectInfoPanel({ + element: testDiv, + customMap: map + }); + + assert.ok(testDiv.innerHTML.indexOf("Piotr") >= 0); + assert.ok(testDiv.innerHTML.indexOf("Joe") >= 0); + + panel.destroy(); + }); + });