1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-24 18:04:43 +02:00

MDL-59759 core_message: Use SAVE_CANCEL modal for delete dialog

This commit is contained in:
Jun Pataleta 2017-08-09 11:37:37 +08:00
parent fb7fa04e3b
commit 23356f410f
3 changed files with 19 additions and 12 deletions

File diff suppressed because one or more lines are too long

@ -531,19 +531,26 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
return;
}
Str.get_strings([
var stringsPromise = Str.get_strings([
{key: 'confirm'},
{key: 'deleteallconfirm', component: 'message'}
]).then(function(s) {
return ModalFactory.create({
title: s[0],
type: ModalFactory.types.CONFIRM,
body: s[1]
}, this.messageArea.find(SELECTORS.DELETEALLMESSAGES));
}.bind(this)).then(function(modal) {
{key: 'deleteallconfirm', component: 'message'},
{key: 'delete'}
]);
var deleteModalPromise = ModalFactory.create(
{
type: ModalFactory.types.SAVE_CANCEL
},
this.messageArea.find(SELECTORS.DELETEALLMESSAGES)
);
$.when(stringsPromise, deleteModalPromise).then(function(s, modal) {
modal.setTitle(s[0]);
modal.setBody(s[1]);
modal.setSaveButtonText(s[2]);
this._confirmationModal = modal;
// Only delete the conversation if the user agreed in the confirmation modal.
modal.getRoot().on(ModalEvents.yes, function() {
modal.getRoot().on(ModalEvents.save, function() {
var otherUserId = this._getUserId();
var request = {
methodname: 'core_message_delete_conversation',

@ -19,7 +19,7 @@ Feature: Delete all messages
And I click on "start-delete-messages" "message_area_action"
And I click on "Delete all" "button"
# Confirm dialogue.
And I click on "Yes" "button"
And I click on "Delete" "button" in the ".modal-footer" "css_element"
# Confirm the interface is immediately updated.
Then I should not see "User 2" in the "conversations" "message_area_region_content"
# Confirm the changes are persisted.