2021-12-02 01:41:56 +01:00
|
|
|
import BootstrapDialog from './BootstrapDialog';
|
2021-12-14 18:13:39 +01:00
|
|
|
import { $assert, $defined } from '@wisemapping/core-js';
|
2021-07-16 16:41:58 +02:00
|
|
|
|
2021-12-05 00:39:20 +01:00
|
|
|
class BootstrapDialogRequest extends BootstrapDialog {
|
|
|
|
constructor(url, title, options) {
|
|
|
|
super(title, options);
|
2021-10-05 02:05:34 +02:00
|
|
|
this.requestOptions = {};
|
|
|
|
this.requestOptions.cache = false;
|
|
|
|
const me = this;
|
|
|
|
this.requestOptions.fail = function (xhr) {
|
|
|
|
// Intercept form requests ...
|
|
|
|
console.log('Failure:');
|
|
|
|
console.log(xhr);
|
|
|
|
};
|
|
|
|
|
2021-12-05 17:14:15 +01:00
|
|
|
this.requestOptions.success = function success() {
|
2021-10-05 02:05:34 +02:00
|
|
|
// Intercept form requests ...
|
|
|
|
const forms = me._native.find('form');
|
2021-12-05 17:14:15 +01:00
|
|
|
forms.forEach((form) => {
|
2021-10-05 02:05:34 +02:00
|
|
|
$(form).on('submit', (event) => {
|
|
|
|
// Intercept form ...
|
|
|
|
me.requestOptions.url = form.action;
|
|
|
|
me.requestOptions.method = form.method ? form.method : 'post';
|
|
|
|
$.ajax(me.requestOptions);
|
|
|
|
event.stopPropagation();
|
|
|
|
return false;
|
2021-07-16 16:41:58 +02:00
|
|
|
});
|
2021-10-05 02:05:34 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
this._native.find('.modal-body').load(url, () => {
|
|
|
|
me.acceptButton.unbind('click').click(() => {
|
|
|
|
submitDialogForm();
|
|
|
|
});
|
|
|
|
me._native.on('hidden.bs.modal', function () {
|
|
|
|
$(this).remove();
|
|
|
|
});
|
|
|
|
me.show();
|
|
|
|
});
|
2021-12-05 00:39:20 +01:00
|
|
|
}
|
2021-10-05 02:05:34 +02:00
|
|
|
|
|
|
|
onDialogShown() {
|
|
|
|
if (typeof (onDialogShown) === 'function') {
|
|
|
|
onDialogShown();
|
2021-07-16 16:41:58 +02:00
|
|
|
}
|
2021-12-05 00:39:20 +01:00
|
|
|
}
|
|
|
|
}
|
2021-07-16 16:41:58 +02:00
|
|
|
|
2021-12-05 18:25:16 +01:00
|
|
|
export default BootstrapDialogRequest;
|