From e73779fec18a417ac04d694f75b6f9bbce0f47ea Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 15:31:50 +0300 Subject: render tags on the client --- js/Article.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'js/Article.js') diff --git a/js/Article.js b/js/Article.js index 4f3a162de..a11004a0a 100644 --- a/js/Article.js +++ b/js/Article.js @@ -130,6 +130,14 @@ const Article = { Headlines.toggleUnread(id, 0); }, + renderTags: function (id, tags) { + const tags_short = tags.length > 5 ? tags.slice(0, 5) : tags; + + return ` + ${tags_short.length > 0 ? tags_short.map((tag) => ` + ${tag}` + ).join(", ") : `${__("no tags")}`}`; + }, renderLabels: function(id, labels) { return `${labels.map((label) => ` ${comments}
${hl.author}
label_outline - ${hl.tags_str} + ${Article.renderTags(hl.id, hl.tags)}  (+)
${hl.buttons}
@@ -343,13 +351,13 @@ const Article = { dialog.hide(); if (data) { - const id = data.id; - - const tags = App.byId("ATSTR-" + id); - const tooltip = dijit.byId("ATSTRTIP-" + id); + if (Headlines.headlines[data.id]) { + Headlines.headlines[data.id].tags = data.tags; + } - if (tags) tags.innerHTML = data.content; - if (tooltip) tooltip.attr('label', data.content_full); + App.findAll(`span[data-tags-for="${data.id}"`).forEach((ctr) => { + ctr.innerHTML = Article.renderTags(data.id, data.tags); + }); } } catch (e) { App.Error.report(e); -- cgit v1.2.3