Brainstorm huge refactor
This commit is contained in:
@@ -7,9 +7,12 @@
|
||||
$pageTitle = 'Fociz — Microsoft Outlook Mail';
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
require_once __DIR__ . '/includes/integrations/microsoft.php';
|
||||
require_once __DIR__ . '/includes/boards.php';
|
||||
|
||||
$userId = (int)($currentUser['id'] ?? 0);
|
||||
$isAdmin = (($currentUser['role'] ?? '') === 'ADMIN');
|
||||
$db = get_db_connection();
|
||||
$userBoards = fociz_get_user_boards_with_lanes($db, $userId, $isAdmin);
|
||||
|
||||
// Haal initiële inbox data op (met 45s cache, tenzij ?refresh=1)
|
||||
$forceRefresh = !empty($_GET['refresh']) && $_GET['refresh'] === '1';
|
||||
@@ -325,6 +328,55 @@ $jsonMessages = json_encode($messages, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_Q
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Optie: Tevens toevoegen aan Bord & Tijdlijn -->
|
||||
<div class="p-3 rounded-xl bg-slate-50 dark:bg-slate-900/40 border border-slate-200 dark:border-slate-800 space-y-2.5">
|
||||
<label class="flex items-center space-x-2.5 cursor-pointer select-none">
|
||||
<input type="checkbox" id="mailPlanAddToBoard" onchange="toggleMailBoardOptions(this.checked)" class="w-4 h-4 rounded text-indigo-600 focus:ring-indigo-500 border-slate-300 dark:border-slate-700 dark:bg-slate-900 cursor-pointer">
|
||||
<span class="text-xs font-bold text-slate-800 dark:text-slate-200 flex items-center space-x-1.5">
|
||||
<i data-lucide="layout-grid" class="w-3.5 h-3.5 text-indigo-600 dark:text-indigo-400"></i>
|
||||
<span>Tevens toevoegen aan Bord & Tijdlijn</span>
|
||||
</span>
|
||||
</label>
|
||||
<div id="mailBoardOptionsWrapper" class="hidden space-y-2.5 pt-2.5 border-t border-slate-200/70 dark:border-slate-800">
|
||||
<?php if (empty($userBoards)): ?>
|
||||
<p class="text-[11px] text-slate-500 dark:text-slate-400">Er zijn geen actieve borden gevonden.</p>
|
||||
<?php else: ?>
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<div>
|
||||
<label for="mailPlanBoardSelect" class="block text-[10px] font-bold text-slate-600 dark:text-slate-400 mb-1 uppercase tracking-wider">Bord</label>
|
||||
<select id="mailPlanBoardSelect" onchange="onMailBoardSelectChange(this.value)" class="w-full bg-white dark:bg-[#0c0f17] border border-slate-200 dark:border-slate-800 rounded-xl px-2.5 py-1.5 text-xs text-slate-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-indigo-500">
|
||||
<?php foreach ($userBoards as $b): ?>
|
||||
<option value="<?= (int)$b['id'] ?>"><?= htmlspecialchars($b['title']) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label for="mailPlanLaneSelect" class="block text-[10px] font-bold text-slate-600 dark:text-slate-400 mb-1 uppercase tracking-wider">Kolom</label>
|
||||
<select id="mailPlanLaneSelect" class="w-full bg-white dark:bg-[#0c0f17] border border-slate-200 dark:border-slate-800 rounded-xl px-2.5 py-1.5 text-xs text-slate-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-indigo-500">
|
||||
<!-- Wordt gevuld via JS -->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pt-1">
|
||||
<label class="flex items-center space-x-2 cursor-pointer select-none">
|
||||
<input type="checkbox" id="mailPlanScheduleOnTimeline" checked onchange="toggleMailTimelineDates(this.checked)" class="w-3.5 h-3.5 rounded text-indigo-600 focus:ring-indigo-500 border-slate-300 dark:border-slate-700 dark:bg-slate-900 cursor-pointer">
|
||||
<span class="text-xs font-medium text-slate-700 dark:text-slate-300">Inplannen op de Project Tijdlijn</span>
|
||||
</label>
|
||||
<div id="mailTimelineDatesWrapper" class="grid grid-cols-2 gap-2 mt-2">
|
||||
<div>
|
||||
<label for="mailTimelineStartDate" class="block text-[10px] font-bold text-slate-600 dark:text-slate-400 mb-1 uppercase tracking-wider">Startdatum</label>
|
||||
<input type="date" id="mailTimelineStartDate" class="w-full bg-white dark:bg-[#0c0f17] border border-slate-200 dark:border-slate-800 rounded-xl px-2.5 py-1.5 text-xs text-slate-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-indigo-500">
|
||||
</div>
|
||||
<div>
|
||||
<label for="mailTimelineEndDate" class="block text-[10px] font-bold text-slate-600 dark:text-slate-400 mb-1 uppercase tracking-wider">Einddatum</label>
|
||||
<input type="date" id="mailTimelineEndDate" class="w-full bg-white dark:bg-[#0c0f17] border border-slate-200 dark:border-slate-800 rounded-xl px-2.5 py-1.5 text-xs text-slate-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-indigo-500">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end space-x-2 pt-3 border-t border-slate-100 dark:border-slate-800">
|
||||
<button type="button" onclick="closePlanMailModal()" class="px-4 py-2 rounded-xl text-xs font-semibold text-slate-600 dark:text-slate-400 hover:bg-slate-100 dark:hover:bg-slate-800 transition cursor-pointer">
|
||||
Annuleren
|
||||
@@ -833,6 +885,58 @@ function closeOutsideWorkhoursModalMail(choice) {
|
||||
}
|
||||
}
|
||||
|
||||
const availableUserBoards = <?= json_encode($userBoards, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?> || [];
|
||||
|
||||
function toggleMailBoardOptions(show) {
|
||||
const wrapper = document.getElementById('mailBoardOptionsWrapper');
|
||||
if (wrapper) {
|
||||
if (show) {
|
||||
wrapper.classList.remove('hidden');
|
||||
const boardSelect = document.getElementById('mailPlanBoardSelect');
|
||||
if (boardSelect && boardSelect.value) {
|
||||
onMailBoardSelectChange(boardSelect.value);
|
||||
}
|
||||
const planDate = document.getElementById('planMailDate')?.value || '';
|
||||
const startInput = document.getElementById('mailTimelineStartDate');
|
||||
const endInput = document.getElementById('mailTimelineEndDate');
|
||||
if (startInput && !startInput.value) startInput.value = planDate;
|
||||
if (endInput && !endInput.value) endInput.value = planDate;
|
||||
} else {
|
||||
wrapper.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onMailBoardSelectChange(boardId) {
|
||||
const laneSelect = document.getElementById('mailPlanLaneSelect');
|
||||
if (!laneSelect) return;
|
||||
laneSelect.innerHTML = '';
|
||||
|
||||
const board = availableUserBoards.find(b => String(b.id) === String(boardId));
|
||||
if (board && board.lanes && board.lanes.length > 0) {
|
||||
board.lanes.forEach((lane, idx) => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = lane.id;
|
||||
opt.textContent = lane.title;
|
||||
if (idx === 0) opt.selected = true;
|
||||
laneSelect.appendChild(opt);
|
||||
});
|
||||
} else {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = '';
|
||||
opt.textContent = 'Geen kolommen beschikbaar';
|
||||
laneSelect.appendChild(opt);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleMailTimelineDates(show) {
|
||||
const wrapper = document.getElementById('mailTimelineDatesWrapper');
|
||||
if (wrapper) {
|
||||
if (show) wrapper.classList.remove('hidden');
|
||||
else wrapper.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
function openPlanMailModal() {
|
||||
if (!selectedMessage) return;
|
||||
document.getElementById('planMailId').value = selectedMessage.id;
|
||||
@@ -843,6 +947,22 @@ function openPlanMailModal() {
|
||||
const notice = document.getElementById('mailPlanOpenBlockNotice');
|
||||
if (notice) notice.classList.add('hidden');
|
||||
|
||||
const planDate = document.getElementById('planMailDate')?.value || '';
|
||||
const addToBoardCb = document.getElementById('mailPlanAddToBoard');
|
||||
if (addToBoardCb) {
|
||||
addToBoardCb.checked = false;
|
||||
toggleMailBoardOptions(false);
|
||||
}
|
||||
const schedTimelineCb = document.getElementById('mailPlanScheduleOnTimeline');
|
||||
if (schedTimelineCb) {
|
||||
schedTimelineCb.checked = true;
|
||||
toggleMailTimelineDates(true);
|
||||
}
|
||||
const tStart = document.getElementById('mailTimelineStartDate');
|
||||
const tEnd = document.getElementById('mailTimelineEndDate');
|
||||
if (tStart) tStart.value = planDate;
|
||||
if (tEnd) tEnd.value = planDate;
|
||||
|
||||
updatePlanMailEndTimeBadge();
|
||||
|
||||
const modal = document.getElementById('planMailModal');
|
||||
@@ -910,6 +1030,13 @@ async function submitPlanEmail(e, options = {}) {
|
||||
if (typeof lucide !== 'undefined') lucide.createIcons();
|
||||
}
|
||||
|
||||
const addToBoard = document.getElementById('mailPlanAddToBoard')?.checked || false;
|
||||
const boardId = parseInt(document.getElementById('mailPlanBoardSelect')?.value || '0', 10);
|
||||
const laneId = parseInt(document.getElementById('mailPlanLaneSelect')?.value || '0', 10);
|
||||
const scheduleOnTimeline = document.getElementById('mailPlanScheduleOnTimeline')?.checked || false;
|
||||
const timelineStartDate = document.getElementById('mailTimelineStartDate')?.value || planDate;
|
||||
const timelineEndDate = document.getElementById('mailTimelineEndDate')?.value || timelineStartDate;
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/mail.php?action=plan_email', {
|
||||
method: 'POST',
|
||||
@@ -922,7 +1049,13 @@ async function submitPlanEmail(e, options = {}) {
|
||||
duration_minutes: durationMinutes,
|
||||
priority: priority,
|
||||
web_link: webLink,
|
||||
sender: sender
|
||||
sender: sender,
|
||||
add_to_board: addToBoard,
|
||||
board_id: boardId,
|
||||
lane_id: laneId,
|
||||
schedule_on_timeline: scheduleOnTimeline,
|
||||
timeline_start_date: timelineStartDate,
|
||||
timeline_end_date: timelineEndDate
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
|
||||
Reference in New Issue
Block a user