forked from extern/egroupware
allow et2_dialog.confirm to postSubmit (to download something)
This commit is contained in:
parent
b328bf151a
commit
fcc8bc9527
@ -657,10 +657,11 @@ jQuery.extend(et2_dialog, //(function(){ "use strict"; return
|
||||
* @param {widget} _senders widget that has been clicked
|
||||
* @param {String} _dialogMsg message shows in dialog box
|
||||
* @param {String} _titleMsg message shows as a title of the dialog box
|
||||
* @param {Bool} _postSubmit true: use postSubmit instead of submit
|
||||
*
|
||||
* @description submit the form contents including the button that has been pressed
|
||||
*/
|
||||
confirm: function(_senders,_dialogMsg, _titleMsg)
|
||||
confirm: function(_senders,_dialogMsg, _titleMsg, _postSubmit)
|
||||
{
|
||||
var senders = _senders;
|
||||
var buttonId = _senders.id;
|
||||
@ -670,9 +671,16 @@ jQuery.extend(et2_dialog, //(function(){ "use strict"; return
|
||||
var callbackDialog = function (button_id)
|
||||
{
|
||||
if (button_id == et2_dialog.YES_BUTTON )
|
||||
{
|
||||
if (_postSubmit)
|
||||
{
|
||||
senders.getRoot().getInstanceManager().postSubmit(buttonId);
|
||||
}
|
||||
else
|
||||
{
|
||||
senders.getRoot().getInstanceManager().submit(buttonId);
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_dialog.show_dialog(callbackDialog, egw.lang(dialogMsg), egw.lang(titleMsg), {},
|
||||
et2_dialog.BUTTON_YES_NO, et2_dialog.WARNING_MESSAGE, undefined, egw);
|
||||
@ -771,7 +779,7 @@ jQuery.extend(et2_dialog, //(function(){ "use strict"; return
|
||||
.text(response.data)
|
||||
.appendTo(log);
|
||||
|
||||
totals.failed++
|
||||
totals.failed++;
|
||||
|
||||
// Ask to retry / ignore / abort
|
||||
et2_createWidget("dialog", {
|
||||
|
@ -670,47 +670,7 @@ etemplate2.prototype.autocomplete_fixer = function ()
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Submit form via ajax
|
||||
*
|
||||
* @param {(et2_button|string)} button button widget or string with id
|
||||
* @param {boolean|string} async true: do an asynchronious submit, string: spinner message (please wait...)
|
||||
* default is asynchronoush with message
|
||||
* @param {boolean} no_validation - Do not do individual widget validation, just submit their current values
|
||||
* @param {et2_widget|undefined} _container container to submit, default whole template
|
||||
* @return {boolean} true if submit was send, false if eg. validation stoped submit
|
||||
*/
|
||||
etemplate2.prototype.submit = function(button, async, no_validation, _container)
|
||||
{
|
||||
var api = this.widgetContainer.egw();
|
||||
|
||||
if (typeof async == 'undefined' || typeof async == 'string')
|
||||
{
|
||||
api.loading_prompt('et2_submit_spinner', true, api.lang(typeof async == 'string' ? async : 'Please wait...'));
|
||||
async = true;
|
||||
}
|
||||
if(typeof no_validation == 'undefined')
|
||||
{
|
||||
no_validation = false;
|
||||
}
|
||||
var container = _container || this.widgetContainer;
|
||||
|
||||
// Get the form values
|
||||
var values = this.getValues(container);
|
||||
|
||||
// Trigger the submit event
|
||||
var canSubmit = true;
|
||||
if(!no_validation)
|
||||
{
|
||||
container.iterateOver(function(_widget) {
|
||||
if (_widget.submit(values) === false)
|
||||
{
|
||||
canSubmit = false;
|
||||
}
|
||||
}, this, et2_ISubmitListener);
|
||||
}
|
||||
|
||||
if (canSubmit)
|
||||
etemplate2.prototype._set_button = function (button, values)
|
||||
{
|
||||
if (typeof button == 'string')
|
||||
{
|
||||
@ -756,6 +716,51 @@ etemplate2.prototype.submit = function(button, async, no_validation, _container)
|
||||
values[button.id] = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Submit form via ajax
|
||||
*
|
||||
* @param {(et2_button|string)} button button widget or string with id
|
||||
* @param {boolean|string} async true: do an asynchronious submit, string: spinner message (please wait...)
|
||||
* default is asynchronoush with message
|
||||
* @param {boolean} no_validation - Do not do individual widget validation, just submit their current values
|
||||
* @param {et2_widget|undefined} _container container to submit, default whole template
|
||||
* @return {boolean} true if submit was send, false if eg. validation stoped submit
|
||||
*/
|
||||
etemplate2.prototype.submit = function(button, async, no_validation, _container)
|
||||
{
|
||||
var api = this.widgetContainer.egw();
|
||||
|
||||
if (typeof async == 'undefined' || typeof async == 'string')
|
||||
{
|
||||
api.loading_prompt('et2_submit_spinner', true, api.lang(typeof async == 'string' ? async : 'Please wait...'));
|
||||
async = true;
|
||||
}
|
||||
if(typeof no_validation == 'undefined')
|
||||
{
|
||||
no_validation = false;
|
||||
}
|
||||
var container = _container || this.widgetContainer;
|
||||
|
||||
// Get the form values
|
||||
var values = this.getValues(container);
|
||||
|
||||
// Trigger the submit event
|
||||
var canSubmit = true;
|
||||
if(!no_validation)
|
||||
{
|
||||
container.iterateOver(function(_widget) {
|
||||
if (_widget.submit(values) === false)
|
||||
{
|
||||
canSubmit = false;
|
||||
}
|
||||
}, this, et2_ISubmitListener);
|
||||
}
|
||||
|
||||
if (canSubmit)
|
||||
{
|
||||
if (button) this._set_button(button, values);
|
||||
|
||||
// Create the request object
|
||||
if (this.menuaction)
|
||||
@ -786,8 +791,10 @@ etemplate2.prototype.submit = function(button, async, no_validation, _container)
|
||||
*
|
||||
* Only use this one if you need it, use the ajax submit() instead.
|
||||
* It ensures eT2 session continues to exist on server by unbinding unload handler and rebinding it.
|
||||
*
|
||||
* @param {(et2_button|string)} button button widget or string with id
|
||||
*/
|
||||
etemplate2.prototype.postSubmit = function()
|
||||
etemplate2.prototype.postSubmit = function(button)
|
||||
{
|
||||
// Get the form values
|
||||
var values = this.getValues(this.widgetContainer);
|
||||
@ -803,6 +810,8 @@ etemplate2.prototype.postSubmit = function()
|
||||
|
||||
if (canSubmit)
|
||||
{
|
||||
if (button) this._set_button(button, values);
|
||||
|
||||
// unbind our session-destroy handler, as we are submitting
|
||||
this.unbind_unload();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user