diff --git a/assets/js/grido.js b/assets/js/grido.js index 36cc1246..84aa3bdb 100644 --- a/assets/js/grido.js +++ b/assets/js/grido.js @@ -68,11 +68,14 @@ */ initFilters: function() { + var that = this; $('.filter select, .filter [type=checkbox]', this.$element) .off('change.grido') - .on('change.grido', this.sendFilterForm); + .on('change.grido', function(){ + that.sendFilterForm(); + }); + - var that = this; $('.filter input, .filter textarea', this.$element) .off('focus.grido') .on('focus.grido', function() { diff --git a/src/Components/Filters/Condition.php b/src/Components/Filters/Condition.php index 39ea3622..3c245c12 100644 --- a/src/Components/Filters/Condition.php +++ b/src/Components/Filters/Condition.php @@ -12,6 +12,7 @@ namespace Grido\Components\Filters; use Grido\Exception; +use Nette; /** * Builds filter condition. @@ -25,8 +26,11 @@ * @property mixed $value * @property-read callable $callback */ -class Condition extends \Nette\Object +class Condition { + + use Nette\SmartObject; + const OPERATOR_OR = 'OR'; const OPERATOR_AND = 'AND'; diff --git a/src/Customization.php b/src/Customization.php index 195c3820..a21c36aa 100644 --- a/src/Customization.php +++ b/src/Customization.php @@ -11,8 +11,7 @@ namespace Grido; -use Grido\Grid; -use Nette\Object; +use Nette; /** * Customization. @@ -23,9 +22,11 @@ * @property string|array $buttonClass * @property string|array $iconClass */ -class Customization extends Object +class Customization { + use Nette\SmartObject; + const TEMPLATE_DEFAULT = 'default'; const TEMPLATE_BOOTSTRAP = 'bootstrap'; diff --git a/src/DataSources/ArraySource.php b/src/DataSources/ArraySource.php index 04fff8d4..5b95e65b 100644 --- a/src/DataSources/ArraySource.php +++ b/src/DataSources/ArraySource.php @@ -13,8 +13,8 @@ use Grido\Exception; use Grido\Components\Filters\Condition; - use Nette\Utils\Strings; +use Nette; /** * Array data source. @@ -27,8 +27,10 @@ * @property-read array $data * @property-read int $count */ -class ArraySource extends \Nette\Object implements IDataSource +class ArraySource implements IDataSource { + use Nette\SmartObject; + /** @var array */ protected $data; diff --git a/src/DataSources/DibiFluent.php b/src/DataSources/DibiFluent.php index f0910f52..b75398de 100644 --- a/src/DataSources/DibiFluent.php +++ b/src/DataSources/DibiFluent.php @@ -12,6 +12,7 @@ namespace Grido\DataSources; use Grido\Exception; +use Nette; /** * Dibi Fluent data source. @@ -26,8 +27,10 @@ * @property-read int $count * @property-read array $data */ -class DibiFluent extends \Nette\Object implements IDataSource +class DibiFluent implements IDataSource { + use Nette\SmartObject; + /** @var \DibiFluent */ protected $fluent; diff --git a/src/DataSources/Doctrine.php b/src/DataSources/Doctrine.php index aba0e4f1..6c6925e3 100644 --- a/src/DataSources/Doctrine.php +++ b/src/DataSources/Doctrine.php @@ -17,6 +17,7 @@ use Nette\Utils\Strings; use Nette\Utils\Random; use Doctrine\ORM\Tools\Pagination\Paginator; +use Nette; /** * Doctrine data source. @@ -32,8 +33,10 @@ * @property-read int $count * @property-read array $data */ -class Doctrine extends \Nette\Object implements IDataSource +class Doctrine implements IDataSource { + use Nette\SmartObject; + /** @var \Doctrine\ORM\QueryBuilder */ protected $qb; diff --git a/src/DataSources/Model.php b/src/DataSources/Model.php index 11775b7b..f895dab9 100644 --- a/src/DataSources/Model.php +++ b/src/DataSources/Model.php @@ -12,6 +12,7 @@ namespace Grido\DataSources; use Grido\Exception; +use Nette; /** * Model of data source. @@ -22,8 +23,10 @@ * * @property-read IDataSource $dataSource */ -class Model extends \Nette\Object +class Model { + use Nette\SmartObject; + /** @var array */ public $callback = []; diff --git a/src/DataSources/NetteDatabase.php b/src/DataSources/NetteDatabase.php index bd389a39..03b7d774 100644 --- a/src/DataSources/NetteDatabase.php +++ b/src/DataSources/NetteDatabase.php @@ -13,6 +13,7 @@ use Grido\Exception; use Grido\Components\Filters\Condition; +use Nette; /** * Nette Database data source. @@ -25,8 +26,10 @@ * @property-read int $count * @property-read array $data */ -class NetteDatabase extends \Nette\Object implements IDataSource +class NetteDatabase implements IDataSource { + use Nette\SmartObject; + /** @var \Nette\Database\Table\Selection */ protected $selection; diff --git a/src/Grid.php b/src/Grid.php index 3f95b403..f8a4e2b1 100644 --- a/src/Grid.php +++ b/src/Grid.php @@ -135,6 +135,22 @@ class Grid extends Components\Container /** @var Customization */ protected $customization; + /** + * Grid constructor. + */ + public function __construct() + { + parent::__construct(); + list($parent, $name) = func_get_args() + [null, null]; + if ($parent !== null) { + $parent->addComponent($this, $name); + + } elseif (is_string($name)) { + $this->name = $name; + } + } + + /** * Sets a model that implements the interface Grido\DataSources\IDataSource or data-source object. * @param mixed $model diff --git a/src/Translations/FileTranslator.php b/src/Translations/FileTranslator.php index 4fde6561..ce828a39 100644 --- a/src/Translations/FileTranslator.php +++ b/src/Translations/FileTranslator.php @@ -12,6 +12,7 @@ namespace Grido\Translations; use Grido\Exception; +use Nette; /** * Simple file translator. @@ -20,8 +21,10 @@ * @subpackage Translations * @author Petr Bugyík */ -class FileTranslator extends \Nette\Object implements \Nette\Localization\ITranslator +class FileTranslator implements \Nette\Localization\ITranslator { + use Nette\SmartObject; + /** @var array */ protected $translations = [];