v16: подпункты с чекбоксами прямо в таблице, раскрытие по ▶
This commit is contained in:
parent
14ca3d5c60
commit
26ee5d4356
49
index.html
49
index.html
@ -254,17 +254,62 @@ function downloadHTML(){
|
||||
}
|
||||
|
||||
// ===== MY EVENTS =====
|
||||
var expandedEvents = {};
|
||||
function toggleExpand(eid) { expandedEvents[eid] = !expandedEvents[eid]; renderMyEvents(); }
|
||||
|
||||
function renderMyEvents(){
|
||||
var my=getMy(),h='<div class="panel" style="border-radius:0 0 12px 12px">';
|
||||
h+='<div class="filters"><select id="mySF" onchange="renderMyEvents()"><option value="">Все</option><option value="done">Исполнено</option><option value="warn">На контроле</option><option value="late">Просрочено</option><option value="wait">В процессе</option></select></div>';
|
||||
var sf=document.getElementById("mySF");sf=sf?sf.value:"";
|
||||
var list=my;if(sf)list=list.filter(function(e){return e.s===sf});
|
||||
h+='<table><tr><th>№</th><th>Мероприятие</th><th>Раздел</th><th>Срок</th><th>Прогресс</th><th>Статус</th><th></th></tr>';
|
||||
list.forEach(function(e){h+='<tr><td>'+e.id+'</td><td style="font-size:12px;max-width:320px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="'+esc(e.t)+'">'+esc(e.t)+'</td><td><span class="badge blue">'+["I","II","III","IV","V"][e.sec]+'</span></td><td>'+e.due+'</td><td>'+pct(e.p)+'</td><td>'+sb(e.s)+'</td><td><button class="btn btn-sm" onclick="openEdit('+e.id+')">📝</button></td></tr>'});
|
||||
h+='<table><tr><th>№</th><th>Мероприятие / Подпункты</th><th>Раздел</th><th>Срок</th><th>Прогресс</th><th>Статус</th><th></th></tr>';
|
||||
list.forEach(function(e){
|
||||
var hasSub = e.sub && e.sub.length;
|
||||
var sc = getSC(e.id);
|
||||
var subDone = hasSub ? sc.length : 0;
|
||||
var subTotal = hasSub ? e.sub.length : 0;
|
||||
h+='<tr><td>'+e.id+'</td>';
|
||||
h+='<td style="font-size:12px;max-width:340px">';
|
||||
if(hasSub) h+='<span onclick="toggleExpand('+e.id+')" style="cursor:pointer;margin-right:6px">'+(expandedEvents[e.id]?'▼':'▶')+'</span>';
|
||||
h+='<span title="'+esc(e.t)+'" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:280px;display:inline-block;vertical-align:middle">'+esc(e.t)+'</span>';
|
||||
if(hasSub) h+=' <span style="font-size:11px;color:var(--gray-500)">('+subDone+'/'+subTotal+')</span>';
|
||||
h+='</td>';
|
||||
h+='<td><span class="badge blue">'+["I","II","III","IV","V"][e.sec]+'</span></td>';
|
||||
h+='<td>'+e.due+'</td><td>'+pct(e.p)+'</td><td>'+sb(e.s)+'</td>';
|
||||
h+='<td><button class="btn btn-sm" onclick="openEdit('+e.id+')">📝</button></td></tr>';
|
||||
|
||||
// Sub-items
|
||||
if(hasSub && expandedEvents[e.id]){
|
||||
e.sub.forEach(function(s,i){
|
||||
var ch = sc.indexOf(i) >= 0;
|
||||
h+='<tr style="background:var(--gray-100)"><td></td>';
|
||||
h+='<td style="font-size:12px;padding-left:44px"><input type="checkbox" id="si_'+e.id+'_'+i+'" '+(ch?'checked':'')+' onchange="toggleSubItem('+e.id+','+i+',this.checked)" style="margin-right:6px"><span style="color:var(--gray-500)">'+s.l+') '+esc(s.t)+'</span></td>';
|
||||
h+='<td></td><td></td><td></td><td></td><td></td></tr>';
|
||||
});
|
||||
}
|
||||
});
|
||||
h+='</table></div>';
|
||||
document.getElementById("tab-myevents").innerHTML=h;
|
||||
}
|
||||
|
||||
function toggleSubItem(eid, subIdx, checked) {
|
||||
var sc = getSC(eid);
|
||||
if(checked) { if(sc.indexOf(subIdx) < 0) sc.push(subIdx); }
|
||||
else { sc = sc.filter(function(x){ return x !== subIdx; }); }
|
||||
setSC(eid, sc);
|
||||
// Update event progress based on sub-items
|
||||
var e = null; for(var i=0;i<events.length;i++){if(events[i].id===eid){e=events[i];break}}
|
||||
if(e && e.sub && e.sub.length) {
|
||||
var pct = Math.round(sc.length / e.sub.length * 100);
|
||||
if(sc.length === e.sub.length && e.s === 'warn') e.s = 'done';
|
||||
else if(sc.length === 0 && e.s === 'done') e.s = 'warn';
|
||||
e.p = Math.max(e.p, pct);
|
||||
e.h.push(new Date().toLocaleDateString()+' — '+curUser.name+': подпункты '+sc.length+'/'+e.sub.length);
|
||||
saveEvents();
|
||||
}
|
||||
renderMyEvents();
|
||||
}
|
||||
|
||||
// ===== ANALYTICS =====
|
||||
function renderAnalytics(){
|
||||
var h='<div class="stats-row">';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user