mirror of
https://github.com/silverstripe/silverstripe-contentreview
synced 2024-10-22 17:05:47 +02:00
parent
01c77790f7
commit
5245cda255
@ -51,6 +51,15 @@ class ContentReviewDefaultSettings extends DataExtension
|
|||||||
*/
|
*/
|
||||||
private static $content_review_template = 'ContentReviewEmail';
|
private static $content_review_template = 'ContentReviewEmail';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of members in which the dropdown will morph into a gridfield
|
||||||
|
*
|
||||||
|
* @config
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private static $content_review_gridfield_threshold = 500;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -120,10 +129,18 @@ class ContentReviewDefaultSettings extends DataExtension
|
|||||||
$usersMap = $users->map('ID', 'Title')->toArray();
|
$usersMap = $users->map('ID', 'Title')->toArray();
|
||||||
asort($usersMap);
|
asort($usersMap);
|
||||||
|
|
||||||
|
if(Member::get()->count() > Config::inst()->get('SiteConfig', 'content_review_gridfield_threshold')) {
|
||||||
|
$gridfieldconfig = GridFieldConfig_RelationEditor::create();
|
||||||
|
$gridfieldconfig->removeComponentsByType(new GridFieldAddNewButton());
|
||||||
|
$userField = GridField::create('OwnerUsers', _t("ContentReview.PAGEOWNERUSERS", "Users"),
|
||||||
|
$this->OwnerUsers(), $gridfieldconfig)
|
||||||
|
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
||||||
|
} else {
|
||||||
$userField = ListboxField::create('OwnerUsers', _t('ContentReview.PAGEOWNERUSERS', 'Users'), $usersMap)
|
$userField = ListboxField::create('OwnerUsers', _t('ContentReview.PAGEOWNERUSERS', 'Users'), $usersMap)
|
||||||
->setMultiple(true)
|
->setMultiple(true)
|
||||||
->setAttribute('data-placeholder', _t('ContentReview.ADDUSERS', 'Add users'))
|
->setAttribute('data-placeholder', _t('ContentReview.ADDUSERS', 'Add users'))
|
||||||
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
||||||
|
}
|
||||||
|
|
||||||
$fields->addFieldToTab('Root.ContentReview', $userField);
|
$fields->addFieldToTab('Root.ContentReview', $userField);
|
||||||
|
|
||||||
|
@ -345,16 +345,24 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
|||||||
$viewersOptionsField = OptionsetField::create("ContentReviewType", _t("ContentReview.OPTIONS", "Options"), $options);
|
$viewersOptionsField = OptionsetField::create("ContentReviewType", _t("ContentReview.OPTIONS", "Options"), $options);
|
||||||
|
|
||||||
$users = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN"));
|
$users = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN"));
|
||||||
|
|
||||||
$usersMap = $users->map("ID", "Title")->toArray();
|
$usersMap = $users->map("ID", "Title")->toArray();
|
||||||
|
|
||||||
asort($usersMap);
|
asort($usersMap);
|
||||||
|
|
||||||
|
if(Member::get()->count() > Config::inst()->get('SiteConfig', 'content_review_gridfield_threshold')) {
|
||||||
|
// grid field for large numbers of users
|
||||||
|
$gridfieldconfig = GridFieldConfig_RelationEditor::create();
|
||||||
|
$gridfieldconfig->removeComponentsByType(new GridFieldAddNewButton());
|
||||||
|
$userField = GridField::create('OwnerUsers', _t("ContentReview.PAGEOWNERUSERS", "Users"),
|
||||||
|
$this->OwnerUsers(), $gridfieldconfig)
|
||||||
|
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
||||||
|
} else {
|
||||||
$userField = ListboxField::create("OwnerUsers", _t("ContentReview.PAGEOWNERUSERS", "Users"), $usersMap)
|
$userField = ListboxField::create("OwnerUsers", _t("ContentReview.PAGEOWNERUSERS", "Users"), $usersMap)
|
||||||
->setMultiple(true)
|
->setMultiple(true)
|
||||||
->addExtraClass('custom-setting')
|
->addExtraClass('custom-setting')
|
||||||
->setAttribute("data-placeholder", _t("ContentReview.ADDUSERS", "Add users"))
|
->setAttribute("data-placeholder", _t("ContentReview.ADDUSERS", "Add users"))
|
||||||
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$groupsMap = array();
|
$groupsMap = array();
|
||||||
|
|
||||||
|
@ -23,3 +23,14 @@ CMS users without the permission to change the content review schedule can still
|
|||||||
and previous reviews in the same view, but cannot change anything.
|
and previous reviews in the same view, but cannot change anything.
|
||||||
|
|
||||||
![](_images/content-review-settings-ro.png)
|
![](_images/content-review-settings-ro.png)
|
||||||
|
|
||||||
|
## If your database contains a large number of members
|
||||||
|
|
||||||
|
The page owners selector will change from a ListboxField to a Gridfield in order
|
||||||
|
to prevent your browser from crashing. By default this numbers is 500. You can
|
||||||
|
customise this threshold by editing your .yml with the following settings:
|
||||||
|
|
||||||
|
```
|
||||||
|
SiteTree:
|
||||||
|
content_review_gridfield_threshold: 500
|
||||||
|
```
|
@ -334,4 +334,34 @@ class SiteTreeContentReviewTest extends ContentReviewBaseTest
|
|||||||
|
|
||||||
SS_Datetime::clear_mock_now();
|
SS_Datetime::clear_mock_now();
|
||||||
}
|
}
|
||||||
|
public function testSiteSettingsFieldsListBox()
|
||||||
|
{
|
||||||
|
$author = $this->objFromFixture("Member", "editor");
|
||||||
|
|
||||||
|
$this->logInAs($author);
|
||||||
|
|
||||||
|
/** @var Page|SiteTreeContentReview $page */
|
||||||
|
$page = $this->objFromFixture("Page", "contact");
|
||||||
|
|
||||||
|
$fields = $page->getSettingsFields();
|
||||||
|
|
||||||
|
$this->assertInstanceOf('ListboxField', $fields->dataFieldByName('OwnerUsers'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSiteSettingsFieldsGridfield()
|
||||||
|
{
|
||||||
|
$author = $this->objFromFixture("Member", "editor");
|
||||||
|
|
||||||
|
$this->logInAs($author);
|
||||||
|
|
||||||
|
/** @var Page|SiteTreeContentReview $page */
|
||||||
|
$page = $this->objFromFixture("Page", "contact");
|
||||||
|
|
||||||
|
// update the minimum threshhold to change to gridfield
|
||||||
|
Config::inst()->update('SiteConfig', 'content_review_gridfield_threshold', 1);
|
||||||
|
|
||||||
|
$fields = $page->getSettingsFields();
|
||||||
|
|
||||||
|
$this->assertInstanceOf('GridField', $fields->dataFieldByName('OwnerUsers'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user