mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
parent
0584ad3c49
commit
ff710c9b92
@ -9,6 +9,7 @@ class GridFieldAddExistingSearchButton implements
|
|||||||
|
|
||||||
protected $title;
|
protected $title;
|
||||||
protected $fragment;
|
protected $fragment;
|
||||||
|
protected $searchList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $fragment
|
* @param string $fragment
|
||||||
@ -46,6 +47,22 @@ class GridFieldAddExistingSearchButton implements
|
|||||||
$this->fragment = $fragment;
|
$this->fragment = $fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a custom list to use to provide the searchable items.
|
||||||
|
*
|
||||||
|
* @param SS_List $list
|
||||||
|
*/
|
||||||
|
public function setSearchList(SS_List $list) {
|
||||||
|
$this->searchList = $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return SS_List|null
|
||||||
|
*/
|
||||||
|
public function getSearchList() {
|
||||||
|
return $this->searchList;
|
||||||
|
}
|
||||||
|
|
||||||
public function getHTMLFragments($grid) {
|
public function getHTMLFragments($grid) {
|
||||||
GridFieldExtensions::include_requirements();
|
GridFieldExtensions::include_requirements();
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class GridFieldAddExistingSearchHandler extends RequestHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function doSearch($data, $form) {
|
public function doSearch($data, $form) {
|
||||||
$list = $this->context->getResults($data);
|
$list = $this->context->getQuery($data, false, false, $this->getSearchList());
|
||||||
$list = $list->subtract($this->grid->getList());
|
$list = $list->subtract($this->grid->getList());
|
||||||
$list = new PaginatedList($list, $this->request);
|
$list = new PaginatedList($list, $this->request);
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ class GridFieldAddExistingSearchHandler extends RequestHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function Items() {
|
public function Items() {
|
||||||
$list = DataList::create($this->grid->getList()->dataClass());
|
$list = $this->getSearchList();
|
||||||
$list = $list->subtract($this->grid->getList());
|
$list = $list->subtract($this->grid->getList());
|
||||||
$list = new PaginatedList($list, $this->request);
|
$list = new PaginatedList($list, $this->request);
|
||||||
|
|
||||||
@ -99,4 +99,11 @@ class GridFieldAddExistingSearchHandler extends RequestHandler {
|
|||||||
return Controller::join_links($this->grid->Link(), 'add-existing-search', $action);
|
return Controller::join_links($this->grid->Link(), 'add-existing-search', $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return DataList
|
||||||
|
*/
|
||||||
|
protected function getSearchList() {
|
||||||
|
return $this->button->getSearchList() ?: DataList::create($this->grid->getList()->dataClass());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user