mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 09:05:59 +00:00
BUGFIX Fixed createtranslation action (broken after moving to extension)
This commit is contained in:
parent
e40b5f909b
commit
181bb07f4c
@ -4,16 +4,11 @@
|
||||
*/
|
||||
class TranslatableCMSMainExtension extends Extension {
|
||||
|
||||
function extraStatics() {
|
||||
return array(
|
||||
'allowed_actions' => array(
|
||||
'createtranslation',
|
||||
)
|
||||
);
|
||||
}
|
||||
static $allowed_actions = array(
|
||||
'createtranslation',
|
||||
);
|
||||
|
||||
function init() {
|
||||
|
||||
// Locale" attribute is either explicitly added by LeftAndMain Javascript logic,
|
||||
// or implied on a translated record (see {@link Translatable->updateCMSFields()}).
|
||||
// $Lang serves as a "context" which can be inspected by Translatable - hence it
|
||||
@ -76,7 +71,7 @@ class TranslatableCMSMainExtension extends Extension {
|
||||
$translatedRecord->ID,
|
||||
$langCode
|
||||
);
|
||||
|
||||
|
||||
return Director::redirect($url);
|
||||
}
|
||||
|
||||
|
@ -48,29 +48,22 @@
|
||||
* Requires:
|
||||
* jquery.metadata
|
||||
*/
|
||||
$('.CMSMain .createTranslation').entwine({
|
||||
$('.CMSMain :input[name=action_createtranslation]').entwine({
|
||||
|
||||
/**
|
||||
* Constructor: onmatch
|
||||
*/
|
||||
onmatch: function() {
|
||||
var self = this;
|
||||
|
||||
this.find(':input[name=action_createtranslation]').bind('click', function(e) {
|
||||
var form = self.parents('form');
|
||||
// redirect to new URL
|
||||
// TODO This should really be a POST request
|
||||
|
||||
document.location.href = $('base').attr('href') +
|
||||
jQuery(self).metadata().url +
|
||||
'?ID=' + form.find(':input[name=ID]').val() +
|
||||
'&newlang=' + self.find(':input[name=NewTransLang]').val() +
|
||||
'&locale=' + form.find(':input[name=Locale]').val();
|
||||
onclick: function() {
|
||||
var form = this.parents('form'), locale = form.find(':input[name=NewTransLang]').val();
|
||||
var params = {
|
||||
'ID': form.find(':input[name=ID]').val(),
|
||||
'newlang': locale,
|
||||
'locale': locale,
|
||||
'SecurityID': form.find(':input[name=SecurityID]').val()
|
||||
};
|
||||
// redirect to new URL
|
||||
// TODO This should really be a POST request
|
||||
// TODO Fix hardcode URL
|
||||
document.location.href = $('base').attr('href') + 'admin/createtranslation?' + $.param(params);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
this._super();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user