ENHANCEMENT Filterpanel for assetadmin

This commit is contained in:
Stig Lindqvist 2012-02-21 16:02:54 +13:00
parent f620f9b46c
commit 876c809a7d
2 changed files with 36 additions and 1 deletions

View File

@ -31,6 +31,7 @@ class AssetAdmin extends LeftAndMain {
'savefile',
'deleteUnusedThumbnails' => 'ADMIN',
'SyncForm',
'filter',
);
/**
@ -103,6 +104,40 @@ JS
return $form;
}
/**
* Returns a form for filtering of files and assets gridfield
*
* @return Form
* @see AssetAdmin.js
*/
public function FilterForm() {
$fields = new FieldList();
// Below is the filters that this field should filter on
$fields->push(new TextField('Title'));
$fields->push(new TextField('ClassName','Type'));
$actions = new FieldList();
$actions->push(new FormAction('doFilter', 'Filter'));
$actions->push(new ResetFormAction('doResetFilter', 'Clear Filter'));
$form = new Form($this, 'filter', $fields, $actions);
$form->addExtraClass('cms-filter-form');
// This have to match data-name attribute on the gridfield so that the javascript selectors work
$form->setAttribute('data-gridfield', 'File');
return $form;
}
/**
* If this method get's called, it means that javascript didn't hook into to the submit on
* FilterForm and we can currently not do a Filter without javascript.
*
* @param SS_HTTPRequest $data
* @throws SS_HTTPResponse_Exception
*/
public function filter(SS_HTTPRequest $data) {
throw new SS_HTTPResponse_Exception('Filterpanel doesn\'t work without javascript enabled.');
}
public function AddForm() {
$form = parent::AddForm();
$form->Actions()->fieldByName('action_doAdd')->setTitle(_t('AssetAdmin.ActionAdd', 'Add folder'));

View File

@ -1,7 +1,7 @@
<div class="cms-content-tools west cms-panel cms-panel-layout collapsed" id="cms-content-tools" data-expandOnClick="true" data-layout-type="border">
<div class="cms-panel-content center">
<h3 class="cms-panel-header"><% _t('FILTER', 'Filter') %></h3>
TODO
$FilterForm
</div>
<div class="cms-panel-content-collapsed">
<h3 class="cms-panel-header"><% _t('FILTER', 'Filter') %></h3>