added signups to forms listing

This commit is contained in:
Jonathan Labreuille
2016-07-19 13:44:32 +02:00
parent a5300624c2
commit 1dd4ade04d
4 changed files with 17 additions and 1 deletions

View File

@ -15,6 +15,10 @@ const columns = [
name: 'segments', name: 'segments',
label: MailPoet.I18n.t('segments') label: MailPoet.I18n.t('segments')
}, },
{
name: 'signups',
label: MailPoet.I18n.t('signups')
},
{ {
name: 'created_at', name: 'created_at',
label: MailPoet.I18n.t('createdOn'), label: MailPoet.I18n.t('createdOn'),
@ -149,6 +153,9 @@ const FormList = React.createClass({
<td className="column-format" data-colname={MailPoet.I18n.t('segments')}> <td className="column-format" data-colname={MailPoet.I18n.t('segments')}>
{ segments } { segments }
</td> </td>
<td className="column-format" data-colname={MailPoet.I18n.t('signups')}>
{ form.signups }
</td>
<td className="column-date" data-colname={MailPoet.I18n.t('createdOn')}> <td className="column-date" data-colname={MailPoet.I18n.t('createdOn')}>
<abbr>{ MailPoet.Date.format(form.created_at) }</abbr> <abbr>{ MailPoet.Date.format(form.created_at) }</abbr>
</td> </td>

View File

@ -39,6 +39,11 @@ class Form extends Model {
return parent::save(); return parent::save();
} }
function withSignups() {
$this->signups = StatisticsForms::where('form_id', $this->id)->count();
return $this;
}
static function search($orm, $search = '') { static function search($orm, $search = '') {
return $orm->whereLike('name', '%'.$search.'%'); return $orm->whereLike('name', '%'.$search.'%');
} }

View File

@ -29,7 +29,10 @@ class Forms {
// fetch segments relations for each returned item // fetch segments relations for each returned item
foreach($listing_data['items'] as $key => $form) { foreach($listing_data['items'] as $key => $form) {
$form = $form->asArray(); $form = $form
->withSignups()
->asArray();
$form['segments'] = ( $form['segments'] = (
!empty($form['settings']['segments']) !empty($form['settings']['segments'])
? $form['settings']['segments'] ? $form['settings']['segments']

View File

@ -41,6 +41,7 @@
'formName': __('Name'), 'formName': __('Name'),
'segments': __('Lists'), 'segments': __('Lists'),
'signups': __('Signups'),
'createdOn': __('Created on'), 'createdOn': __('Created on'),
'oneFormTrashed': __('1 form was moved to the trash'), 'oneFormTrashed': __('1 form was moved to the trash'),
'multipleFormsTrashed': __('%$1d forms were moved to the trash'), 'multipleFormsTrashed': __('%$1d forms were moved to the trash'),