Skip to content

Commit

Permalink
Added filter by module availability
Browse files Browse the repository at this point in the history
  • Loading branch information
vovayatsyuk committed Mar 29, 2017
1 parent aaf0cd7 commit 6a7d091
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/code/community/TM/Core/Block/Adminhtml/Module/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public function __construct()
$this->setId('moduleGrid');
$this->setDefaultSort('release_date');
$this->setDefaultDir('DESC');
$this->setDefaultFilter(array(
'version' => TM_Core_Block_Adminhtml_Module_Grid_Filter_Version::VERSION_AVAILABLE
));
$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
$this->setVarNameFilter('module_filter');
Expand All @@ -31,6 +34,7 @@ protected function _prepareColumns()
$this->addColumn('version', array(
'header' => Mage::helper('tmcore')->__('Version'),
'align' => 'center',
'filter' => 'tmcore/adminhtml_module_grid_filter_version',
'renderer' => 'tmcore/adminhtml_module_grid_renderer_version',
'index' => 'version',
'width' => '150px'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

class TM_Core_Block_Adminhtml_Module_Grid_Filter_Version
extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select
{
const VERSION_AVAILABLE = 'available';
const VERSION_UNAVAILABLE = 'unavailable';

protected static $_options = array(
null => null,
self::VERSION_AVAILABLE => 'Available',
self::VERSION_UNAVAILABLE => 'Unavailable',
);

protected function _getOptions()
{
$result = array();
foreach (self::$_options as $code => $label) {
$result[] = array(
'value' => $code,
'label' => Mage::helper('adminhtml')->__($label)
);
}

return $result;
}

public function getCondition()
{
switch ($this->getValue()) {
case self::VERSION_AVAILABLE:
return array('neq' => '');
case self::VERSION_UNAVAILABLE:
return array('eq' => '');
default:
return null;
}
}
}

0 comments on commit 6a7d091

Please sign in to comment.