summaryrefslogtreecommitdiff
path: root/plugins/kolab_notes
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-11-04 18:01:53 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-11-04 18:01:53 (GMT)
commit52da8302cb0f29c57fac5a2c7b054c70c1e18c53 (patch)
treee776cf13f4f37e4771908e19d5e456b3eacd244e /plugins/kolab_notes
parent1eed6b74c95397cf9176b98c28d0d4732cb0656c (diff)
downloadroundcubemail-plugins-kolab-52da8302cb0f29c57fac5a2c7b054c70c1e18c53.tar.gz
Apply dialog decision when dragging a yet unsaved note to another list (#3516)
Diffstat (limited to 'plugins/kolab_notes')
-rw-r--r--plugins/kolab_notes/notes.js39
1 files changed, 32 insertions, 7 deletions
diff --git a/plugins/kolab_notes/notes.js b/plugins/kolab_notes/notes.js
index 5a9e05f..d6e43d6 100644
--- a/plugins/kolab_notes/notes.js
+++ b/plugins/kolab_notes/notes.js
@@ -219,9 +219,28 @@ function rcube_kolab_notes_ui(settings)
// move dragged notes to this folder
if (folder_drop_target) {
noteslist.draglayer.hide();
- move_notes(folder_drop_target);
- noteslist.clear_selection();
- reset_view();
+
+ // check unsaved changes first
+ var new_folder_id = folder_drop_target;
+ warn_unsaved_changes(
+ // ok
+ function() {
+ move_notes(new_folder_id);
+ reset_view();
+ noteslist.clear_selection();
+ },
+ // nok
+ undefined,
+ // beforesave
+ function(savedata) {
+ savedata.list = new_folder_id;
+
+ // remove from list and thus avoid being moved (again)
+ var id = me.selected_note.id;
+ noteslist.remove_row(id);
+ delete notesdata[id];
+ }
+ );
}
folder_drop_target = null;
})
@@ -1094,7 +1113,7 @@ function rcube_kolab_notes_ui(settings)
{
data.id = rcmail.html_identifier_encode(data.uid);
- var row, is_new = notesdata[data.id] == undefined
+ var row, is_new = (notesdata[data.id] == undefined && data.list == me.selected_list);
notesdata[data.id] = data;
if (is_new || me.selected_note && data.id == me.selected_note.id) {
@@ -1142,7 +1161,7 @@ function rcube_kolab_notes_ui(settings)
/**
* Collect data from the edit form and submit it to the server
*/
- function save_note()
+ function save_note(beforesave)
{
if (!me.selected_note) {
return false;
@@ -1150,6 +1169,11 @@ function rcube_kolab_notes_ui(settings)
var savedata = get_save_data();
+ // run savedata through the given callback function
+ if (typeof beforesave == 'function') {
+ beforesave(savedata);
+ }
+
// add reference to old list if changed
if (me.selected_note.list && savedata.list != me.selected_note.list) {
savedata._fromlist = me.selected_note.list;
@@ -1227,7 +1251,7 @@ function rcube_kolab_notes_ui(settings)
/**
* Check for unsaved changes and warn the user
*/
- function warn_unsaved_changes(ok, nok)
+ function warn_unsaved_changes(ok, nok, beforesave)
{
if (typeof ok != 'function')
ok = function(){ };
@@ -1248,8 +1272,9 @@ function rcube_kolab_notes_ui(settings)
buttons.push({
text: rcmail.gettext('save'),
click: function() {
- save_note();
+ save_note(beforesave);
dialog.dialog('close');
+ rcmail.busy = false; // don't block next action
ok();
}
});