MDL-59759 core_message: Use SAVE_CANCEL modal for delete dialog
authorJun Pataleta <jun@moodle.com>
Wed, 9 Aug 2017 03:37:37 +0000 (11:37 +0800)
committerJun Pataleta <jun@moodle.com>
Mon, 4 Sep 2017 02:44:51 +0000 (10:44 +0800)
message/amd/build/message_area_messages.min.js
message/amd/src/message_area_messages.js
message/tests/behat/delete_all_messages.feature

index 9a6fab9..fb627be 100644 (file)
Binary files a/message/amd/build/message_area_messages.min.js and b/message/amd/build/message_area_messages.min.js differ
index 4c5711b..77e6f50 100644 (file)
@@ -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',
index ebfbef7..2adf5b3 100644 (file)
@@ -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.