FIX Duplicated tabset, invalid Pjax request, update translations and Spam/Approve buttons

This commit is contained in:
Robbie Averill 2017-12-14 16:08:43 +13:00
parent 118de6b595
commit 216ad8eb54
3 changed files with 38 additions and 26 deletions

View File

@ -44,13 +44,13 @@ en:
DELETEALLCOMMENTS: 'Delete all comments on this page'
SilverStripe\Comments\Admin\CommentAdmin:
ADMIN_PERMISSION: 'Access to ''Comments'' section'
ApprovedComments: Approved
ApprovedComments: Approved ({count})
Comments: Approved
MENUTITLE: Comments
Moderated: Moderated
NeedsModeration: 'Needs Moderation'
NewComments: New
SpamComments: Spam
NewComments: New ({count})
SpamComments: Spam ({count})
SilverStripe\Comments\Admin\CommentsGridFieldAction:
APPROVE: Approve
COMMENTAPPROVED: 'Comment approved.'

View File

@ -45,7 +45,7 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider
{
return array(
"CMS_ACCESS_CommentAdmin" => array(
'name' => _t('SilverStripe\\Comments\\Admin\\CommentAdmin.ADMIN_PERMISSION', "Access to 'Comments' section"),
'name' => _t(__CLASS__ . '.ADMIN_PERMISSION', "Access to 'Comments' section"),
'category' => _t('SilverStripe\\Security\\Permission.CMS_ACCESS_CATEGORY', 'CMS Access')
)
);
@ -94,34 +94,42 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider
CommentsGridFieldConfig::create()
);
$newCount = '(' . count($newComments) . ')';
$approvedCount = '(' . count($approvedComments) . ')';
$spamCount = '(' . count($spamComments) . ')';
$fields = new FieldList(
$root = new TabSet(
'Comments',
new Tab(
$fields = FieldList::create(
$root = TabSet::create(
'Root',
Tab::create(
'NewComments',
_t(__CLASS__.'.NewComments', 'New') . ' ' . $newCount,
_t(
__CLASS__.'.NewComments',
'New ({count})',
['count' => count($newComments)]
),
$newGrid
),
new Tab(
Tab::create(
'ApprovedComments',
_t(__CLASS__.'.ApprovedComments', 'Approved') . ' ' . $approvedCount,
_t(
__CLASS__.'.ApprovedComments',
'Approved ({count})',
['count' => count($approvedComments)]
),
$approvedGrid
),
new Tab(
Tab::create(
'SpamComments',
_t(__CLASS__.'.SpamComments', 'Spam') . ' ' . $spamCount,
_t(
__CLASS__.'.SpamComments',
'Spam ({count})',
['count' => count($spamComments)]
),
$spamGrid
)
)
);
$actions = new FieldList();
$actions = FieldList::create();
$form = new Form(
$form = Form::create(
$this,
'EditForm',
$fields,
@ -132,7 +140,7 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
if ($form->Fields()->hasTabset()) {
// $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
$form->Fields()->findOrMakeTab('Root')->setTemplate('SilverStripe\\Forms\\CMSTabSet');
$form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
}

View File

@ -62,20 +62,24 @@ class CommentsGridFieldAction implements GridField_ColumnProvider, GridField_Act
$field .= GridField_FormAction::create(
$gridField,
'CustomAction' . $record->ID . 'Spam',
_t('SilverStripe\\Comments\\Admin\\CommentsGridFieldAction.SPAM', 'Spam'),
_t(__CLASS__ . '.SPAM', 'Spam'),
'spam',
array('RecordID' => $record->ID)
)->Field();
)
->addExtraClass('btn btn-secondary grid-field__icon-action')
->Field();
}
if ($record->IsSpam || !$record->Moderated) {
$field .= GridField_FormAction::create(
$gridField,
'CustomAction' . $record->ID . 'Approve',
_t('SilverStripe\\Comments\\Admin\\CommentsGridFieldAction.APPROVE', 'Approve'),
_t(__CLASS__ . '.APPROVE', 'Approve'),
'approve',
array('RecordID' => $record->ID)
)->Field();
)
->addExtraClass('btn btn-secondary grid-field__icon-action')
->Field();
}
return $field;
@ -101,7 +105,7 @@ class CommentsGridFieldAction implements GridField_ColumnProvider, GridField_Act
// output a success message to the user
Controller::curr()->getResponse()->setStatusCode(
200,
_t('SilverStripe\\Comments\\Admin\\CommentsGridFieldAction.COMMENTMARKEDSPAM', 'Comment marked as spam.')
_t(__CLASS__ . '.COMMENTMARKEDSPAM', 'Comment marked as spam.')
);
}
@ -112,7 +116,7 @@ class CommentsGridFieldAction implements GridField_ColumnProvider, GridField_Act
// output a success message to the user
Controller::curr()->getResponse()->setStatusCode(
200,
_t('SilverStripe\\Comments\\Admin\\CommentsGridFieldAction.COMMENTAPPROVED', 'Comment approved.')
_t(__CLASS__ . '.COMMENTAPPROVED', 'Comment approved.')
);
}
}