Project

General

Profile

roos-fs tasks #840 » Newversion project management.html

Vadim Pariev, 12/02/2025 09:31 PM

 
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Shift / Week Planning</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
height: 100vh;
overflow: hidden;
}

header {
padding: 10px 20px;
background: #1f2933;
color: #fff;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
}

header h1 {
font-size: 20px;
margin: 0;
}

.week-controls {
display: flex;
align-items: center;
gap: 8px;
}

.week-controls button {
padding: 4px 8px;
border-radius: 4px;
border: 1px solid #ccc;
background: #fff;
cursor: pointer;
font-size: 12px;
}

.week-label {
font-size: 14px;
font-weight: bold;
color: #e5e7eb;
}

/* Main content: three conceptual areas */
main {
display: flex;
flex: 1;
height: 100%;
}

/* Left side: Team selection + Task pool */
#left-panel {
width: 30%;
background: #f3f3f3;
padding: 20px;
display: flex;
flex-direction: column;
border-right: 2px solid #ccc;
box-sizing: border-box;
gap: 16px;
}

/* Team selection area */
#team-selection {
padding: 10px;
background: #ffffff;
border-radius: 6px;
border: 1px solid #ccc;
}

#team-selection h2 {
margin-top: 0;
font-size: 16px;
}

#team-selection label {
display: block;
font-size: 14px;
margin-bottom: 4px;
}

#team-select {
width: 100%;
padding: 6px 8px;
border-radius: 4px;
border: 1px solid #bbb;
box-sizing: border-box;
}

/* Task pool area */
#task-pool {
flex: 1;
background: #f3f3f3;
display: flex;
flex-direction: column;
box-sizing: border-box;
}

#task-pool h2 {
margin-top: 0;
font-size: 16px;
}

.filters {
margin-bottom: 15px;
display: flex;
flex-direction: column;
gap: 8px;
}

.filters label {
font-size: 14px;
}

.filters input,
.filters select {
padding: 6px 8px;
border-radius: 4px;
border: 1px solid #bbb;
width: 100%;
box-sizing: border-box;
}

.task {
color: white;
padding: 10px;
margin-bottom: 10px;
border-radius: 6px;
cursor: grab;
user-select: none;
font-size: 14px;
}

.task.blue {
background: #4a90e2;
}

.task.green {
background: #50b26b;
}

.task.orange {
background: #f5a623;
}

.task.purple {
background: #9b59b6;
}

.task.assigned {
cursor: default;
margin: 5px 0;
}

/* Weekly calendar */
#calendar {
width: 70%;
display: grid;
grid-template-columns: repeat(5, 1fr);
background: white;
}

.day {
border-left: 1px solid #ddd;
border-right: 1px solid #ddd;
padding: 10px;
box-sizing: border-box;
}

.day h3 {
text-align: center;
margin-top: 0;
margin-bottom: 8px;
font-size: 14px;
}

.day .date-label {
text-align: center;
font-size: 12px;
color: #666;
margin-bottom: 4px;
}

.dropzone {
height: calc(100% - 40px);
border: 2px dashed #ccc;
border-radius: 6px;
padding: 10px;
min-height: 300px;
box-sizing: border-box;
overflow-y: auto;
}

/* Debug panel for stored planning entries (optional) */
#planning-debug {
position: absolute;
bottom: 0;
left: 0;
right: 0;
max-height: 120px;
overflow: auto;
background: #111827;
color: #e5e7eb;
font-size: 11px;
padding: 8px 12px;
box-sizing: border-box;
}

#planning-debug h3 {
margin: 0 0 4px 0;
font-size: 12px;
}

#planning-debug pre {
margin: 0;
white-space: pre-wrap;
word-break: break-word;
}
</style>
</head>
<body>
<header>
<h1>Shift / Week Planning</h1>
<div class="week-controls">
<button id="prev-week">&lt; Previous</button>
<span class="week-label" id="week-label">Week</span>
<button id="next-week">Next &gt;</button>
<button id="current-week">Today</button>
</div>
</header>

<main>
<!-- LEFT PANEL: Team Selection + Task Pool -->
<div id="left-panel">
<!-- 1) Team selection area -->
<div id="team-selection">
<h2>Team Selection</h2>
<label for="team-select">Team:</label>
<select id="team-select">
<option value="">Select a team...</option>
<option value="team-a">Team A</option>
<option value="team-b">Team B</option>
<option value="team-c">Team C</option>
</select>
</div>

<!-- 2) Task pool area -->
<div id="task-pool">
<h2>Tasks (1 hour each)</h2>

<div class="filters">
<label for="location-filter">Location:</label>
<select id="location-filter">
<option value="all">All locations</option>
<option value="berlin">Berlin</option>
<option value="hamburg">Hamburg</option>
<option value="munich">Munich</option>
</select>

<input type="text" id="task-search" placeholder="Search tasks..." />
</div>

<!-- Task pool items (now with team + id + duration) -->
<div class="task blue" draggable="true"
data-location="berlin"
data-team="team-a"
data-task-id="task-a"
data-duration="60">
Task A - Berlin (Team A)
</div>

<div class="task green" draggable="true"
data-location="hamburg"
data-team="team-a"
data-task-id="task-b"
data-duration="60">
Task B - Hamburg (Team A)
</div>

<div class="task orange" draggable="true"
data-location="munich"
data-team="team-b"
data-task-id="task-c"
data-duration="60">
Task C - Munich (Team B)
</div>

<div class="task purple" draggable="true"
data-location="berlin"
data-team="team-c"
data-task-id="task-d"
data-duration="60">
Task D - Berlin (Team C)
</div>
</div>
</div>

<!-- 3) Weekly calendar / planning board -->
<div id="calendar">
<div class="day" data-day-index="0">
<h3>Monday</h3>
<div class="date-label"></div>
<div class="dropzone"></div>
</div>
<div class="day" data-day-index="1">
<h3>Tuesday</h3>
<div class="date-label"></div>
<div class="dropzone"></div>
</div>
<div class="day" data-day-index="2">
<h3>Wednesday</h3>
<div class="date-label"></div>
<div class="dropzone"></div>
</div>
<div class="day" data-day-index="3">
<h3>Thursday</h3>
<div class="date-label"></div>
<div class="dropzone"></div>
</div>
<div class="day" data-day-index="4">
<h3>Friday</h3>
<div class="date-label"></div>
<div class="dropzone"></div>
</div>
</div>
</main>

<!-- Debug section to show stored planning entries -->
<section id="planning-debug">
<h3>Planned Entries (teamId, taskId, date, duration)</h3>
<pre id="planning-debug-content">[]</pre>
</section>

<script>
const zones = document.querySelectorAll('.dropzone');
const searchInput = document.getElementById('task-search');
const locationFilter = document.getElementById('location-filter');
const allTasks = document.querySelectorAll('#task-pool .task');
const teamSelect = document.getElementById('team-select');
const weekLabel = document.getElementById('week-label');
const prevWeekBtn = document.getElementById('prev-week');
const nextWeekBtn = document.getElementById('next-week');
const currentWeekBtn = document.getElementById('current-week');
const debugContent = document.getElementById('planning-debug-content');

// In-memory storage of planned entries (this is where you'd call your backend)
const planningEntries = [];

// Week handling: we store the Monday of the current visible week
let currentMonday = getMonday(new Date());

function getMonday(d) {
const date = new Date(d);
const day = date.getDay();
const diff = (day === 0 ? -6 : 1) - day; // adjust when day is Sunday (0)
date.setDate(date.getDate() + diff);
date.setHours(0, 0, 0, 0);
return date;
}

function formatISO(date) {
return date.toISOString().slice(0, 10);
}

function formatLabel(date) {
return date.toLocaleDateString(undefined, { day: '2-digit', month: '2-digit' });
}

function updateWeekView() {
// Update week label (e.g. Week of 01.12.2025)
const labelDate = currentMonday.toLocaleDateString(undefined, {
day: '2-digit',
month: '2-digit',
year: 'numeric'
});
weekLabel.textContent = `Week of ${labelDate}`;

// Set dates on each day column
const dayElements = document.querySelectorAll('.day');
dayElements.forEach(dayEl => {
const index = parseInt(dayEl.dataset.dayIndex, 10);
const date = new Date(currentMonday);
date.setDate(currentMonday.getDate() + index);
const iso = formatISO(date);
dayEl.dataset.date = iso; // store actual date on the column
dayEl.querySelector('.date-label').textContent = formatLabel(date);
});
}

function attachDragHandlers() {
// Attach drag handlers only for pool tasks that are draggable
const tasks = document.querySelectorAll('#task-pool .task[draggable="true"]');

tasks.forEach(task => {
task.addEventListener('dragstart', e => {
e.dataTransfer.setData('text/plain', task.innerText);
e.dataTransfer.effectAllowed = 'move';
task.classList.add('dragging');
});

task.addEventListener('dragend', () => {
task.classList.remove('dragging');
});
});
}

function applyFilters() {
const query = searchInput.value.toLowerCase();
const location = locationFilter.value;
const selectedTeam = teamSelect.value;

allTasks.forEach(task => {
const textMatch = task.innerText.toLowerCase().includes(query);
const taskLocation = task.dataset.location || 'all';
const locationMatch = location === 'all' || taskLocation === location;
const teamMatch =
!selectedTeam || task.dataset.team === selectedTeam;

task.style.display = textMatch && locationMatch && teamMatch ? '' : 'none';
});
}

function updateDebugPanel() {
debugContent.textContent = JSON.stringify(planningEntries, null, 2);
}

// Initial binding
attachDragHandlers();
updateWeekView();

// Filter listeners
searchInput.addEventListener('input', applyFilters);
locationFilter.addEventListener('change', applyFilters);
teamSelect.addEventListener('change', applyFilters);

// Week navigation
prevWeekBtn.addEventListener('click', () => {
currentMonday.setDate(currentMonday.getDate() - 7);
updateWeekView();
// TODO: load planning from backend for this week + selected team
});

nextWeekBtn.addEventListener('click', () => {
currentMonday.setDate(currentMonday.getDate() + 7);
updateWeekView();
// TODO: load planning from backend for this week + selected team
});

currentWeekBtn.addEventListener('click', () => {
currentMonday = getMonday(new Date());
updateWeekView();
// TODO: load planning from backend for this week + selected team
});

// Dropzones
zones.forEach(zone => {
zone.addEventListener('dragover', e => {
e.preventDefault();
zone.style.background = '#eef';
});

zone.addEventListener('dragleave', () => {
zone.style.background = '';
});

zone.addEventListener('drop', e => {
e.preventDefault();
const dragged = document.querySelector('#task-pool .task.dragging');
const selectedTeam = teamSelect.value;

if (!selectedTeam) {
alert('Please select a team before assigning tasks to the week.');
zone.style.background = '';
return;
}

if (dragged) {
const dayEl = zone.closest('.day');
const date = dayEl.dataset.date;

const taskId = dragged.dataset.taskId;
const duration = parseInt(dragged.dataset.duration || '60', 10);
const teamId = selectedTeam;

// Clone for visual representation
const clone = dragged.cloneNode(true);
clone.classList.add('assigned');
clone.removeAttribute('draggable');
clone.dataset.team = teamId;
zone.appendChild(clone);

// Store planning entry (this is where you'd call your backend)
planningEntries.push({
teamId,
taskId,
date,
duration
});

updateDebugPanel();
}
zone.style.background = '';
});
});
</script>
</body>
</html>
(1-1/3)