CallBackery
view release on metacpan or search on metacpan
lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/plugin/Action.js view on Meta::CPAN
return;
}
switch (btCfg.action) {
case 'save':
var formData = getFormData();
var key = btCfg.key;
callbackery.data.Server.getInstance().callAsync(function (ret) {
that.fireDataEvent('actionResponse', ret || {});
}, 'processPluginData', cfg.name, { "key": key, "formData": formData });
break;
case 'submitVerify':
case 'submit':
var formData = getFormData();
if (formData === false) {
callbackery.ui.MsgBox.getInstance().error(
this.tr("Validation Error"),
this.tr("The form can only be submitted when all data fields have valid content.")
);
return;
}
var key = btCfg.key;
var asyncCall = function () {
callbackery.data.Server.getInstance().callAsyncSmartBusy(function (ret) {
that.fireDataEvent('actionResponse', ret || {});
}, 'processPluginData', cfg.name, { "key": key, "formData": formData });
};
if (btCfg.action == 'submitVerify') {
var title = btCfg.label != null ? btCfg.label : btCfg.key;
callbackery.ui.MsgBox.getInstance().yesno(
this.xtr(title),
this.xtr(btCfg.question)
)
.addListenerOnce('choice', function (e) {
if (e.getData() == 'yes') {
asyncCall();
}
}, this);
}
else {
asyncCall();
}
break;
case 'download':
case 'display':
var formData = getFormData();
let busy = callbackery.ui.Busy.getInstance();
if (formData === false) {
callbackery.ui.MsgBox.getInstance().error(
this.tr("Validation Error"),
this.tr("The form can only be submitted when all data fields have valid content.")
);
return;
}
var key = btCfg.key;
if (btCfg.busyMessage) {
busy.manifest(this.xtr(btCfg.busyMessage));
} else {
busy.manifest(this.tr('Preparing Download ...'));
}
setTimeout(() => { busy.vanish(); }, 3 * 1000); // hide the activity indicator after 3 seconds anyway
callbackery.data.Server.getInstance().callAsyncSmart(function (cookie) {
let url = 'download'
+ '?name=' + cfg.name
+ '&key=' + key
+ '&xsc=' + encodeURIComponent(cookie)
+ '&formData=' + encodeURIComponent(qx.lang.Json.stringify(formData));
if (btCfg.action == 'display') {
window.open(url + '&display=1', '_blank');
return;
}
var iframe = new qx.ui.embed.Iframe().set({
width: 100,
height: 100
});
iframe.addListener('load', function (e) {
busy.vanish();
var response = {
exception: {
message: String(that.tr("No Data")),
code: 9999
}
};
try {
// innerHTML is wrapped in `<pre>` tags, which we remove.
let innerHTML = iframe.getBody().innerHTML;
if (innerHTML) {
innerHTML = innerHTML.replace(/^<.*?>/, '');
innerHTML = innerHTML.replace(/<.*?>$/, '');
}
// If there is text left, it should be the json from the server.
// JSON parsing an empty string is an error.
if (innerHTML) {
response = qx.lang.Json.parse(innerHTML);
}
// otherwise remove standard exception.
else {
response = {};
}
} catch (e) { };
if (response.exception) {
callbackery.ui.MsgBox.getInstance().error(
that.tr("Download Exception"),
that.xtr(response.exception.message) + " (" + response.exception.code + ")"
);
}
that.getApplicationRoot().remove(iframe);
if (btCfg.closeAfterDownload) {
that.fireDataEvent('actionResponse', { action: 'cancel' });
}
});
iframe.setSource(url);
that.getApplicationRoot().add(iframe, { top: -1000, left: -1000 });
}, 'getSessionCookie');
break;
case 'cancel':
this.fireDataEvent('actionResponse', { action: 'cancel' });
break;
case 'wizzard':
var parent = that.getLayoutParent();
while (!parent.classname.match(/Page|Popup/)) {
( run in 2.299 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )