@rig-c/review 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/DESIGN.md +19 -0
- package/package.json +1 -1
- package/src/compare-html.ts +5 -5
- package/web/animation-inspection.ts +2 -0
- package/web/catalog-en.ts +18 -3
- package/web/catalog-ko.ts +39 -24
- package/web/compare-picked-tools.ts +1 -0
- package/web/compare.css +2 -4
- package/web/compare.html +1 -1
- package/web/compare.ts +2 -1
- package/web/inspection-persistence.ts +145 -22
- package/web/inspector-blocks.ts +112 -38
- package/web/interview-panel.ts +10 -3
- package/web/job-rig-screen.ts +5 -4
- package/web/job-session.ts +33 -63
- package/web/main.ts +167 -35
- package/web/part-selection.ts +5 -0
- package/web/parts-viewport-provider.ts +18 -8
- package/web/stage-comments.ts +16 -10
- package/web/styles.css +117 -39
- package/web/view-controls.ts +22 -11
- package/web/workspace-ui.ts +8 -6
package/web/inspector-blocks.ts
CHANGED
|
@@ -32,17 +32,29 @@ export interface InspectorBlocksOptions {
|
|
|
32
32
|
available?:readonly string[];
|
|
33
33
|
/** Called when a click or a key changes a section's active tab. */
|
|
34
34
|
changed?:()=>void;
|
|
35
|
-
/** The rig reuses its block rows in the heading, with one
|
|
35
|
+
/** The rig reuses its block rows in the heading, with one programmatic Comments selection. */
|
|
36
36
|
bottom?:{strip:HTMLElement;comment:HTMLButtonElement;panel:HTMLElement};
|
|
37
37
|
}
|
|
38
|
-
export interface InspectorBlocks {state():ActiveBlocks;restore(state:ActiveBlocks):void;select(section:string,id:string):void;activate(section:string):void;dispose():void}
|
|
38
|
+
export interface InspectorBlocks {state():ActiveBlocks;restore(state:ActiveBlocks):void;select(section:string,id:string):void;activate(section:string):void;register(tab:{id:string;panel:HTMLElement;label:string;position?:'first'|'last'}):()=>void;dispose():void}
|
|
39
39
|
|
|
40
40
|
interface Tab {button:HTMLButtonElement;id:string;panel:HTMLElement;included:HTMLElement[]}
|
|
41
41
|
const isRow=(node:Element)=>node.classList.contains('block-row');
|
|
42
|
+
function bindPopupMenu(id:string,items:()=>HTMLButtonElement[],cleanups:(()=>void)[],place?:(menu:HTMLElement)=>void):{button:HTMLButtonElement;menu:HTMLElement;close:(focus?:boolean)=>void} {
|
|
43
|
+
const button=actionButton('⋯',null),menu=panelMake('div',{id,hidden:true}),listen=(node:HTMLElement,type:string,fn:(event:Event)=>void)=>{node.addEventListener(type,fn);cleanups.push(()=>node.removeEventListener(type,fn));};
|
|
44
|
+
button.setAttribute('aria-haspopup','menu');button.setAttribute('aria-controls',id);button.setAttribute('aria-expanded','false');menu.setAttribute('role','menu');
|
|
45
|
+
const close=(focus=true)=>{menu.hidden=true;button.setAttribute('aria-expanded','false');if(focus)button.focus();};
|
|
46
|
+
const open=(last=false)=>{const visible=items();if(!visible.length)return;const list=visible.filter(item=>!item.disabled);menu.hidden=false;place?.(menu);button.setAttribute('aria-expanded','true');if(list.length)list[last?list.length-1:0]!.focus();else{menu.tabIndex=-1;menu.focus();}};
|
|
47
|
+
listen(button,'click',()=>menu.hidden?open():close());
|
|
48
|
+
listen(button,'keydown',event=>{const key=(event as KeyboardEvent).key;if(['ArrowDown','ArrowUp','Enter',' '].includes(key)){event.preventDefault();open(key==='ArrowUp');}else if(key==='Escape'){event.preventDefault();close();}});
|
|
49
|
+
listen(menu,'keydown',event=>{const key=(event as KeyboardEvent).key,list=items().filter(item=>!item.disabled);if(key==='Escape'){event.preventDefault();close();}else if(['ArrowDown','ArrowUp','Home','End'].includes(key)&&list.length){event.preventDefault();const index=list.indexOf(event.target as HTMLButtonElement);list[key==='Home'?0:key==='End'?list.length-1:(index+(key==='ArrowDown'?1:list.length-1))%list.length]!.focus();}});
|
|
50
|
+
listen(menu,'focusout',event=>{const target=(event as FocusEvent).relatedTarget;if(target!==button&&!menu.contains(target as Node|null))close(false);});
|
|
51
|
+
return {button,menu,close};
|
|
52
|
+
}
|
|
42
53
|
|
|
43
54
|
export function bindInspectorBlocks(options:InspectorBlocksOptions):InspectorBlocks {
|
|
44
|
-
const rows=new Map<string,InspectorTabs>(),ids=new Map<string,Set<string>>();
|
|
45
|
-
const definitions=new Map<string,{section:HTMLElement;row:HTMLElement;scrollRoot:HTMLElement;tabs:Tab[]}>(),saved:ActiveBlocks={};
|
|
55
|
+
const rows=new Map<string,InspectorTabs>(),ids=new Map<string,Set<string>>(),cleanups:(()=>void)[]=[];
|
|
56
|
+
const definitions=new Map<string,{section:HTMLElement;row:HTMLElement;scrollRoot:HTMLElement;tabs:Tab[];syncOverflow:()=>void}>(),saved:ActiveBlocks={};
|
|
57
|
+
const external=new Set<string>();
|
|
46
58
|
let active:string|undefined;
|
|
47
59
|
let disposedState:ActiveBlocks|undefined;
|
|
48
60
|
const state=()=>disposedState??Object.fromEntries([...rows].map(([name,row])=>[name,row.state()!]));
|
|
@@ -50,7 +62,7 @@ export function bindInspectorBlocks(options:InspectorBlocksOptions):InspectorBlo
|
|
|
50
62
|
const resolve=(name:string,id:string)=>id==='transport'&&!ids.get(name)?.has(id)?'motion-tools':id;
|
|
51
63
|
for(const section of options.sections){
|
|
52
64
|
const name=section.dataset.inspectorPanel??'';if(!name)continue;
|
|
53
|
-
// In Animate the row heads the
|
|
65
|
+
// In Animate the row heads the section directly and switches the whole panel body.
|
|
54
66
|
const children=[...section.children],directRow=children.find(isRow) as HTMLElement|undefined;
|
|
55
67
|
const scrollRoot=directRow?section:children.find(node=>[...node.children].some(isRow)) as HTMLElement|undefined;if(!scrollRoot)continue;
|
|
56
68
|
const row=directRow??[...scrollRoot.children].find(isRow) as HTMLElement;
|
|
@@ -64,7 +76,43 @@ export function bindInspectorBlocks(options:InspectorBlocksOptions):InspectorBlo
|
|
|
64
76
|
}
|
|
65
77
|
if(!tabs.length&&!options.bottom)continue;
|
|
66
78
|
if(options.bottom){
|
|
67
|
-
|
|
79
|
+
let syncOverflow=()=>{};
|
|
80
|
+
if(typeof (doc as Document).createElement==='function'&&tabs.length){
|
|
81
|
+
const placeOverflow=(menu:HTMLElement)=>{
|
|
82
|
+
if(typeof row.getBoundingClientRect!=='function')return;
|
|
83
|
+
const rect=row.getBoundingClientRect(),inspector=row.closest('.inspector'),main=section.closest('main')?.getBoundingClientRect(),bounds=inspector?.getBoundingClientRect();
|
|
84
|
+
// A collapsed inspector retains its heading, not a clipping body.
|
|
85
|
+
const clip=inspector?.getAttribute('data-collapsed')==='true'||!bounds?.height?main:bounds,above=Math.max(0,rect.top-Math.max(clip?.top??0,main?.top??0)-8),below=Math.max(0,Math.min(innerHeight,clip?.bottom??innerHeight,main?.bottom??innerHeight)-rect.bottom-8);
|
|
86
|
+
const up=below<Math.min(menu.scrollHeight,220)&&above>below,height=Math.min(220,up?above:below);menu.dataset.side=up?'above':'below';menu.style.maxHeight=height+'px';
|
|
87
|
+
// Keep the popup in viewport coordinates when native focus scrolls its items.
|
|
88
|
+
menu.style.position='fixed';menu.style.right=Math.max(0,innerWidth-rect.right)+'px';menu.style.top=(up?rect.top-4-Math.min(menu.scrollHeight,height):rect.bottom+4)+'px';menu.style.bottom='auto';
|
|
89
|
+
};
|
|
90
|
+
const items:HTMLButtonElement[]=[],more=bindPopupMenu('workspace-tabs-more-'+name,()=>{syncOverflow();return items.filter(item=>!item.hidden);},cleanups,placeOverflow);
|
|
91
|
+
more.button.className='workspace-tabs-more';more.button.hidden=true;more.menu.className='workspace-tabs-menu';
|
|
92
|
+
const updateItems=()=>{
|
|
93
|
+
for(const item of items.splice(0))item.remove();
|
|
94
|
+
for(const tab of tabs){
|
|
95
|
+
const item=actionButton(tab.button.textContent??'',()=>{more.close(false);rows.get(name)?.select(tab.id);syncOverflow();tab.button.focus();});
|
|
96
|
+
item.setAttribute('role','menuitem');item.dataset.blockMoreTarget=tab.id;item.tabIndex=-1;item.hidden=true;items.push(item);more.menu.append(item);
|
|
97
|
+
}
|
|
98
|
+
};updateItems();
|
|
99
|
+
row.append(more.button,more.menu);
|
|
100
|
+
syncOverflow=()=>{
|
|
101
|
+
if(items.length!==tabs.length)updateItems();
|
|
102
|
+
const label=tr('More tabs');more.button.setAttribute('aria-label',label);more.button.setAttribute('title',label);
|
|
103
|
+
for(const tab of tabs)tab.button.removeAttribute('data-tab-overflow');
|
|
104
|
+
if(row.hidden||!(row.clientWidth>0)){more.button.hidden=true;more.close(false);return;}
|
|
105
|
+
more.button.hidden=false;
|
|
106
|
+
const availableWidth=row.getBoundingClientRect?.().width??row.clientWidth,gap=4,moreWidth=(more.button.getBoundingClientRect?.().width??more.button.offsetWidth??28)+gap,widths=tabs.map(tab=>tab.button.getBoundingClientRect?.().width??tab.button.offsetWidth);
|
|
107
|
+
if(widths.reduce((sum,w,i)=>sum+w+(i>0?gap:0),0)<=availableWidth){more.button.hidden=true;more.close(false);return;}
|
|
108
|
+
const selectedIndex=tabs.findIndex(tab=>tab.button.getAttribute('aria-selected')==='true'),visible=new Set<number>();
|
|
109
|
+
let used=moreWidth+(selectedIndex>=0?widths[selectedIndex]!+gap:0);if(selectedIndex>=0)visible.add(selectedIndex);
|
|
110
|
+
for(let i=0;i<tabs.length;i++)if(i!==selectedIndex){if(used+widths[i]!+gap<=availableWidth){visible.add(i);used+=widths[i]!+gap;}}
|
|
111
|
+
for(const [i,tab]of tabs.entries()){const over=!visible.has(i);if(over)tab.button.setAttribute('data-tab-overflow','true');items[i]!.hidden=!over;items[i]!.disabled=tab.button.disabled;items[i]!.textContent=tab.button.textContent;const title=tab.button.getAttribute('title');if(title)items[i]!.setAttribute('title',title);else items[i]!.removeAttribute('title');}
|
|
112
|
+
if(!more.menu.hidden)placeOverflow(more.menu);
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
definitions.set(name,{section,row,scrollRoot,tabs,syncOverflow});saved[name]=tabs.find(tab=>tab.button.getAttribute('aria-selected')==='true')?.id??tabs[0]?.id??'feedback';
|
|
68
116
|
row.hidden=true;options.bottom.strip.append(row);continue;
|
|
69
117
|
}
|
|
70
118
|
ids.set(name,new Set(tabs.map(tab=>tab.id)));
|
|
@@ -73,46 +121,84 @@ export function bindInspectorBlocks(options:InspectorBlocksOptions):InspectorBlo
|
|
|
73
121
|
panels:tabs.map(tab=>tab.panel),root:row,scrollRoot,initialize:true,
|
|
74
122
|
}));
|
|
75
123
|
}
|
|
124
|
+
const syncActiveOverflow=()=>{if(active)definitions.get(active)?.syncOverflow();};
|
|
125
|
+
if(options.bottom&& [...definitions.values()].some(d=>typeof (d.section.ownerDocument as Document).createElement==='function')){
|
|
126
|
+
cleanups.push(onLanguageChange(syncActiveOverflow));
|
|
127
|
+
if(typeof ResizeObserver==='function'){const ro=new ResizeObserver(syncActiveOverflow);ro.observe(options.bottom.strip);cleanups.push(()=>ro.disconnect());}
|
|
128
|
+
}
|
|
76
129
|
// Rebind the existing tab controller when the header mode changes. The shared Comments
|
|
77
130
|
// button/panel retain identity; each mode retains its own last selected block.
|
|
78
|
-
const activate=(name:string)=>{
|
|
131
|
+
const activate=(name:string,force=false)=>{
|
|
79
132
|
if(!options.bottom||!definitions.has(name))return;
|
|
80
|
-
if(active===name)return;
|
|
133
|
+
if(active===name&&!force)return;
|
|
81
134
|
if(active){saved[active]=rows.get(active)?.state()??saved[active]!;rows.get(active)?.dispose();rows.delete(active);definitions.get(active)!.row.hidden=true;}
|
|
82
|
-
active=name;const {section,row,scrollRoot,tabs}=definitions.get(name)!,bottom=options.bottom;
|
|
83
|
-
bottom.comment.dataset.blockTarget='feedback';
|
|
135
|
+
active=name;const {section,row,scrollRoot,tabs,syncOverflow}=definitions.get(name)!,bottom=options.bottom;
|
|
136
|
+
bottom.comment.dataset.blockTarget='feedback';bottom.comment.hidden=true;bottom.comment.remove();row.hidden=false;
|
|
84
137
|
const all=[...tabs,{button:bottom.comment,id:'feedback',panel:bottom.panel,included:[]}];
|
|
85
138
|
ids.set(name,new Set(all.map(tab=>tab.id)));
|
|
86
|
-
const sync=()=>{section.dataset.comments=String(rows.get(name)?.state()==='feedback');options.changed?.();};
|
|
139
|
+
const sync=()=>{section.dataset.comments=String(rows.get(name)?.state()==='feedback'||external.has(rows.get(name)?.state()??''));syncOverflow();options.changed?.();};
|
|
87
140
|
for(const tab of all)tab.button.setAttribute('aria-selected',String(tab.id===saved[name]));
|
|
88
141
|
rows.set(name,bindInspectorTabs(sync,()=>{},{tabs:all.map(tab=>({id:tab.id,button:tab.button,panels:[tab.panel],included:tab.included,attribute:'aria-selected'})),panels:all.map(tab=>tab.panel),root:row,scrollRoot,initialize:true}));
|
|
89
|
-
section.dataset.comments=String(saved[name]==='feedback');
|
|
142
|
+
section.dataset.comments=String(saved[name]==='feedback'||external.has(saved[name]!));
|
|
143
|
+
for(const tab of tabs)if(external.has(tab.id))tab.panel.setAttribute('aria-labelledby',tab.button.id);syncOverflow();
|
|
90
144
|
};
|
|
91
145
|
if(options.bottom)activate(options.sections[0]?.dataset.inspectorPanel??'');
|
|
92
146
|
return {
|
|
93
147
|
state:()=>({...saved,...state()}),activate,
|
|
94
|
-
|
|
148
|
+
register(tab){
|
|
149
|
+
if(!options.bottom||external.has(tab.id))return ()=>{};
|
|
150
|
+
external.add(tab.id);tab.panel.hidden=true;tab.panel.setAttribute('role','tabpanel');
|
|
151
|
+
const buttons:HTMLButtonElement[]=[];
|
|
152
|
+
for(const [name,definition]of definitions){
|
|
153
|
+
const button=actionButton(tr(tab.label),null);button.id='inspector-tab-'+name+'-'+tab.id;
|
|
154
|
+
button.dataset.blockTarget=tab.id;button.setAttribute('role','tab');button.setAttribute('aria-controls',tab.panel.id);button.setAttribute('aria-selected','false');button.tabIndex=-1;
|
|
155
|
+
definition.row.insertBefore(button,tab.position==='first'?definition.tabs[0]?.button??null:definition.row.querySelector('.workspace-tabs-more'));buttons.push(button);
|
|
156
|
+
const entry={button,id:tab.id,panel:tab.panel,included:[]};
|
|
157
|
+
if(tab.position==='first')definition.tabs.unshift(entry);else definition.tabs.push(entry);
|
|
158
|
+
}
|
|
159
|
+
const localize=onLanguageChange(()=>{for(const button of buttons)setSourceText(button,tab.label);syncActiveOverflow();});
|
|
160
|
+
if(active)activate(active,true);
|
|
161
|
+
let removed=false;
|
|
162
|
+
const remove=()=>{if(removed)return;removed=true;localize();external.delete(tab.id);
|
|
163
|
+
for(const [name,definition]of definitions){definition.tabs.splice(definition.tabs.findIndex(item=>item.id===tab.id),1);if(rows.get(name)?.state()===tab.id)rows.get(name)?.select(definition.tabs[0]?.id??'feedback');if(saved[name]===tab.id)saved[name]=definition.tabs[0]?.id??'feedback';}
|
|
164
|
+
for(const button of buttons)button.remove();tab.panel.hidden=true;if(active)activate(active,true);
|
|
165
|
+
};
|
|
166
|
+
cleanups.push(remove);return remove;
|
|
167
|
+
},
|
|
168
|
+
select:(name,id)=>{rows.get(name)?.select(resolve(name,id));definitions.get(name)?.syncOverflow();},
|
|
95
169
|
/** Restore saved tabs without touching the workspace's section scroll offset. */
|
|
96
|
-
restore(value){for(const [name,id]of Object.entries(value)){if(options.bottom){const definition=definitions.get(name);if(id==='feedback'||definition?.tabs.some(tab=>tab.id===resolve(name,id)))saved[name]=resolve(name,id);}rows.get(name)?.restore(resolve(name,id));}},
|
|
97
|
-
dispose(){disposedState=state();for(const row of rows.values())row.dispose();rows.clear();ids.clear();},
|
|
170
|
+
restore(value){for(const [name,id]of Object.entries(value)){if(options.bottom){const definition=definitions.get(name);if(id==='feedback'||definition?.tabs.some(tab=>tab.id===resolve(name,id)))saved[name]=resolve(name,id);}rows.get(name)?.restore(resolve(name,id));definitions.get(name)?.syncOverflow();}},
|
|
171
|
+
dispose(){disposedState=state();for(const cleanup of cleanups)cleanup();for(const row of rows.values())row.dispose();rows.clear();ids.clear();},
|
|
98
172
|
};
|
|
99
173
|
}
|
|
100
174
|
|
|
101
175
|
/** Compose the real rig acts into C6; all fields, submit nodes and their listeners retain identity. */
|
|
102
|
-
export function mountRigInspector(root:Document=document):BottomPanel&{actBar:ActBar;comments:{button:HTMLButtonElement;panel:HTMLElement}} {
|
|
176
|
+
export function mountRigInspector(root:Document=document,actHome?:HTMLElement):BottomPanel&{actBar:ActBar;answersRendered:boolean;syncActRow:()=>void;comments:{button:HTMLButtonElement;panel:HTMLElement}} {
|
|
103
177
|
const inspector=root.querySelector<HTMLElement>('.inspector')!,body=inspector.querySelector<HTMLElement>('.inspector-body')!,heading=inspector.querySelector<HTMLElement>('.inspector-heading')!;
|
|
104
178
|
const feedback=root.getElementById('inspector-feedback')!,dialog=root.getElementById('review-dialog')!;
|
|
105
179
|
const [label,status,actions]=[feedback.querySelector<HTMLLabelElement>('label[for="review-status"]')!,root.getElementById('review-status')!,dialog.querySelector<HTMLElement>('.review-dialog-actions')!];
|
|
106
|
-
const actBar=mountActBar({id:'workspace-review-act',decision:[label,status],actions,submit:root.getElementById('save') as HTMLButtonElement,saveState:root.getElementById('review-draft-state')!,saveStateCopies:[root.getElementById('draft-state')].flatMap(node=>node?[{node,title:true}]:[])}),act=actBar.element;
|
|
180
|
+
const actBar=mountActBar({id:'workspace-review-act',decision:[label,status],actions,submit:root.getElementById('save') as HTMLButtonElement,saveState:root.getElementById('review-draft-state')!,saveStateCopies:[root.getElementById(actHome?'dirty':'draft-state')].flatMap(node=>node?[{node,title:true}]:[])}),act=actBar.element;
|
|
181
|
+
if(actHome)for(const id of ['draft-state','draft-recovery'])root.getElementById(id)!.hidden=true;
|
|
107
182
|
const title=dialog.querySelector<HTMLElement>('.review-dialog-header')!;title.querySelector('#review-dialog-close')?.remove();
|
|
108
183
|
feedback.className='workspace-review-panel';feedback.hidden=true;feedback.prepend(title);body.append(feedback);dialog.remove();
|
|
109
184
|
feedback.removeAttribute('data-inspector-panel');
|
|
110
|
-
|
|
185
|
+
root.getElementById('proposal-panel')!.prepend(root.getElementById('comments-list-host')!);
|
|
186
|
+
const bottom=mountBottomPanel({kind:'rig',heading,act,actHome:actHome??heading,tabs:[]}),comment=actionButton(tr('Comments'),null);
|
|
187
|
+
comment.hidden=true;feedback.setAttribute('role','region');feedback.setAttribute('aria-labelledby','stage-comment');
|
|
111
188
|
delete comment.dataset.inspector;bottom.strip.removeAttribute('role');
|
|
112
189
|
for(const button of root.querySelectorAll<HTMLButtonElement>('[data-mode][data-inspector]')){button.id||='mode-'+button.dataset.mode;const panel=root.getElementById('inspector-'+button.dataset.mode)!;panel.setAttribute('role','region');panel.setAttribute('aria-labelledby',button.id);}
|
|
113
190
|
bottom.row={tabs:[...root.querySelectorAll<HTMLButtonElement>('[data-mode][data-inspector]')].map(button=>({id:button.dataset.mode!,button,attribute:'aria-pressed',panels:[root.getElementById('inspector-'+button.dataset.mode)!]})),panels:[root.getElementById('inspector-rig')!,root.getElementById('inspector-playback')!],initialize:true};
|
|
114
|
-
|
|
115
|
-
|
|
191
|
+
bottom.actHome.append(act);
|
|
192
|
+
const syncActRow=()=>{
|
|
193
|
+
if(!actHome)return;
|
|
194
|
+
const headline=root.getElementById('workspace-ask-headline'),error=root.getElementById('review-message');
|
|
195
|
+
const question=!!headline&&!headline.hidden&&!!headline.textContent?.trim();
|
|
196
|
+
const refusal=!!error&&!error.hidden&&error.classList.contains('error')&&!!error.textContent?.trim()&&['save','request-changes','workspace-pending-ask'].every(id=>root.getElementById(id)?.hidden!==false);
|
|
197
|
+
// Loading may render answers before the question; an early read refusal can
|
|
198
|
+
// still use this row once its caller has hidden every answer control.
|
|
199
|
+
actHome.hidden=act.hidden||(!question&&!refusal);root.getElementById('dirty')!.hidden=!actHome.hidden;
|
|
200
|
+
};
|
|
201
|
+
return {...bottom,actBar,answersRendered:false,syncActRow,comments:{button:comment,panel:feedback}};
|
|
116
202
|
}
|
|
117
203
|
|
|
118
204
|
export interface BottomPanel {
|
|
@@ -134,7 +220,7 @@ export function mountBottomPanel(options:BottomPanelOptions):BottomPanel {
|
|
|
134
220
|
panel.setAttribute('role','tabpanel');panel.setAttribute('aria-labelledby',button.id);
|
|
135
221
|
strip.append(button);return {id,button,panels:[panel],attribute:'aria-selected' as const};
|
|
136
222
|
});
|
|
137
|
-
const
|
|
223
|
+
const collapseLabel=tr('Collapse bottom panel'),collapse=actionButton('⌄',null);collapse.id='workspace-bottom-collapse';collapse.setAttribute('aria-expanded','true');collapse.setAttribute('aria-controls','workspace-inspector');collapse.setAttribute('aria-label',collapseLabel);collapse.setAttribute('title',collapseLabel);
|
|
138
224
|
options.heading.replaceChildren(strip,collapse);
|
|
139
225
|
return {row:{tabs,panels:tabs.flatMap(tab=>tab.panels),initialize:true},strip,act:options.act,actHome:options.actHome,collapse,kind:options.kind};
|
|
140
226
|
}
|
|
@@ -164,25 +250,13 @@ export function mountActBar(options:ActBarOptions):ActBar {
|
|
|
164
250
|
const cleanups:(()=>void)[]=[],labels:{button:HTMLButtonElement;label:string}[]=[];
|
|
165
251
|
const listen=(node:HTMLElement,type:string,fn:(event:Event)=>void)=>{node.addEventListener(type,fn);cleanups.push(()=>node.removeEventListener(type,fn));};
|
|
166
252
|
if(options.overflow?.length){
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
menu.setAttribute('role','menu');
|
|
170
|
-
const close=(focus=true)=>{menu.hidden=true;button.setAttribute('aria-expanded','false');if(focus)button.focus();};
|
|
171
|
-
const items=options.overflow.map(action=>{
|
|
253
|
+
const items:HTMLButtonElement[]=[],more=bindPopupMenu(options.id+'-menu',()=>items,cleanups);
|
|
254
|
+
for(const action of options.overflow){
|
|
172
255
|
const item=actionButton(tr(action.label),null);item.setAttribute('role','menuitem');item.tabIndex=-1;
|
|
173
|
-
listen(item,'click',()=>{close();action.handler();});labels.push({button:item,label:action.label});menu.append(item);
|
|
174
|
-
}
|
|
175
|
-
const open=(last=false)=>{menu.hidden=false;button.setAttribute('aria-expanded','true');items[last?items.length-1:0]!.focus();};
|
|
176
|
-
listen(button,'click',()=>menu.hidden?open():close());
|
|
177
|
-
listen(button,'keydown',event=>{const key=(event as KeyboardEvent).key;if(['ArrowDown','ArrowUp','Enter',' '].includes(key)){event.preventDefault();open(key==='ArrowUp');}else if(key==='Escape'){event.preventDefault();close();}});
|
|
178
|
-
listen(menu,'keydown',event=>{
|
|
179
|
-
const key=(event as KeyboardEvent).key;
|
|
180
|
-
if(key==='Escape'){event.preventDefault();close();return;}
|
|
181
|
-
if(['ArrowDown','ArrowUp','Home','End'].includes(key)){event.preventDefault();const index=items.indexOf(event.target as HTMLButtonElement);items[key==='Home'?0:key==='End'?items.length-1:(index+(key==='ArrowDown'?1:items.length-1))%items.length]!.focus();}
|
|
182
|
-
});
|
|
183
|
-
listen(menu,'focusout',event=>{const target=(event as FocusEvent).relatedTarget;if(target!==button&&!menu.contains(target as Node|null))close(false);});
|
|
256
|
+
listen(item,'click',()=>{more.close();action.handler();});labels.push({button:item,label:action.label});more.menu.append(item);items.push(item);
|
|
257
|
+
}
|
|
184
258
|
// Item listeners own activation; events from the sibling popup never trigger submit.
|
|
185
|
-
actions.append(button,menu);labels.push({button,label:'More act actions'});
|
|
259
|
+
actions.append(more.button,more.menu);labels.push({button:more.button,label:'More act actions'});
|
|
186
260
|
}
|
|
187
261
|
const refresh=()=>{
|
|
188
262
|
if(options.submitLabel!==undefined)options.submit.textContent=tr(typeof options.submitLabel==='function'?options.submitLabel():options.submitLabel);
|
package/web/interview-panel.ts
CHANGED
|
@@ -6,6 +6,11 @@ import { createViewControls } from './view-controls.ts';
|
|
|
6
6
|
import {WorkspacePreferenceStore,panelBounds} from './workspace-preferences.ts';
|
|
7
7
|
import { createPartsViewport } from './parts-viewport-provider.ts';
|
|
8
8
|
|
|
9
|
+
/** The active image-question form is mounted only while it owns the main reference pane. */
|
|
10
|
+
export function hasTransientQuestionImage(root:{querySelector(selector:string):Element|null}=document):boolean {
|
|
11
|
+
return root.querySelector('#workspace-interview-answer[data-question-image-active=true] [data-interview-main]')!==null;
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
type Ask = InterviewQuestion['set']['asks'][number];
|
|
10
15
|
type Pick = Picks['picks'][number];
|
|
11
16
|
/** Element factory: the stage interview translates with `t`; the job page tags `data-job-text` for its own relocalize. */
|
|
@@ -202,7 +207,7 @@ export function interviewRecords(diagnostics:readonly InterviewDiagnostic[]=[],h
|
|
|
202
207
|
|
|
203
208
|
/** B's list | image | survey builder. Hosts supply genuine source data and their own submit transport. */
|
|
204
209
|
export function createInterviewForm(options:{question:InterviewDisplayQuestion;id:string;node?:InterviewText;form?:HTMLFormElement;fieldset?:HTMLFieldSetElement;source?:HTMLElement;
|
|
205
|
-
images:readonly {name:string;src:string}[];questions?:readonly {label:string;answered:boolean}[]|(()=>readonly {label:string;answered:boolean}[]);selected?:number;onSelect?:(index:number)=>void;answered?:boolean;
|
|
210
|
+
mainView?:boolean;images:readonly {name:string;src:string}[];questions?:readonly {label:string;answered:boolean}[]|(()=>readonly {label:string;answered:boolean}[]);selected?:number;onSelect?:(index:number)=>void;answered?:boolean;
|
|
206
211
|
diagnostics?:readonly InterviewDiagnostic[];historical?:readonly HistoricalInterview[]}) {
|
|
207
212
|
const question=options.question,copy=new Map<HTMLElement,string>();
|
|
208
213
|
const make=<K extends keyof HTMLElementTagNameMap>(tag:K,content?:string)=>element(tag,content,options.node);
|
|
@@ -231,22 +236,24 @@ export function createInterviewForm(options:{question:InterviewDisplayQuestion;i
|
|
|
231
236
|
if(question.partsUnavailable)context.append(node('p','interview.partsUnavailable'));
|
|
232
237
|
const provenance=make('p'),binding=make('code',question.ref.path+' · '+question.ref.sha256);context.append(provenance,binding);
|
|
233
238
|
if(question.answer)context.append(make('pre',[question.answer.by,question.answer.at,question.answer.source].filter(value=>typeof value==='string').join(' · ')),make('pre',typeof question.answer.verbatim==='string'?question.answer.verbatim:''));
|
|
239
|
+
if(options.mainView&&options.images.length){form.dataset.interviewMain='';Object.assign(form,{interviewImages:options.images});}
|
|
234
240
|
const art=make('aside');art.className='interview-art';form.prepend(art);
|
|
235
241
|
let view:ReturnType<typeof interviewImageView>|undefined,list:HTMLElement|undefined,records:HTMLElement|undefined;
|
|
236
242
|
const showImage=(index:number)=>{view?.dispose();view?.element.remove();view=interviewImageView(options.images,index,showImage,context);art.append(view.element);};
|
|
237
243
|
const refresh=()=>{
|
|
244
|
+
submit.hidden=!question.editable||form.dataset.interviewAnswered==='true';
|
|
238
245
|
provenance.textContent=t('interview.provenance',[question.set.drafted_by,question.set.drafted_at]);
|
|
239
246
|
const questions=typeof options.questions==='function'?options.questions():options.questions;
|
|
240
247
|
const items=questions?.map((item,index)=>({...item,answered:index===(options.selected??0)?form.dataset.interviewAnswered==='true':item.answered}))??[{label:question.set.question+' · '+question.set.id,answered:form.dataset.interviewAnswered==='true'}];
|
|
241
248
|
const next=interviewQuestionList(items,options.selected??0,options.onSelect??(()=>{}),false,options.node);list?.remove();form.prepend(next);list=next;
|
|
242
249
|
records?.remove();records=interviewRecords(options.diagnostics,options.historical,options.node);context.append(records);
|
|
243
250
|
};
|
|
244
|
-
const submit=node('button','interview.save');submit.type='submit';submit.hidden=!question.editable;
|
|
251
|
+
const submit=node('button','interview.save');submit.type='submit';submit.hidden=!question.editable;
|
|
245
252
|
const status=node('p',!question.editable?'interview.history':question.saved?'interview.saved':'interview.choose');status.setAttribute('role','status');form.append(status);
|
|
246
253
|
const localize=()=>{for(const [item,key]of copy)item.textContent=t(item.dataset.jobText??key);refresh();};
|
|
247
254
|
const dispose=()=>{view?.dispose();form.removeEventListener('input',refresh);form.removeEventListener('change',refresh);form.removeEventListener('job-form-language',localize);};
|
|
248
255
|
form.addEventListener('input',refresh);form.addEventListener('change',refresh);form.addEventListener('job-form-language',localize);
|
|
249
|
-
try{if(options.images.length)showImage(0);else
|
|
256
|
+
try{if(!options.mainView&&options.images.length)showImage(0);else{art.hidden=true;fields.append(context);}fields.append(submit);refresh();}catch(error){dispose();throw error;}
|
|
250
257
|
return {form,fieldset:fields,submit,status,retainedNote,
|
|
251
258
|
read:()=>jobInterviewValue(question.set.question,question.set.asks,item=>answers.find(answer=>answer.item===item)!.answer.value(),retainedNote??''),
|
|
252
259
|
localize,dispose};
|
package/web/job-rig-screen.ts
CHANGED
|
@@ -113,7 +113,6 @@ export function createJobRigScreen(options: {
|
|
|
113
113
|
if (!options.formDependencies) throw new Error('JOB_ACT_KIND_DISABLED');
|
|
114
114
|
const inspection = await prepareJobInspection(display, signal);
|
|
115
115
|
try {
|
|
116
|
-
const forms = prepareJobForms(display, options.window.state().pending, ask => formFor(ask, inspection, options.formDependencies!));
|
|
117
116
|
let previous = display.publication.previousPublicationId, picture:JobRigScreenPrepared|null = null;
|
|
118
117
|
const jobId=jobPublicationRoutes(display,location.origin).jobId;
|
|
119
118
|
const seen = new Set([display.publication.publicationId]);
|
|
@@ -140,6 +139,7 @@ export function createJobRigScreen(options: {
|
|
|
140
139
|
picture = {jobRigScreen:true,display,entry:options.routes(display).entry,checkpoints:new Set(),parts};
|
|
141
140
|
}
|
|
142
141
|
if(signal.aborted)throw new Error('JOB_PRELOAD_CANCELLED');
|
|
142
|
+
const forms = prepareJobForms(display, options.window.state().pending, ask => formFor(ask, inspection, {...options.formDependencies!,interviewMainView:!!picture}),!!picture);
|
|
143
143
|
return {jobRigScreen:true,display,entry:options.routes(display).entry,checkpoints:new Set(),record:{inspection,forms,picture}};
|
|
144
144
|
} catch(error) {inspection.dispose();throw error;}
|
|
145
145
|
}
|
|
@@ -171,7 +171,8 @@ export function createJobRigScreen(options: {
|
|
|
171
171
|
let modals:JobRigScreenPrepared['modals'];
|
|
172
172
|
const asks=options.window.state().pending.filter(ask=>ask.publicationId===display.publication.publicationId&&ask.subject.kind!=='review-verdict'&&ask.subject.kind!=='parts-verdict'&&jobRigScreenAsk(display,ask,checkpoints));
|
|
173
173
|
if(!backdropOnly&&options.formDependencies){
|
|
174
|
-
|
|
174
|
+
// The shared main workspace loads visuals; modal forms keep data and checkpoint evidence.
|
|
175
|
+
const inspection=await prepareJobInspection(display,signal,true,false);
|
|
175
176
|
try{modals={inspection,forms:prepareJobForms(display,asks,ask=>formFor(ask,inspection,options.formDependencies!))};}
|
|
176
177
|
catch(error){inspection.dispose();throw error;}
|
|
177
178
|
}
|
|
@@ -284,7 +285,7 @@ export function createJobRigScreen(options: {
|
|
|
284
285
|
function refreshRecordForms():void {
|
|
285
286
|
const record=mounted?.record??mounted?.modals,deps=options.formDependencies;if(!record||!deps)return;
|
|
286
287
|
const state=options.window.state(),display=record.inspection.display;
|
|
287
|
-
const next=prepareJobForms(display,state.pending.filter(ask=>ask.subject.kind!=='parts-verdict'&&ask.subject.kind!=='review-verdict'&&jobRigScreenAsk(display,ask,mounted!.checkpoints)),ask=>record.forms.get(ask.askId)??formFor(ask,record.inspection,deps));
|
|
288
|
+
const next=prepareJobForms(display,state.pending.filter(ask=>ask.subject.kind!=='parts-verdict'&&ask.subject.kind!=='review-verdict'&&jobRigScreenAsk(display,ask,mounted!.checkpoints)),ask=>{const previous=record.forms.get(ask.askId),saved=state.pending.find(item=>item.askId===ask.askId);if(previous&&saved?.act?.kind==='interview-picks'&&ask.status==='answered'&&!previous.submitting&&previous.form.dataset.interviewAnswered!=='true'){previous.dispose?.();return formFor(saved,record.inspection,{...deps,interviewMainView:!!mounted?.record?.picture});}return previous??formFor(saved??ask,record.inspection,{...deps,interviewMainView:!!mounted?.record?.picture});},!!mounted?.record?.picture);
|
|
288
289
|
for(const [id,entry]of next)record.forms.set(id,entry);
|
|
289
290
|
for(const [id,entry]of record.forms){const ask=state.pending.find(ask=>ask.askId===id);entry.fieldset.disabled=entry.submitting||ask?.status!=='pending'||state.preparing||state.closed||!state.receipt||!options.access.capability;}
|
|
290
291
|
screen?.recordForms?.([...record.forms.values()].map(entry=>entry.form));
|
|
@@ -328,7 +329,7 @@ export function createJobRigScreen(options: {
|
|
|
328
329
|
/** Unsupported asks stay on the shared screen with a named explanation. */
|
|
329
330
|
changed(state: {readonly pending: readonly PendingAskV3[]; readonly closed: boolean; readonly preparing?:boolean; readonly error?:string|null; readonly errorOrigin?:string; readonly previousLabel?:string|null; readonly displayed?:DisplayPublicationV3|null}): void {
|
|
330
331
|
if (!mounted) return;
|
|
331
|
-
if(mounted.record){refreshRecordForms();if(mounted.refusal){screen?.message(options.translate('job.refusal.'+mounted.refusal),true);const notice=document.getElementById('message');if(notice)notice.title=mounted.refusal;}if(state.closed)screen?.message(options.translate('job.closed'),true);return;}
|
|
332
|
+
if(mounted.record){screen?.pendingSubjects?.(pendingSubjects());refreshRecordForms();if(mounted.refusal){screen?.message(options.translate('job.refusal.'+mounted.refusal),true);const notice=document.getElementById('message');if(notice)notice.title=mounted.refusal;}if(state.closed)screen?.message(options.translate('job.closed'),true);return;}
|
|
332
333
|
const refusal=jobRigScreenRefusal(mounted.display,state.pending,mounted.checkpoints);
|
|
333
334
|
if(refusal){screen?.message(options.translate('job.refusal.'+refusal),true);const notice=document.getElementById('message');if(notice)notice.title=refusal;return;}
|
|
334
335
|
screen?.pendingSubjects?.(pendingSubjects());
|
package/web/job-session.ts
CHANGED
|
@@ -130,10 +130,11 @@ export function prepareJobForms<Form>(
|
|
|
130
130
|
display: DisplayPublicationV3,
|
|
131
131
|
asks: readonly PendingAskV3[],
|
|
132
132
|
prepare: (ask: PendingAskV3) => Form,
|
|
133
|
+
answeredInterviews = false,
|
|
133
134
|
): Map<string, Form> {
|
|
134
135
|
const prepared = new Map<string, Form>();
|
|
135
136
|
for (const ask of asks) {
|
|
136
|
-
if (ask.publicationId !== display.publication.publicationId || ask.status !== 'pending') continue;
|
|
137
|
+
if (ask.publicationId !== display.publication.publicationId || ask.status !== 'pending' && !(answeredInterviews && ask.status === 'answered' && ask.subject.kind === 'interview-picks')) continue;
|
|
137
138
|
assertJobAskSource(ask, display);
|
|
138
139
|
prepared.set(ask.askId, prepare(ask));
|
|
139
140
|
}
|
|
@@ -866,8 +867,8 @@ export function mediaReady(media: HTMLVideoElement, name: 'loadeddata' | 'seeked
|
|
|
866
867
|
failed();
|
|
867
868
|
});
|
|
868
869
|
}
|
|
869
|
-
/** Prepare
|
|
870
|
-
export async function prepareJobInspection(display: DisplayPublicationV3, signal: AbortSignal, formsOnly=false): Promise<JobPreparedInspection> {
|
|
870
|
+
/** Prepare off-stage; modal-only callers may skip workspace visuals, never checkpoint evidence. */
|
|
871
|
+
export async function prepareJobInspection(display: DisplayPublicationV3, signal: AbortSignal, formsOnly=false, preloadVisuals=true): Promise<JobPreparedInspection> {
|
|
871
872
|
const routes = jobPublicationRoutes(display, location.origin);
|
|
872
873
|
const metadata = await jobJson<JobInspectionMetadataV3>(routes.api('review'), signal);
|
|
873
874
|
const publishedSource = display.publication.source;
|
|
@@ -1006,7 +1007,7 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
|
|
|
1006
1007
|
checkpointEvidence[index] = {packet, table, images};
|
|
1007
1008
|
})());
|
|
1008
1009
|
}
|
|
1009
|
-
for (const reference of metadata.manifest?.references ?? []) {
|
|
1010
|
+
for (const reference of preloadVisuals ? metadata.manifest?.references ?? [] : []) {
|
|
1010
1011
|
if (reference.id === metadata.sourcePainting?.id) continue;
|
|
1011
1012
|
preload.push((async () => {
|
|
1012
1013
|
if (reference.type === 'image') {
|
|
@@ -1105,7 +1106,7 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
|
|
|
1105
1106
|
}
|
|
1106
1107
|
})());
|
|
1107
1108
|
}
|
|
1108
|
-
if (metadata.sourcePainting) {
|
|
1109
|
+
if (preloadVisuals && metadata.sourcePainting) {
|
|
1109
1110
|
const source = metadata.sourcePainting;
|
|
1110
1111
|
preload.push(image(routes.instance(source.url), source.sha256).then(element => {
|
|
1111
1112
|
element.alt = source.path;
|
|
@@ -1113,11 +1114,11 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
|
|
|
1113
1114
|
width: element.naturalWidth, height: element.naturalHeight, seek: async () => { } });
|
|
1114
1115
|
}));
|
|
1115
1116
|
}
|
|
1116
|
-
for (const part of parts?.items ?? []) {
|
|
1117
|
+
for (const part of preloadVisuals ? parts?.items ?? [] : []) {
|
|
1117
1118
|
preload.push(image(routes.api('stage-parts/image/' + part.index), part.imageHash)
|
|
1118
1119
|
.then(element => { element.alt = part.name; partImages.set(part.name, element); }));
|
|
1119
1120
|
}
|
|
1120
|
-
for (const page of parts?.pages ?? []) {
|
|
1121
|
+
for (const page of preloadVisuals ? parts?.pages ?? [] : []) {
|
|
1121
1122
|
preload.push(image(routes.api('stage-parts/page/' + page.index))
|
|
1122
1123
|
.then(element => { partPages.set(page.index, element); }));
|
|
1123
1124
|
}
|
|
@@ -1321,6 +1322,7 @@ export function createJobFormHelpers(node: JobFormNode, t: typeof import('./i18n
|
|
|
1321
1322
|
|
|
1322
1323
|
/** The answer builder owns no page shell, transport or draft collection. */
|
|
1323
1324
|
export interface JobFormDependencies {
|
|
1325
|
+
interviewMainView?:boolean;
|
|
1324
1326
|
node: JobFormNode;
|
|
1325
1327
|
translate: typeof import('./i18n.ts').t;
|
|
1326
1328
|
helpers: ReturnType<typeof createJobFormHelpers> & {
|
|
@@ -1339,7 +1341,7 @@ export interface JobFormDependencies {
|
|
|
1339
1341
|
}
|
|
1340
1342
|
|
|
1341
1343
|
/** Build the existing answer form with explicit host dependencies. */
|
|
1342
|
-
function formFor(ask:
|
|
1344
|
+
function formFor(ask: JobWindowAsk, prepared: JobPreparedInspection, deps: JobFormDependencies): JobForm {
|
|
1343
1345
|
const {node, translate: t, helpers: {selectValues, imageGallery, planTextList, planStepText, assertJobAskSource, jobCheckpointContext},
|
|
1344
1346
|
draftStorage, localDraftKey, saveDraft, window, access, pageId} = deps;
|
|
1345
1347
|
if (ask.publicationId !== prepared.display.publication.publicationId)
|
|
@@ -1370,9 +1372,14 @@ export interface JobFormDependencies {
|
|
|
1370
1372
|
let disposeInterview:(()=>void)|undefined;
|
|
1371
1373
|
let interviewForm:ReturnType<typeof createInterviewForm>|undefined;
|
|
1372
1374
|
if (subject.kind === 'interview-picks') {
|
|
1373
|
-
|
|
1375
|
+
let question:InterviewDisplayQuestion|undefined = prepared.interview?.questions.find(item => item.set.id === subject.setId && item.set.question === subject.questionId);
|
|
1374
1376
|
if (!question || !question.editable) throw new Error('JOB_ASK_INVALID');
|
|
1375
1377
|
if (question.ref.sha256 !== ask.source.optionSet?.sha256) throw new Error('JOB_ACT_SOURCE_STALE');
|
|
1378
|
+
if(ask.status==='answered'&&ask.act?.kind==='interview-picks'){
|
|
1379
|
+
const value=ask.act.value;
|
|
1380
|
+
const picks=value.selections.map(selection=>({ask:selection.itemId,option_id:selection.optionId,...(selection.otherText!==null?{other_text:selection.otherText}:{})}));
|
|
1381
|
+
question={...question,saved:interviewPicksRecord(question.ref,picks,value.note,ask.act.at)};
|
|
1382
|
+
}
|
|
1376
1383
|
const interviewState = prepared.interview?.interview ?? prepared.display.publication.interview ?? null;
|
|
1377
1384
|
const inspectionRecord = interviewState?.records.find(
|
|
1378
1385
|
item => item.timeKind === 'inspection' &&
|
|
@@ -1393,7 +1400,7 @@ export interface JobFormDependencies {
|
|
|
1393
1400
|
legacyNotice.dataset.record = legacyDiagnostic.record;
|
|
1394
1401
|
fields.prepend(legacyNotice);
|
|
1395
1402
|
}
|
|
1396
|
-
interviewForm=createInterviewForm({question,id:'interview-answer-'+ask.askId,node,form,fieldset:fields,source,
|
|
1403
|
+
interviewForm=createInterviewForm({question,id:'interview-answer-'+ask.askId,node,form,fieldset:fields,source,mainView:deps.interviewMainView,
|
|
1397
1404
|
images:question.images.map(image=>({name:image.name,src:jobPublicationRoutes(prepared.display,location.origin).instance(image.url)})),answered:ask.status==='answered'});
|
|
1398
1405
|
disposeInterview=interviewForm.dispose;read=interviewForm.read;
|
|
1399
1406
|
submitKey = 'interview.save';
|
|
@@ -1417,58 +1424,9 @@ export interface JobFormDependencies {
|
|
|
1417
1424
|
(JSON.stringify(evidence.packet) !== JSON.stringify(declared) || evidence.packet.planStepId !== checkpoint.step.id)) {
|
|
1418
1425
|
throw new Error('CHECKPOINT_EVIDENCE_INVALID');
|
|
1419
1426
|
}
|
|
1420
|
-
if (evidence) {
|
|
1421
|
-
const section = node('section');
|
|
1422
|
-
section.dataset.jobCheckpointEvidence = subject.checkpointId;
|
|
1423
|
-
section.append(node('h4', 'job.checkpointEvidence'));
|
|
1424
|
-
section.append(imageGallery(evidence.packet.tiles.map((tile, index) => ({name: tile.label,
|
|
1425
|
-
sha256: tile.sha256, element: evidence.images[index]?.cloneNode(true) as HTMLImageElement})), true));
|
|
1426
|
-
const tableHost = node('div');
|
|
1427
|
-
tableHost.style.overflow = 'auto';
|
|
1428
|
-
tableHost.style.maxHeight = '50dvh';
|
|
1429
|
-
const table = node('table');
|
|
1430
|
-
table.dataset.jobCheckpointTable = '';
|
|
1431
|
-
const caption = node('caption', 'job.checkpointTable');
|
|
1432
|
-
if (evidence.packet.table.label !== undefined) {
|
|
1433
|
-
delete caption.dataset.jobText;
|
|
1434
|
-
caption.textContent = evidence.packet.table.label;
|
|
1435
|
-
caption.setAttribute('translate', 'no');
|
|
1436
|
-
}
|
|
1437
|
-
const head = node('thead');
|
|
1438
|
-
head.setAttribute('translate', 'no');
|
|
1439
|
-
const columns = node('tr');
|
|
1440
|
-
for (const column of evidence.table.columns) {
|
|
1441
|
-
const cell = node('th');
|
|
1442
|
-
cell.scope = 'col';
|
|
1443
|
-
cell.textContent = column;
|
|
1444
|
-
columns.append(cell);
|
|
1445
|
-
}
|
|
1446
|
-
head.append(columns);
|
|
1447
|
-
const body = node('tbody');
|
|
1448
|
-
body.setAttribute('translate', 'no');
|
|
1449
|
-
for (const row of evidence.table.rows) {
|
|
1450
|
-
const cells = node('tr');
|
|
1451
|
-
for (const value of row) {
|
|
1452
|
-
const cell = node('td');
|
|
1453
|
-
cell.textContent = String(value);
|
|
1454
|
-
cells.append(cell);
|
|
1455
|
-
}
|
|
1456
|
-
body.append(cells);
|
|
1457
|
-
}
|
|
1458
|
-
table.append(caption, head, body);
|
|
1459
|
-
tableHost.append(table);
|
|
1460
|
-
const routes = node('pre');
|
|
1461
|
-
routes.textContent = evidence.packet.routesText;
|
|
1462
|
-
routes.setAttribute('translate', 'no');
|
|
1463
|
-
const recommendation = node('pre');
|
|
1464
|
-
recommendation.textContent = evidence.packet.recommendationText;
|
|
1465
|
-
recommendation.setAttribute('translate', 'no');
|
|
1466
|
-
section.append(tableHost, node('h4', 'job.checkpointRoutes'), routes,
|
|
1467
|
-
node('h4', 'job.checkpointRecommendation'), recommendation);
|
|
1468
|
-
fields.append(section, node('p', 'job.checkpointRouteMapping'));
|
|
1469
|
-
}
|
|
1470
1427
|
const outcome = selectValues(['', 'pass', 'fail'], ['Pending', 'Pass', 'job.fail']);
|
|
1471
1428
|
outcome.required = true;
|
|
1429
|
+
outcome.hidden = true;
|
|
1472
1430
|
outcome.name = 'outcome';
|
|
1473
1431
|
fields.append(outcome);
|
|
1474
1432
|
read = () => ({ checkpointId: subject.checkpointId, outcome: outcome.value as 'pass' | 'fail', words: commentWords() });
|
|
@@ -1500,6 +1458,14 @@ export interface JobFormDependencies {
|
|
|
1500
1458
|
}
|
|
1501
1459
|
const submit = interviewForm?.submit??node('button', submitKey);
|
|
1502
1460
|
submit.type = 'submit';
|
|
1461
|
+
submit.classList.add('primary');
|
|
1462
|
+
if(subject.kind==='checkpoint'){
|
|
1463
|
+
submit.dataset.jobText='Pass';submit.textContent=t('Pass');
|
|
1464
|
+
submit.onclick=()=>{form.querySelector<HTMLSelectElement>('select[name=outcome]')!.value='pass';form.dispatchEvent(new Event('input'));};
|
|
1465
|
+
const fail=node('button','job.fail');fail.type='submit';
|
|
1466
|
+
fail.onclick=()=>{form.querySelector<HTMLSelectElement>('select[name=outcome]')!.value='fail';form.dispatchEvent(new Event('input'));};
|
|
1467
|
+
fields.append(fail);
|
|
1468
|
+
}
|
|
1503
1469
|
fields.append(submit);
|
|
1504
1470
|
const status = interviewForm?.status??node('p');
|
|
1505
1471
|
status.setAttribute('role', 'status');
|
|
@@ -1509,7 +1475,8 @@ export interface JobFormDependencies {
|
|
|
1509
1475
|
if(disposeInterview)form.addEventListener('job-form-dispose',disposeInterview);
|
|
1510
1476
|
try {
|
|
1511
1477
|
const saved = JSON.parse(draftStorage().getItem(localDraftKey(prepared.display)) ?? 'null');
|
|
1512
|
-
|
|
1478
|
+
// A finalized answer is read back from its act; a local draft never overrides it.
|
|
1479
|
+
if (ask.status !== 'answered' && saved?.publicationId === prepared.display.publication.publicationId &&
|
|
1513
1480
|
saved?.sourceHash === prepared.display.publication.source.sourceHash) {
|
|
1514
1481
|
assertJobAskSource({...ask, source: saved.source}, prepared.display);
|
|
1515
1482
|
const original = saved.forms?.find((item: {
|
|
@@ -1566,6 +1533,7 @@ export interface JobFormDependencies {
|
|
|
1566
1533
|
status.textContent = t('job.saved');
|
|
1567
1534
|
if(subject.kind==='interview-picks'){form.dataset.interviewAnswered='true';form.dispatchEvent(new Event('change'));}
|
|
1568
1535
|
saveDraft();
|
|
1536
|
+
form.dispatchEvent(new Event('job-answer-saved',{bubbles:true}));
|
|
1569
1537
|
}
|
|
1570
1538
|
catch (error) {
|
|
1571
1539
|
entry.submitting = false;
|
|
@@ -1609,13 +1577,15 @@ export async function joinedInterviewForms(access:InstanceAccess,present:(forms:
|
|
|
1609
1577
|
entry.form.onsubmit=async event=>{
|
|
1610
1578
|
event.preventDefault();if(!question.editable||!access.capability||entry!.fieldset.disabled||!entry!.form.reportValidity())return;
|
|
1611
1579
|
answer.fieldset.disabled=true;
|
|
1580
|
+
let saved=false;
|
|
1612
1581
|
try{
|
|
1613
1582
|
const value=answer.read(),picks=value.selections.map(selection=>({ask:selection.itemId,option_id:selection.optionId,...(selection.otherText!==null?{other_text:selection.otherText}:{})}));
|
|
1614
1583
|
const record=interviewPicksRecord(question.ref,picks,answer.retainedNote,new Date().toISOString());
|
|
1615
1584
|
await request('/api/interview/picks',record);
|
|
1616
|
-
question.saved=record;answer.form.dataset.interviewAnswered='true';answer.status.dataset.jobText='interview.saved';answer.status.textContent=t('interview.saved');answer.form.dispatchEvent(new Event('change'));
|
|
1585
|
+
question.saved=record;answer.form.dataset.interviewAnswered='true';answer.status.dataset.jobText='interview.saved';answer.status.textContent=t('interview.saved');answer.form.dispatchEvent(new Event('change'));saved=true;
|
|
1617
1586
|
}catch(error){const code=error instanceof Error?error.message.split(':')[0]:'';answer.status.dataset.jobText=interviewErrors[code]??'interview.failed';answer.status.textContent=t(answer.status.dataset.jobText);}
|
|
1618
1587
|
finally{answer.fieldset.disabled=!question.editable||!access.capability;}
|
|
1588
|
+
if(saved)answer.form.dispatchEvent(new Event('job-answer-saved',{bubbles:true}));
|
|
1619
1589
|
};
|
|
1620
1590
|
forms.set(index,entry);
|
|
1621
1591
|
}
|
|
@@ -1673,7 +1643,7 @@ export async function mountJobScreen(host:HTMLElement):Promise<()=>void> {
|
|
|
1673
1643
|
window:{state:()=>window.state(),submit:input=>window.submit(input)},readPublication:(id,signal)=>transport.readPublication(id,signal),
|
|
1674
1644
|
routes:display=>jobPublicationRoutes(display,location.origin),load:async()=>(await import('./main.ts')).mountRigScreen()});
|
|
1675
1645
|
let bootstrapNotice:HTMLElement|null=null;
|
|
1676
|
-
const report=(error:unknown,fallback?:string)=>{if(rigScreen.mounted()){rigScreen.report(error,fallback);return;}if(!bootstrapNotice){bootstrapNotice=node('p');bootstrapNotice.setAttribute('role','status');host.
|
|
1646
|
+
const report=(error:unknown,fallback?:string)=>{if(rigScreen.mounted()){rigScreen.report(error,fallback);return;}if(!bootstrapNotice){bootstrapNotice=node('p');bootstrapNotice.setAttribute('role','status');bootstrapNotice.setAttribute('translate','no');host.prepend(bootstrapNotice);}bootstrapNotice.textContent=jobWindowRefusal(error,fallback);const code=error instanceof Error?error.message:error;bootstrapNotice.title=typeof code==='string'&&/^[A-Z][A-Z0-9_]*$/.test(code)&&Object.hasOwn(enCatalog,code)&&Object.hasOwn(koCatalog,code)?code:fallback??'JOB_WINDOW_FAILED';};
|
|
1677
1647
|
const window=createJobWindow<JobRigScreenPrepared|null>({jobId:access.jobId,pageId,transport,adapter:{
|
|
1678
1648
|
async prepare(display,signal){return rigScreen.prepare(display,signal);},
|
|
1679
1649
|
captureDraft(){drafts.saveDraft();const forms=modalState()?.forms;const dirty=forms?[...forms].filter(([,entry])=>entry.dirty):[];return dirty.length?dirty.map(([askId,entry])=>({askId,value:entry.read()})):null;},
|