Skip to content

Commit

Permalink
Merge pull request #651 from themeum/dev
Browse files Browse the repository at this point in the history
Tutor LMS v2.6.0 merged to master
  • Loading branch information
harunollyo authored Jan 15, 2024
2 parents abbc343 + 0209687 commit 9bc4cb9
Show file tree
Hide file tree
Showing 47 changed files with 1,648 additions and 703 deletions.
60 changes: 56 additions & 4 deletions assets/react/admin-dashboard/segments/manage-api-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ document.addEventListener("DOMContentLoaded", async function() {
const submitBtn = document.querySelector("#tutor-generate-api-keys button[type=submit]");
const modal = document.getElementById("tutor-add-new-api-keys");
const noRecordElem = document.getElementById("tutor-api-keys-no-record");

const updatePermissionForm = document.querySelector("#tutor-update-permission-form");
const updateSubmitBtn = document.querySelector("#tutor-update-permission-modal button[type=submit]");
const updatePermissionModal = document.querySelector("#tutor-update-permission-modal");

if (!keysListWrapper) {
return;
}

// Add API keys
if (apiKeysForm) {
apiKeysForm.onsubmit = async (e) => {
e.preventDefault();
Expand All @@ -32,8 +37,8 @@ document.addEventListener("DOMContentLoaded", async function() {
const { success, data } = res;

if (success) {
listTable.insertAdjacentHTML("beforeend", `${data}`);
tutor_toast(__("Success", "tutor"), __("API key & secret generated successfully"), "success");
listTable.insertAdjacentHTML("afterbegin", `${data}`);
tutor_toast(__("Success", "tutor"), __("API key & secret generated successfully", 'tutor'), "success");
} else {
tutor_toast(__("Failed", "tutor"), data, "error");
}
Expand All @@ -47,20 +52,55 @@ document.addEventListener("DOMContentLoaded", async function() {
if (noRecordElem) {
noRecordElem.remove();
}
// Reset form
apiKeysForm.reset();
}
};
}

// Edit API keys
if (updatePermissionForm) {
updatePermissionForm.onsubmit = async (e) => {
e.preventDefault();

const formData = new FormData(updatePermissionForm);

try {
updateSubmitBtn.classList.add("is-loading");
updateSubmitBtn.setAttribute("disabled", true);

const post = await ajaxHandler(formData);
const res = await post.json();
const { success, data } = res;

if (success) {
document.getElementById(formData.get("meta_id")).innerHTML = data;
tutor_toast(__("Success", "tutor"), __("API key permission updated successfully", 'tutor'), "success");
} else {
tutor_toast(__("Failed", "tutor"), data, "error");
}
} catch (error) {
tutor_toast(__("Failed", "tutor"), defaultErrMsg, "error");
} finally {
updateSubmitBtn.classList.remove("is-loading");
updateSubmitBtn.removeAttribute("disabled");
updatePermissionModal.classList.remove("tutor-is-active");
document.body.classList.remove('tutor-modal-open');
updatePermissionForm.reset();
}
};
}

// Revoke api keys
if (listTable) {
listTable.addEventListener("click", async (e) => {
const target = e.target;

// Revoke API keys
if (target.hasAttribute("data-meta-id")) {
const metaId = target.dataset.metaId;
const formData = tutorFormData([{ action: "tutor_revoke_api_keys", meta_id: metaId }]);

try {
// Show loading
target.classList.add("is-loading");
target.setAttribute("disabled", true);

Expand All @@ -80,6 +120,18 @@ document.addEventListener("DOMContentLoaded", async function() {
target.removeAttribute("disabled");
}
}

// Add meta id to forms input value
if (target.hasAttribute("data-update-id")) {
const metaId = target.dataset.updateId;
const permission = target.dataset.permission;
const description = target.dataset.description;
if (metaId) {
updatePermissionForm.querySelector("input[name=meta_id]").value = metaId;
updatePermissionForm.querySelector("select[name=permission]").value = permission;
updatePermissionForm.querySelector("textarea[name=description]").value = description;
}
}
});
}
});
7 changes: 7 additions & 0 deletions assets/react/front/tutor-front.js
Original file line number Diff line number Diff line change
Expand Up @@ -928,4 +928,11 @@ jQuery(document).ready(function($) {
}, 1000); // Adjust the delay (in milliseconds) as needed
}

jQuery('#tutor-registration-form [name="password_confirmation"]').on('input', function(){
let original = jQuery('[name="password"]');
let val = (original.val() || '').trim();
let matched = val && jQuery(this).val() === val;

jQuery(this).parent().find('.tutor-validation-icon')[matched ? 'show' : 'hide']();
});
});
78 changes: 0 additions & 78 deletions assets/scss/admin-dashboard/_registration-notce.scss

This file was deleted.

Loading

0 comments on commit 9bc4cb9

Please sign in to comment.