mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
FIX Remove "Page" literal field when editing a doc set in a page context. Simplify exception test.
This commit is contained in:
parent
d8f3685601
commit
7fb2662958
@ -117,8 +117,12 @@ class DMSDocumentSet extends DataObject
|
|||||||
$gridFieldConfig->addComponent($sortableComponent);
|
$gridFieldConfig->addComponent($sortableComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
$field = $fields->fieldByName('Root.Main.PageID');
|
// Don't show which page this is if we're already editing within a page context
|
||||||
$field->setTitle(_t('DMSDocumentSet.SHOWONPAGE', 'Show on page'));
|
if (Controller::curr() instanceof CMSPageEditController) {
|
||||||
|
$fields->removeByName('PageID');
|
||||||
|
} else {
|
||||||
|
$fields->fieldByName('Root.Main.PageID')->setTitle(_t('DMSDocumentSet.SHOWONPAGE', 'Show on page'));
|
||||||
|
}
|
||||||
|
|
||||||
$gridFieldConfig->getComponentByType('GridFieldDataColumns')
|
$gridFieldConfig->getComponentByType('GridFieldDataColumns')
|
||||||
->setDisplayFields($self->getDocumentDisplayFields())
|
->setDisplayFields($self->getDocumentDisplayFields())
|
||||||
|
@ -194,11 +194,24 @@ class DMSDocumentSetTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
public function testExceptionOnNoTitleGiven()
|
public function testExceptionOnNoTitleGiven()
|
||||||
{
|
{
|
||||||
$set = DMSDocumentSet::create(array('Title' => ''));
|
DMSDocumentSet::create(array('Title' => ''))->write();
|
||||||
try {
|
}
|
||||||
$set->write();
|
|
||||||
} catch (ValidationException $e) {
|
/**
|
||||||
throw $e;
|
* Ensure that when editing in a page context that the "page" field is removed, or is labelled "Show on page"
|
||||||
}
|
* otherwise
|
||||||
|
*/
|
||||||
|
public function testPageFieldRemovedWhenEditingInPageContext()
|
||||||
|
{
|
||||||
|
$set = $this->objFromFixture('DMSDocumentSet', 'ds1');
|
||||||
|
|
||||||
|
$fields = $set->getCMSFields();
|
||||||
|
$this->assertInstanceOf('DropdownField', $fields->fieldByName('Root.Main.PageID'));
|
||||||
|
|
||||||
|
$pageController = new CMSPageEditController;
|
||||||
|
$pageController->pushCurrent();
|
||||||
|
|
||||||
|
$fields = $set->getCMSFields();
|
||||||
|
$this->assertNull($fields->fieldByName('Root.Main.PageID'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user