This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from mwgamble/add_edit_column_to_grids
Grid usability enhancements
- Loading branch information
Showing
5 changed files
with
203 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
app/code/community/BL/CustomGrid/Model/Custom/Column/Action.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
class BL_CustomGrid_Model_Custom_Column_Action extends BL_CustomGrid_Model_Custom_Column_Abstract | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $_getter = "getId"; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $_field = "id"; | ||
|
||
/** | ||
* Apply the custom column to the given grid collection | ||
* | ||
* @param Varien_Data_Collection_Db $collection | ||
* @param Mage_Adminhtml_Block_Widget_Grid $gridBlock | ||
* @param BL_CustomGrid_Model_Grid $gridModel | ||
* @param string $columnBlockId | ||
* @param string $columnIndex | ||
* @param array $params | ||
* @param Mage_Core_Model_Store $store | ||
* @return $this | ||
*/ | ||
public function applyToGridCollection( | ||
Varien_Data_Collection_Db $collection, | ||
Mage_Adminhtml_Block_Widget_Grid $gridBlock, | ||
BL_CustomGrid_Model_Grid $gridModel, | ||
$columnBlockId, | ||
$columnIndex, | ||
array $params, | ||
Mage_Core_Model_Store $store | ||
) { | ||
return $this; | ||
} | ||
|
||
public function getForcedBlockValues( | ||
Mage_Adminhtml_Block_Widget_Grid $gridBlock, | ||
BL_CustomGrid_Model_Grid $gridModel, | ||
$customBlockId, | ||
$columnIndex, | ||
array $params, | ||
Mage_Core_Model_Store $store | ||
) { | ||
$values = array( | ||
"type" => "action", | ||
"filter" => false, | ||
"sortable" => false, | ||
"is_system" => true, | ||
); | ||
|
||
$editSettings = $this->getCurrentBlockValues(); | ||
if (isset($editSettings["actions"])) { | ||
$values["actions"] = $editSettings["actions"]; | ||
$values["actions"]["edit"]["caption"] = "Edit"; | ||
$values["actions"]["edit"]["url"] = array("base" => "*/*/edit"); | ||
} | ||
|
||
return $values; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
app/code/community/BL/CustomGrid/Model/Grid/Type/Product/Attributes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
class BL_CustomGrid_Model_Grid_Type_Product_Attributes extends BL_CustomGrid_Model_Grid_Type_Abstract | ||
{ | ||
/** | ||
* @return string[]|string | ||
*/ | ||
protected function _getSupportedBlockTypes() | ||
{ | ||
return array( | ||
'adminhtml/catalog_product_attribute_grid', | ||
); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
app/code/community/BL/CustomGrid/Model/Grid/Type/Product/Rating.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* | ||
* @category BL | ||
* @package BL_CustomGrid | ||
* @copyright Copyright (c) 2014 Benoît Leulliette <[email protected]> | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
class BL_CustomGrid_Model_Grid_Type_Product_Rating extends BL_CustomGrid_Model_Grid_Type_Abstract | ||
{ | ||
/** | ||
* @return string[]|string | ||
*/ | ||
protected function _getSupportedBlockTypes() | ||
{ | ||
return array('adminhtml/rating_grid'); | ||
} | ||
|
||
/** | ||
* @param string $blockType | ||
* @return array | ||
*/ | ||
protected function _getBaseEditableFields($blockType) | ||
{ | ||
$fields = array( | ||
'rating_code' => array( | ||
'type' => 'text', | ||
'required' => true, | ||
), | ||
'position' => array( | ||
'type' => 'text', | ||
'required' => true, | ||
'form_class' => 'validate-number', | ||
), | ||
); | ||
|
||
return $fields; | ||
} | ||
|
||
protected function _getEntityRowIdentifiersKeys($blockType) | ||
{ | ||
return array('rating_id'); | ||
} | ||
|
||
protected function _loadEditedEntity($blockType, BL_CustomGrid_Object $config, array $params, $entityId) | ||
{ | ||
return Mage::getModel('rating/rating')->load($entityId); | ||
} | ||
|
||
protected function _getEditRequiredAclPermissions($blockType) | ||
{ | ||
return 'catalog/reviews_ratings/ratings'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters