MDL-71963 Core: Add toast for confirmation modal success
This commit is contained in:
+2
-1
@@ -42,6 +42,7 @@ $string['deletecheck'] = 'Delete {$a} block?';
|
||||
$string['deletecheck_modal'] = 'Delete block?';
|
||||
$string['deleteblock'] = 'Delete {$a} block';
|
||||
$string['deleteblockcheck'] = 'Are you sure that you want to delete this block titled {$a}?';
|
||||
$string['deleteblockinprogress'] = 'Block {$a} is currently being removed from this page';
|
||||
$string['deleteblockwarning'] = '<p>You are about to delete a block that appears elsewhere.</p><p>Original block location: {$a->location}<br />Display on page types: {$a->pagetype}</p><p>Are you sure you want to continue?</p>';
|
||||
$string['hideblock'] = 'Hide {$a} block';
|
||||
$string['hidepanel'] = 'Hide panel';
|
||||
@@ -79,4 +80,4 @@ $string['dockblock'] = 'Dock {$a} block';
|
||||
$string['hidedockpanel'] = 'Hide the dock panel';
|
||||
$string['undockall'] = 'Undock all';
|
||||
$string['undockblock'] = 'Undock {$a} block';
|
||||
$string['undockitem'] = 'Undock this item';
|
||||
$string['undockitem'] = 'Undock this item';
|
||||
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core/confirm",["core/notification","core/str"],function(a,b){"use strict";b=d(b);function c(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;c=function(){return a};return a}function d(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=c();if(b&&b.has(a)){return b.get(a)}var d={},e=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in a){if(Object.prototype.hasOwnProperty.call(a,f)){var g=e?Object.getOwnPropertyDescriptor(a,f):null;if(g&&(g.get||g.set)){Object.defineProperty(d,f,g)}else{d[f]=a[f]}}}d.default=a;if(b){b.set(a,d)}return d}var e=!1,f=function(b,c,d){return new Promise(function(e,f){(0,a.saveCancel)(b,c,d,e,f)})},g=function(a,c){if(a["confirmation".concat(c,"Str")]){return b.get_string.apply(null,JSON.parse(a["confirmation".concat(c,"Str")]))}return a["confirmation".concat(c)]},h=function(){document.addEventListener("click",function(a){var b=a.target.closest("[data-confirmation=\"modal\"]");if(b){a.preventDefault();f(g(b.dataset,"Title"),g(b.dataset,"Question"),g(b.dataset,"YesButton")).then(function(){window.location.href=b.dataset.confirmationDestination}).catch(function(){})}})};if(!e){h();e=!0}});
|
||||
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core/confirm",["core/notification","core/str","core/toast"],function(a,b,c){"use strict";b=e(b);function d(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;d=function(){return a};return a}function e(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=d();if(b&&b.has(a)){return b.get(a)}var c={},e=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in a){if(Object.prototype.hasOwnProperty.call(a,f)){var g=e?Object.getOwnPropertyDescriptor(a,f):null;if(g&&(g.get||g.set)){Object.defineProperty(c,f,g)}else{c[f]=a[f]}}}c.default=a;if(b){b.set(a,c)}return c}var f=!1,g=function(b,c,d){return new Promise(function(e,f){(0,a.saveCancel)(b,c,d,e,f)})},h=function(a,c){if(a["confirmation".concat(c,"Str")]){return b.get_string.apply(null,JSON.parse(a["confirmation".concat(c,"Str")]))}return a["confirmation".concat(c)]},i=function(){document.addEventListener("click",function(b){var d=b.target.closest("[data-confirmation=\"modal\"]");if(d){b.preventDefault();g(h(d.dataset,"Title"),h(d.dataset,"Question"),h(d.dataset,"YesButton")).then(function(){if("true"===d.dataset.confirmationToast){var b=h(d.dataset,"ToastConfirmation");if("string"==typeof b){(0,c.add)(b)}else{b.then(function(a){return(0,c.add)(a)}).catch(function(b){return(0,a.exception)(b)})}}window.location.href=d.dataset.confirmationDestination}).catch(function(){})}})};if(!f){i();f=!0}});
|
||||
//# sourceMappingURL=confirm.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
+10
-1
@@ -42,8 +42,9 @@
|
||||
* );
|
||||
*/
|
||||
|
||||
import {saveCancel} from 'core/notification';
|
||||
import {saveCancel, exception} from 'core/notification';
|
||||
import * as Str from 'core/str';
|
||||
import {add as addToast} from 'core/toast';
|
||||
|
||||
// We want to ensure that we only initialize the listeners only once.
|
||||
let registered = false;
|
||||
@@ -96,6 +97,14 @@ const registerConfirmationListeners = () => {
|
||||
getConfirmationString(confirmRequest.dataset, 'YesButton'),
|
||||
)
|
||||
.then(() => {
|
||||
if (confirmRequest.dataset[`confirmationToast`] === 'true') {
|
||||
const stringForToast = getConfirmationString(confirmRequest.dataset, 'ToastConfirmation');
|
||||
if (typeof stringForToast === "string") {
|
||||
addToast(stringForToast);
|
||||
} else {
|
||||
stringForToast.then(str => addToast(str)).catch(e => exception(e));
|
||||
}
|
||||
}
|
||||
window.location.href = confirmRequest.dataset.confirmationDestination;
|
||||
return;
|
||||
}).catch(() => {}); // Catch an empty function as the user cancelled rather than an actual error.
|
||||
|
||||
Reference in New Issue
Block a user