mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
NEW Allow existing document sets to be linked to pages
This commit is contained in:
parent
d8f3685601
commit
8a7fe273a6
@ -20,10 +20,15 @@ class DMSSiteTreeExtension extends DataExtension
|
||||
'Document Sets',
|
||||
false,
|
||||
$this->owner->DocumentSets(), //->Sort('DocumentSort'),
|
||||
new GridFieldConfig_RecordEditor
|
||||
$config = new GridFieldConfig_RelationEditor
|
||||
);
|
||||
$gridField->addExtraClass('documentsets');
|
||||
|
||||
// Only show document sets in the autocompleter that have not been assigned to a page already
|
||||
$config->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchList(
|
||||
DMSDocumentSet::get()->filter(array('PageID' => 0))
|
||||
);
|
||||
|
||||
$fields->addFieldToTab(
|
||||
'Root.Document Sets (' . $this->owner->DocumentSets()->count() . ')',
|
||||
$gridField
|
||||
|
@ -62,6 +62,8 @@ DMSDocumentSet:
|
||||
dsSaveLinkedDocuments:
|
||||
Title: Test Set 6
|
||||
Page: =>SiteTree.s9
|
||||
unlinked_set:
|
||||
Title: Document Set not linked
|
||||
DMSDocument:
|
||||
d1:
|
||||
Filename: test-file-file-doesnt-exist-1
|
||||
|
@ -82,4 +82,24 @@ class DMSSiteTreeExtensionTest extends SapphireTest
|
||||
}
|
||||
$this->assertCount(0, $siteTree->getAllDocuments()->filter('EmbargoedUntilPublished', true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that document sets that are assigned to pages to not show up in "link existing" autocomplete
|
||||
* search results
|
||||
*/
|
||||
public function testGetRelatedDocumentsForAutocompleter()
|
||||
{
|
||||
$page = $this->objFromFixture('SiteTree', 's1');
|
||||
$gridField = $page->getCMSFields()->fieldByName('Root.Document Sets (2).Document Sets');
|
||||
$this->assertInstanceOf('GridField', $gridField);
|
||||
|
||||
$autocompleter = $gridField->getConfig()->getComponentByType('GridFieldAddExistingAutocompleter');
|
||||
$jsonResult = $autocompleter->doSearch(
|
||||
$gridField,
|
||||
new SS_HTTPRequest('GET', '/', array('gridfield_relationsearch' => 'Document Set'))
|
||||
);
|
||||
|
||||
$this->assertContains('Document Set not linked', $jsonResult);
|
||||
$this->assertNotContains('Document Set 1', $jsonResult);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user