mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-24 06:14:25 +02:00
SortBox: Fix some documenation and code style issues
This commit is contained in:
parent
f7b35b04f4
commit
e231ef8061
@ -12,22 +12,17 @@ use Icinga\Web\Request;
|
|||||||
/**
|
/**
|
||||||
* SortBox widget
|
* SortBox widget
|
||||||
*
|
*
|
||||||
* The "SortBox" Widget allows you to create a generic sort input for sortable views. It automatically creates a form
|
* The "SortBox" Widget allows you to create a generic sort input for sortable views. It automatically creates a select
|
||||||
* containing a select box with all sort options and a dropbox with the sort direction. It also handles automatic
|
* box with all sort options and a dropbox with the sort direction. It also handles automatic submission of sorting
|
||||||
* submission of sorting changes and draws an additional submit button when JavaScript is disabled.
|
* changes and draws an additional submit button when JavaScript is disabled.
|
||||||
*
|
*
|
||||||
* The constructor takes an string for the component name and an array containing the select options, where the key is
|
* The constructor takes a string for the component name and an array containing the select options, where the key is
|
||||||
* the value to be submitted and the value is the label that will be shown. You then should call setRequest in order
|
* the value to be submitted and the value is the label that will be shown. You then should call setRequest in order
|
||||||
* to make sure the form is correctly populated when a request with a sort parameter is being made.
|
* to make sure the form is correctly populated when a request with a sort parameter is being made.
|
||||||
*
|
*
|
||||||
* Example:
|
* Call setQuery in case you'll do not want to handle URL parameters manually, but to automatically apply the user's
|
||||||
* <pre><code>
|
* chosen sort rules on the given sortable query. This will also allow the SortBox to display the user the correct
|
||||||
* $this->view->sortControl = new SortBox(
|
* default sort rules if the given query provides already some sort rules.
|
||||||
* $this->getRequest()->getActionName(),
|
|
||||||
* $columns
|
|
||||||
* );
|
|
||||||
* $this->view->sortControl->setRequest($this->getRequest());
|
|
||||||
* </code></pre>
|
|
||||||
*/
|
*/
|
||||||
class SortBox extends AbstractWidget
|
class SortBox extends AbstractWidget
|
||||||
{
|
{
|
||||||
@ -39,25 +34,25 @@ class SortBox extends AbstractWidget
|
|||||||
protected $sortFields;
|
protected $sortFields;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the form that will be created
|
* The name used to uniquely identfy the forms being created
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $name;
|
protected $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A request object used for initial form population
|
* The request to fetch sort rules from
|
||||||
*
|
*
|
||||||
* @var Request
|
* @var Request
|
||||||
*/
|
*/
|
||||||
protected $request;
|
protected $request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What to apply sort parameters on
|
* The query to apply sort rules on
|
||||||
*
|
*
|
||||||
* @var Sortable
|
* @var Sortable
|
||||||
*/
|
*/
|
||||||
protected $query = null;
|
protected $query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a SortBox with the entries from $sortFields
|
* Create a SortBox with the entries from $sortFields
|
||||||
@ -85,9 +80,9 @@ class SortBox extends AbstractWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply the parameters from the given request on this SortBox
|
* Set the request to fetch sort rules from
|
||||||
*
|
*
|
||||||
* @param Request $request The request to use for populating the form
|
* @param Request $request
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
@ -98,9 +93,11 @@ class SortBox extends AbstractWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Sortable $query
|
* Set the query to apply sort rules on
|
||||||
*
|
*
|
||||||
* @return $this
|
* @param Sortable $query
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setQuery(Sortable $query)
|
public function setQuery(Sortable $query)
|
||||||
{
|
{
|
||||||
@ -108,6 +105,13 @@ class SortBox extends AbstractWidget
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply the sort rules from the given or current request on the query
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
public function handleRequest(Request $request = null)
|
public function handleRequest(Request $request = null)
|
||||||
{
|
{
|
||||||
if ($this->query !== null) {
|
if ($this->query !== null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user