FEATURE: add Levelup component to GridField as GridFieldLevelup

This commit is contained in:
Normann Lou 2012-05-07 13:40:41 +12:00
parent 4e18cc581b
commit 7324712e9e
5 changed files with 62 additions and 0 deletions

View File

@ -10,6 +10,8 @@ multiple images. */
.cms .ss-gridfield p button#action_export { margin-top: 12px; }
.cms .ss-gridfield p button#action_export span.btn-icon-download-csv { height: 17px; }
.cms .ss-gridfield p button#action_export span.ui-button-text { padding-left: 26px; }
.cms .ss-gridfield .grid-levelup { text-indent: -9999em; margin-bottom: 6px; }
.cms .ss-gridfield .grid-levelup a.list-parent-link { background: transparent url(../images/gridfield-level-up.png) no-repeat 0 0; display: block; }
.cms .ss-gridfield .add-existing-autocompleter { width: 500px; }
.cms .ss-gridfield .add-existing-autocompleter input.relation-search { width: 380px; }
.cms .ss-gridfield .grid-print-button { display: inline-block; }

View File

@ -0,0 +1,49 @@
<?php
class GridFieldLevelup implements GridField_HTMLProvider{
/**
* @var integer - the record id of the level up to
*/
protected $levelID = null;
/**
*
* @param integer $levelID - the record id of the level up to
*/
public function __construct($levelID = null) {
if($levelID && is_numeric($levelID)) {
$this->levelID = $levelID;
}
}
public function getHTMLFragments($gridField) {
$modelClass = $gridField->getModelClass();
if(isset($_GET['ParentID']) && $_GET['ParentID']){
$modelObj = DataObject::get_by_id($modelClass, $_GET['ParentID']);
if(is_callable(array($modelObj, 'getParent'))){
$levelup = $modelObj->getParent();
if(!$levelup){
$parentID = 0;
}else{
$parentID = $levelup->ID;
}
}
//$controller = $gridField->getForm()->Controller();
$forTemplate = new ArrayData(array(
'UpLink' => sprintf(
'<a class="cms-panel-link list-parent-link" href="?ParentID=%d&view=list" data-target-panel="#Form_ListViewForm" data-pjax="ListViewForm">%s</a>',
$parentID,
_t('GridField.LEVELUP', 'Level up' )
),
));
return array(
'before' => $forTemplate->renderWith('GridFieldLevelup'),
//'header' => $forTemplate->renderWith('GridFieldLevelup_Row'),
);
}
}
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

View File

@ -76,6 +76,14 @@ $gf_grid_x: 16px;
}
.ss-gridfield {
.grid-levelup {
text-indent: -9999em;
a.list-parent-link{
background: transparent url(../images/gridfield-level-up.png) no-repeat 0 0;
display:block;
}
margin-bottom: 6px;
}
.add-existing-autocompleter {
input.relation-search {
width: 380px;

View File

@ -0,0 +1,3 @@
<div class="grid-levelup">
$UpLink
</div>