Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FEATURE: add Levelup component to GridField as GridFieldLevelup

  • Loading branch information...
commit 7324712e9eabfeb31064d766f4e5299a8835cb29 1 parent 4e18cc5
@normann normann authored
View
2  css/GridField.css
@@ -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
49 forms/gridfield/GridFieldLevelup.php
@@ -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'),
+ );
+ }
+ }
+}
+?>
View
BIN  images/gridfield-level-up.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
8 scss/GridField.scss
@@ -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
3  templates/Includes/GridFieldLevelup.ss
@@ -0,0 +1,3 @@
+<div class="grid-levelup">
+ $UpLink
+</div>
Please sign in to comment.
Something went wrong with that request. Please try again.