feat(tasks): add keyboard index and productivity dashboard improvements
This commit is contained in:
1 parent
02edb51b8a
commit
667776e43f
44 files changed
+1224
-138
No files matched your search
@@ -19,7 +19,7 @@
|
||||
function field(key,type,container){const label=el('label'),n=el(type==='select'?'select':'input');label.append(el('span',labels[key]));if(type!=='select')n.type=type;else ['todo','doing','done','cancelled'].forEach((v,i)=>{const o=el('option',[t('To do','未着手'),t('Doing','進行中'),t('Done','完了'),t('Cancelled','取りやめ')][i]);o.value=v;n.append(o);});n.name=key;n.value=item[key]||'';n.disabled=!writable;n.ariaLabel=labels[key];if(key==='title'){n.required=true;n.maxLength=300;label.className='task-inline-title';}inputs[key]=n;label.append(n);container.append(label);
|
||||
n.addEventListener('input',()=>{draft[key]=n.value;dirtyRows.add(row);});n.addEventListener('change',()=>{draft[key]=n.value;dirtyRows.add(row);flush();});
|
||||
n.addEventListener('keydown',e=>{if(e.key==='Enter'){e.preventDefault();n.blur();}if(e.key==='Escape'){e.preventDefault();n.value=item[key]||'';draft[key]=n.value;flush();}});}
|
||||
field('title','text',line);field('status','select',line);['planned_on','due_on','review_on','start_on','end_on'].forEach(k=>field(k,'date',dates));
|
||||
field('title','text',line);const titlePreview=el('div',undefined,'task-title-preview');titlePreview.setAttribute('aria-hidden','true');inputs.title.after(titlePreview);inputs.title.addEventListener('input',()=>window.PagesTaskPresentation?.render(titlePreview,inputs.title.value,false));field('status','select',line);['planned_on','due_on','review_on','start_on','end_on'].forEach(k=>field(k,'date',dates));
|
||||
const complete=el('button','○');complete.type='button';complete.title=complete.ariaLabel=t('Toggle completion','完了を切り替え');complete.disabled=!writable;complete.dataset.action='complete';complete.addEventListener('click',()=>{draft.status=item.status==='done'?'todo':'done';inputs.status.value=draft.status;dirtyRows.add(row);flush();});line.prepend(complete);
|
||||
const parent=el('a','↳');parent.title=parent.ariaLabel=t('Parent task','親タスク');parent.hidden=!item.parent_uuid;if(item.parent_uuid){row.classList.add('task-is-child');parent.href='/v/plan/task/'+encodeURIComponent(item.parent_uuid);}row.append(parent,line,dates,actions,status);
|
||||
function button(label,icon,fn){const b=el('button',icon);b.type='button';b.title=b.ariaLabel=label;b.addEventListener('click',fn);actions.append(b);return b;}
|
||||
@@ -60,11 +60,11 @@
|
||||
}
|
||||
if(edit&&!data.writable){message(t('This Wiki note is read-only.','このWikiメモは読み取り専用です。'));return;}location.assign(edit?data.edit_url:data.url);
|
||||
}catch(e){message(e.message);}}
|
||||
button(t('View Wiki note (create if missing)','Wikiメモを表示(未作成なら新規作成)'),'▤',()=>openNote(false)).dataset.action='note-view';
|
||||
const noteView=button(t('View Wiki note (create if missing)','Wikiメモを表示(未作成なら新規作成)'),'▤',()=>openNote(false));noteView.dataset.action='note-view';
|
||||
const editNote=button(t('Edit / create Wiki note','Wikiメモを編集・新規作成'),'✎',()=>openNote(true));editNote.dataset.action='note-edit';editNote.disabled=!writable;
|
||||
if(options.planDate&&writable){button(t('Schedule for ','取り組む日を変更:')+options.planDate,'→',()=>{if(blocked())return;draft.planned_on=options.planDate;inputs.planned_on.value=draft.planned_on;dirtyRows.add(row);flush();}).dataset.action='schedule-day';}
|
||||
const estimate=el('small',undefined,'task-inline-estimate');actions.prepend(estimate);
|
||||
function paint(){row.dataset.done=String(['done','cancelled'].includes(item.status));complete.textContent=item.status==='done'?'✓':'○';row.dataset.archived=String(item.archived);estimate.textContent=item.estimate_minutes?item.estimate_minutes+' min':'';}
|
||||
function paint(){window.PagesTaskPresentation?.render(titlePreview,item.title,false);noteView.classList.toggle('has-wiki-note',!!item.page_uuid);noteView.textContent=item.page_uuid?'▣':'▤';noteView.title=noteView.ariaLabel=item.page_uuid?t('Open linked Wiki page','関連Wikiページを開く'):t('Create Wiki note','Wikiメモを作成');row.dataset.done=String(['done','cancelled'].includes(item.status));complete.textContent=item.status==='done'?'✓':'○';row.dataset.archived=String(item.archived);estimate.textContent=item.estimate_minutes?item.estimate_minutes+' min':'';}
|
||||
async function flush(){if(saving||!writable||!Object.keys(draft).length)return;if(!inputs.title.reportValidity())return;saving=true;row.setAttribute('aria-busy','true');message(t('Saving…','保存中…'),'saving');try{while(Object.keys(draft).length){const patch={...draft};const fresh=await request(api+'/'+item.uuid);const saved=await request(api+'/'+item.uuid,{method:'PUT',headers:{'If-Match':'"'+item.version+'"'},body:JSON.stringify({...fresh.item,...patch})});item=saved.item;for(const [k,v]of Object.entries(patch)){if(draft[k]===v)delete draft[k];}paint();}dirtyRows.delete(row);message(t('Saved','保存しました'),'saved');document.getElementById('tasks-app')?.dispatchEvent(new Event('task-today-refresh'));options.onChanged?.(item,row);}catch(e){message(e.message);}finally{saving=false;row.removeAttribute('aria-busy');}}
|
||||
const restoreExpanded=expandedRows.has(item.uuid);
|
||||
if(options.initialChildren?.length){options.initialChildren.forEach(c=>children.append(create(c,{...options,initialChildren:[],context:false,nested:true})));showChildren(true);}
|
||||
|
||||
Reference in new issue
Block a user