From 7324712e9eabfeb31064d766f4e5299a8835cb29 Mon Sep 17 00:00:00 2001 From: Normann Lou Date: Mon, 7 May 2012 13:40:41 +1200 Subject: [PATCH] FEATURE: add Levelup component to GridField as GridFieldLevelup --- css/GridField.css | 2 + forms/gridfield/GridFieldLevelup.php | 49 +++++++++++++++++++++++++ images/gridfield-level-up.png | Bin 0 -> 661 bytes scss/GridField.scss | 8 ++++ templates/Includes/GridFieldLevelup.ss | 3 ++ 5 files changed, 62 insertions(+) create mode 100644 forms/gridfield/GridFieldLevelup.php create mode 100644 images/gridfield-level-up.png create mode 100644 templates/Includes/GridFieldLevelup.ss diff --git a/css/GridField.css b/css/GridField.css index 1f101c1d0..dbe78d889 100644 --- a/css/GridField.css +++ b/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; } diff --git a/forms/gridfield/GridFieldLevelup.php b/forms/gridfield/GridFieldLevelup.php new file mode 100644 index 000000000..51f3170da --- /dev/null +++ b/forms/gridfield/GridFieldLevelup.php @@ -0,0 +1,49 @@ +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( + '%s', + $parentID, + _t('GridField.LEVELUP', 'Level up' ) + ), + )); + + return array( + 'before' => $forTemplate->renderWith('GridFieldLevelup'), + //'header' => $forTemplate->renderWith('GridFieldLevelup_Row'), + ); + } + } +} +?> \ No newline at end of file diff --git a/images/gridfield-level-up.png b/images/gridfield-level-up.png new file mode 100644 index 0000000000000000000000000000000000000000..b3c7fa4fd1541517ebf465e5d7b9c510fbacee58 GIT binary patch literal 661 zcmV;G0&4wxk;weMGFPB zMe(r`L>FFH(k|RMir_*)tPJYTm5_xS7os5Q#)TjVF03x<-_T;+hz}?@9jV}=f{u?& zCmB>)|&UeovS4olt|5Fr6u4cT zio$R<3_}D$AoP6*LjBU-fe6$;*lQHjoUU%*a+UAv&ER)}B&pG9%~OXb`0}!k=|dA- zzDxVR6Ht&K2+Z1%EqrmY1IH0)G&(q0-OQzZJtXQ{Y&y9R=INt5_`*UPz905buiH3r za4VPoq#%i!2d4&_XO8XU&8CO3F>1D!z_x9;ZW~eL5XpN~_iyAuK@uh(kq}dIn(o|x z_A+-&@=e^bRxmz3iYL!MX7*-x^b}=^mf3*`DEPTJj`LE1Cg;WXSb<;~JSgc{(%9~! zz}>V}6@@a$C5|F^tE;K*s0JK8Mp-c+JTJACD;21vQlTdI2*MzMOEu5MVnb*R(GRCF z1eAdkxekwvq(5aLg4X;D+>Qf%_wk;iMFj1#L8VdC66Mlha+Ck%)+Wf~i5Pfd+KHg)_T*=hA3{tic&Sv_9pL!ra_8whFY4QSf zQb9$drc+<#9TYviiTKN#Uk`Y>Pwywl?Q{JEvas7J$S^)NmcHJ;yXLXpE|Hy+CR2Gw va0}h0+4xDaQG))L{SjeB5)FFI{}5mRGg=c78#-{!00000NkvXXu0mjfb$u + $UpLink + \ No newline at end of file