당직근무 0.15.0 (웹 2026-11-25.4): 근무 순서 이름

- 옵션 → 근무 순서 이름: 당직 다음 날(비번)부터 순서 자리마다 그날 당직 서는 사람 이름. 근무 종류는 글자로만 보이고 당직 기초 설정 화면은 그대로
- 달력에 보일 것: 근무와 이름 둘 다 · 이름만 · 근무만(nameDisplay). 앱 달력·위젯·근무표 그림, 웹 달력·그림, 기본 달력 반영과 구독 제목
- 근무표 names(순서와 같은 길이) 저장·검사, 구버전 저장 때 보존, 소속 공유 제외. 날짜별 변경 날은 이름 없음
- 앱 0.15.0 / 설치 번호 24. APK 875878바이트, SHA-256 22f4070a33d0d4c553f0391cb13f473dbec73d2174ba7a5e653318b394c3c55e
- 검사: 서버 106개, 앱 단위 59개, 웹 이름 계산, 위젯 기기 검사(세 가지 표시)
This commit is contained in:
블리어 committed 2026-11-25 01:45:53 +00:00
1 parent 6c77fc998c
commit 8c455f4448
32 files changed
+432 -58

No files matched your search

+32 -5
View File
@@ -10,6 +10,11 @@ let regularShort = '일반';
function cleanRegularName(value){return String(value??'').trim().split(/\s+/).filter(Boolean).join(' ');}
function shortRegular(name){const chars=[...name];return chars.length<=3?name:chars.slice(0,2).join('');}
function applyShiftNames(){const name=cleanRegularName(displaySettings().regularName)||siteRegularName();labels.REGULAR=name||DEFAULT_REGULAR;regularShort=name?shortRegular(name):'일반';for(const node of document.querySelectorAll('.regular-name'))node.textContent=labels.REGULAR;}
// 근무 순서에 넣은 이름을 달력에 어떻게 보일지(근무만 · 이름만 · 둘 다). 이름이 없는 날은 근무가 보인다.
function slotView(key){const r=rotation(),display=displaySettings(),shift=shiftOn(key);if(!shift)return {shift:'',name:'',shiftKey:null,hidden:false};const name=r?WorkPlan.nameOn(r,key):'',mode=display.nameDisplay||'both',label=shift==='REGULAR'?regularShort:labels[shift],hidden=shift==='REGULAR'&&display.hideRegular===true;
if(name&&mode==='name')return {shift:'',name,shiftKey:shift,hidden:false,only:true};return {shift:label,name:name&&mode==='both'?name:'',shiftKey:shift,hidden};}
function slotTitle(key){const shift=shiftOn(key);if(!shift)return '';const r=rotation(),name=r?WorkPlan.nameOn(r,key):'',mode=displaySettings().nameDisplay||'both';return name&&mode!=='shift'?labels[shift]+' · '+name:labels[shift];}
function cleanSlotName(value){return String(value??'').trim().split(/\s+/).filter(Boolean).join(' ');}
// 고르는 목록에서는 바꾼 이름이 다른 근무 이름과 같을 때 원래 이름을 덧붙여 구분한다(예: 주간 (일반근무)).
function shiftChoices(){return Object.entries(labels).map(([value,name])=>[value,value==='REGULAR'&&name!==DEFAULT_REGULAR&&Object.entries(labels).some(([other,label])=>other!=='REGULAR'&&label===name)?name+' ('+DEFAULT_REGULAR+')':name]);}
const classes = {DUTY:'duty',OFF:'off',REGULAR:'regular',DAY:'daytime',EVENING:'evening',NIGHT:'night',REST:'rest',LEAVE:'rest',SICK:'rest',TRAINING:'night',ANNUAL_LEAVE:'rest',MONTHLY_LEAVE:'rest',VACATION:'rest',OFFICIAL_LEAVE:'rest',FAMILY_LEAVE:'rest'};
@@ -109,15 +114,15 @@ function render(){
const today=todayKey(),day=dayDate(today),r=rotation(),display=displaySettings(),current=shiftOn(today);
document.body.classList.toggle('five-day',false);
$('today-date').textContent=new Intl.DateTimeFormat('ko-KR',{month:'long',day:'numeric',weekday:'long',timeZone:'UTC'}).format(day);
$('today-duty').textContent=current?'오늘은 '+labels[current]:'근무표를 설정해 주세요';
$('today-duty').textContent=current?'오늘은 '+slotTitle(today):'근무표를 설정해 주세요';
$('today-caption').textContent=eventsOn(today).length?`오늘 예정된 일정 ${eventsOn(today).length}개`:'여유 있게 하루를 계획하세요.';
$('rotation-label').textContent=r?'주'+(WorkPlan.regime(r,today).workWeek||6)+'일제 · '+WorkPlan.regime(r,today).pattern.length+'일 반복 근무':'반복 근무를 등록할 수 있습니다.';
const days=Array.from({length:new Date(Number(month.slice(0,4)),Number(month.slice(5)),0).getDate()},(_,i)=>month+'-'+String(i+1).padStart(2,'0'));$('month-count').textContent=effective().filter(item=>item.kind==='event'&&days.some(key=>eventOccurrence(item.data,key)!==null)).length+personalAnniversaries().filter(item=>days.some(key=>annualMatches(item.data,key,lunarData))).length;
$('month').textContent=Number(month.slice(0,4))+'년 '+Number(month.slice(5))+'월';
const companions=people();document.body.classList.toggle('with-people',companions.length>0);$('grid').replaceChildren();const first=calendarFirstDate(month,display.weekStart);
$('calendar-weekdays').replaceChildren();for(const day of calendarWeekdays(display.weekStart))$('calendar-weekdays').append(text('span',['일','월','화','수','목','금','토'][day],day===0?'sun':day===6?'sat':''));
for(let i=0;i<42;i++){const date=new Date(first);date.setUTCDate(first.getUTCDate()+i);const key=dateKey(date),shift=shiftOn(key),name=holiday(key),events=eventsOn(key);const button=document.createElement('button');button.type='button';button.className='day'+(key.slice(0,7)!==month?' outside':'')+(key===selected?' selected':'')+(key===today?' current':'')+(date.getUTCDay()===0?' sun':date.getUTCDay()===6?(r&&WorkPlan.regime(r,key).workWeek===5?' sat holiday':' sat'):'')+(name?' holiday':'')+(display.dutyAsWeekday===true&&shift==='DUTY'?' duty-weekday':'')+(display.offAsHoliday===true&&shift==='OFF'?' off-red':'');button.setAttribute('aria-label',`${key} ${shift?labels[shift]:''} ${name} 일정 ${events.length}개`);button.append(text('span',String(date.getUTCDate()),'day-number'));const lunar=display.showLunar?lunarLabel(key):null;if(lunar){button.classList.add('with-lunar');button.append(text('span',lunar,'lunar-date'));button.setAttribute('aria-label',button.getAttribute('aria-label')+' '+lunar);}if(shift)button.append(text('span',shift==='REGULAR'?regularShort:labels[shift],'shift '+classes[shift]+(shift==='REGULAR'&&display.hideRegular===true?' is-hidden':'')));for(const workName of workNamesOn(key).slice(0,2))button.append(text('span',workName.name,'work-name person-'+workName.color.toLowerCase()));if(name)button.append(text('span',name.includes('대체공휴일')?'대체휴일':name.replace('기독탄신일','성탄절').replace('1월 1일','신정'),'holiday-name'));if(events.length)button.append(text('span','일정 '+events.length+'개','event-count'));const annual=events.find(item=>item.kind==='anniversary');if(annual)button.append(text('span',annual.data.title,'anniversary-badge'));const duties=companions.filter(item=>WorkPlan.working(personShift(item,key)));for(const item of duties.slice(0,2))button.append(text('span',item.data.name,'person-badge person-'+item.data.color.toLowerCase()));if(duties.length>2)button.append(text('span','외 '+(duties.length-2)+'명','event-count'));button.setAttribute('aria-label',button.getAttribute('aria-label')+' '+labels.REGULAR+' 아래 이름 '+workNamesOn(key).map(item=>item.name).join(' ')+' 함께 근무 '+duties.map(item=>item.data.name).join(' '));button.onclick=()=>{selected=key;render();};$('grid').append(button);}
const selectedDay=dayDate(selected);$('selected-date').textContent=new Intl.DateTimeFormat('ko-KR',{month:'long',day:'numeric',weekday:'short',timeZone:'UTC'}).format(selectedDay);$('day-detail').textContent=[labels[shiftOn(selected)],holiday(selected)].filter(Boolean).join(' · ')||'등록한 일정을 확인하고 새로 추가하세요.';
for(let i=0;i<42;i++){const date=new Date(first);date.setUTCDate(first.getUTCDate()+i);const key=dateKey(date),shift=shiftOn(key),name=holiday(key),events=eventsOn(key);const button=document.createElement('button');button.type='button';button.className='day'+(key.slice(0,7)!==month?' outside':'')+(key===selected?' selected':'')+(key===today?' current':'')+(date.getUTCDay()===0?' sun':date.getUTCDay()===6?(r&&WorkPlan.regime(r,key).workWeek===5?' sat holiday':' sat'):'')+(name?' holiday':'')+(display.dutyAsWeekday===true&&shift==='DUTY'?' duty-weekday':'')+(display.offAsHoliday===true&&shift==='OFF'?' off-red':'');button.setAttribute('aria-label',`${key} ${shift?slotTitle(key):''} ${name} 일정 ${events.length}개`);button.append(text('span',String(date.getUTCDate()),'day-number'));const lunar=display.showLunar?lunarLabel(key):null;if(lunar){button.classList.add('with-lunar');button.append(text('span',lunar,'lunar-date'));button.setAttribute('aria-label',button.getAttribute('aria-label')+' '+lunar);}if(shift){const view=slotView(key);if(view.only)button.append(text('span',view.name,'shift slot-only '+classes[shift]));else{button.append(text('span',view.shift,'shift '+classes[shift]+(view.hidden?' is-hidden':'')));if(view.name)button.append(text('span',view.name,'slot-name'));}}for(const workName of workNamesOn(key).slice(0,2))button.append(text('span',workName.name,'work-name person-'+workName.color.toLowerCase()));if(name)button.append(text('span',name.includes('대체공휴일')?'대체휴일':name.replace('기독탄신일','성탄절').replace('1월 1일','신정'),'holiday-name'));if(events.length)button.append(text('span','일정 '+events.length+'개','event-count'));const annual=events.find(item=>item.kind==='anniversary');if(annual)button.append(text('span',annual.data.title,'anniversary-badge'));const duties=companions.filter(item=>WorkPlan.working(personShift(item,key)));for(const item of duties.slice(0,2))button.append(text('span',item.data.name,'person-badge person-'+item.data.color.toLowerCase()));if(duties.length>2)button.append(text('span','외 '+(duties.length-2)+'명','event-count'));button.setAttribute('aria-label',button.getAttribute('aria-label')+' '+labels.REGULAR+' 아래 이름 '+workNamesOn(key).map(item=>item.name).join(' ')+' 함께 근무 '+duties.map(item=>item.data.name).join(' '));button.onclick=()=>{selected=key;render();};$('grid').append(button);}
const selectedDay=dayDate(selected);$('selected-date').textContent=new Intl.DateTimeFormat('ko-KR',{month:'long',day:'numeric',weekday:'short',timeZone:'UTC'}).format(selectedDay);$('day-detail').textContent=[slotTitle(selected),holiday(selected)].filter(Boolean).join(' · ')||'등록한 일정을 확인하고 새로 추가하세요.';
$('agenda').replaceChildren();const events=eventsOn(selected);if(!events.length)$('agenda').append(text('div','등록된 일정이 없습니다.\n가벼운 메모부터 시작해 보세요.','empty'));for(const item of events){const node=document.createElement('button');node.className='event-item '+(item.data.category==='PARTTIME'?'parttime':item.data.category==='WORK'?'work':item.data.category==='LEAVE'?'leave':'');node.append(text('strong',item.data.title),text('span',eventTimeSummary(item.data)),text('span',categories[item.data.category]));node.onclick=()=>openEvent(item);$('agenda').append(node);}
$('people-list').replaceChildren();if(!companions.length)$('people-list').append(text('p','이름과 근무 주기를 등록해 함께 볼 수 있습니다.','small'));for(const item of companions){const node=text('button',item.data.name+' · '+labels[personShift(item,selected)],'person-row person-'+item.data.color.toLowerCase());node.append(text('small','주'+(item.data.workWeek||6)+'일제 · '+WorkPlan.regime(item.data,selected).pattern.length+'일 반복 · '+personColors[item.data.color]));if(item.shared)node.append(text('small','소속 공유 · 본인만 수정 가능'));node.onclick=()=>item.shared?openCompany():openPerson(item);$('people-list').append(node);}
$('holiday-note').textContent=holidayData[month.slice(0,4)]?(localStorage.getItem('duty-holiday-saved')==='1'?' · 서버에 보관된 정상 자료 사용':''):'이 연도의 공휴일 자료가 아직 없습니다.';updateStatus();
@@ -136,7 +141,8 @@ function moveMonth(step){const d=dayDate(month+'-01');d.setUTCMonth(d.getUTCMont
$('prev').onclick=()=>moveMonth(-1);$('next').onclick=()=>moveMonth(1);$('today').onclick=()=>{selected=todayKey();month=selected.slice(0,7);render();};
function drawRotation(pattern){$('rotation-count').value=pattern.length;$('rotation-days').replaceChildren();pattern.forEach((shift,index)=>{const label=text('label',(index+1)+'일째');const select=document.createElement('select');for(const [value,name] of shiftChoices()){const option=text('option',name);option.value=value;select.append(option);}select.value=shift;label.append(select);$('rotation-days').append(label);});}
$('rotation').onclick=()=>{const r=rotation()??{anchor:todayKey(),pattern:['DUTY','OFF']};$('rotation-anchor').value=r.anchor;$('rotation-work-week').value=String(r.workWeek||6);resetPatternMode('rotation');drawRotation(r.pattern);$('rotation-error').textContent='';$('rotation-dialog').showModal();};
$('rotation-form').onsubmit=event=>{event.preventDefault();const pattern=[...$('rotation-days').querySelectorAll('select')].map(node=>node.value);if(pattern.length!==Number($('rotation-count').value)){$('rotation-error').textContent='반복 일수를 확인해 주세요.';return;}queue('rotation','rotation',{...rotation(),...displaySettings(),anchor:$('rotation-anchor').value,pattern,workWeek:Number($('rotation-work-week').value)});$('rotation-dialog').close();notify('반복 근무를 저장했습니다.');};
$('rotation-form').onsubmit=event=>{event.preventDefault();const pattern=[...$('rotation-days').querySelectorAll('select')].map(node=>node.value);if(pattern.length!==Number($('rotation-count').value)){$('rotation-error').textContent='반복 일수를 확인해 주세요.';return;}// 근무 순서 이름은 따로 된 창에서 넣는다. 순서 길이가 그대로면 넣어 둔 이름을 남기고 바뀌면 비운다.
const oldNames=rotation()?.names||[];queue('rotation','rotation',{...rotation(),...displaySettings(),anchor:$('rotation-anchor').value,pattern,workWeek:Number($('rotation-work-week').value),names:oldNames.length===pattern.length?oldNames:[]});$('rotation-dialog').close();notify('반복 근무를 저장했습니다.');};
// 저장 시 최신 근무표에서 표시 항목만 바꾼다. 기초 설정과 옵션이 서로의 값을 되돌리지 않게 한다.
function openDisplayOptions(){
const r=displaySettings();
@@ -154,6 +160,27 @@ $('options-form').onsubmit=event=>{
queue('preferences','preferences',{dutyAsWeekday:$('rotation-duty-weekday').checked,showLunar:$('rotation-show-lunar').checked,offAsHoliday:$('rotation-off-red').checked,weekStart:Number($('rotation-week-start').value),regularName,hideRegular:$('regular-hide').checked});
$('options-dialog').close();notify('개인 설정을 저장했습니다.');
};
// 근무 순서 이름: 당직이 아닌 자리(비번부터)마다 이름만 적는다. 근무 종류는 글자로만 보이고 여기서 바꾸지 않는다.
function openSlotNames(){
const r=rotation();if(!r){notify('먼저 당직 기초 설정에서 근무 순서를 저장해 주세요.');return;}
const names=r.names||[];$('slot-names').replaceChildren();
r.pattern.forEach((shift,index)=>{if(shift==='DUTY')return;const label=text('label',(index+1)+'일째 · '+labels[shift]);const input=document.createElement('input');input.className='slot-input';input.dataset.index=String(index);input.maxLength=20;input.placeholder='이름 (선택)';input.value=names[index]||'';label.append(input);$('slot-names').append(label);});
if(!$('slot-names').children.length)$('slot-names').append(text('p','당직만 있는 순서라 이름을 넣을 자리가 없습니다.','small'));
$('name-display-label').hidden=!member;
$('name-display-note').textContent=member?'이름이 없는 날과 날짜별로 바꾼 날은 근무가 보입니다.':'회원으로 로그인하면 근무와 이름 중 무엇을 보일지 고를 수 있습니다. 지금은 둘 다 보입니다.';
const mode=displaySettings().nameDisplay;$('name-display').value=['shift','name','both'].includes(mode)?mode:'both';
$('slot-names-error').textContent='';$('slot-names-dialog').showModal();
}
$('slot-names-open').onclick=openSlotNames;
$('slot-names-form').onsubmit=event=>{
event.preventDefault();const r=rotation();if(!r)return;
const names=r.pattern.map((_,index)=>{const input=$('slot-names').querySelector(`[data-index="${index}"]`);return input?cleanSlotName(input.value):'';});
if(names.some(name=>[...name].length>10||/\p{C}/u.test(name))){$('slot-names-error').textContent='이름은 10자까지 쓸 수 있습니다.';return;}
queue('rotation','rotation',{...rotation(),...displaySettings(),names:names.some(Boolean)?names:[]});
const d=displaySettings(),mode=$('name-display').value;
if(member&&mode!==(d.nameDisplay||'both'))queue('preferences','preferences',{dutyAsWeekday:d.dutyAsWeekday===true,showLunar:d.showLunar===true,offAsHoliday:d.offAsHoliday===true,weekStart:d.weekStart===1?1:0,regularName:cleanRegularName(d.regularName),hideRegular:d.hideRegular===true,nameDisplay:mode});
$('slot-names-dialog').close();notify('근무 순서 이름을 저장했습니다.');
};
let authMode='login', personId=null;
function openAuth(mode){authMode=mode;$('auth-form').reset();$('auth-error').textContent='';const joining=mode==='register',resetting=mode==='reset';$('auth-heading').textContent=joining?'회원가입':resetting?'비밀번호 복구':'회원 로그인';$('auth-submit').textContent=joining?'가입하고 시작':resetting?'비밀번호 재설정':'로그인';$('auth-help').textContent=joining?'아이디는 영문과 숫자 및 밑줄 3~32자입니다. 비밀번호는 6자 이상으로 입력해 주세요.':resetting?'관리자가 본인 확인 후 발급한 복구 코드를 입력하세요.':'홈페이지와 앱에서 같은 회원으로 로그인하세요.';$('auth-name-label').hidden=!joining;$('auth-name').required=joining;$('auth-code-label').hidden=!resetting;$('auth-code').required=resetting;$('auth-repeat-label').hidden=mode==='login';$('auth-repeat').required=mode!=='login';$('auth-password').minLength=mode==='login'?1:6;$('auth-password').autocomplete=mode==='login'?'current-password':'new-password';$('auth-recovery').hidden=mode!=='login';if(!$('auth-dialog').open)$('auth-dialog').showModal();}
$('create').onclick=()=>openAuth('register');$('join').onclick=()=>openAuth('login');$('auth-recovery').onclick=()=>openAuth('reset');
@@ -177,7 +204,7 @@ $('person-delete').onclick=async()=>{if(await confirmAction('이 캘린더에
// 회원·소속·홈페이지 설정은 관리자 페이지(admin)에서 다룬다. 이 화면에서는 이동 버튼만 둔다.
$('admin-open').onclick=()=>{location.href='admin';};
function describe(item){if(!item||item.deleted)return '삭제된 일정';const d=item.data;if(item.kind==='anniversary')return d.title+'\n'+annualDescription(d)+'\n'+d.notes;if(item.kind==='preferences')return '당직일 평일색: '+(d.dutyAsWeekday?'켜짐':'꺼짐')+'\n비번 빨간색: '+(d.offAsHoliday?'켜짐':'꺼짐')+'\n음력 표시: '+(d.showLunar?'켜짐':'꺼짐')+'\n주 시작: '+(d.weekStart===1?'월요일':'일요일')+'\n일반근무 이름: '+(cleanRegularName(d.regularName)||DEFAULT_REGULAR+' (기본)')+'\n일반근무 숨기기: '+(d.hideRegular?'켜짐':'꺼짐');if(item.kind==='name_rule')return d.name+'\n'+nameRuleDescription(d);if(item.kind==='person')return `${d.name} · ${personColors[d.color]}\n첫째 날: ${d.anchor}\n${d.pattern.map(key=>labels[key]).join(' → ')}`;if(item.kind==='rotation')return `첫째 날: ${d.anchor}\n${d.pattern.map(key=>labels[key]).join(' → ')}`;return `${d.title}\n${d.date} ~ ${d.endDate}\n${d.allDay?'하루 종일':d.startTime+' ~ '+d.endTime}\n${categories[d.category]}\n${d.notes}`;}
function describe(item){if(!item||item.deleted)return '삭제된 일정';const d=item.data;if(item.kind==='anniversary')return d.title+'\n'+annualDescription(d)+'\n'+d.notes;if(item.kind==='preferences')return '당직일 평일색: '+(d.dutyAsWeekday?'켜짐':'꺼짐')+'\n비번 빨간색: '+(d.offAsHoliday?'켜짐':'꺼짐')+'\n음력 표시: '+(d.showLunar?'켜짐':'꺼짐')+'\n주 시작: '+(d.weekStart===1?'월요일':'일요일')+'\n일반근무 이름: '+(cleanRegularName(d.regularName)||DEFAULT_REGULAR+' (기본)')+'\n일반근무 숨기기: '+(d.hideRegular?'켜짐':'꺼짐')+'\n순서 이름 표시: '+({shift:'근무만',name:'이름만',both:'둘 다'}[d.nameDisplay]||'둘 다');if(item.kind==='name_rule')return d.name+'\n'+nameRuleDescription(d);if(item.kind==='person')return `${d.name} · ${personColors[d.color]}\n첫째 날: ${d.anchor}\n${d.pattern.map(key=>labels[key]).join(' → ')}`;if(item.kind==='rotation')return `첫째 날: ${d.anchor}\n${d.pattern.map(key=>labels[key]).join(' → ')}`;return `${d.title}\n${d.date} ~ ${d.endDate}\n${d.allDay?'하루 종일':d.startTime+' ~ '+d.endTime}\n${categories[d.category]}\n${d.notes}`;}
function showConflict(){const op=pending.find(item=>conflicts.includes(item.changeId));if(!op){$('conflict-dialog').close();return;}$('conflict-local').textContent=describe(op);$('conflict-remote').textContent=describe(model.items.find(item=>item.id===op.id));if(!$('conflict-dialog').open)$('conflict-dialog').showModal();}
$('resolve').onclick=showConflict;
function resolveConflict(useLocal){const op=pending.find(item=>conflicts.includes(item.changeId));if(!op)return;pending=pending.filter(item=>item.changeId!==op.changeId);conflicts=conflicts.filter(id=>id!==op.changeId);if(useLocal)pending.push({...op,baseVersion:model.items.find(item=>item.id===op.id)?.version??0,changeId:crypto.randomUUID()});persist();render();showConflict();sync();}