summaryrefslogtreecommitdiffstats
path: root/core/src/OC/dialogs.js
diff options
context:
space:
mode:
authorGary Kim <gary@garykim.dev>2019-11-03 16:22:59 +0800
committerGary Kim <gary@garykim.dev>2019-11-05 20:39:07 +0800
commit0efa78d1e207e3b345fd435494f892974e441f61 (patch)
treeb17412f47c2e5ddf8dc57730ef5cd1833b614bd9 /core/src/OC/dialogs.js
parent827a3c545afbffead72a89931ab1a4a07ce3a3d2 (diff)
downloadnextcloud-server-0efa78d1e207e3b345fd435494f892974e441f61.tar.gz
nextcloud-server-0efa78d1e207e3b345fd435494f892974e441f61.zip
Prompt on destructive user actions
Signed-off-by: Gary Kim <gary@garykim.dev>
Diffstat (limited to 'core/src/OC/dialogs.js')
-rw-r--r--core/src/OC/dialogs.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/core/src/OC/dialogs.js b/core/src/OC/dialogs.js
index abc5b3e1c3a..8f50a5d0606 100644
--- a/core/src/OC/dialogs.js
+++ b/core/src/OC/dialogs.js
@@ -2,8 +2,10 @@
/* eslint-disable */
/*
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
+ * @copyright Copyright (c) 2019 Gary Kim <gary@garykim.dev>
*
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
+ * @author Gary Kim <gary@garykim.dev>
*
* @license GNU AGPL version 3 or any later version
*
@@ -93,6 +95,25 @@ const Dialogs = {
* displays confirmation dialog
* @param {string} text content of dialog
* @param {string} title dialog title
+ * @param {{type: Int, confirm: String, cancel: String, confirmClasses: String}} buttons text content of buttons
+ * @param {function} callback which will be triggered when user presses OK (true or false would be passed to callback respectively)
+ * @param {boolean} [modal] make the dialog modal
+ * @returns {Promise}
+ */
+ confirmDestructive: function(text, title, buttons, callback, modal) {
+ return this.message(
+ text,
+ title,
+ 'none',
+ buttons,
+ callback,
+ modal
+ )
+ },
+ /**
+ * displays confirmation dialog
+ * @param {string} text content of dialog
+ * @param {string} title dialog title
* @param {function} callback which will be triggered when user presses OK (true or false would be passed to callback respectively)
* @param {boolean} [modal] make the dialog modal
* @returns {Promise}
@@ -534,6 +555,34 @@ const Dialogs = {
defaultButton: true
}
break
+ default:
+ if (typeof(buttons) === 'object') {
+ switch (buttons.type) {
+ case Dialogs.YES_NO_BUTTONS:
+ buttonlist = [{
+ text: buttons.cancel || t('core', 'No'),
+ click: function() {
+ if (callback !== undefined) {
+ callback(false)
+ }
+ $(dialogId).ocdialog('close')
+ }
+ },
+ {
+ text: buttons.confirm || t('core', 'Yes'),
+ click: function() {
+ if (callback !== undefined) {
+ callback(true)
+ }
+ $(dialogId).ocdialog('close')
+ },
+ defaultButton: true,
+ classes: buttons.confirmClasses
+ }]
+ break
+ }
+ }
+ break
}
$(dialogId).ocdialog({