mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
API-CHANGE: SSF-33 Adding "look for new files" trigger. Removing the legacy implementation of SyncForm and replacing it with an implementation that can be triggered via ajax.
This commit is contained in:
parent
12c01d45de
commit
adefc15e5a
@ -30,7 +30,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
'removefile',
|
'removefile',
|
||||||
'savefile',
|
'savefile',
|
||||||
'deleteUnusedThumbnails' => 'ADMIN',
|
'deleteUnusedThumbnails' => 'ADMIN',
|
||||||
'SyncForm',
|
'doSync',
|
||||||
'filter',
|
'filter',
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -169,6 +169,19 @@ JS
|
|||||||
$addFolderBtn = '';
|
$addFolderBtn = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($folder->canEdit()) {
|
||||||
|
$syncButton = new LiteralField(
|
||||||
|
'SyncButton',
|
||||||
|
sprintf(
|
||||||
|
'<a class="ss-ui-button ss-ui-action cms-link-ajax" data-icon="" href="%s">%s</a>',
|
||||||
|
$this->Link('doSync'),
|
||||||
|
_t('FILESYSTEMSYNC','Sync files')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$syncButton = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Move existing fields to a "details" tab, unless they've already been tabbed out through extensions.
|
// Move existing fields to a "details" tab, unless they've already been tabbed out through extensions.
|
||||||
// Required to keep Folder->getCMSFields() simple and reuseable,
|
// Required to keep Folder->getCMSFields() simple and reuseable,
|
||||||
// without any dependencies into AssetAdmin (e.g. useful for "add folder" views).
|
// without any dependencies into AssetAdmin (e.g. useful for "add folder" views).
|
||||||
@ -192,7 +205,8 @@ JS
|
|||||||
$actionsComposite = Object::create('CompositeField',
|
$actionsComposite = Object::create('CompositeField',
|
||||||
Object::create('CompositeField',
|
Object::create('CompositeField',
|
||||||
$uploadBtn,
|
$uploadBtn,
|
||||||
$addFolderBtn
|
$addFolderBtn,
|
||||||
|
$syncButton //TODO: add this into a batch actions menu as in https://github.com/silverstripe/silverstripe-design/raw/master/Design/ss3-ui_files-manager-list-view.jpg
|
||||||
)->addExtraClass('cms-actions-row')
|
)->addExtraClass('cms-actions-row')
|
||||||
)->addExtraClass('cms-content-toolbar field'),
|
)->addExtraClass('cms-content-toolbar field'),
|
||||||
$gridField
|
$gridField
|
||||||
@ -419,28 +433,15 @@ JS
|
|||||||
//------------------------------------------------------------------------------------------//
|
//------------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
// Data saving handlers
|
// Data saving handlers
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Form
|
* Can be queried with an ajax request to trigger the filesystem sync. It returns a FormResponse status message
|
||||||
|
* to display in the CMS
|
||||||
*/
|
*/
|
||||||
public function SyncForm() {
|
public function doSync() {
|
||||||
$form = new Form(
|
$message = Filesystem::sync();
|
||||||
$this,
|
FormResponse::status_message($message, 'good');
|
||||||
'SyncForm',
|
echo FormResponse::respond();
|
||||||
new FieldList(
|
|
||||||
),
|
|
||||||
new FieldList(
|
|
||||||
FormAction::create('doSync', _t('FILESYSTEMSYNC','Look for new files'))
|
|
||||||
->describe(_t('AssetAdmin_left.ss.FILESYSTEMSYNC_DESC', 'SilverStripe maintains its own database of the files & images stored in your assets/ folder. Click this button to update that database, if files are added to the assets/ folder from outside SilverStripe, for example, if you have uploaded files via FTP.'))
|
|
||||||
->setUseButtonTag(true)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$form->setFormMethod('GET');
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function doSync($data, $form) {
|
|
||||||
return Filesystem::sync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user