Skip to content

Commit

Permalink
Update templates, js, spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
fmido88 authored Feb 17, 2024
1 parent dc85eee commit 0a253f0
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 79 deletions.
2 changes: 1 addition & 1 deletion amd/build/balance.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 amd/build/expenders.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 amd/build/expenders.min.js.map

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

1 change: 1 addition & 0 deletions amd/src/balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function getData() {
});
}
}

export const init = (formid) => {
form = document.getElementById(formid);
holder = form.querySelector("[data-purpose=balance-holder]");
Expand Down
33 changes: 29 additions & 4 deletions amd/src/expenders.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,51 @@
*/

export const init = (uniqid) => {
// Manual refund policy.
var enrolWalletPolicyUrl = document.getElementById('enrol_wallet_transactions-policy-url-' + uniqid);
if (enrolWalletPolicyUrl) {
var policy = document.getElementById('enrol_wallet_transactions-policy-' + uniqid);
if (enrolWalletPolicyUrl && policy) {
enrolWalletPolicyUrl.addEventListener("click", function() {
var policy = document.getElementById('enrol_wallet_transactions-policy-' + uniqid);
if (policy.style.display === "none") {
policy.style.display = "block";
} else {
policy.style.display = "none";
}
});
}

// More balance details.
var moreBalanceDetails = document.getElementById('more-details-' + uniqid);
if (moreBalanceDetails) {
var details = document.getElementById('balance-details-' + uniqid);
if (moreBalanceDetails && details) {
moreBalanceDetails.addEventListener("click", function() {
var details = document.getElementById('balance-details-' + uniqid);
if (details.style.display === "none") {
details.style.display = "flex";
} else {
details.style.display = "none";
}
});
}

// Show top up options after confirm the agreement.
var walletPolicyAgreed = document.getElementById('wallet_topup_policy_confirm_' + uniqid);
var topUpBox = document.getElementById('enrol_wallet_topup_box_' + uniqid);
if (walletPolicyAgreed && topUpBox) {
// As the user may click the check box while the page not loaded yet.
setTimeout(function() {
showHideTopUp();
});

walletPolicyAgreed.addEventListener('change', function() {
showHideTopUp();
});

const showHideTopUp = () => {
if (walletPolicyAgreed.checked == true) {
topUpBox.style.display = 'block';
} else {
topUpBox.style.display = 'none';
}
};
}
};
6 changes: 3 additions & 3 deletions classes/api/instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
class instance extends external_api {
/**
* Returns description of get_balance_details() parameters
* Returns description of get_cost() parameters
*
* @return external_function_parameters
*/
Expand All @@ -43,7 +43,7 @@ public static function get_cost_parameters() {
}

/**
* Returns the balance details for a single user.
* Returns the cost of an instance to the given user.
*
* @param int $instanceid
* @param int $userid
Expand All @@ -60,7 +60,7 @@ public static function get_cost($instanceid, $userid) {
}

/**
* Returns description of get_balance_details() result value.
* Returns description of get_cost() result value.
*
* @return external_single_structure
*/
Expand Down
10 changes: 5 additions & 5 deletions classes/api/offers_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
use enrol_wallet\util\offers;

/**
* Class balance_op
* Class offers form.
*
* @package enrol_wallet
* @copyright 2024 2024, Mohammad Farouk <[email protected]>
* @copyright 2024 Mohammad Farouk <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class offers_form extends external_api {
/**
* Returns description of get_balance_details() parameters
* Returns description of get_form_fragment() parameters
*
* @return external_function_parameters
*/
Expand All @@ -45,7 +45,7 @@ public static function get_form_fragment_parameters() {
}

/**
* Returns the balance details for a single user.
* Return an html fragment of form elements used in offers editing.
*
* @param string $type
* @param int $increment
Expand All @@ -65,7 +65,7 @@ public static function get_form_fragment($type, $increment, $courseid) {
}

/**
* Returns description of get_balance_details() result value.
* Returns description of get_form_fragment() result value.
*
* @return external_description
*/
Expand Down
3 changes: 2 additions & 1 deletion classes/category/operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ public function add($amount, $refundable = true, $free = false) {
'refundable' => $this->details[$this->catid]->refundable ?? 0,
'nonrefundable' => $this->details[$this->catid]->nonrefundable ?? 0,
'free' => $this->details[$this->catid]->free ?? 0,
'balance' => $this->details[$this->catid]->balance ?? 0,
];
$catobj->balance = $this->details[$this->catid]->balance
?? $catobj->refundable + $catobj->nonrefundable;
if ($refundable) {
$this->refundable += $amount;
$catobj->refundable += $amount;
Expand Down
Loading

0 comments on commit 0a253f0

Please sign in to comment.