mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API Show GridFieldEditButton even without edit permissions (for readonly forms)
This commit is contained in:
parent
1848d7e90a
commit
bbc8e06d49
@ -72,9 +72,9 @@ class GridFieldEditButton implements GridField_ColumnProvider {
|
|||||||
* @return string - the HTML for the column
|
* @return string - the HTML for the column
|
||||||
*/
|
*/
|
||||||
public function getColumnContent($gridField, $record, $columnName) {
|
public function getColumnContent($gridField, $record, $columnName) {
|
||||||
if(!$record->canEdit()){
|
// No permission checks, handled through GridFieldDetailForm,
|
||||||
return;
|
// which can make the form readonly if no edit permissions are available.
|
||||||
}
|
|
||||||
$data = new ArrayData(array(
|
$data = new ArrayData(array(
|
||||||
'Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')
|
'Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')
|
||||||
));
|
));
|
||||||
|
@ -25,15 +25,16 @@ class GridFieldEditButtonTest extends SapphireTest {
|
|||||||
$this->form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList());
|
$this->form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDontShowEditLinks() {
|
public function testShowEditLinks() {
|
||||||
if(Member::currentUser()) { Member::currentUser()->logOut(); }
|
if(Member::currentUser()) { Member::currentUser()->logOut(); }
|
||||||
|
|
||||||
$content = new CSSContentParser($this->gridField->FieldHolder());
|
$content = new CSSContentParser($this->gridField->FieldHolder());
|
||||||
// Check that there are content
|
// Check that there are content
|
||||||
$this->assertEquals(3, count($content->getBySelector('.ss-gridfield-item')));
|
$this->assertEquals(3, count($content->getBySelector('.ss-gridfield-item')));
|
||||||
// Make sure that there are no edit links
|
// Make sure that there are edit links, even though the user doesn't have "edit" permissions
|
||||||
$this->assertEquals(0, count($content->getBySelector('.edit-link')),
|
// (he can still view the records)
|
||||||
'Edit links should not show when not logged in.');
|
$this->assertEquals(2, count($content->getBySelector('.edit-link')),
|
||||||
|
'Edit links should show when not logged in.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testShowEditLinksWithAdminPermission() {
|
public function testShowEditLinksWithAdminPermission() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user