From 762c5e773cedb7e26f894f6b56975c3b8ec596b4 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 7 Feb 2021 11:40:46 +0100 Subject: [PATCH] use entities for group/publication descriptions --- config.jsonc | 21 +++- static/html/entities.publication.entity.html | 8 ++ static/js/documentInfoView.leftovers.js | 112 ++++++++++++++++++- 3 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 static/html/entities.publication.entity.html diff --git a/config.jsonc b/config.jsonc index eb9b2e8..fa7a312 100644 --- a/config.jsonc +++ b/config.jsonc @@ -557,7 +557,26 @@ "id" and "name" keys are required. If "alternativeNames" is present, these will act as synonyms when autocompleting values entered as annotations. */ - "entities": [], + "entities": [ + { + "id": "group", + "title": "Group", + "keys": [ + {"id": "id", "title": "ID", "type": "string"}, + {"id": "name", "title": "Name", "type": "string"}, + {"id": "description", "title": "Description", "type": "text"} + ] + }, + { + "id": "publication", + "title": "Publication", + "keys": [ + {"id": "id", "title": "ID", "type": "string"}, + {"id": "name", "title": "Name", "type": "string"}, + {"id": "description", "title": "Description", "type": "text"} + ] + } + ], /* "flags", if set to true, will cause flag icons to appear in filters. */ diff --git a/static/html/entities.publication.entity.html b/static/html/entities.publication.entity.html new file mode 100644 index 0000000..33b40c1 --- /dev/null +++ b/static/html/entities.publication.entity.html @@ -0,0 +1,8 @@ +
+
+
About {name}:
+
+
{description}
+
+
+
diff --git a/static/js/documentInfoView.leftovers.js b/static/js/documentInfoView.leftovers.js index 5abc159..fc003d7 100644 --- a/static/js/documentInfoView.leftovers.js +++ b/static/js/documentInfoView.leftovers.js @@ -112,6 +112,12 @@ pandora.ui.documentInfoView = function(data, isMixed) { }); if (!isMultiple) { + var $left = Ox.Element() + .css({ + position: 'absolute' + }) + .appendTo($info); + var $icon = Ox.Element({ element: '', }) @@ -128,7 +134,7 @@ pandora.ui.documentInfoView = function(data, isMixed) { .bindEvent({ singleclick: toggleIconSize }) - .appendTo($info), + .appendTo($left), $reflection = $('
') .addClass('OxReflection') @@ -140,7 +146,7 @@ pandora.ui.documentInfoView = function(data, isMixed) { height: iconSize / 2 + 'px', overflow: 'hidden' }) - .appendTo($info), + .appendTo($left), $reflectionIcon = $('') .attr({ @@ -163,6 +169,16 @@ pandora.ui.documentInfoView = function(data, isMixed) { .appendTo($reflection); } + var $data = $('
') + .addClass('OxTextPage') + .css({ + position: 'absolute', + left: margin + 'px', + top: margin + iconHeight + margin + 'px', + width: iconSize + 'px', + }) + .appendTo($left); + var $text = Ox.Element() .addClass('OxTextPage') .css({ @@ -201,6 +217,83 @@ pandora.ui.documentInfoView = function(data, isMixed) { if (!canEdit) { pandora.createLinks($info); } + // Group & Publication description ----------------------------------------------------- + if (!isMultiple) { + ;['group', 'publication'].forEach(key => { + var $box = $('
').appendTo($data); + (data[key] ? pandora.api.findEntities : Ox.noop)({ + query: { + conditions: [{ + key: 'type', operator: '==', value: key + }, { + key: 'name', operator: '==', value: data[key] + }], + operator: '&' + }, + keys: ['id', 'name', 'description'] + }, function(result) { + if ((result && result.data.items.length == 1) || canEdit) { + var entity = {} + if (result && result.data.items.length) { + entity = result.data.items[0] + } + $('
') + .html(Ox._('About {0}:', [data[key]])) + .css({ + 'padding-top': '4px', + 'font-weight': 'bold' + }) + .appendTo($box); + $('
') + .append( + Ox.EditableContent({ + clickLink: pandora.clickLink, + editable: false, + format: function(value) { + return value.replace( + /') + .html('Description:') + .css({ + 'padding-top': '4px', + 'font-weight': 'bold' + }) + .appendTo($text); $('
') .append( Ox.EditableContent({ @@ -276,6 +375,13 @@ pandora.ui.documentInfoView = function(data, isMixed) { } if (canEdit || data.content) { + $('
') + .html('Content:') + .css({ + 'padding-top': '4px', + 'font-weight': 'bold' + }) + .appendTo($text); $('
') .append( Ox.EditableContent({