Add children() method to Newsletter model to get child newsletters (history in case of post notif)

- added conditional display of "view history" link in Notification listing
- fixed indentation in duplicatePostNotif method according to code sniffer report
This commit is contained in:
Jonathan Labreuille
2016-07-18 16:47:12 +02:00
parent b837a153d1
commit 0706450f9a
3 changed files with 32 additions and 5 deletions

View File

@@ -252,6 +252,20 @@ const NewsletterListNotification = React.createClass({
</span>
);
},
renderHistoryLink: function(newsletter) {
const childrenCount = ~~(newsletter.children_count);
if (childrenCount === 0) {
return (
MailPoet.I18n.t('notSentYet')
);
} else {
return (
<Link
to={ `/notification/history/${ newsletter.id }` }
>{ MailPoet.I18n.t('viewHistory') }</Link>
);
}
},
renderItem: function(newsletter, actions) {
const rowClasses = classNames(
'manage-column',
@@ -277,9 +291,7 @@ const NewsletterListNotification = React.createClass({
{ this.renderSettings(newsletter) }
</td>
<td className="column" data-colname={ MailPoet.I18n.t('history') }>
<Link
to={ `/notification/history/${ newsletter.id }` }
>{ MailPoet.I18n.t('viewHistory') }</Link>
{ this.renderHistoryLink(newsletter) }
</td>
<td className="column-date" data-colname={ MailPoet.I18n.t('lastModifiedOn') }>
<abbr>{ MailPoet.Date.format(newsletter.updated_at) }</abbr>