Maribor v žepu – TikTok Visit Maribor
interaktivni projektni načrt in gantogram (Generacija Z)
Naloga
Začetek
Dni
Izvajalec
Strošek (€)
+
${group.title}
${sum.start}
${sum.duration}
Skupina
${formatEur(sum.cost)}
`;
gLeft.onclick = () => toggleGroup(group.id);
leftContainer.appendChild(gLeft);
// Vrstica skupine na časovnici
const gRight = document.createElement(‘div’);
gRight.className = ‘grid-row-right group-row’;
fillGridCells(gRight, dayFlags, pxPerDay);
const gLeftPx = Math.max(0, daysBetween(PROJECT_START, parseIsoDate(sum.start))) * pxPerDay;
const gWidthPx = Math.max(sum.duration * pxPerDay, 24);
const gBar = document.createElement(‘div’);
gBar.className = ‘task-bar bar-group’;
gBar.style.left = `${gLeftPx}px`;
gBar.style.width = `${gWidthPx}px`;
gBar.innerHTML = ``;
gBar.onclick = () => toggleGroup(group.id);
gRight.appendChild(gBar);
rightContainer.appendChild(gRight);
if (group.expanded) {
group.items.forEach(item => {
const selected = item.id === currentTaskId;
const dimmed = !isItemHighlighted(item);
const tLeft = document.createElement(‘div’);
tLeft.className = `grid-row-left ${selected ? ‘selected-row’ : ”} ${dimmed ? ‘dimmed’ : ”}`;
const diamondPrefix = item.isMilestone ? `◆` : ”;
const critIndicator = item.isCritical ? `` : ”;
tLeft.innerHTML = `
${diamondPrefix}
${item.title}
${critIndicator}
${item.start}
${item.duration}
${item.owner}
${formatEur(item.cost)}
›
`;
tLeft.onclick = () => selectItem(item.id);
leftContainer.appendChild(tLeft);
const tRight = document.createElement(‘div’);
tRight.className = `grid-row-right ${selected ? ‘selected-row’ : ”} ${dimmed ? ‘dimmed’ : ”}`;
fillGridCells(tRight, dayFlags, pxPerDay);
const startOffsetPx = Math.max(0, daysBetween(PROJECT_START, parseIsoDate(item.start))) * pxPerDay;
if (item.isMilestone) {
const diamondEl = document.createElement(‘div’);
diamondEl.className = `milestone-diamond ${selected ? ‘is-selected’ : ”}`;
diamondEl.style.left = `${startOffsetPx + Math.max(0, (pxPerDay – 18) / 2)}px`;
diamondEl.title = `${item.title} (${item.start})`;
bindPointerAction(diamondEl, item, ‘move’, pxPerDay);
const tagEl = document.createElement(‘div’);
tagEl.className = ‘milestone-tag’;
tagEl.style.left = `${startOffsetPx + pxPerDay + 6}px`;
tagEl.textContent = item.title;
tRight.appendChild(diamondEl);
tRight.appendChild(tagEl);
} else {
const barColorClass = item.isCritical ? ‘bar-crimson is-critical’ : ‘bar-steel’;
const barEl = document.createElement(‘div’);
barEl.className = `task-bar ${barColorClass} ${selected ? ‘is-selected’ : ”}`;
barEl.style.left = `${startOffsetPx}px`;
barEl.style.width = `${Math.max(item.duration * pxPerDay, 22)}px`;
barEl.title = `${item.title} • ${item.duration} dni • ${formatEur(item.cost)}`;
const handleL = document.createElement(‘div’);
handleL.className = ‘resize-edge left’;
bindPointerAction(handleL, item, ‘resize-left’, pxPerDay);
const handleR = document.createElement(‘div’);
handleR.className = ‘resize-edge right’;
bindPointerAction(handleR, item, ‘resize-right’, pxPerDay);
const labelEl = document.createElement(‘span’);
labelEl.className = ‘bar-text’;
labelEl.textContent = `${item.title} (${item.duration}d)`;
barEl.appendChild(handleL);
barEl.appendChild(labelEl);
barEl.appendChild(handleR);
bindPointerAction(barEl, item, ‘move’, pxPerDay);
tRight.appendChild(barEl);
}
rightContainer.appendChild(tRight);
});
}
});
refreshTotals();
}
function fillGridCells(rowEl, dayFlags, pxPerDay) {
const frag = document.createDocumentFragment();
for (let i = 0; i {
if (ev.button !== 0) return;
ev.stopPropagation();
ev.preventDefault();
const originX = ev.clientX;
const initStart = item.start;
const initDur = item.duration;
let moved = false;
function handleMove(moveEv) {
const diffPx = moveEv.clientX – originX;
const diffDays = Math.round(diffPx / pxPerDay);
if (diffDays !== 0) moved = true;
if (mode === ‘move’) {
const nextStart = shiftIsoDate(initStart, diffDays);
const nd = parseIsoDate(nextStart);
if (nd >= PROJECT_START && nd = PROJECT_START) {
item.start = nextStart;
item.duration = initDur – clamped;
}
}
renderGantt();
if (currentTaskId === item.id) {
fillInspector(item.id);
}
}
function handleUp() {
document.removeEventListener(‘mousemove’, handleMove);
document.removeEventListener(‘mouseup’, handleUp);
if (!moved && mode === ‘move’) {
selectItem(item.id);
}
}
document.addEventListener(‘mousemove’, handleMove);
document.addEventListener(‘mouseup’, handleUp);
});
}
function findItemRecord(id) {
for (const g of groups) {
const found = g.items.find(it => it.id === id);
if (found) return { group: g, item: found };
}
return null;
}
function selectItem(id) {
currentTaskId = id;
renderGantt();
fillInspector(id);
}
function fillInspector(id) {
const rec = findItemRecord(id);
const emptyBox = document.getElementById(‘inspector-empty’);
const formEl = document.getElementById(‘inspector-form’);
if (!rec) {
emptyBox.style.display = ‘block’;
formEl.style.display = ‘none’;
return;
}
emptyBox.style.display = ‘none’;
formEl.style.display = ‘flex’;
document.getElementById(‘edit-group-name’).textContent = rec.group.title;
document.getElementById(‘edit-title’).value = rec.item.title;
document.getElementById(‘edit-milestone’).checked = rec.item.isMilestone;
document.getElementById(‘edit-critical’).checked = rec.item.isCritical;
document.getElementById(‘edit-start’).value = rec.item.start;
document.getElementById(‘edit-duration’).value = rec.item.duration;
document.getElementById(‘edit-cost’).value = rec.item.cost;
document.getElementById(‘edit-owner’).value = rec.item.owner;
document.getElementById(‘edit-notes’).value = rec.item.notes || ”;
}
function onMilestoneCheckboxChange() {
if (document.getElementById(‘edit-milestone’).checked) {
document.getElementById(‘edit-duration’).value = 1;
document.getElementById(‘edit-cost’).value = 0;
}
}
function applyTaskEdit(ev) {
ev.preventDefault();
if (!currentTaskId) return;
const rec = findItemRecord(currentTaskId);
if (!rec) return;
rec.item.title = document.getElementById(‘edit-title’).value.trim();
rec.item.isMilestone = document.getElementById(‘edit-milestone’).checked;
rec.item.isCritical = document.getElementById(‘edit-critical’).checked;
rec.item.start = document.getElementById(‘edit-start’).value;
rec.item.duration = Math.max(1, Number(document.getElementById(‘edit-duration’).value));
rec.item.cost = Math.max(0, Number(document.getElementById(‘edit-cost’).value));
rec.item.owner = document.getElementById(‘edit-owner’).value;
rec.item.notes = document.getElementById(‘edit-notes’).value.trim();
renderGantt();
const msg = document.getElementById(‘edit-status’);
msg.textContent = ‘✓ Shranjeno’;
setTimeout(() => { msg.textContent = ”; }, 2000);
}
function addItemToGroup(groupId) {
const targetGroup = groups.find(g => g.id === groupId) || groups[0];
const sum = summarizeGroup(targetGroup);
const index = targetGroup.items.length + 1;
const newItem = {
id: Date.now(),
title: `${targetGroup.id}.${index} Novo opravilo`,
start: sum.start,
duration: 3,
owner: “Trženje in PR”,
cost: 150,
isMilestone: false,
isCritical: false,
notes: “Dodatna naloga v okviru kampanje Maribor v žepu.”
};
targetGroup.items.push(newItem);
targetGroup.expanded = true;
selectItem(newItem.id);
}
function removeSelectedTask() {
if (!currentTaskId) return;
for (const g of groups) {
const pos = g.items.findIndex(it => it.id === currentTaskId);
if (pos !== -1) {
g.items.splice(pos, 1);
break;
}
}
currentTaskId = null;
fillInspector(null);
renderGantt();
}
function changeViewMode(mode) {
activeViewMode = mode;
document.querySelectorAll(‘[data-view]’).forEach(btn => {
btn.classList.toggle(‘active’, btn.dataset.view === mode);
});
renderGantt();
}
function changeFilterMode(mode) {
activeFilterMode = mode;
document.querySelectorAll(‘[data-filter]’).forEach(btn => {
btn.classList.toggle(‘active’, btn.dataset.filter === mode);
});
renderGantt();
}
function toggleGroup(groupId) {
const g = groups.find(item => item.id === groupId);
if (g) {
g.expanded = !g.expanded;
renderGantt();
}
}
function toggleAllGroups(expand) {
groups.forEach(g => g.expanded = expand);
renderGantt();
}
function bindVerticalSync() {
const tScroll = document.getElementById(‘table-scroll’);
const gScroll = document.getElementById(‘timeline-scroll’);
let lockT = false;
let lockG = false;
tScroll.addEventListener(‘scroll’, () => {
if (!lockT) {
lockG = true;
gScroll.scrollTop = tScroll.scrollTop;
}
lockT = false;
});
gScroll.addEventListener(‘scroll’, () => {
if (!lockG) {
lockT = true;
tScroll.scrollTop = gScroll.scrollTop;
}
lockG = false;
});
}
window.addEventListener(‘DOMContentLoaded’, () => {
bindVerticalSync();
renderGantt();
fillInspector(currentTaskId);
});
“`