REFACTOR: use tables instead of custom fields for polls (#6359)

Co-authored-by: Guo Xiang Tan <tgx_world@hotmail.com>
This commit is contained in:
Régis Hanol
2018-11-19 14:50:00 +01:00
committed by GitHub
parent 86dafc1f25
commit 4459665dee
37 changed files with 1912 additions and 1573 deletions
@@ -39,12 +39,12 @@ function initializePolls(api) {
const polls = this.get("polls");
if (polls) {
this._polls = this._polls || {};
_.map(polls, (v, k) => {
const existing = this._polls[k];
polls.forEach(p => {
const existing = this._polls[p.name];
if (existing) {
this._polls[k].setProperties(v);
this._polls[p.name].setProperties(p);
} else {
this._polls[k] = Em.Object.create(v);
this._polls[p.name] = Em.Object.create(p);
}
});
this.set("pollsObject", this._polls);
@@ -81,14 +81,11 @@ function initializePolls(api) {
const pollName = $poll.data("poll-name");
const poll = polls[pollName];
if (poll) {
const isMultiple = poll.get("type") === "multiple";
const glue = new WidgetGlue("discourse-poll", register, {
id: `${pollName}-${post.id}`,
post,
poll,
vote: votes[pollName] || [],
isMultiple
vote: votes[pollName] || []
});
glue.appendTo(pollElem);
_glued.push(glue);