Chromium Code Reviews| Index: ui/file_manager/file_manager/foreground/js/ui/file_manager_ui.js |
| diff --git a/ui/file_manager/file_manager/foreground/js/ui/file_manager_ui.js b/ui/file_manager/file_manager/foreground/js/ui/file_manager_ui.js |
| index 54cf35f6743e09bc7700242bdd03fda795f4adff..3586b38275d4f269d8a2134c371c5cd041d1d181 100644 |
| --- a/ui/file_manager/file_manager/foreground/js/ui/file_manager_ui.js |
| +++ b/ui/file_manager/file_manager/foreground/js/ui/file_manager_ui.js |
| @@ -72,6 +72,22 @@ function FileManagerUI(providersModel, element, launchParam) { |
| this.deleteConfirmDialog = new FilesConfirmDialog(this.element); |
| this.deleteConfirmDialog.setOkLabel(str('DELETE_BUTTON_LABEL')); |
| + /** |
| + * Confirm dialog for file move operation. |
| + * @type {!FilesConfirmDialog} |
| + * @const |
| + */ |
| + this.moveConfirmDialog = new FilesConfirmDialog(this.element); |
| + this.moveConfirmDialog.setOkLabel(str('CONFIRM_MOVE_BUTTON_LABEL')); |
| + |
| + /** |
| + * Confirm dialog for file copy operation. |
| + * @type {!FilesConfirmDialog} |
| + * @const |
| + */ |
| + this.copyConfirmDialog = new FilesConfirmDialog(this.element); |
| + this.copyConfirmDialog.setOkLabel(str('CONFIRM_COPY_BUTTON_LABEL')); |
| + |
| /** |
| * Share dialog. |
| * @type {!ShareDialog} |
| @@ -319,6 +335,17 @@ function FileManagerUI(providersModel, element, launchParam) { |
| } |
| } |
| +/** |
| + * Types of file operations. |
| + * |
| + * @enum {string} |
| + * @const |
| + */ |
| +FileManagerUI.ActionType = { |
| + COPY: 'copy', |
| + MOVE: 'move', |
| +}; |
| + |
| /** |
| * Initializes here elements, which are expensive or hidden in the beginning. |
| * |
| @@ -541,3 +568,35 @@ FileManagerUI.prototype.showOpenInOtherDesktopAlert = function(entries) { |
| this.alertDialog.showWithTitle(title, message, null, null, null); |
| }.bind(this)); |
| }; |
| + |
| +/** |
| + * Handles confirmation of operations by user interaction. |
| + * @param {!FileManagerUI.ActionType} type Type of the operation. |
| + * @param {string} message_title The title of the dialog box. |
| + * @param {!Array<string>} message_body The message body to show in the dialog |
| + * box. |
| + * @return {!Promise<boolean>} |
| + */ |
| +FileManagerUI.prototype.confirmationHandler = function( |
|
fukino
2017/06/09 07:05:46
nit: As this is a method, lets start from verbs, l
yamaguchi
2017/06/09 09:49:15
Done.
|
| + type, message_title, message_body) { |
| + var dialog = null; |
| + switch (type) { |
| + case FileManagerUI.ActionType.MOVE: |
| + dialog = this.moveConfirmDialog; |
| + break; |
| + case FileManagerUI.ActionType.COPY: |
| + dialog = this.copyConfirmDialog; |
| + break; |
| + } |
| + assert(dialog); |
| + return new Promise(function(resolve, reject) { |
| + dialog.showWithTitle( |
| + message_title, message_body.join(' '), |
| + function() { |
| + resolve(true); |
| + }, |
| + function() { |
| + resolve(false); |
| + }); |
| + }); |
| +}; |