Fixed spatial issues with finding map cuts data.
This commit is contained in:
@@ -1,110 +0,0 @@
|
||||
/**
|
||||
* Admin Cuts Management Module
|
||||
* Main initialization file that imports and orchestrates all cut management modules
|
||||
*/
|
||||
|
||||
// Global admin cuts manager instance
|
||||
let adminCutsManager = null;
|
||||
|
||||
// Initialize the admin cuts system when DOM is ready
|
||||
document.addEventListener('DOMContentLoaded', async function() {
|
||||
console.log('DOM loaded, initializing admin cuts system...');
|
||||
|
||||
try {
|
||||
// Wait for all module classes to be loaded
|
||||
if (typeof AdminCutsManager === 'undefined') {
|
||||
console.error('AdminCutsManager class not loaded');
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof CutDrawing === 'undefined') {
|
||||
console.error('CutDrawing class not loaded');
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof CutLocationManager === 'undefined') {
|
||||
console.error('CutLocationManager class not loaded');
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof CutPrintUtils === 'undefined') {
|
||||
console.error('CutPrintUtils class not loaded');
|
||||
return;
|
||||
}
|
||||
|
||||
// Create manager instance
|
||||
adminCutsManager = new AdminCutsManager();
|
||||
|
||||
// Initialize the system
|
||||
await adminCutsManager.initialize();
|
||||
|
||||
console.log('Admin cuts system initialized successfully');
|
||||
|
||||
// Make manager globally accessible for debugging
|
||||
window.adminCutsManager = adminCutsManager;
|
||||
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize admin cuts system:', error);
|
||||
|
||||
// Show error notification if available
|
||||
if (typeof showNotification === 'function') {
|
||||
showNotification('Failed to initialize cuts management system', 'error');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Global functions for backward compatibility
|
||||
function startDrawing() {
|
||||
if (adminCutsManager && adminCutsManager.cutDrawing) {
|
||||
adminCutsManager.handleStartDrawing();
|
||||
}
|
||||
}
|
||||
|
||||
function finishDrawing() {
|
||||
if (adminCutsManager && adminCutsManager.cutDrawing) {
|
||||
adminCutsManager.cutDrawing.finishDrawing();
|
||||
}
|
||||
}
|
||||
|
||||
function cancelDrawing() {
|
||||
if (adminCutsManager && adminCutsManager.cutDrawing) {
|
||||
adminCutsManager.cutDrawing.cancelDrawing();
|
||||
}
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
if (adminCutsManager) {
|
||||
adminCutsManager.resetForm();
|
||||
}
|
||||
}
|
||||
|
||||
function exportCuts() {
|
||||
if (adminCutsManager) {
|
||||
adminCutsManager.exportCuts();
|
||||
}
|
||||
}
|
||||
|
||||
function refreshCuts() {
|
||||
if (adminCutsManager) {
|
||||
adminCutsManager.loadCuts();
|
||||
}
|
||||
}
|
||||
|
||||
// Debug functions
|
||||
function debugFormState() {
|
||||
if (adminCutsManager) {
|
||||
adminCutsManager.debugFormState();
|
||||
}
|
||||
}
|
||||
|
||||
function debugOpacityState() {
|
||||
if (adminCutsManager) {
|
||||
adminCutsManager.debugOpacityState();
|
||||
}
|
||||
}
|
||||
|
||||
function forceUpdateDrawingStyle() {
|
||||
if (adminCutsManager) {
|
||||
adminCutsManager.forceUpdateDrawingStyle();
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@
|
||||
* Handles email composition, broadcasting to all users, and progress tracking
|
||||
*/
|
||||
|
||||
// Email state
|
||||
let allUsersData = [];
|
||||
// Email state - use users module data instead of declaring our own
|
||||
// let allUsersData = []; // Removed - use window.adminUsers.getAllUsersData() instead
|
||||
|
||||
// Email All Users Functions
|
||||
async function showEmailUsersModal() {
|
||||
@@ -14,12 +14,15 @@ async function showEmailUsersModal() {
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success && data.users) {
|
||||
allUsersData = data.users;
|
||||
// Use the users module to store user data
|
||||
if (window.adminUsers && window.adminUsers.setAllUsersData) {
|
||||
window.adminUsers.setAllUsersData(data.users);
|
||||
}
|
||||
|
||||
// Update recipients count
|
||||
const recipientsCount = document.getElementById('recipients-count');
|
||||
if (recipientsCount) {
|
||||
recipientsCount.textContent = `${allUsersData.length}`;
|
||||
recipientsCount.textContent = `${data.users.length}`;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -144,18 +147,19 @@ async function sendEmailToAllUsers(e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (allUsersData.length === 0) {
|
||||
const allUsers = (window.adminUsers && window.adminUsers.getAllUsersData) ? window.adminUsers.getAllUsersData() : [];
|
||||
if (allUsers.length === 0) {
|
||||
window.adminCore.showStatus('No users found to email', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmMessage = `Send this email to all ${allUsersData.length} users?`;
|
||||
const confirmMessage = `Send this email to all ${allUsers.length} users?`;
|
||||
if (!confirm(confirmMessage)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize progress tracking
|
||||
initializeEmailProgress(allUsersData.length);
|
||||
initializeEmailProgress(allUsers.length);
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/users/email-all', {
|
||||
@@ -223,7 +227,8 @@ function initializeEmailProgress(totalCount) {
|
||||
if (closeBtn) closeBtn.style.display = 'none';
|
||||
|
||||
// Add status items for each user
|
||||
allUsersData.forEach(user => {
|
||||
const allUsers = (window.adminUsers && window.adminUsers.getAllUsersData) ? window.adminUsers.getAllUsersData() : [];
|
||||
allUsers.forEach(user => {
|
||||
if (statusList) {
|
||||
const statusItem = document.createElement('div');
|
||||
statusItem.className = 'email-status-item';
|
||||
@@ -389,6 +394,10 @@ window.adminEmail = {
|
||||
updateEmailPreview,
|
||||
sendEmailToAllUsers,
|
||||
setupEmailModalEventListeners,
|
||||
getAllUsersData: () => allUsersData,
|
||||
setAllUsersData: (data) => { allUsersData = data; }
|
||||
getAllUsersData: () => (window.adminUsers && window.adminUsers.getAllUsersData) ? window.adminUsers.getAllUsersData() : [],
|
||||
setAllUsersData: (data) => {
|
||||
if (window.adminUsers && window.adminUsers.setAllUsersData) {
|
||||
window.adminUsers.setAllUsersData(data);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,6 +30,12 @@ function initializeAdminMap() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if Leaflet is available
|
||||
if (typeof L === 'undefined') {
|
||||
console.error('Leaflet (L) is not defined. Map initialization failed.');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Initializing admin map...');
|
||||
adminMap = L.map('admin-map').setView([53.5461, -113.4938], 11);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user