Merge pull request #238 from christopherdarling/gridfieldfix

API Add support for gridfield
This commit is contained in:
Damian Mooyman 2016-03-24 11:55:52 +13:00
commit e84b61246e
3 changed files with 22 additions and 8 deletions

View File

@ -16,3 +16,7 @@ HtmlEditorField_Toolbar:
DataQuery: DataQuery:
extensions: extensions:
['Translatable'] ['Translatable']
GridFieldDetailForm_ItemRequest:
extensions:
['TranslatableCMSMainExtension']

View File

@ -120,15 +120,25 @@ class TranslatableCMSMainExtension extends Extension {
// persist in the database before the user requests it // persist in the database before the user requests it
$translatedRecord = $record->createTranslation($langCode); $translatedRecord = $record->createTranslation($langCode);
if ( $this->owner instanceof GridFieldDetailForm_ItemRequest ) {
$controller = $this->owner->getController();
$this->owner->record = $translatedRecord;
$url = $this->owner->Link('edit');
} else {
$controller = $this->owner;
$url = Controller::join_links( $url = Controller::join_links(
$this->owner->Link('show'), $this->owner->Link('show'),
$translatedRecord->ID $translatedRecord->ID
); );
}
// set the X-Pjax header to Content, so that the whole admin panel will be refreshed // set the X-Pjax header to Content, so that the whole admin panel will be refreshed
$this->owner->getResponse()->addHeader('X-Pjax', 'Content'); $controller->getResponse()->addHeader('X-Pjax', 'Content');
return $this->owner->redirect($url); return $controller->redirect($url);
} }
function updateLink(&$link) { function updateLink(&$link) {

View File

@ -66,7 +66,7 @@
* Requires: * Requires:
* jquery.metadata * jquery.metadata
*/ */
$('.LeftAndMain :input[name=action_createtranslation]').entwine({ $(':input[name=action_createtranslation]').entwine({
onclick: function(e) { onclick: function(e) {
this.parents('form').trigger('submit', [this]); this.parents('form').trigger('submit', [this]);