mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FEATURE: add Levelup component to GridField as GridFieldLevelup
This commit is contained in:
parent
4e18cc581b
commit
7324712e9e
@ -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; }
|
||||
|
49
forms/gridfield/GridFieldLevelup.php
Normal file
49
forms/gridfield/GridFieldLevelup.php
Normal 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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
BIN
images/gridfield-level-up.png
Normal file
BIN
images/gridfield-level-up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 661 B |
@ -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;
|
||||
|
3
templates/Includes/GridFieldLevelup.ss
Normal file
3
templates/Includes/GridFieldLevelup.ss
Normal file
@ -0,0 +1,3 @@
|
||||
<div class="grid-levelup">
|
||||
$UpLink
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user