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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user