MDL-73090 reportbuilder: confirmation before resetting conditions.
Also prefetch all lang strings used by conditions editor.
This commit is contained in:
@@ -175,6 +175,8 @@ $string['reportsource'] = 'Report source';
|
||||
$string['reportsource_help'] = 'The report source defines where the data for the report will come from.';
|
||||
$string['reportupdated'] = 'Report updated';
|
||||
$string['resetall'] = 'Reset all';
|
||||
$string['resetconditions'] = 'Reset conditions';
|
||||
$string['resetconditionsconfirm'] = 'Are you sure you want to reset all conditions for this report?';
|
||||
$string['selectacondition'] = 'Select a condition';
|
||||
$string['selectafilter'] = 'Select a filter';
|
||||
$string['selectareportsource'] = 'Select a report source';
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -28,6 +28,7 @@ import {dispatchEvent} from 'core/event_dispatcher';
|
||||
import 'core/inplace_editable';
|
||||
import Notification from 'core/notification';
|
||||
import Pending from 'core/pending';
|
||||
import {prefetchStrings} from 'core/prefetch';
|
||||
import SortableList from 'core/sortable_list';
|
||||
import {get_string as getString, get_strings as getStrings} from 'core/str';
|
||||
import Templates from 'core/templates';
|
||||
@@ -84,26 +85,52 @@ const initConditionsForm = () => {
|
||||
conditionForm.addEventListener(conditionForm.events.NOSUBMIT_BUTTON_PRESSED, event => {
|
||||
event.preventDefault();
|
||||
|
||||
const pendingPromise = new Pending('core_reportbuilder/conditions:reset');
|
||||
getStrings([
|
||||
{key: 'resetconditions', component: 'core_reportbuilder'},
|
||||
{key: 'resetconditionsconfirm', component: 'core_reportbuilder'},
|
||||
{key: 'resetall', component: 'core_reportbuilder'},
|
||||
]).then(([confirmTitle, confirmText, confirmButton]) => {
|
||||
Notification.confirm(confirmTitle, confirmText, confirmButton, null, () => {
|
||||
const pendingPromise = new Pending('core_reportbuilder/conditions:reset');
|
||||
|
||||
resetConditions(reportElement.dataset.reportId)
|
||||
.then(data => reloadSettingsConditionsRegion(reportElement, data))
|
||||
.then(() => getString('conditionsreset', 'core_reportbuilder'))
|
||||
.then(addToast)
|
||||
.then(() => {
|
||||
dispatchEvent(reportEvents.tableReload, {}, reportElement);
|
||||
return pendingPromise.resolve();
|
||||
})
|
||||
.catch(Notification.exception);
|
||||
resetConditions(reportElement.dataset.reportId)
|
||||
.then(data => reloadSettingsConditionsRegion(reportElement, data))
|
||||
.then(() => getString('conditionsreset', 'core_reportbuilder'))
|
||||
.then(addToast)
|
||||
.then(() => {
|
||||
dispatchEvent(reportEvents.tableReload, {}, reportElement);
|
||||
return pendingPromise.resolve();
|
||||
})
|
||||
.catch(Notification.exception);
|
||||
});
|
||||
return;
|
||||
}).catch(Notification.exception);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialise module
|
||||
* Initialise module, prefetch all required strings
|
||||
*
|
||||
* @param {Boolean} initialized Ensure we only add our listeners once
|
||||
*/
|
||||
export const init = (initialized) => {
|
||||
export const init = initialized => {
|
||||
prefetchStrings('core_reportbuilder', [
|
||||
'conditionadded',
|
||||
'conditiondeleted',
|
||||
'conditionmoved',
|
||||
'conditionsapplied',
|
||||
'conditionsreset',
|
||||
'deletecondition',
|
||||
'deleteconditionconfirm',
|
||||
'resetall',
|
||||
'resetconditions',
|
||||
'resetconditionsconfirm',
|
||||
]);
|
||||
|
||||
prefetchStrings('core', [
|
||||
'delete',
|
||||
]);
|
||||
|
||||
initConditionsForm();
|
||||
if (initialized) {
|
||||
return;
|
||||
@@ -149,7 +176,7 @@ export const init = (initialized) => {
|
||||
getStrings([
|
||||
{key: 'deletecondition', component: 'core_reportbuilder', param: conditionName},
|
||||
{key: 'deleteconditionconfirm', component: 'core_reportbuilder', param: conditionName},
|
||||
{key: 'delete', component: 'moodle'},
|
||||
{key: 'delete', component: 'core'},
|
||||
]).then(([confirmTitle, confirmText, confirmButton]) => {
|
||||
Notification.confirm(confirmTitle, confirmText, confirmButton, null, () => {
|
||||
const pendingPromise = new Pending('core_reportbuilder/conditions:remove');
|
||||
|
||||
@@ -80,6 +80,11 @@ Feature: Manage custom report conditions
|
||||
| Email address operator | Does not contain |
|
||||
| Email address value | example.com |
|
||||
And I click on "Apply" "button" in the "[data-region='settings-conditions']" "css_element"
|
||||
And I click on "Reset" "button" in the "[data-region='settings-conditions']" "css_element"
|
||||
And I should see "Nothing to display"
|
||||
And I click on "Reset all" "button" in the "[data-region='settings-conditions']" "css_element"
|
||||
And I click on "Reset all" "button" in the "Reset conditions" "dialogue"
|
||||
Then I should see "Conditions reset"
|
||||
And the following fields in the "Email address" "core_reportbuilder > Condition" match these values:
|
||||
| Email address operator | Is any value |
|
||||
And I should see "User One" in the "reportbuilder-table" "table"
|
||||
And I should see "User Two" in the "reportbuilder-table" "table"
|
||||
|
||||
Reference in New Issue
Block a user