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:
@ -252,6 +252,20 @@ const NewsletterListNotification = React.createClass({
|
|||||||
</span>
|
</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) {
|
renderItem: function(newsletter, actions) {
|
||||||
const rowClasses = classNames(
|
const rowClasses = classNames(
|
||||||
'manage-column',
|
'manage-column',
|
||||||
@ -277,9 +291,7 @@ const NewsletterListNotification = React.createClass({
|
|||||||
{ this.renderSettings(newsletter) }
|
{ this.renderSettings(newsletter) }
|
||||||
</td>
|
</td>
|
||||||
<td className="column" data-colname={ MailPoet.I18n.t('history') }>
|
<td className="column" data-colname={ MailPoet.I18n.t('history') }>
|
||||||
<Link
|
{ this.renderHistoryLink(newsletter) }
|
||||||
to={ `/notification/history/${ newsletter.id }` }
|
|
||||||
>{ MailPoet.I18n.t('viewHistory') }</Link>
|
|
||||||
</td>
|
</td>
|
||||||
<td className="column-date" data-colname={ MailPoet.I18n.t('lastModifiedOn') }>
|
<td className="column-date" data-colname={ MailPoet.I18n.t('lastModifiedOn') }>
|
||||||
<abbr>{ MailPoet.Date.format(newsletter.updated_at) }</abbr>
|
<abbr>{ MailPoet.Date.format(newsletter.updated_at) }</abbr>
|
||||||
|
@ -123,7 +123,8 @@ class Newsletter extends Model {
|
|||||||
'parent_id' => $this->id,
|
'parent_id' => $this->id,
|
||||||
'type' => self::TYPE_NOTIFICATION_HISTORY,
|
'type' => self::TYPE_NOTIFICATION_HISTORY,
|
||||||
'status' => self::STATUS_SENDING
|
'status' => self::STATUS_SENDING
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$notification_history = self::create();
|
$notification_history = self::create();
|
||||||
$notification_history->hydrate($data);
|
$notification_history->hydrate($data);
|
||||||
@ -163,6 +164,14 @@ class Newsletter extends Model {
|
|||||||
return parent::delete();
|
return parent::delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function children() {
|
||||||
|
return $this->has_many(
|
||||||
|
__NAMESPACE__.'\Newsletter',
|
||||||
|
'parent_id',
|
||||||
|
'id'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function segments() {
|
function segments() {
|
||||||
return $this->has_many_through(
|
return $this->has_many_through(
|
||||||
__NAMESPACE__.'\Segment',
|
__NAMESPACE__.'\Segment',
|
||||||
@ -177,6 +186,11 @@ class Newsletter extends Model {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function withChildrenCount() {
|
||||||
|
$this->children_count = $this->children()->count();
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
function options() {
|
function options() {
|
||||||
return $this->has_many_through(
|
return $this->has_many_through(
|
||||||
__NAMESPACE__.'\NewsletterOptionField',
|
__NAMESPACE__.'\NewsletterOptionField',
|
||||||
|
@ -267,7 +267,8 @@ class Newsletters {
|
|||||||
} else if($newsletter->type === Newsletter::TYPE_NOTIFICATION) {
|
} else if($newsletter->type === Newsletter::TYPE_NOTIFICATION) {
|
||||||
$newsletter
|
$newsletter
|
||||||
->withOptions()
|
->withOptions()
|
||||||
->withSegments();
|
->withSegments()
|
||||||
|
->withChildrenCount();
|
||||||
} else if($newsletter->type === Newsletter::TYPE_NOTIFICATION_HISTORY) {
|
} else if($newsletter->type === Newsletter::TYPE_NOTIFICATION_HISTORY) {
|
||||||
$newsletter
|
$newsletter
|
||||||
->withSegments()
|
->withSegments()
|
||||||
|
Reference in New Issue
Block a user