Skip to content

Commit

Permalink
MDL-69166 core_payment: Use a custom modal type for gateway selector
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies committed Oct 27, 2020
1 parent 2bb4498 commit b23dcc3
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 4 deletions.
2 changes: 2 additions & 0 deletions payment/amd/build/events.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions payment/amd/build/events.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion payment/amd/build/gateways_modal.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion payment/amd/build/gateways_modal.min.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions payment/amd/build/modal_gateways.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions payment/amd/build/modal_gateways.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions payment/amd/src/events.js
@@ -0,0 +1,27 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Contain the events the payment modal can fire.
*
* @module core_payment/events
* @package core_payment
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

export default {
proceed: 'core_payment-modal_gateways:proceed',
};
6 changes: 4 additions & 2 deletions payment/amd/src/gateways_modal.js
Expand Up @@ -28,8 +28,10 @@ import {get_string as getString} from 'core/str';
import {getGatewaysSupportingCurrency} from './repository';
import Selectors from './selectors';
import ModalEvents from 'core/modal_events';
import PaymentEvents from 'core_payment/events';
import {add as addToast, addToastRegion} from 'core/toast';
import Notification from 'core/notification';
import ModalGateways from './modal_gateways';

/**
* Register event listeners for the module.
Expand Down Expand Up @@ -65,7 +67,7 @@ const show = async(rootNode, {
focusOnClose = null,
} = {}) => {
const modal = await ModalFactory.create({
type: ModalFactory.types.SAVE_CANCEL,
type: ModalGateways.TYPE,
title: await getString('selectpaymenttype', 'core_payment'),
body: await Templates.render('core_payment/gateways_modal', {}),
});
Expand All @@ -84,7 +86,7 @@ const show = async(rootNode, {
}
});

modal.getRoot().on(ModalEvents.save, (e) => {
modal.getRoot().on(PaymentEvents.proceed, (e) => {
const root = modal.getRoot()[0];
const gateway = (root.querySelector(Selectors.values.gateway) || {value: ''}).value;

Expand Down

0 comments on commit b23dcc3

Please sign in to comment.