Merge pull request 'Open editors in staff and clan workspaces' (#487) from fix/editor-workspace-placement-20261122 into main

This commit is contained in:
unimatrix 2026-11-22 12:54:17 +00:00
commit 3589efd27c
5 changed files with 10 additions and 9 deletions

View file

@ -18,7 +18,7 @@ export function mountCodexManagement(host,{initial='keys',fetcher=fetch}={}){
const keys=make('div',undefined,'codex-management-grid'),matrix=make('article',undefined,'codex-management-box codex-instrument-artwork');matrix.style.gridColumn='1 / -1';matrix.style.padding='8px';const artwork=make('img');artwork.src='https://cp.dunerealms.com/assets/jarvis-keys-deeds-screen-v1.png';artwork.alt='J.A.R.V.I.S. catalogue artwork showing all key and deed types, their icons and purposes.';artwork.width=1536;artwork.height=1024;artwork.decoding='async';artwork.style.cssText='display:block;width:100%;height:auto;border-radius:8px';matrix.append(artwork);keys.append(matrix);const provenance=box('The mark of origin','Original keys carry an original seal. Authorised staff issues carry a staff seal.');for(const [title,copy] of [['Original seal','An original key may replace a staff-issued upgrade without granting duplicate rights.'],['Staff seal','Each issue records the issuer, reason and a server-signed issue proof.'],['Replacement','A replacement invalidates the unused predecessor and retains its original provenance.']]){const row=make('section',undefined,'codex-seal-note');row.append(make('strong',title),make('p',copy));provenance.append(row);}keys.append(provenance);groups.push({id:'keys',title:'Keys & deeds',content:keys});
const issuance=createKeyGeneratorDesign({fetcher});disposers.push(()=>issuance.dispose());const replace=box('Replace or revoke','Select an existing unused instance. No second entitlement is created.');replace.append(field('Instance ID','Unique J.A.R.V.I.S. instance'),field('Reason','Required audit reason'),locked('Replace key'),locked('Revoke unused key'));issuance.append(replace);groups.push({id:'issuance',title:'Issuance',content:issuance});
const definitions=box('Items & definitions','Definitions describe a type; every issued item receives its own unique instance ID.');definitions.append(field('Search definitions','Name, type or definition ID'),empty(['Artwork','Definition','Type','Quality','Revision','State'],'Definition service not connected.'),locked('Create definition'));retained(definitions,'Open existing item catalogue','./cp-v2-item-register.mjs','mountItemRegister');groups.push({id:'items',title:'Items & definitions',content:definitions});
const definitions=box('Items & definitions','Definitions describe a type; every issued item receives its own unique instance ID.');definitions.append(field('Search definitions','Name, type or definition ID'),empty(['Artwork','Definition','Type','Quality','Revision','State'],'Definition service not connected.'),locked('Create definition'));const itemEditorLink=make('a','Open Item Editor');itemEditorLink.href='#bureau/items';definitions.append(itemEditorLink);groups.push({id:'items',title:'Items & definitions',content:definitions});
const kits=box('Kits','Kit definitions, equipment and redeemable kit instances share the J.A.R.V.I.S. catalogue.');kits.append(empty(['Kit','Revision','Contents','Availability'],'Kit catalogue adapter pending.'),locked('Define kit'));retained(kits,'Open existing kit service','./cp-v2-kit-directorate.mjs','mountKitDirectorate',['server-kits']);groups.push({id:'kits',title:'Kits',content:kits});
const publication=box('Publication','Review versions and their distribution channels before publication.');publication.append(empty(['Definition','Revision','Approval','Channels','State'],'Publication queue is not connected.'),locked('Publish approved revision'));retained(publication,'Open existing publication service','./cp-v2-kit-directorate.mjs','mountKitDirectorate',['kit-publishing']);groups.push({id:'publication',title:'Publication',content:publication});
const delivery=box('Deliveries & claims','Track each delivery attempt against one instance. Retries retain the same delivery identity.');delivery.append(field('Delivery state',['All states','Queued','Processing','Delivered','Failed','Redeemed','Revoked']),empty(['Instance','Recipient','Method','State','Last attempt','Action'],'Delivery service not connected. No delivery totals are inferred.'),locked('Retry selected delivery'));groups.push({id:'delivery',title:'Delivery',content:delivery});

View file

@ -1,5 +1,4 @@
import {createCPV2Page,element as el} from './cp-v2-page-template.mjs';
import {mountKitsetBuilder} from './cp-v2-kitset-builder.mjs';
import {mountItemDesigner} from './cp-v2-item-designer.mjs';
export function itemCatalogue(data){
if(data?.schemaVersion!==1||!Array.isArray(data.items)||data.items.length>1000||!Array.isArray(data.qualityTiers)||data.qualityTiers.length>20)throw Error('Invalid item catalogue.');
@ -11,11 +10,11 @@ export function mountItemRegister(host,{fetcher=fetch}={}){
let active=true,controller=null,data=null,page=1;
const register=el('section',undefined,'cp-v2-company-section'),definitions=el('section',undefined,'cp-v2-company-section'),publishing=el('section',undefined,'cp-v2-company-section');
const search=el('input');search.type='search';search.placeholder='Search item, material or lore';search.setAttribute('aria-label',search.placeholder);const tier=el('select');tier.setAttribute('aria-label','Filter rarity');const all=el('option','All rarities');all.value='';tier.append(all);const refresh=el('button','Refresh catalogue');refresh.type='button';const tools=el('div',undefined,'cp-v2-company-actions');tools.append(search,tier,refresh);const status=el('p','Loading the published item register…','cp-v2-news-status');status.setAttribute('role','status');const tableHost=el('div');register.append(status,tools,tableHost);
const kitsets=el('section',undefined,'cp-v2-company-section'),disposeKitsets=mountKitsetBuilder(kitsets,{fetcher});
const disposeDesigner=mountItemDesigner(definitions,{fetcher});
publishing.append(el('h4','Item publication'),el('p','A staff item-publication queue and game-delivery approval API are not connected.'),el('p','PLANNED · No item is published or issued from this workspace.','cp-v2-bank-status'));
const {root}=createCPV2Page({title:'Item Registry',description:'Published equipment, rarity and lore from the same catalogue used by the public armoury.',artwork:'nav-manual-v2.webp',tabs:[{id:'item-register',label:'Published items',content:register},{id:'item-definitions',label:'Definition management',content:definitions},{id:'item-kitsets',label:'Kitset workshop',content:kitsets},{id:'item-publication',label:'Publication',content:publishing}]});host.replaceChildren(root);
const {root,activate}=createCPV2Page({title:'Item Editor',description:'Published equipment, rarity and lore from the same catalogue used by the public armoury.',artwork:'nav-manual-v2.webp',tabs:[{id:'item-register',label:'Published items',content:register},{id:'item-definitions',label:'Item editor',content:definitions},{id:'item-publication',label:'Publication',content:publishing}]});host.replaceChildren(root);activate('item-definitions');
function render(){if(!data)return;const q=search.value.trim().toLowerCase(),filtered=data.items.filter(item=>(!tier.value||item.quality===tier.value)&&[item.name,item.id,item.baseMaterial,...item.lore].join(' ').toLowerCase().includes(q)),pages=Math.max(1,Math.ceil(filtered.length/12));page=Math.min(page,pages);const table=el('table',undefined,'cp-v2-company-table'),head=el('thead'),hr=el('tr'),body=el('tbody');for(const label of ['Item','Rarity','Material','Stack','Details']){const th=el('th',label);th.scope='col';hr.append(th);}head.append(hr);for(const item of filtered.slice((page-1)*12,page*12)){const tr=el('tr'),details=el('details');details.append(el('summary','Details'));if(item.image){const image=el('img');image.src='https://www.dunerealms.com'+item.image;image.alt=item.name;image.width=image.height=96;image.loading='lazy';details.append(image);}details.append(el('p','Reference: '+item.id),el('p','Model: '+(item.model||'Not specified')));for(const line of item.lore)details.append(el('p',line));if(item.appearance)details.append(el('p',item.appearance));for(const value of [item.name,data.qualityTiers.find(t=>t.key===item.quality)?.label||item.quality,item.baseMaterial||'Not specified',item.maxStackSize||'Not specified',details]){const td=el('td');if(typeof value==='object')td.append(value);else td.textContent=String(value);tr.append(td);}body.append(tr);}if(!filtered.length){const tr=el('tr'),td=el('td','No registered items match this view.');td.colSpan=5;tr.append(td);body.append(tr);}table.append(head,body);const wrap=el('div',undefined,'cp-v2-company-table-wrap');wrap.append(table);const nav=el('div',undefined,'cp-v2-company-actions'),prev=el('button','Previous'),next=el('button','Next');prev.type=next.type='button';prev.disabled=page===1;next.disabled=page===pages;prev.onclick=()=>{page--;render();};next.onclick=()=>{page++;render();};nav.append(prev,el('span',filtered.length+' items · Page '+page+' of '+pages),next);tableHost.replaceChildren(wrap,nav);}
async function load(){controller?.abort();controller=new AbortController();const c=controller,timer=setTimeout(()=>c.abort(),15000);data=null;search.disabled=tier.disabled=refresh.disabled=true;tableHost.replaceChildren();try{const r=await fetcher('/api/items/catalogue',{credentials:'same-origin',cache:'no-store',signal:c.signal}),d=await r.json();if(!r.ok)throw Error(d.message||'Item catalogue unavailable.');const confirmed=itemCatalogue(d);if(!active||c!==controller)return;data=confirmed;tier.replaceChildren(all);for(const t of data.qualityTiers){const option=el('option',t.label);option.value=t.key;tier.append(option);}page=1;render();status.textContent=data.items.length+' published item definitions loaded. This register is read-only.';}catch(error){if(active&&c===controller)status.textContent=c.signal.aborted?'Catalogue read timed out. Refresh to retry.':error.message;}finally{clearTimeout(timer);if(active&&c===controller){refresh.disabled=false;search.disabled=tier.disabled=!data;}}}
search.oninput=tier.onchange=()=>{page=1;render();};refresh.onclick=()=>void load();void load();return()=>{active=false;controller?.abort();disposeDesigner();disposeKitsets();root.remove();};
search.oninput=tier.onchange=()=>{page=1;render();};refresh.onclick=()=>void load();void load();return()=>{active=false;controller?.abort();disposeDesigner();root.remove();};
}

View file

@ -8,7 +8,7 @@ import {mountItemDesigner} from './cp-v2-item-designer.mjs';
const el=(tag,text,cls)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=text;if(cls)n.className=cls;return n;};
const button=(label,action)=>{const b=el('button',label);b.type='button';b.onclick=action;return b;};
export function mountKitsetBuilder(host,{fetcher=fetch}={}){
export function mountKitsetBuilder(host,{fetcher=fetch,ownerScope=null}={}){
if(!document.querySelector('link[data-kitset-builder]')){const css=el('link');css.rel='stylesheet';css.href=new URL('./cp-v2-kitset-builder.css',import.meta.url).href;css.dataset.kitsetBuilder='';document.head.append(css);}
let scopes=[],active=true,ready=false,busy=false,id=crypto.randomUUID(),revision=0,items=[],baseline='',drafts=[],definitions=[],page=0,selected=null,disposeEditor=null;
const controller=new AbortController(),root=el('section',undefined,'kitset-builder');
@ -75,6 +75,6 @@ export function mountKitsetBuilder(host,{fetcher=fetch}={}){
catch(error){if(active&&!controller.signal.aborted)status.textContent=error.message;}finally{busy=false;render();}
}
price.oninput=()=>render();search.oninput=rarity.onchange=()=>{page=0;renderLibrary();};name.oninput=owner.onchange=()=>render();
async function start(){try{const [sets,response]=await Promise.all([request(),fetcher('/api/items/designs',{credentials:'same-origin',cache:'no-store',signal:controller.signal})]);const data=await response.json();if(!response.ok)throw Error(data.message||'Item definitions unavailable.');if(!Array.isArray(sets.kitsets)||!Array.isArray(data.definitions))throw Error('Invalid design register.');if(!active)return;if(!Array.isArray(sets.scopes)||!sets.scopes.length)throw Error('No kit owners available.');scopes=sets.scopes;for(const scope of scopes){const option=el('option',scope.label+' · '+scope.limit+' designs');option.value=scope.kind+':'+scope.id;owner.append(option);}drafts=sets.kitsets;definitions=data.definitions;fillSaved();ready=true;status.textContent='Choose templates or reuse saved item designs. Saving a kitset creates no item keys.';}catch(error){if(active&&!controller.signal.aborted)status.textContent=error.message;}render();}
async function start(){try{const [sets,response]=await Promise.all([request(),fetcher('/api/items/designs',{credentials:'same-origin',cache:'no-store',signal:controller.signal})]);const data=await response.json();if(!response.ok)throw Error(data.message||'Item definitions unavailable.');if(!Array.isArray(sets.kitsets)||!Array.isArray(data.definitions))throw Error('Invalid design register.');if(!active)return;if(!Array.isArray(sets.scopes)||!sets.scopes.length)throw Error('No kit owners available.');scopes=ownerScope?sets.scopes.filter(s=>s.kind===ownerScope.kind&&s.id===ownerScope.id):sets.scopes;if(!scopes.length)throw Error('Kit design authority for this organisation is unavailable.');for(const scope of scopes){const option=el('option',scope.label+' · '+scope.limit+' designs');option.value=scope.kind+':'+scope.id;owner.append(option);}drafts=ownerScope?sets.kitsets.filter(d=>d.design.owner.kind===ownerScope.kind&&d.design.owner.id===ownerScope.id):sets.kitsets;definitions=data.definitions;fillSaved();ready=true;status.textContent='Choose templates or reuse saved item designs. Saving a kitset creates no item keys.';}catch(error){if(active&&!controller.signal.aborted)status.textContent=error.message;}render();}
render();void start();return()=>{active=false;controller.abort();disposeEditor?.();if(dialog.open)dialog.close();root.remove();};
}

View file

@ -1,3 +1,4 @@
import {mountKitsetBuilder} from './cp-v2-kitset-builder.mjs';
import {mountClientClans} from './cp-v2-client-clans.mjs';
import {mountClanRebellions} from './cp-v2-rebellions.mjs';
import {mountProgressionDesign} from './cp-v2-progression.mjs';
@ -14,6 +15,7 @@ export function mountPlayWorkspace(host,workspace,id,options={}){
if(workspace==='clan'&&id==='clan-decisions')return mountProgressionDesign(host,{context:'clan',organisation:options.accountId?{id:options.accountId}:null,initialView:'decisions'});
if(workspace==='quests'||workspace==='clan'&&id==='clan-quests')return mountProgressionDesign(host,{organisation:workspace==='clan'&&options.accountId?{id:options.accountId}:null,context:workspace==='clan'?'clan':'personal',dashboard:workspace==='quests'&&id==='quest-dashboard'});
if(workspace==='events'||workspace==='clan'&&id==='clan-events')return mountRealmEvents(host,{kind:workspace==='clan'?'clan':null,fetcher:options.fetcher||fetch});
if(workspace==='clan'&&id==='clan-tailor')return mountKitsetBuilder(host,{fetcher:options.fetcher||fetch,ownerScope:{kind:'clan',id:options.accountId}});
if(workspace==='clan'&&id==='clan-elections')return mountElectionDesign(host,{context:'clan'});
if(workspace==='clan'&&id==='clan-advertising')return mountAdvertisingDesign(host,{context:'clan'});
if(workspace==='clan'){if(['clan-shop','clan-listings','clan-post-listing'].includes(id))return mountExchangeDesign(host,{context:'clan',organisationScope:options.accountId?{kind:'clan',id:options.accountId}:null,view:id==='clan-listings'?'mine':id==='clan-post-listing'?'post':'browse',fetcher:options.fetcher||fetch});if(id==='clan-boards')return mountNativeService(host,'clan-boards',{...options,organisationId:options.accountId,singleHeading:true});if(id==='clan-patronage')return mountPatronage(host,{fetcher:options.fetcher||fetch,sellDeed:options.sellDeed??null});if(id==='clan-claims')return mountClaims(host,{kind:'clan',fetcher:options.fetcher||fetch,clanId:options.accountId||new URLSearchParams(location.hash.split('?')[1]||'').get('clientclan')||null});if(id==='clan-subhouses')return mountClientClans(host,{fetcher:options.fetcher||fetch,clanId:options.accountId||new URLSearchParams(location.hash.split('?')[1]||'').get('clientclan')||null});if(id==='clan-bank')return mountClanBank(host,options);

File diff suppressed because one or more lines are too long