FEATURE: show date ranges in heading on Top page

This commit is contained in:
Neil Lalonde 2015-07-01 11:48:59 -04:00
parent 8e09bc7b9d
commit 05b611853c
4 changed files with 31 additions and 5 deletions

View File

@ -1,5 +1,3 @@
import { iconHTML } from 'discourse/helpers/fa-icon';
const TITLE_SUBS = {
all: 'all_time',
yearly: 'this_year',
@ -7,7 +5,26 @@ const TITLE_SUBS = {
daily: 'today',
};
export default Ember.Handlebars.makeBoundHelper(function (period) {
export default Ember.Handlebars.makeBoundHelper(function (period, options) {
const title = I18n.t('filters.top.' + (TITLE_SUBS[period] || 'this_week'));
return new Handlebars.SafeString(iconHTML('calendar-o') + " " + title);
if (options.hash.showDateRange) {
var dateString = "";
switch(period) {
case 'yearly':
dateString = moment().subtract(1, 'year').format(I18n.t('dates.full_with_year_no_time'));
break;
case 'weekly':
dateString = moment().subtract(1, 'week').format(I18n.t('dates.full_no_year_no_time')) + " - " + moment().format(I18n.t('dates.full_no_year_no_time'));
break;
case 'monthly':
dateString = moment().subtract(1, 'month').format(I18n.t('dates.full_no_year_no_time')) + " - " + moment().format(I18n.t('dates.full_no_year_no_time'));
break;
case 'daily':
dateString = moment().format(I18n.t('dates.full_no_year_no_time'));
break;
}
return new Handlebars.SafeString(title + " <span class='top-date-string'>" + dateString + "</span>");
} else {
return new Handlebars.SafeString(title);
}
});

View File

@ -1,4 +1,4 @@
<h2>{{period-title period}}</h2>
<h2>{{period-title period showDateRange=true}}</h2>
<button>{{fa-icon "caret-down"}}</button>
<div id='period-popup' {{bind-attr class="showPeriods::hidden :period-popup"}}>

View File

@ -232,6 +232,13 @@ ol.category-breadcrumb {
h2 {
float: left;
margin: 5px 0 10px;
.top-date-string {
color: scale-color($primary, $lightness: 60%);
font-weight: normal;
font-size: 0.7em;
text-transform: uppercase;
}
}
button {

View File

@ -33,8 +33,10 @@ en:
time: "h:mm a"
long_no_year: "MMM D h:mm a"
long_no_year_no_time: "MMM D"
full_no_year_no_time: "MMMM Do"
long_with_year: "MMM D, YYYY h:mm a"
long_with_year_no_time: "MMM D, YYYY"
full_with_year_no_time: "MMMM Do, YYYY"
long_date_with_year: "MMM D, 'YY LT"
long_date_without_year: "MMM D, LT"
long_date_with_year_without_time: "MMM D, 'YY"