mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 12:05:56 +00:00
FIX Ensure documents are drag-and-drop reorderable in document sets
This commit is contained in:
parent
d8f3685601
commit
58ac37a1e8
@ -29,6 +29,7 @@ class DMSDocumentSet extends DataObject
|
|||||||
// Flag indicating if a document was added directly to a set - in which case it is set - or added
|
// Flag indicating if a document was added directly to a set - in which case it is set - or added
|
||||||
// via the query-builder.
|
// via the query-builder.
|
||||||
'ManuallyAdded' => 'Boolean(1)',
|
'ManuallyAdded' => 'Boolean(1)',
|
||||||
|
'DocumentSort' => 'Int'
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -87,6 +88,8 @@ class DMSDocumentSet extends DataObject
|
|||||||
'Title'
|
'Title'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
$fields->removeByName('DocumentSetSort');
|
||||||
|
|
||||||
// Document listing
|
// Document listing
|
||||||
$gridFieldConfig = GridFieldConfig::create()
|
$gridFieldConfig = GridFieldConfig::create()
|
||||||
->addComponents(
|
->addComponents(
|
||||||
@ -109,12 +112,7 @@ class DMSDocumentSet extends DataObject
|
|||||||
$gridFieldConfig->addComponent($paginatorComponent);
|
$gridFieldConfig->addComponent($paginatorComponent);
|
||||||
|
|
||||||
if (class_exists('GridFieldSortableRows')) {
|
if (class_exists('GridFieldSortableRows')) {
|
||||||
$sortableComponent = new GridFieldSortableRows('DocumentSort');
|
$gridFieldConfig->addComponent(new GridFieldSortableRows('DocumentSort'));
|
||||||
// setUsePagination method removed from newer version of SortableGridField.
|
|
||||||
if (method_exists($sortableComponent, 'setUsePagination')) {
|
|
||||||
$sortableComponent->setUsePagination(false)->setForceRedraw(true);
|
|
||||||
}
|
|
||||||
$gridFieldConfig->addComponent($sortableComponent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$field = $fields->fieldByName('Root.Main.PageID');
|
$field = $fields->fieldByName('Root.Main.PageID');
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<h3>$Title</h3>
|
<h3>$Title</h3>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
<% loop $getDocuments %>
|
<% loop $getDocuments.Sort(DocumentSort) %>
|
||||||
<% include Document %>
|
<% include Document %>
|
||||||
<% end_loop %>
|
<% end_loop %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -173,6 +173,26 @@ class DMSDocumentSetTest extends SapphireTest
|
|||||||
$this->assertSame('unit-test', $field->Value());
|
$this->assertSame('unit-test', $field->Value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure that if the module is available, the orderable rows GridField component is added
|
||||||
|
*/
|
||||||
|
public function testDocumentsAreOrderable()
|
||||||
|
{
|
||||||
|
if (!class_exists('GridFieldSortableRows')) {
|
||||||
|
$this->markTestSkipped('Test requires undefinedoffset/sortablegridfield installed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$fields = $this->objFromFixture('DMSDocumentSet', 'ds1')->getCMSFields();
|
||||||
|
|
||||||
|
$gridField = $fields->fieldByName('Root.Main.Documents');
|
||||||
|
$this->assertInstanceOf('GridField', $gridField);
|
||||||
|
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
'GridFieldSortableRows',
|
||||||
|
$gridField->getConfig()->getComponentByType('GridFieldSortableRows')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that extra documents are added after write
|
* Test that extra documents are added after write
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user