Add forever to the suspension dropdown

This commit is contained in:
Robin Ward 2017-10-02 15:04:22 -04:00
parent 823936ca9c
commit f7c967b754
7 changed files with 33 additions and 3 deletions

View File

@ -7,6 +7,7 @@
{{future-date-input
class="suspend-until"
label="admin.user.suspend_duration"
includeForever=true
input=suspendUntil}}
</label>
</div>

View File

@ -307,7 +307,9 @@
<div class='value'>
{{i18n-yes-no model.isSuspended}}
{{#if model.isSuspended}}
{{i18n "admin.user.suspended_until" until=model.suspendedTillDate}}
{{#unless model.suspendedForever}}
{{i18n "admin.user.suspended_until" until=model.suspendedTillDate}}
{{/unless}}
{{/if}}
</div>
<div class='controls'>

View File

@ -9,6 +9,8 @@ const LATER_THIS_WEEK = 'later_this_week';
const THIS_WEEKEND = 'this_weekend';
const NEXT_WEEK = 'next_week';
const NEXT_MONTH = 'next_month';
const FOREVER = 'forever';
export const PICK_DATE_AND_TIME = 'pick_date_and_time';
export const SET_BASED_ON_LAST_POST = 'set_based_on_last_post';
@ -66,6 +68,13 @@ export default Combobox.extend({
});
}
if (this.get('includeForever')) {
selections.push({
id: FOREVER,
name: I18n.t('topic.auto_update_input.forever')
});
}
selections.push({
id: PICK_DATE_AND_TIME,
name: I18n.t('topic.auto_update_input.pick_date_and_time')
@ -133,7 +142,7 @@ export default Combobox.extend({
output += `<span>${state.text}</span>`;
if (time) {
if (time && state.id !== FOREVER) {
output += `<span class='future-date-input-selector-datetime'>${time}</span>`;
}
@ -170,6 +179,10 @@ export default Combobox.extend({
time = time.add(1, 'month').startOf('month').hour(timeOfDay).minute(0);
icon = 'briefcase';
break;
case FOREVER:
time = time.add(1000, 'year').hour(timeOfDay).minute(0);
icon = 'gavel';
break;
case PICK_DATE_AND_TIME:
time = null;
icon = 'calendar-plus-o';

View File

@ -178,6 +178,11 @@ const User = RestModel.extend({
return suspendedTill && moment(suspendedTill).isAfter();
},
@computed("suspended_till")
suspendedForever(suspendedTill) {
return moment().diff(suspendedTill, 'years') < -500;
},
@computed("suspended_till")
suspendedTillDate(suspendedTill) {
return longDate(suspendedTill);

View File

@ -8,6 +8,7 @@
statusType=statusType
value=selection
input=input
includeForever=includeForever
width="50%"
none="topic.auto_update_input.none"}}
</div>

View File

@ -84,7 +84,13 @@
{{#if model.isSuspended}}
<div class='suspended'>
{{d-icon "ban"}}
<b>{{i18n 'user.suspended_notice' date=model.suspendedTillDate}}</b><br>
<b>
{{#if model.suspendedForever}}
{{i18n 'user.suspended_permanently'}}
{{else}}
{{i18n 'user.suspended_notice' date=model.suspendedTillDate}}
{{/if}}
</b><br>
{{#if model.suspend_reason}}
<b>{{i18n 'user.suspended_reason'}}</b> {{model.suspend_reason}}
{{/if}}

View File

@ -604,6 +604,7 @@ en:
admin_tooltip: "This user is an admin"
blocked_tooltip: "This user is blocked"
suspended_notice: "This user is suspended until {{date}}."
suspended_permanently: "This user is suspended."
suspended_reason: "Reason: "
github_profile: "Github"
email_activity_summary: "Activity Summary"
@ -1568,6 +1569,7 @@ en:
this_weekend: "This weekend"
next_week: "Next week"
next_month: "Next month"
forever: "Forever"
pick_date_and_time: "Pick date and time"
set_based_on_last_post: "Close based on last post"
publish_to_category: