mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
UX: show close date on automatically closed polls
This commit is contained in:
@@ -7,6 +7,7 @@ import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||
import evenRound from "discourse/plugins/poll/lib/even-round";
|
||||
import { avatarFor } from 'discourse/widgets/post';
|
||||
import round from "discourse/lib/round";
|
||||
import { relativeAge } from 'discourse/lib/formatter';
|
||||
|
||||
function optionHtml(option) {
|
||||
return new RawHtml({ html: `<span>${option.html}</span>` });
|
||||
@@ -353,8 +354,12 @@ createWidget('discourse-poll-info', {
|
||||
|
||||
if (poll.close) {
|
||||
const closeDate = moment.utc(poll.close);
|
||||
const title = closeDate.format("LLL");
|
||||
const timeLeft = moment().to(closeDate.local(), true);
|
||||
result.push(new RawHtml({ html: `<span class="info-text" title="${closeDate.format("LLL")}">${I18n.t("poll.automatic_close.closes_in", { timeLeft })}</span>` }));
|
||||
|
||||
result.push(new RawHtml({
|
||||
html: `<span class="info-text" title="${title}">${I18n.t("poll.automatic_close.closes_in", { timeLeft })}</span>`
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,6 +409,16 @@ createWidget('discourse-poll-buttons', {
|
||||
}));
|
||||
}
|
||||
|
||||
if (attrs.isAutomaticallyClosed) {
|
||||
const closeDate = moment.utc(poll.get("close"));
|
||||
const title = closeDate.format("LLL");
|
||||
const age = relativeAge(closeDate.toDate(), { addAgo: true });
|
||||
|
||||
results.push(new RawHtml({
|
||||
html: `<span class="info-text" title="${title}">${I18n.t("poll.automatic_close.age", { age })}</span>`
|
||||
}));
|
||||
}
|
||||
|
||||
if (this.currentUser &&
|
||||
(this.currentUser.get("id") === post.get('user_id') ||
|
||||
this.currentUser.get("staff")) &&
|
||||
|
||||
Reference in New Issue
Block a user