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