Fix "There are unsaved changes..." warning when terminating document session (Bifrost#T220027)
As there's no way to detect unsaved changes in Collabora, we skip the warning. We also make sure to detroy the session after closing it in Collabora, so it have a chance to save the document state.
This commit is contained in:
parent
b87333e0e2
commit
7ca7273ae9
1 changed files with 28 additions and 29 deletions
|
@ -1487,11 +1487,28 @@ rcube_webmail.prototype.document_editors = function()
|
||||||
// close editing session
|
// close editing session
|
||||||
rcube_webmail.prototype.document_close = function()
|
rcube_webmail.prototype.document_close = function()
|
||||||
{
|
{
|
||||||
|
var delete_fn = function() {
|
||||||
|
document_editor.terminate(function() {
|
||||||
|
var win = window.opener || window.parent;
|
||||||
|
|
||||||
|
if (win && win.rcmail && win.file_api)
|
||||||
|
win.file_api.document_delete(rcmail.env.file_data.session.id);
|
||||||
|
|
||||||
|
// For Elastic: hide the parent dialog
|
||||||
|
if (rcmail.is_framed()) {
|
||||||
|
parent.$('.ui-dialog:visible button.cancel').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
window.close();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// check document "unsaved changes" state and display a warning
|
// check document "unsaved changes" state and display a warning
|
||||||
if (this.commands['document-save'])
|
// skip the warning for WOPI, Collabora will save the document anyway on session close
|
||||||
this.confirm_dialog(this.gettext('kolab_files.unsavedchanges'), 'kolab_files.terminate', function() {
|
if (this.commands['document-save'] && (!this.env.file_data.viewer || !this.env.file_data.viewer.wopi))
|
||||||
file_api.document_delete(rcmail.env.file_data.session.id);
|
this.confirm_dialog(this.gettext('kolab_files.unsavedchanges'), 'kolab_files.terminate', delete_fn, {button_class: 'delete'});
|
||||||
}, {button_class: 'delete'});
|
else
|
||||||
|
delete_fn();
|
||||||
};
|
};
|
||||||
|
|
||||||
// document editors management dialog
|
// document editors management dialog
|
||||||
|
@ -4089,43 +4106,25 @@ function kolab_files_ui()
|
||||||
this.document_delete = function(id)
|
this.document_delete = function(id)
|
||||||
{
|
{
|
||||||
this.req = this.set_busy(true, 'kolab_files.sessionterminating');
|
this.req = this.set_busy(true, 'kolab_files.sessionterminating');
|
||||||
this.deleted_session = id;
|
|
||||||
this.request('document_delete', {id: id}, 'document_delete_response');
|
this.request('document_delete', {id: id}, 'document_delete_response');
|
||||||
};
|
};
|
||||||
|
|
||||||
// document session delete response handler
|
// document session delete response handler
|
||||||
this.document_delete_response = function(response)
|
this.document_delete_response = function(response, params)
|
||||||
{
|
{
|
||||||
if (!this.response(response))
|
if (!this.response(response))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (rcmail.task == 'files' && rcmail.env.action == 'edit') {
|
var list = rcmail.sessionslist;
|
||||||
if (document_editor && document_editor.terminate)
|
|
||||||
document_editor.terminate();
|
|
||||||
// use timeout to have a chance to properly propagate termination request
|
|
||||||
setTimeout(function() { window.close(); }, 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @todo: force sessions info update
|
|
||||||
|
|
||||||
var win = window, list = rcmail.sessionslist;
|
|
||||||
|
|
||||||
if (!list) {
|
|
||||||
win = window.opener || window.parent;
|
|
||||||
if (win && win.rcmail && win.file_api)
|
|
||||||
list = win.rcmail.sessionslist;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove session from the list (if sessions list exist)
|
// remove session from the list (if sessions list exist)
|
||||||
if (list)
|
if (list)
|
||||||
list.remove_row(this.deleted_session);
|
list.remove_row(params.id);
|
||||||
if (win && win.file_api && win.file_api.env.sessions_list)
|
|
||||||
delete win.file_api.env.sessions_list[this.deleted_session];
|
|
||||||
|
|
||||||
// For Elastic: hide the parent dialog
|
if (this.env.sessions_list)
|
||||||
if (rcmail.is_framed()) {
|
delete this.env.sessions_list[params.id];
|
||||||
parent.$('.ui-dialog:visible button.cancel').click();
|
|
||||||
}
|
// @todo: force sessions info update, update files list
|
||||||
};
|
};
|
||||||
|
|
||||||
// Invite document session participants
|
// Invite document session participants
|
||||||
|
|
Loading…
Add table
Reference in a new issue