Remove maintenance feature
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
/* global window, document, jQuery */
|
||||
|
||||
/**
|
||||
* Event Popup, Day Popup, Event CRUD, and Maintenance Task Handling
|
||||
* Event Popup, Day Popup, and Event CRUD
|
||||
*
|
||||
* - Clicking an event item with data-luxtools-event="1" opens a detail popup.
|
||||
* - Clicking empty space in a calendar day cell opens a day popup listing all events.
|
||||
* - Day popup includes a "Create Event" action for authenticated users.
|
||||
* - Event popup includes "Edit" and "Delete" actions for authenticated users.
|
||||
* - Clicking a maintenance task action button sends an AJAX request to
|
||||
* complete/reopen the task.
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
@@ -889,99 +887,6 @@
|
||||
return { confirmDelete: confirmDelete, executeDelete: executeDelete };
|
||||
})();
|
||||
|
||||
// ============================================================
|
||||
// Maintenance Task Actions
|
||||
// ============================================================
|
||||
var MaintenanceTasks = (function () {
|
||||
function handleAction(button) {
|
||||
var action = button.getAttribute("data-action");
|
||||
if (!action) return;
|
||||
|
||||
var item = button.closest("[data-task-uid]");
|
||||
if (!item) item = button.closest("[data-uid]");
|
||||
if (!item) return;
|
||||
|
||||
var uid =
|
||||
item.getAttribute("data-task-uid") ||
|
||||
item.getAttribute("data-uid") ||
|
||||
"";
|
||||
var date =
|
||||
item.getAttribute("data-task-date") ||
|
||||
item.getAttribute("data-date") ||
|
||||
"";
|
||||
var recurrence =
|
||||
item.getAttribute("data-task-recurrence") ||
|
||||
item.getAttribute("data-recurrence") ||
|
||||
"";
|
||||
|
||||
if (!uid || !date) return;
|
||||
|
||||
var ajaxUrl = getAjaxUrl();
|
||||
var sectok = getSecurityToken(item);
|
||||
|
||||
button.disabled = true;
|
||||
button.textContent = "...";
|
||||
|
||||
var params =
|
||||
"call=luxtools_maintenance_task" +
|
||||
"&action=" +
|
||||
encodeURIComponent(action) +
|
||||
"&uid=" +
|
||||
encodeURIComponent(uid) +
|
||||
"&date=" +
|
||||
encodeURIComponent(date) +
|
||||
"&recurrence=" +
|
||||
encodeURIComponent(recurrence) +
|
||||
"§ok=" +
|
||||
encodeURIComponent(sectok);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", ajaxUrl, true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
xhr.onload = function () {
|
||||
var result;
|
||||
try {
|
||||
result = JSON.parse(xhr.responseText);
|
||||
} catch (e) {
|
||||
result = { ok: false, error: "Invalid response" };
|
||||
}
|
||||
|
||||
if (result.ok) {
|
||||
if (action === "complete") {
|
||||
item.classList.add("luxtools-task-completed");
|
||||
button.textContent = "Reopen";
|
||||
button.setAttribute("data-action", "reopen");
|
||||
} else {
|
||||
item.classList.remove("luxtools-task-completed");
|
||||
item.style.opacity = "1";
|
||||
button.textContent = "Complete";
|
||||
button.setAttribute("data-action", "complete");
|
||||
}
|
||||
button.disabled = false;
|
||||
|
||||
if (result.remoteOk === false && result.remoteError) {
|
||||
showNotification(result.remoteError, "warning");
|
||||
}
|
||||
} else {
|
||||
showNotification(result.error || "Action failed", "error");
|
||||
button.textContent = action === "complete" ? "Complete" : "Reopen";
|
||||
button.disabled = false;
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onerror = function () {
|
||||
showNotification("Network error", "error");
|
||||
button.textContent = action === "complete" ? "Complete" : "Reopen";
|
||||
button.disabled = false;
|
||||
};
|
||||
|
||||
xhr.send(params);
|
||||
}
|
||||
|
||||
return { handleAction: handleAction };
|
||||
})();
|
||||
|
||||
// ============================================================
|
||||
// Event Delegation
|
||||
// ============================================================
|
||||
@@ -990,26 +895,6 @@
|
||||
function (e) {
|
||||
var target = e.target;
|
||||
|
||||
// Maintenance task action buttons (day pages)
|
||||
if (
|
||||
target.classList &&
|
||||
target.classList.contains("luxtools-task-action")
|
||||
) {
|
||||
e.preventDefault();
|
||||
MaintenanceTasks.handleAction(target);
|
||||
return;
|
||||
}
|
||||
|
||||
// Maintenance task complete buttons (syntax plugin list)
|
||||
if (
|
||||
target.classList &&
|
||||
target.classList.contains("luxtools-task-complete-btn")
|
||||
) {
|
||||
e.preventDefault();
|
||||
MaintenanceTasks.handleAction(target);
|
||||
return;
|
||||
}
|
||||
|
||||
// Event form save
|
||||
if (
|
||||
target.classList &&
|
||||
@@ -1166,5 +1051,4 @@
|
||||
|
||||
Luxtools.EventPopup = EventPopup;
|
||||
Luxtools.DayPopup = DayPopup;
|
||||
Luxtools.MaintenanceTasks = MaintenanceTasks;
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user