API Add support for gridfield

This commit is contained in:
Christopher Darling 2016-03-23 21:55:35 +00:00
parent 7bfece9666
commit 87687abdab
3 changed files with 22 additions and 8 deletions

View File

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

View File

@ -120,15 +120,25 @@ class TranslatableCMSMainExtension extends Extension {
// persist in the database before the user requests it
$translatedRecord = $record->createTranslation($langCode);
$url = Controller::join_links(
$this->owner->Link('show'),
$translatedRecord->ID
);
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(
$this->owner->Link('show'),
$translatedRecord->ID
);
}
// 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) {

View File

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