Sep 16 - Optimize code, part 1
This commit is contained in:
@@ -680,16 +680,28 @@ function handleCheckinError(error) {
|
||||
}
|
||||
|
||||
function updateSubmitButton(isLoading) {
|
||||
const submitButton = document.getElementById("submitCheckin");
|
||||
// The check-in button's id is "submitButton" (qr_destination.html). Looking
|
||||
// only for the old "submitCheckin" id found nothing, so after the form swap
|
||||
// at 1.5 s the button never showed "Processing" and employees tapped again.
|
||||
const submitButton =
|
||||
document.getElementById("submitCheckin") ||
|
||||
document.getElementById("submitButton");
|
||||
if (submitButton) {
|
||||
if (isLoading) {
|
||||
submitButton.disabled = true;
|
||||
submitButton.innerHTML =
|
||||
'<i class="fas fa-spinner fa-spin"></i> <span data-en="Processing..." data-es="Procesando...">Processing...</span>';
|
||||
'<i class="fas fa-spinner fa-spin"></i>' +
|
||||
'<span class="english-text">Processing</span>' +
|
||||
'<span class="language-separator">/</span>' +
|
||||
'<span class="spanish-text">Procesando</span>';
|
||||
} else {
|
||||
submitButton.disabled = false;
|
||||
submitButton.innerHTML =
|
||||
'<i class="fas fa-user-check"></i> <span data-en="Submit" data-es="Someter">Submit</span>';
|
||||
if (typeof renderSubmitButton === "function") {
|
||||
renderSubmitButton(); // the page's own Check In / Check Out label
|
||||
} else {
|
||||
submitButton.innerHTML =
|
||||
'<i class="fas fa-user-check"></i> <span data-en="Submit" data-es="Someter">Submit</span>';
|
||||
}
|
||||
}
|
||||
applyTranslations();
|
||||
}
|
||||
|
||||
+4
-4
@@ -220,7 +220,7 @@ class UsersManager {
|
||||
|
||||
try {
|
||||
const response = await fetch(`/users/${userId}/delete`, {
|
||||
method: "GET",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
'X-CSRF-Token': (window.qrConfig && window.qrConfig.csrfToken) || '',
|
||||
@@ -246,7 +246,7 @@ class UsersManager {
|
||||
async reactivateUser(userId, userName) {
|
||||
try {
|
||||
const response = await fetch(`/users/${userId}/reactivate`, {
|
||||
method: "GET",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
'X-CSRF-Token': (window.qrConfig && window.qrConfig.csrfToken) || '',
|
||||
@@ -279,7 +279,7 @@ class UsersManager {
|
||||
|
||||
try {
|
||||
const response = await fetch(`/users/${userId}/promote`, {
|
||||
method: "GET",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
'X-CSRF-Token': (window.qrConfig && window.qrConfig.csrfToken) || '',
|
||||
@@ -312,7 +312,7 @@ class UsersManager {
|
||||
|
||||
try {
|
||||
const response = await fetch(`/users/${userId}/demote`, {
|
||||
method: "GET",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
'X-CSRF-Token': (window.qrConfig && window.qrConfig.csrfToken) || '',
|
||||
|
||||
Reference in New Issue
Block a user