일반근무 이름 바꾸기 (웹 2026-11-25.1, 앱 0.14.2 소스)

달력 표시에서 일반근무를 직장에서 부르는 이름(주간·일근 등)으로 바꿀 수 있게 했다.
근무 식별자 REGULAR는 그대로 두고 보이는 이름만 바꾸므로 근무표와 통계는 그대로다.

- 서버: 개인 설정 regularName 검사(8자·제어 문자 거부)와 구버전 저장 때 보존, 구독 제목 반영
- 웹: 달력 표시에 이름 칸, 달력 칸·오늘·고르는 목록·이름 표시 문구에 반영
- 앱: ShiftNames와 Shift.title/shortTitle/choiceTitle, 설정 창 칸, 위젯과 안내 줄 반영, 동기화
- 검사: 서버 93개, 앱 단위 53개, 위젯 기기 검사에 이름 확인 추가
- 근무 관리 기기 검사가 고정 날짜 때문에 날짜가 지나면 실패하던 것을 오늘 기준으로 고침

앱 0.14.2 APK는 외부 검사 뒤 따로 배포한다(release.json 앱 버전은 아직 0.14.1).
This commit is contained in:
블리어 committed 2026-11-24 23:54:36 +00:00
1 parent 1982783048
commit 1aa4126727
27 files changed
+267 -41

No files matched your search

+18 -5
View File
@@ -4,6 +4,14 @@
* 충돌한 내용은 별도로 보관하며 사용자가 선택하기 전에는 서버 값을 덮어쓰지 않는다. */
const $ = id => document.getElementById(id);
const labels = {DUTY:'당직',OFF:'비번',REGULAR:'일반근무',DAY:'주간',EVENING:'오후',NIGHT:'야간',REST:'휴무',LEAVE:'연차·휴가',SICK:'병가',TRAINING:'교육',ANNUAL_LEAVE:'연차',MONTHLY_LEAVE:'월차',VACATION:'일반휴가',OFFICIAL_LEAVE:'공가',FAMILY_LEAVE:'경조휴가'};
// 일반근무는 회원이 정한 이름(달력 표시의 일반근무 이름)으로 보인다. 근무 식별자 REGULAR는 그대로라 근무표와 다른 사람 자료는 바뀌지 않는다.
const DEFAULT_REGULAR = labels.REGULAR, REGULAR_NAME_MAX = 8;
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);labels.REGULAR=name||DEFAULT_REGULAR;regularShort=name?shortRegular(name):'일반';for(const node of document.querySelectorAll('.regular-name'))node.textContent=labels.REGULAR;}
// 고르는 목록에서는 바꾼 이름이 다른 근무 이름과 같을 때 원래 이름을 덧붙여 구분한다(예: 주간 (일반근무)).
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'};
const categories = {GENERAL:'개인 일정',WORK:'업무',PARTTIME:'알바·시간근무',LEAVE:'휴가·휴무',BIRTHDAY:'생일',ANNIVERSARY:'기념일'};
const todayKey = () => new Intl.DateTimeFormat('sv-SE',{timeZone:'Asia/Seoul',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date());
@@ -92,6 +100,7 @@ async function enter(){
if(location.hash==='#work-team'&&typeof WorkTeam!=='undefined')WorkTeam.open().catch(error=>notify(error.message));
}
function render(){
applyShiftNames();
if(typeof renderCompany==='function')renderCompany();
const today=todayKey(),day=dayDate(today),r=rotation(),display=displaySettings(),current=shiftOn(today);
document.body.classList.toggle('five-day',false);
@@ -103,7 +112,7 @@ function render(){
$('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'?'일반':labels[shift],'shift '+classes[shift]));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')+' 일반근무 이름 '+workNamesOn(key).map(item=>item.name).join(' ')+' 함께 근무 '+duties.map(item=>item.data.name).join(' '));button.onclick=()=>{selected=key;render();};$('grid').append(button);}
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]));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(' · ')||'등록한 일정을 확인하고 새로 추가하세요.';
$('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);}
@@ -121,7 +130,7 @@ $('event-delete').onclick=async()=>{if(await confirmAction('이 일정을 삭제
$('add').onclick=()=>openEvent();$('day-add').onclick=()=>openEvent();
function moveMonth(step){const d=dayDate(month+'-01');d.setUTCMonth(d.getUTCMonth()+step);month=dateKey(d).slice(0,7);render();}
$('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 Object.entries(labels)){const option=text('option',name);option.value=value;select.append(option);}select.value=shift;label.append(select);$('rotation-days').append(label);});}
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('반복 근무를 저장했습니다.');};
// 저장 시 최신 근무표에서 표시 항목만 바꾼다. 기초 설정과 옵션이 서로의 값을 되돌리지 않게 한다.
@@ -131,10 +140,14 @@ function openDisplayOptions(){
$('rotation-show-lunar').checked=r.showLunar===true;
$('rotation-off-red').checked=r.offAsHoliday===true;
$('rotation-week-start').value=String(r.weekStart===1?1:0);
$('regular-name').value=cleanRegularName(r.regularName);$('options-error').textContent='';
$('options-dialog').showModal();
};
$('options-form').onsubmit=event=>{
event.preventDefault();queue('preferences','preferences',{dutyAsWeekday:$('rotation-duty-weekday').checked,showLunar:$('rotation-show-lunar').checked,offAsHoliday:$('rotation-off-red').checked,weekStart:Number($('rotation-week-start').value)});
event.preventDefault();const regularName=cleanRegularName($('regular-name').value);
if([...regularName].length>REGULAR_NAME_MAX){$('options-error').textContent='일반근무 이름은 '+REGULAR_NAME_MAX+'자까지 입력할 수 있습니다.';return;}
if(/\p{C}/u.test(regularName)){$('options-error').textContent='일반근무 이름에 쓸 수 없는 글자가 있습니다.';return;}
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});
$('options-dialog').close();notify('개인 설정을 저장했습니다.');
};
let authMode='login', personId=null;
@@ -151,7 +164,7 @@ $('password-form').onsubmit=async event=>{event.preventDefault();if($('password-
async function logoutNow(){if($('account-dialog').open)$('account-dialog').close();if(pending.length){notify('전송 대기 중인 내용이 있습니다. 동기화를 마친 뒤 로그아웃해 주세요.');return;}if(!await confirmAction('이 브라우저에서 로그아웃할까요? 다시 로그인하면 저장한 일정을 볼 수 있습니다.','로그아웃'))return;try{await api('logout',{});connected=false;watchGeneration++;localStorage.removeItem(cacheKey());localStorage.removeItem(stateCacheKey());location.reload();}catch(error){notify(error.message);}}
$('logout').onclick=logoutNow;$('account-logout').onclick=logoutNow;
function drawPerson(pattern){$('person-count').value=pattern.length;$('person-days').replaceChildren();pattern.forEach((shift,index)=>{const label=text('label',(index+1)+'일째'),select=document.createElement('select');for(const [value,name] of Object.entries(labels)){const option=text('option',name);option.value=value;select.append(option);}select.value=shift;label.append(select);$('person-days').append(label);});}
function drawPerson(pattern){$('person-count').value=pattern.length;$('person-days').replaceChildren();pattern.forEach((shift,index)=>{const label=text('label',(index+1)+'일째'),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);$('person-days').append(label);});}
function openPerson(item){if(!item&&personalPeople().length>=20){notify('함께 볼 사람은 20명까지 등록할 수 있습니다.');return;}personId=item?.id??null;const d=item?.data??{name:'',color:'BLUE',anchor:selected,pattern:['DUTY','OFF','REGULAR']};$('person-heading').textContent=item?'함께 보는 근무표 수정':'함께 볼 사람 추가';$('person-name').value=d.name;$('person-color').value=d.color;$('person-anchor').value=d.anchor;$('person-work-week').value=String(d.workWeek||6);$('person-duty-weekday').checked=d.dutyAsWeekday===true;resetPatternMode('person');drawPerson(d.pattern);$('person-delete').hidden=!item;$('person-error').textContent='';$('person-dialog').showModal();}
$('person-add').onclick=()=>openPerson();
$('person-form').onsubmit=event=>{event.preventDefault();const pattern=[...$('person-days').querySelectorAll('select')].map(node=>node.value),name=$('person-name').value.trim();if(!name||pattern.length!==Number($('person-count').value)){$('person-error').textContent='이름과 반복 일수를 확인해 주세요.';return;}queue(personId??crypto.randomUUID(),'person',{name,color:$('person-color').value,anchor:$('person-anchor').value,pattern,workWeek:Number($('person-work-week').value),dutyAsWeekday:$('person-duty-weekday').checked});$('person-dialog').close();notify('함께 보는 근무표를 저장했습니다.');};
@@ -160,7 +173,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?'월요일':'일요일');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+' (기본)');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();}