From 6b31bae382aa761cc708a8d88a5e02c4b18cb4f8 Mon Sep 17 00:00:00 2001 From: llj Date: Mon, 11 Dec 2017 16:55:21 +0800 Subject: [PATCH] [dir view] mv/cp multi dirents: add feedback msg --- static/scripts/app/views/dir.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/static/scripts/app/views/dir.js b/static/scripts/app/views/dir.js index 60b2f911a9..bb648a7a6f 100644 --- a/static/scripts/app/views/dir.js +++ b/static/scripts/app/views/dir.js @@ -1223,7 +1223,9 @@ define([ } else { // when mv/cp to another lib, files/dirs should be handled one by one, and need to show progress var op_objs = dirents.where({'selected':true}), - i = 0; + i = 0, + success_num = 0, + first_item; // progress popup var mv_progress_popup = $(_this.mvProgressTemplate()); var details = $('#mv-details', mv_progress_popup), @@ -1267,6 +1269,10 @@ define([ if (op == 'mv') { dirents.remove(op_obj); } + success_num += 1; + if (success_num == 1) { + first_item = obj_name; + } endOrContinue(); } else { // failed or canceled if (data['failed']) { @@ -1333,6 +1339,28 @@ define([ if (op == 'mv') { _this.updateMagnificPopupOptions(); } + if (success_num > 0) { + var msg_s; + if (op == 'mv') { + if (success_num == 1) { + msg_s = gettext("Successfully moved %(name)s."); + } else if (success_num == 2) { + msg_s = gettext("Successfully moved %(name)s and 1 other item."); + } else { + msg_s = gettext("Successfully moved %(name)s and %(amount)s other items."); + } + } else { // cp + if (success_num == 1) { + msg_s = gettext("Successfully copied %(name)s."); + } else if (success_num == 2) { + msg_s = gettext("Successfully copied %(name)s and 1 other item."); + } else { + msg_s = gettext("Successfully copied %(name)s and %(amount)s other items."); + } + } + msg_s = msg_s.replace('%(name)s', first_item).replace('%(amount)s', success_num - 1); + setTimeout(function() { Common.feedback(msg_s, 'success'); }, 600); + } } else { mvcpDirent(++i); }