Files
pages/static/js/task-schedule.js
T
Anya Tokugawa c1175d389f Implement Knowledge City platform, organizer and DAV integration
Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming.

Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
2026-09-27 14:44:43 +09:00

3 lines
3.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(()=>{'use strict';const root=document.getElementById('task-schedule');if(!root)return;const ja=document.documentElement.lang.startsWith('ja'),t=(en,jp)=>ja?jp:en,month=root.dataset.month,project=new URLSearchParams(location.search).get('project')||'',[year,m]=month.split('-').map(Number),days=new Date(Date.UTC(year,m,0)).getUTCDate();const url=(y,n)=>'/v/plan/tasks/schedule/'+y+'/'+String(n).padStart(2,'0')+(project?'?project='+encodeURIComponent(project):'');const prev=new Date(Date.UTC(year,m-2,1)),next=new Date(Date.UTC(year,m,1));root.querySelector('[data-previous]').href=url(prev.getUTCFullYear(),prev.getUTCMonth()+1);root.querySelector('[data-next]').href=url(next.getUTCFullYear(),next.getUTCMonth()+1);root.querySelector('h1').textContent=t('Day schedule','日割り工程表');const input=root.querySelector('input');input.value=month;input.onchange=()=>{if(input.value){const [y,n]=input.value.split('-');location.href=url(y,n);}};root.querySelector('[data-help]').textContent=t('Inclusive work dates, independent of hourly calendar blocks. Change dates inline in the task list. Up to 200 items per month.','工程の開始日・終了日(両端を含む)です。時間枠のカレンダーとは独立しています。日付はタスク一覧で編集できます。月あたり最大200件。');const grid=root.querySelector('[role=table]');grid.style.setProperty('--days',days);const node=(tag,text,cls)=>{const n=document.createElement(tag);n.textContent=text;if(cls)n.className=cls;return n;};const head=node('div','','task-schedule-row');head.append(node('strong',t('Task / subtask','タスク/サブタスク')));for(let i=1;i<=days;i++){const d=node('span',i);d.title=new Date(Date.UTC(year,m-1,i)).toLocaleDateString(undefined,{weekday:'long',timeZone:'UTC'});head.append(d);}grid.append(head);
fetch('/_/api/v1/extension/organizer.tasks/schedule?'+new URLSearchParams({month,project}),{credentials:'same-origin',signal:AbortSignal.timeout(15000)}).then(async r=>{if(!r.ok)throw Error();return r.json();}).then(data=>{for(const item of data.items){const row=node('div','','task-schedule-row'),a=node('a',(item.parent_uuid?'↳ ':'')+item.title);a.href='/v/plan/task/'+item.uuid;a.title=item.title;row.append(a);const start=item.start_on||item.end_on,end=item.end_on||item.start_on,left=start<month+'-01'?1:Number(start.slice(-2)),right=end>month+'-'+days?days:Number(end.slice(-2));const bar=node('a',start+' – '+end,'task-schedule-bar');bar.href=a.href;bar.title=item.title+' · '+bar.textContent;bar.style.gridColumn=(left+1)+' / '+(right+2);bar.dataset.status=item.status;row.append(bar);grid.append(row);}root.querySelector('[role=status]').textContent=data.partial?t('First 200 items shown. Filter by project.','200件まで表示しています。プロジェクトで絞り込んでください。'):data.items.length?'':t('No scheduled tasks.','工程日が設定されたタスクはありません。');}).catch(()=>{root.querySelector('[role=status]').textContent=t('Unable to load schedule.','工程表を取得できません。');});})();