Months
diff --git a/public/js/script.js b/public/js/script.js
index 3bbc334..064742c 100644
--- a/public/js/script.js
+++ b/public/js/script.js
@@ -5,6 +5,7 @@ let customFieldsMap = [];
let lastUsername = '';
let lastApiToken = '';
let currentGanttView = 'month';
+let currentGanttMode = 'team';
let isGanttExpanded = false;
let currentSortCol = null;
let isAsc = true;
@@ -311,7 +312,7 @@ async function startExtraction() {
allTickets = data.tickets;
filteredTickets = [...allTickets];
- customFieldsMap = parseCustomFields(custom);
+ customFieldsMap = data.customFieldsMap || parseCustomFields(custom);
lastUsername = user;
lastApiToken = token;
@@ -361,20 +362,23 @@ function sortTable(colKey) {
}
// --- TICKET UPDATE ---
-async function updateTicket(ticketKey, dueDate, goLiveDate) {
+async function updateTicket(ticketKey, dueDate, goLiveDate, epicTheme, refreshTable = true) {
if (!lastUsername || !lastApiToken) {
showToast('Please extract tickets first.', 'error');
- return;
+ return false;
}
const btn = document.querySelector(`[data-ticket="${ticketKey}"]`);
const orig = btn ? btn.innerHTML : null;
+ const wasDisabled = btn ? btn.disabled : true;
if (btn) { btn.innerHTML = '
'; btn.disabled = true; }
- const goLiveField = customFieldsMap.find(cf => cf.label.toLowerCase().includes('go live'));
+ const goLiveField = getGoLiveField();
+ const epicThemeField = getEpicThemeField();
const updates = {};
if (dueDate !== undefined) updates.duedate = dueDate;
if (goLiveDate !== undefined && goLiveField) updates[goLiveField.id] = goLiveDate;
+ if (epicTheme !== undefined && epicThemeField) updates[epicThemeField.id] = epicTheme;
try {
const resp = await fetch(`${API_BASE}/api/update`, {
@@ -391,15 +395,19 @@ async function updateTicket(ticketKey, dueDate, goLiveDate) {
if (ticket) {
if (updates.duedate !== undefined) ticket.dueDate = updates.duedate;
if (goLiveField && updates[goLiveField.id] !== undefined) ticket[goLiveField.label] = updates[goLiveField.id];
+ if (epicThemeField && updates[epicThemeField.id] !== undefined) ticket[epicThemeField.label] = updates[epicThemeField.id];
}
- renderTable();
+ if (refreshTable) renderTable();
renderRoadmap();
+ renderJSON();
showToast(`Ticket ${ticketKey} updated!`, 'success');
+ return true;
} catch (err) {
showToast(err.message, 'error');
+ return false;
} finally {
- if (btn) { btn.innerHTML = orig; btn.disabled = false; }
+ if (btn) { btn.innerHTML = orig; btn.disabled = wasDisabled; }
}
}
@@ -415,7 +423,7 @@ function getCreateIssueContext() {
const projectMatch = jql.match(/\bproject\s*=\s*["']?([A-Z][A-Z0-9_-]*)["']?/i);
const epicMatch = jql.match(/(?:["']?Epic Link["']?|\bparent|cf\[\d+\])\s*=\s*["']?([A-Z][A-Z0-9_-]*-\d+)["']?/i);
const configuredFields = parseCustomFields(document.getElementById('customFields').value.trim());
- const dateField = configuredFields.find(field => /date|go live|production/i.test(field.label)) || configuredFields[0] || null;
+ const dateField = configuredFields.find(field => /date|go live|production/i.test(field.label)) || configuredFields.find(field => field.id !== 'customfield_10202') || null;
return {
jql,
@@ -508,7 +516,7 @@ function handleUpdateClick(ticketKey, goLiveColName) {
const dueInput = document.getElementById(`due-${ticketKey}`);
const dueDate = dueInput && dueInput.value ? dueInput.value : null;
- let goLiveDate = null;
+ let goLiveDate;
if (goLiveColName) {
const goLiveInput = document.getElementById(`gl-${ticketKey}`);
goLiveDate = goLiveInput && goLiveInput.value ? goLiveInput.value : null;
@@ -516,15 +524,50 @@ function handleUpdateClick(ticketKey, goLiveColName) {
updateTicket(ticketKey, dueDate, goLiveDate);
}
+async function saveEpicTheme(ticketKey) {
+ const epicThemeInput = document.getElementById(`epic-theme-${ticketKey}`);
+ const epicThemeField = getEpicThemeField();
+ const ticket = allTickets.find(t => t.key === ticketKey);
+ if (!epicThemeInput || epicThemeInput.disabled || !epicThemeField || !ticket) return;
+ const existingThemes = Array.isArray(ticket[epicThemeField.label]) ? ticket[epicThemeField.label] : [];
+ const newEpicTheme = epicThemeInput.value.trim();
+ if (newEpicTheme === existingThemes.join(', ')) return;
+ if (/[\s,]/.test(newEpicTheme)) {
+ showToast('Epic/Theme must be a single label without spaces or commas.', 'error');
+ return;
+ }
+ if (existingThemes.length > 1 && !window.confirm(`Replace all existing Epic/Theme labels (${existingThemes.join(', ')}) for ${ticketKey}?`)) {
+ epicThemeInput.value = existingThemes.join(', ');
+ return;
+ }
+ epicThemeInput.disabled = true;
+ try {
+ const saved = await updateTicket(ticketKey, undefined, undefined, newEpicTheme ? [newEpicTheme] : [], false);
+ if (saved) {
+ epicThemeInput.value = newEpicTheme;
+ epicThemeInput.title = 'One project label, without spaces';
+ const warning = document.getElementById(`epic-theme-warning-${ticketKey}`);
+ if (warning) warning.remove();
+ }
+ } finally {
+ epicThemeInput.disabled = false;
+ }
+}
+
// --- GANTT DATE EDIT MODAL ---
let dateEditContext = { ticketKey: null, goLiveColName: null };
// Detects the real go-live custom field name, ignoring known built-in ticket properties
+function getGoLiveField() {
+ return customFieldsMap.find(field => /go live/i.test(field.label)) || customFieldsMap.find(field => /date|production/i.test(field.label)) || null;
+}
+
function getGoLiveColumnName() {
- if (!allTickets.length) return null;
- return Object.keys(allTickets[0]).find(key =>
- !['key','url','summary','description','status','statusCategory','assignee','reporter','priority','issueType','created','updated','dueDate','resolution','resolutionDate','labels','components','fixVersions','projectName'].includes(key)
- ) || null;
+ return getGoLiveField()?.label || null;
+}
+
+function getEpicThemeField() {
+ return customFieldsMap.find(field => field.id === 'customfield_10202') || null;
}
function openDateEditModal(ticketKey) {
@@ -599,6 +642,7 @@ function fmtDate(d) { if(!d) return '
- '; try { r
function renderTable() {
const goLiveColName = getGoLiveColumnName();
+ const epicThemeField = getEpicThemeField();
const colMapping = {
'Ticket': 'key',
@@ -615,6 +659,8 @@ function renderTable() {
cols.push(goLiveColName);
colMapping[goLiveColName] = goLiveColName;
}
+ cols.push('Epic/Theme');
+ if (epicThemeField) colMapping['Epic/Theme'] = epicThemeField.label;
cols.push('Actions');
document.getElementById('tableHead').innerHTML = '
' + cols.map(c => {
@@ -649,13 +695,17 @@ function renderTable() {
body += ` `;
}
+ const epicThemes = epicThemeField && Array.isArray(t[epicThemeField.label]) ? t[epicThemeField.label] : [];
+ const themeTitle = epicThemes.length > 1 ? 'Multiple labels: changing this value replaces them all' : 'One project label, without spaces';
+ body += ` ${epicThemes.length > 1 ? ` ⚠ ` : ''} `;
+
body += `
Update
`;
});
- document.getElementById('tableBody').innerHTML = body || '
No results found ';
+ document.getElementById('tableBody').innerHTML = body || `
No results found `;
}
// --- ROADMAP (GANTT) ---
@@ -664,6 +714,26 @@ function setGanttView(view) {
renderRoadmap();
}
+function setGanttMode(mode) {
+ currentGanttMode = mode;
+ document.querySelectorAll('[data-gantt-mode]').forEach(button => {
+ button.classList.toggle('active', button.dataset.ganttMode === mode);
+ });
+ renderRoadmap();
+}
+
+function sortTicketsByDueDate(tickets) {
+ return [...tickets].sort((a, b) => {
+ const dateA = Date.parse(a.dueDate);
+ const dateB = Date.parse(b.dueDate);
+ const orderA = Number.isNaN(dateA) ? Infinity : dateA;
+ const orderB = Number.isNaN(dateB) ? Infinity : dateB;
+
+ if (orderA !== orderB) return orderA - orderB;
+ return String(a.key || '').localeCompare(String(b.key || ''));
+ });
+}
+
function toggleGanttExpand() {
isGanttExpanded = !isGanttExpanded;
updateGanttExpandState();
@@ -734,7 +804,7 @@ function renderRoadmap() {
return;
}
- const goLiveColName = Object.keys(filteredTickets[0]).find(k => k.toLowerCase().includes('go live')) || "Go Live Date";
+ const goLiveColName = getGoLiveColumnName() || 'Go Live Date';
const leftWidth = 280;
let colWidth = 140;
@@ -807,12 +877,22 @@ function renderRoadmap() {
return leftWidth + (index * colWidth) + (ratio * colWidth);
};
+ const epicThemeField = getEpicThemeField();
const grouped = ticketsWithDates.reduce((acc, t) => {
- const name = t.assignee || "Unassigned";
- if (!acc[name]) acc[name] = [];
- acc[name].push(t);
+ const themes = epicThemeField && Array.isArray(t[epicThemeField.label]) ? t[epicThemeField.label] : [];
+ const name = currentGanttMode === 'epic'
+ ? themes.length > 1 ? 'Multiple epic themes' : (themes[0] || 'No epic theme')
+ : t.assignee || 'Unassigned';
+ if (!acc.has(name)) acc.set(name, []);
+ acc.get(name).push(t);
return acc;
- }, {});
+ }, new Map());
+ const roadmapGroups = currentGanttMode === 'global'
+ ? [{ name: null, tickets: sortTicketsByDueDate(ticketsWithDates) }]
+ : [...grouped.keys()].sort().map(name => ({
+ name,
+ tickets: sortTicketsByDueDate(grouped.get(name))
+ }));
let html = `
`;
@@ -822,20 +902,21 @@ function renderRoadmap() {
html += `
Today
`;
}
- html += `