ENHANCEMENT Confirming deletion of records in GridField via JavaScript alert

This commit is contained in:
Ingo Schommer 2012-02-21 21:30:51 +01:00
parent 3c29a9268c
commit abedf2a4a9
3 changed files with 11 additions and 3 deletions

View File

@ -712,6 +712,7 @@ class GridField_Action extends FormAction {
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascript(THIRDPARTY_DIR . '/json-js/json2.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/i18n.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/GridField.js');
@ -729,7 +730,7 @@ class GridField_Action extends FormAction {
// And generate field
$attributes = array(
'class' => 'action' . ($this->extraClass() ? $this->extraClass() : ''),
'class' => ($this->extraClass() ? $this->extraClass() : '') . ' action-' . $this->actionName,
'id' => $this->id(),
'type' => 'submit',
// Note: This field needs to be less than 65 chars, otherwise Suhosin security patch

View File

@ -27,7 +27,7 @@
if(successCallback) successCallback.apply(this, arguments);
},
error: function(e) {
alert(ss.i18n._t('GRIDFIELD.ERRORINTRANSACTION', 'An error occured while fetching data from the server\n Please try again later.'));
alert(ss.i18n._t('GRIDFIELD.ERRORINTRANSACTION'));
form.removeClass('loading');
}
}, ajaxOpts));
@ -64,6 +64,13 @@
e.preventDefault();
}
});
$('fieldset.ss-gridfield .action-deleterecord').entwine({
onclick: function(e){
if(!confirm(ss.i18n._t('TABLEFIELD.DELETECONFIRMMESSAGE'))) return false;
else this._super(e);
}
});
/*
* Upon focusing on a filter <input> element, move "filter" and "reset" buttons and display next to the current <input> element

View File

@ -16,7 +16,7 @@ jQuery(function($){
data: form.serialize()+'&'+escape(searchField.attr('name'))+'='+escape(searchField.val()),
success: function(data) {
response( $.map(JSON.parse(data), function( name, id ) {
return { label: name, value: name, id: id }
return { label: name, value: name, id: id };
}));
},
error: function(e) {