Warn about unsaved changes on session close (T845)
This commit is contained in:
parent
98cc54d67c
commit
725ae222a4
4 changed files with 18 additions and 8 deletions
|
@ -113,13 +113,17 @@ window.rcmail && window.files_api && rcmail.addEventListener('init', function()
|
||||||
|
|
||||||
if (rcmail.env.action == 'edit' && rcmail.env.file_data.viewer && rcmail.env.file_data.viewer.manticore)
|
if (rcmail.env.action == 'edit' && rcmail.env.file_data.viewer && rcmail.env.file_data.viewer.manticore)
|
||||||
manticore = new manticore_api({
|
manticore = new manticore_api({
|
||||||
|
// UI elements
|
||||||
iframe: $('#fileframe').get(0),
|
iframe: $('#fileframe').get(0),
|
||||||
export_menu: rcmail.gui_objects.exportmenu ? $('ul', rcmail.gui_objects.exportmenu).get(0) : null,
|
export_menu: rcmail.gui_objects.exportmenu ? $('ul', rcmail.gui_objects.exportmenu).get(0) : null,
|
||||||
title_input: $('#document-title').get(0),
|
title_input: $('#document-title').get(0),
|
||||||
members_list: $('#members').get(0),
|
members_list: $('#members').get(0),
|
||||||
photo_url: '?_task=addressbook&_action=photo&_email=%email',
|
photo_url: '?_task=addressbook&_action=photo&_email=%email',
|
||||||
photo_default_url: rcmail.env.photo_placeholder,
|
photo_default_url: rcmail.env.photo_placeholder,
|
||||||
|
// events
|
||||||
ready: function(data) { manticore_init(); },
|
ready: function(data) { manticore_init(); },
|
||||||
|
documentChanged: function(data) { rcmail.enable_command('document-save', true); },
|
||||||
|
// notifications/alerts
|
||||||
set_busy: function(state, message) { return rcmail.set_busy(state, message ? 'kolab_files.' + message : ''); },
|
set_busy: function(state, message) { return rcmail.set_busy(state, message ? 'kolab_files.' + message : ''); },
|
||||||
hide_message: function(id) { return rcmail.hide_message(id); },
|
hide_message: function(id) { return rcmail.hide_message(id); },
|
||||||
display_message: function(label, type) { return rcmail.display_message('kolab_files.' + label, type); },
|
display_message: function(label, type) { return rcmail.display_message('kolab_files.' + label, type); },
|
||||||
|
@ -1124,15 +1128,17 @@ function manticore_init()
|
||||||
{
|
{
|
||||||
var info = rcmail.env.file_data;
|
var info = rcmail.env.file_data;
|
||||||
|
|
||||||
rcmail.enable_command('document-save', 'document-export', true);
|
rcmail.enable_command('document-export', true);
|
||||||
|
|
||||||
if (info && info.session && info.session.is_owner)
|
if (info && info.session && info.session.is_owner)
|
||||||
rcmail.enable_command('files-close', 'document-editors', true);
|
rcmail.enable_command('document-close', 'document-editors', true);
|
||||||
};
|
};
|
||||||
|
|
||||||
rcube_webmail.prototype.document_save = function()
|
rcube_webmail.prototype.document_save = function()
|
||||||
{
|
{
|
||||||
manticore.save();
|
manticore.save(function(data) {
|
||||||
|
rcmail.enable_command('document-save', false);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
rcube_webmail.prototype.document_export = function(type)
|
rcube_webmail.prototype.document_export = function(type)
|
||||||
|
@ -1151,10 +1157,13 @@ rcube_webmail.prototype.document_editors = function()
|
||||||
};
|
};
|
||||||
|
|
||||||
// close editing session
|
// close editing session
|
||||||
rcube_webmail.prototype.files_close = function()
|
rcube_webmail.prototype.document_close = function()
|
||||||
{
|
{
|
||||||
// @todo: check document "unsaved changes" state and display a warning
|
// check document "unsaved changes" state and display a warning
|
||||||
file_api.document_delete(this.env.file_data.session.id);
|
if (this.commands['document-save'] && !confirm(this.gettext('kolab_files.unsavedchanges')))
|
||||||
|
return;
|
||||||
|
|
||||||
|
file_api.document_delete(this.env.file_data.session.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
// document editors management dialog
|
// document editors management dialog
|
||||||
|
|
|
@ -950,7 +950,7 @@ class kolab_files_engine
|
||||||
*/
|
*/
|
||||||
protected function action_edit()
|
protected function action_edit()
|
||||||
{
|
{
|
||||||
$this->plugin->add_label('sessionterminating');
|
$this->plugin->add_label('sessionterminating', 'unsavedchanges');
|
||||||
|
|
||||||
$this->file_opener(intval($_GET['_viewer']));
|
$this->file_opener(intval($_GET['_viewer']));
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ $labels['select'] = 'Select';
|
||||||
$labels['terminatesession'] = 'Terminate the session';
|
$labels['terminatesession'] = 'Terminate the session';
|
||||||
$labels['terminate'] = 'Terminate';
|
$labels['terminate'] = 'Terminate';
|
||||||
$labels['sessionterminating'] = 'Terminating the session...';
|
$labels['sessionterminating'] = 'Terminating the session...';
|
||||||
|
$labels['unsavedchanges'] = 'There are unsaved changes in the document that will be lost. Do you want to terminate the session anyway?';
|
||||||
$labels['manageeditors'] = 'Invite to document';
|
$labels['manageeditors'] = 'Invite to document';
|
||||||
$labels['participant'] = 'Participant';
|
$labels['participant'] = 'Participant';
|
||||||
$labels['status'] = 'Status';
|
$labels['status'] = 'Status';
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<!--
|
<!--
|
||||||
<roundcube:button command="files-delete" type="link" class="button delete disabled" classAct="button delete" classSel="button delete pressed" label="delete" title="kolab_files.deletefile" />
|
<roundcube:button command="files-delete" type="link" class="button delete disabled" classAct="button delete" classSel="button delete pressed" label="delete" title="kolab_files.deletefile" />
|
||||||
-->
|
-->
|
||||||
<roundcube:button command="files-close" type="link" class="button delete disabled" classAct="button delete" classSel="button delete pressed" label="kolab_files.terminate" title="kolab_files.terminatesession" />
|
<roundcube:button command="document-close" type="link" class="button delete disabled" classAct="button delete" classSel="button delete pressed" label="kolab_files.terminate" title="kolab_files.terminatesession" />
|
||||||
<span class="dropbutton">
|
<span class="dropbutton">
|
||||||
<roundcube:button command="document-export" type="link" class="button export disabled" classAct="button export" classSel="button export pressed" label="kolab_files.get" title="kolab_files.getfile" />
|
<roundcube:button command="document-export" type="link" class="button export disabled" classAct="button export" classSel="button export pressed" label="kolab_files.get" title="kolab_files.getfile" />
|
||||||
<a href="#export" class="dropbuttontip" id="exportmenulink" onclick="UI.toggle_popup('exportmenu',event);return false" aria-haspopup="true" aria-expanded="false" aria-owns="exportmenu-menu" tabindex="0">Export options</a>
|
<a href="#export" class="dropbuttontip" id="exportmenulink" onclick="UI.toggle_popup('exportmenu',event);return false" aria-haspopup="true" aria-expanded="false" aria-owns="exportmenu-menu" tabindex="0">Export options</a>
|
||||||
|
|
Loading…
Add table
Reference in a new issue