summaryrefslogtreecommitdiffstats
path: root/core/src
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
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')
-rw-r--r--core/src/OC/dialogs.js49
-rw-r--r--core/src/jquery/css/jquery-ui-fixes.scss5
-rw-r--r--core/src/jquery/css/jquery.ocdialog.scss1
3 files changed, 54 insertions, 1 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({
diff --git a/core/src/jquery/css/jquery-ui-fixes.scss b/core/src/jquery/css/jquery-ui-fixes.scss
index b1f7afc1883..34243062ba6 100644
--- a/core/src/jquery/css/jquery-ui-fixes.scss
+++ b/core/src/jquery/css/jquery-ui-fixes.scss
@@ -115,6 +115,9 @@
.ui-state-error-text .ui-icon {
background-image: url('images/ui-icons_ffd27a_256x240.png');
}
+.ui-icon.ui-icon-none {
+ display: none;
+}
/* Misc visuals
----------------------------------*/
@@ -230,4 +233,4 @@
.ui-draggable-handle,
.ui-selectable {
touch-action: pan-y;
-} \ No newline at end of file
+}
diff --git a/core/src/jquery/css/jquery.ocdialog.scss b/core/src/jquery/css/jquery.ocdialog.scss
index 7372f308727..89653ae181a 100644
--- a/core/src/jquery/css/jquery.ocdialog.scss
+++ b/core/src/jquery/css/jquery.ocdialog.scss
@@ -74,6 +74,7 @@
.oc-dialog-content {
width: 100%;
+ max-width: 550px;
}
.oc-dialog.password-confirmation {