Added JQuery DataTables "editable" extension support
authorThierry Florac <thierry.florac@onf.fr>
Tue, 30 Sep 2014 15:03:13 +0200
changeset 74 c2bd88e15b5c
parent 73 a31cca83750d
child 75 e4c5705087a0
Added JQuery DataTables "editable" extension support
src/ztfy/myams/resources/js/myams.js
--- a/src/ztfy/myams/resources/js/myams.js	Tue Sep 30 14:47:39 2014 +0200
+++ b/src/ztfy/myams/resources/js/myams.js	Tue Sep 30 15:03:13 2014 +0200
@@ -1062,6 +1062,7 @@
 
 								function _submitAjaxForm(form, options) {
 
+									var button;
 									var data = form.data();
 									var form_options = data.amsFormOptions;
 
@@ -1072,15 +1073,23 @@
 									else
 										form_data_callback = data.amsFormDataInitCallback;
 									if (form_data_callback) {
+										var veto = {};
 										if (typeof(form_data_callback) == 'function')
-											var form_data = form_data_callback.call(form);
+											var form_data = form_data_callback.call(form, veto);
 										else
-											form_data = ams.executeFunctionByName(form_data_callback, form);
+											form_data = ams.executeFunctionByName(form_data_callback, form, veto);
+										if (veto.veto) {
+											button = form.data('ams-submit-button');
+											if (button)
+												button.button('reset');
+											ams.form.finalizeSubmitFooter.call(form);
+											return false;
+										}
 									} else {
 										form_data = data.amsFormData || {};
 									}
 
-									var button = $(form.data('ams-submit-button'));
+									button = $(form.data('ams-submit-button'));
 									var buttonHandler,
 										buttonTarget;
 									if (button) {
@@ -2287,7 +2296,9 @@
 												(data.amsDatatableGlobalFilter === false ? '' : 'F') +
 												">r<'dt-wrapper't" +
 												(extensions.indexOf('scroller') >= 0 ? 'S' : '') +
-												"><'dt-row dt-bottom-row'<'row'<'col-sm-6'i><'col-sm-6 text-right'p>>";
+												"><'dt-row dt-bottom-row'<'row'<'col-sm-6'" +
+												(data.amsDatatableInformation === false ? '': 'i') +
+												"><'col-sm-6 text-right'p>>";
 											var data_options = {
 												bJQueryUI: false,
 												bFilter: data.amsDatatableGlobalFilter !== false,
@@ -2335,6 +2346,12 @@
 															};
 															settings.oColVis = $.extend({}, cv_default, data.amsDatatableColvisOptions);
 															break;
+														case 'editable':
+															ams.ajax.check($.fn.editable,
+																		   ams.baseURL + 'ext/jquery-jeditable' + (ams.devmode ? '.js' : '.min.js'));
+															ams.ajax.check($.fn.makeEditable,
+																		   ams.baseURL + 'ext/jquery-dataTables-editable' + (ams.devmode ? '.js' : '.min.js'));
+															break;
 														case 'fixedcolumns':
 															ams.ajax.check($.fn.dataTable.FixedColumns,
 																		   ams.baseURL + 'ext/jquery-dataTables-fixedColumns' + (ams.devmode ? '.js' : '.min.js'));
@@ -2387,6 +2404,13 @@
 																						? plugin.columnFilter(cf_settings)
 																						: ams.executeFunctionByName(data.amsDatatableColumnfilterConstructor, table, plugin, cf_settings));
 															break;
+														case 'editable':
+															var ed_settings = $.extend({}, data.amsDatatableEditableOptions, settings.editable);
+															ed_settings = ams.executeFunctionByName(data.amsDatatableEditableInitCallback, table, ed_settings) || ed_settings;
+															table.data('ams-editable', data.amsDatatableEditableConstructor === undefined
+																						? table.makeEditable(ed_settings)
+																						: ams.executeFunctionByName(data.amsDatatableEditableConstructor, table, plugin, ed_settings));
+															break;
 														case 'fixedcolumns':
 															var fc_settings = $.extend({}, data.amsDatatableFixedcolumnsOptions, settings.fixedcolumns);
 															fc_settings = ams.executeFunctionByName(data.amsDatatableFixedcolumnsInitCallback, table, fc_settings) || fc_settings;