mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 03:19:10 +00:00
UX: different auto-close message when 'based on last post' is checked
This commit is contained in:
parent
3a571997a0
commit
0555b84e4d
@ -11,39 +11,37 @@ export default Discourse.View.extend({
|
||||
elementId: 'topic-closing-info',
|
||||
delayedRerender: null,
|
||||
|
||||
shouldRerender: Discourse.View.renderIfChanged('topic.details.auto_close_at'),
|
||||
shouldRerender: Discourse.View.renderIfChanged('topic.closed', 'topic.details.{auto_close_at,auto_close_based_on_last_post,auto_close_hours}'),
|
||||
|
||||
render: function(buffer) {
|
||||
if (!this.present('topic.details.auto_close_at')) return;
|
||||
if (this.get("topic.closed")) return;
|
||||
|
||||
var autoCloseAt = moment(this.get('topic.details.auto_close_at'));
|
||||
|
||||
if (autoCloseAt < new Date()) return;
|
||||
|
||||
var duration = moment.duration(autoCloseAt - moment());
|
||||
var minutesLeft = duration.asMinutes();
|
||||
var timeLeftString = duration.humanize(true);
|
||||
var rerenderDelay = 1000;
|
||||
|
||||
var timeLeftString, rerenderDelay, minutesLeft = duration.asMinutes();
|
||||
|
||||
if (minutesLeft > 1410) {
|
||||
timeLeftString = I18n.t('in_n_days', {count: Math.round(duration.asDays())});
|
||||
if( minutesLeft > 2160 ) {
|
||||
rerenderDelay = 12 * 60 * 60000;
|
||||
} else {
|
||||
rerenderDelay = 60 * 60000;
|
||||
}
|
||||
if (minutesLeft > 2160) {
|
||||
rerenderDelay = 12 * 60 * 60000;
|
||||
} else if (minutesLeft > 1410) {
|
||||
rerenderDelay = 60 * 60000;
|
||||
} else if (minutesLeft > 90) {
|
||||
timeLeftString = I18n.t('in_n_hours', {count: Math.round(duration.asHours())});
|
||||
rerenderDelay = 30 * 60000;
|
||||
} else if (minutesLeft > 2) {
|
||||
timeLeftString = I18n.t('in_n_minutes', {count: Math.round(duration.asMinutes())});
|
||||
rerenderDelay = 60000;
|
||||
} else {
|
||||
timeLeftString = I18n.t('in_n_seconds', {count: Math.round(duration.asSeconds())});
|
||||
rerenderDelay = 1000;
|
||||
}
|
||||
|
||||
var basedOnLastPost = this.get("topic.details.auto_close_based_on_last_post");
|
||||
var key = basedOnLastPost ? 'topic.auto_close_notice_based_on_last_post' : 'topic.auto_close_notice'
|
||||
|
||||
var autoCloseHours = this.get("topic.details.auto_close_hours") || 0;
|
||||
|
||||
buffer.push('<h3><i class="fa fa-clock-o"></i> ');
|
||||
buffer.push( I18n.t('topic.auto_close_notice', {timeLeft: timeLeftString}) );
|
||||
buffer.push( I18n.t(key, { timeLeft: timeLeftString, duration: moment.duration(autoCloseHours, "hours").humanize() }) );
|
||||
buffer.push('</h3>');
|
||||
|
||||
// TODO Sam: concerned this can cause a heavy rerender loop
|
||||
|
@ -141,19 +141,6 @@ en:
|
||||
one: "{{count}} character"
|
||||
other: "{{count}} characters"
|
||||
|
||||
in_n_seconds:
|
||||
one: "in 1 second"
|
||||
other: "in {{count}} seconds"
|
||||
in_n_minutes:
|
||||
one: "in 1 minute"
|
||||
other: "in {{count}} minutes"
|
||||
in_n_hours:
|
||||
one: "in 1 hour"
|
||||
other: "in {{count}} hours"
|
||||
in_n_days:
|
||||
one: "in 1 day"
|
||||
other: "in {{count}} days"
|
||||
|
||||
suggested_topics:
|
||||
title: "Suggested Topics"
|
||||
|
||||
@ -885,6 +872,7 @@ en:
|
||||
deleted: "The topic has been deleted"
|
||||
|
||||
auto_close_notice: "This topic will automatically close %{timeLeft}."
|
||||
auto_close_notice_based_on_last_post: "This topic will close %{duration} after the last reply."
|
||||
auto_close_title: 'Auto-Close Settings'
|
||||
auto_close_save: "Save"
|
||||
auto_close_remove: "Don't Auto-Close This Topic"
|
||||
|
Loading…
x
Reference in New Issue
Block a user