From c6e987f52510e59b8a2b769d2fcc2ddf7d6779a8 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 10 Feb 2023 12:25:09 +0800 Subject: [PATCH] MDL-77174 core_payment: Switch to utility modal --- payment/accounts.php | 10 +++++----- payment/tests/behat/accounts.feature | 11 ++++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/payment/accounts.php b/payment/accounts.php index bfccc651dfe..237f8ec6ee5 100644 --- a/payment/accounts.php +++ b/payment/accounts.php @@ -65,8 +65,11 @@ foreach ($accounts as $account) { $menu->add(new action_menu_link_secondary($account->get_edit_url(), null, get_string('edit'))); if (!$account->get('archived')) { $deleteurl = $account->get_edit_url(['delete' => 1, 'sesskey' => sesskey()]); - $menu->add(new action_menu_link_secondary($deleteurl, null, get_string('deleteorarchive', 'payment'), - ['data-action' => 'delete'])); + $menu->add(new action_menu_link_secondary($deleteurl, null, get_string('deleteorarchive', 'payment'), [ + 'data-modal' => 'confirmation', + 'data-modal-type' => 'delete', + 'data-modal-content-str' => json_encode(['accountdeleteconfirm', 'payment']), + ])); } else { $restoreurl = $account->get_edit_url(['restore' => 1, 'sesskey' => sesskey()]); $menu->add(new action_menu_link_secondary($restoreurl, null, get_string('restoreaccount', 'payment'))); @@ -88,9 +91,6 @@ if (has_capability('moodle/site:config', context_system::instance())) { echo html_writer::div(html_writer::table($table), 'position-relative'); -$PAGE->requires->event_handler('[data-action=delete]', 'click', 'M.util.show_confirm_dialog', - array('message' => get_string('accountdeleteconfirm', 'payment'))); - echo html_writer::div(html_writer::link(new moodle_url($PAGE->url, ['showarchived' => !$showarchived]), $showarchived ? get_string('hidearchived', 'payment') : get_string('showarchived', 'payment')), 'mdl-right'); diff --git a/payment/tests/behat/accounts.feature b/payment/tests/behat/accounts.feature index b1c053b5fc1..8a9ce22a02b 100644 --- a/payment/tests/behat/accounts.feature +++ b/payment/tests/behat/accounts.feature @@ -16,9 +16,8 @@ Feature: Manage payment accounts And I choose "Edit" in the open action menu And I set the field "Account name" to "NewName" And I press "Save changes" - And I should see "PayPal" in the "NewName" "table_row" And I should not see "TestAccount" - And I log out + And I should see "PayPal" in the "NewName" "table_row" @javascript Scenario: Configuring gateways on payment accounts @@ -37,9 +36,8 @@ Feature: Manage payment accounts | Secret | Test | | Enable | 1 | And I press "Save changes" - And I should see "PayPal" in the "Account1" "table_row" And I should not see "Not available" in the "Account1" "table_row" - And I log out + And I should see "PayPal" in the "Account1" "table_row" @javascript Scenario: Deleting payment accounts @@ -51,10 +49,9 @@ Feature: Manage payment accounts And I navigate to "Payments > Payment accounts" in site administration And I open the action menu in "Account1" "table_row" And I choose "Delete or archive" in the open action menu - And I click on "Yes" "button" in the "Confirmation" "dialogue" + And I click on "Yes" "button" in the "Confirm" "dialogue" Then I should not see "Account1" And I should see "Account2" - And I log out @javascript Scenario: Archiving and restoring accounts @@ -73,7 +70,7 @@ Feature: Manage payment accounts And I navigate to "Payments > Payment accounts" in site administration And I open the action menu in "Account1" "table_row" And I choose "Delete or archive" in the open action menu - And I click on "Yes" "button" in the "Confirmation" "dialogue" + And I click on "Yes" "button" in the "Confirm" "dialogue" Then I should not see "Account1" And I should see "Account2" And I follow "Show archived"