mirror of
https://github.com/moparisthebest/mail
synced 2025-02-17 23:40:22 -05:00
Merge pull request #209 from whiteout-io/dev/WO-776
Show time of day instead of date for today in mail-list
This commit is contained in:
commit
9bee0f3def
@ -11,7 +11,7 @@ var INIT_DISPLAY_LEN = 20,
|
|||||||
FOLDER_TYPE_INBOX = 'Inbox',
|
FOLDER_TYPE_INBOX = 'Inbox',
|
||||||
NOTIFICATION_INBOX_TIMEOUT = 5000;
|
NOTIFICATION_INBOX_TIMEOUT = 5000;
|
||||||
|
|
||||||
var MailListCtrl = function($scope, $timeout, $routeParams, statusDisplay, notification, email, keychain, dialog, search, dummy) {
|
var MailListCtrl = function($scope, $timeout, $routeParams, $filter, statusDisplay, notification, email, keychain, dialog, search, dummy) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Init
|
// Init
|
||||||
@ -98,6 +98,20 @@ var MailListCtrl = function($scope, $timeout, $routeParams, statusDisplay, notif
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Date formatting
|
||||||
|
*/
|
||||||
|
$scope.formatDate = function(date) {
|
||||||
|
var now = new Date();
|
||||||
|
|
||||||
|
// return time if mail is from today
|
||||||
|
if(now.getDay() === date.getDay() && now.getMonth() === date.getMonth() && now.getFullYear() === date.getFullYear()) {
|
||||||
|
return $filter('date')(date, 'shortTime');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $filter('date')(date, 'mediumDate');
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// watch tasks
|
// watch tasks
|
||||||
//
|
//
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
<div class="mail-list-entry__attachment">
|
<div class="mail-list-entry__attachment">
|
||||||
<svg><use xlink:href="#icon-attachment" /><title>Attachments</title></svg>
|
<svg><use xlink:href="#icon-attachment" /><title>Attachments</title></svg>
|
||||||
</div>
|
</div>
|
||||||
<time class="mail-list-entry__time">{{email.sentDate | date:'mediumDate'}}</time>
|
<time class="mail-list-entry__time">{{ formatDate(email.sentDate) }}</time>
|
||||||
<div class="mail-list-entry__excerpt">{{email.body ? email.body.substr(0, 200) : ''}}</div>
|
<div class="mail-list-entry__excerpt">{{email.body ? email.body.substr(0, 200) : ''}}</div>
|
||||||
<div class="mail-list-entry__encrypted">
|
<div class="mail-list-entry__encrypted">
|
||||||
<svg ng-show="email.encrypted"><use xlink:href="#icon-encrypted" /><title>Encrypted</title></svg>
|
<svg ng-show="email.encrypted"><use xlink:href="#icon-encrypted" /><title>Encrypted</title></svg>
|
||||||
|
@ -324,4 +324,19 @@ describe('Mail List controller unit test', function() {
|
|||||||
expect(scope.state.mailList.selected).to.equal(mail);
|
expect(scope.state.mailList.selected).to.equal(mail);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('formatDate', function() {
|
||||||
|
it('should output short time if date is today', angular.mock.inject(function($filter) {
|
||||||
|
var now = new Date();
|
||||||
|
var expected = $filter('date')(now, 'shortTime');
|
||||||
|
expect(scope.formatDate(now)).to.equal(expected);
|
||||||
|
}));
|
||||||
|
it('should output date only if date is not today', angular.mock.inject(function($filter) {
|
||||||
|
var yesterday = new Date();
|
||||||
|
yesterday.setTime(yesterday.getTime() - 24*60*60*1000);
|
||||||
|
|
||||||
|
var expected = $filter('date')(yesterday, 'mediumDate');
|
||||||
|
expect(scope.formatDate(yesterday)).to.equal(expected);
|
||||||
|
}));
|
||||||
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user