Permalink
Browse files

ENHANCEMENT Confirming deletion of records in GridField via JavaScrip…

…t alert
  • Loading branch information...
1 parent 3c29a92 commit abedf2a4a90b7d3b68cbfbde19c48a1961329d8a @chillu chillu committed Feb 21, 2012
Showing with 11 additions and 3 deletions.
  1. +2 −1 forms/gridfield/GridField.php
  2. +8 −1 javascript/GridField.js
  3. +1 −1 javascript/GridFieldSearch.js
@@ -712,6 +712,7 @@ public function Field() {
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 @@ public function Field() {
// 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
@@ -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
@@ -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) {

0 comments on commit abedf2a

Please sign in to comment.