Commit c7dfaf189024963ea674bf0a191b7d6d956e8e36
Render poll positions
cel committed on 5/9/2018, 2:03:08 AMParent: b0584f97074489bdd1f5f5a742014874325f4e95
Files changed
lib/render-msg.js | changed |
lib/render-msg.js | |||
---|---|---|---|
@@ -295,8 +295,9 @@ | |||
295 | 295 … | case 'line-comment': return this.lineComment(cb) | |
296 | 296 … | case 'web-init': return this.webInit(cb) | |
297 | 297 … | case 'web-root': return this.webRoot(cb) | |
298 | 298 … | case 'poll': return this.poll(cb) | |
299 … | + case 'position': if (this.c.version === 'v1') return this.pollPosition(cb) | ||
299 | 300 … | default: return this.object(cb) | |
300 | 301 … | } | |
301 | 302 … | } | |
302 | 303 … | ||
@@ -1750,4 +1751,36 @@ | |||
1750 | 1751 … | title: closeDate.toLocaleString() | |
1751 | 1752 … | }, closeDate.toString())) | |
1752 | 1753 … | ), cb) | |
1753 | 1754 … | } | |
1755 … | + | ||
1756 … | +RenderMsg.prototype.pollPosition = function (cb) { | ||
1757 … | + var self = this | ||
1758 … | + var details = self.c.pollDetails || self.c.details || {} | ||
1759 … | + var reason = self.c.reason || '' | ||
1760 … | + var done = multicb({pluck: 1, spread: true}) | ||
1761 … | + self.link(self.c.root, done()) | ||
1762 … | + self.links(self.c.branch, done()) | ||
1763 … | + var msgCb = done() | ||
1764 … | + self.app.getMsg(self.c.root, function (err, msg) { | ||
1765 … | + // ignore error getting root message... it's not that important | ||
1766 … | + msgCb(null, msg) | ||
1767 … | + }) | ||
1768 … | + done(function (err, rootLink, branchLinks, rootMsg) { | ||
1769 … | + if (err) return cb(err) | ||
1770 … | + var rootContent = rootMsg && rootMsg.value.content || {} | ||
1771 … | + var rootDetails = rootContent.pollDetails || rootContent.details || {} | ||
1772 … | + var choices = u.toArray(rootDetails.choices) | ||
1773 … | + var choice = details.choice && choices && choices[details.choice] | ||
1774 … | + return self.wrap(h('div', | ||
1775 … | + rootLink ? h('div', h('small', h('span.symbol', '→'), ' ', rootLink)) : '', | ||
1776 … | + branchLinks.map(function (a, i) { | ||
1777 … | + return h('div', h('small', h('span.symbol', ' ↳'), ' ', a)) | ||
1778 … | + }), | ||
1779 … | + h('p', | ||
1780 … | + 'picked ', | ||
1781 … | + choice ? h('q', choice) : ['choice ', details.choice || '?'] | ||
1782 … | + ), | ||
1783 … | + reason ? h('div', {innerHTML: self.render.markdown(reason, self.c.mentions)}) : '' | ||
1784 … | + ), cb) | ||
1785 … | + }) | ||
1786 … | +} |
Built with git-ssb-web