mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 12:05:56 +00:00
NEW Document sorting (and optional drag'n'drop)
This commit is contained in:
parent
bd75a41f9b
commit
f7f268a859
@ -45,6 +45,7 @@ Example:
|
||||
### Requirements
|
||||
|
||||
* PHP 5.3 with the "fileinfo" module (or alternatively the "whereis" and "file" Unix commands)
|
||||
* (optional) [https://github.com/UndefinedOffset/SortableGridField]("SortableGridField" module)
|
||||
|
||||
### Configuration
|
||||
|
||||
|
@ -18,6 +18,12 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
||||
'Tags' => 'DMSTag'
|
||||
);
|
||||
|
||||
static $many_many_extraFields = array(
|
||||
'Pages' => array(
|
||||
'DocumentSort' => 'Int'
|
||||
),
|
||||
);
|
||||
|
||||
static $display_fields = array(
|
||||
'ID'=>'ID',
|
||||
'Title'=>'Title',
|
||||
|
@ -19,12 +19,17 @@ class DMSSiteTreeExtension extends DataExtension {
|
||||
new GridFieldFilterHeader(),
|
||||
new GridFieldSortableHeader(),
|
||||
new GridFieldDataColumns(),
|
||||
new GridFieldPaginator(15),
|
||||
$paginatorComponent = new GridFieldPaginator(15),
|
||||
new GridFieldEditButton(),
|
||||
new DMSGridFieldDeleteAction(), //special delete dialog to handle custom behaviour of unlinking and deleting
|
||||
new GridFieldDetailForm()
|
||||
//GridFieldLevelup::create($folder->ID)->setLinkSpec('admin/assets/show/%d')
|
||||
);
|
||||
if(class_exists('GridFieldSortableRows')) {
|
||||
$sortableComponent = new GridFieldSortableRows('DocumentSort');
|
||||
$sortableComponent->setUsePagination(false)->setForceRedraw(true);
|
||||
$gridFieldConfig->addComponent($sortableComponent);
|
||||
}
|
||||
|
||||
// HACK: Create a singleton of DMSDocument to ensure extensions are applied before we try to get display fields.
|
||||
singleton('DMSDocument');
|
||||
@ -60,6 +65,13 @@ class DMSSiteTreeExtension extends DataExtension {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded to enforce sorting
|
||||
*/
|
||||
function Documents() {
|
||||
return $this->owner->getManyManyComponents('Documents')->sort('DocumentSort');
|
||||
}
|
||||
|
||||
function onBeforeDelete() {
|
||||
$dmsDocuments = $this->owner->Documents();
|
||||
foreach($dmsDocuments as $document) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user