forked from unimatrix/web
Add illustrated dashboard cards, welcome subboxes and hierarchy placeholder
This commit is contained in:
parent
79e1d7c672
commit
342102f549
2 changed files with 11 additions and 2 deletions
|
|
@ -3,3 +3,9 @@
|
|||
.organisation-dashboard-card table{width:100%;border-collapse:collapse;margin-top:18px;font-size:13px}.organisation-dashboard-card th,.organisation-dashboard-card td{text-align:left;padding:11px 8px;border-bottom:1px solid #b49b5140}.organisation-dashboard-card th{color:#d8c185;font-weight:400}
|
||||
.clan-focused-workspace>.clan-scope{display:none}.clan-focused-workspace>.clan-notice:empty{display:none}.clan-focused-workspace .clan-details{margin:0;padding:0}.clan-center .organisation-dashboard-card>header{display:flex!important;align-items:center;justify-content:flex-start;position:static!important;width:auto!important;min-height:0!important;height:auto!important;background:transparent!important;margin:0 0 16px;padding:0 0 14px;border:0;border-bottom:1px solid #b49b5140;box-shadow:none;gap:12px}.clan-center .organisation-dashboard-welcome>header{flex-direction:column!important;text-align:center;align-items:center!important}.clan-center .organisation-dashboard-welcome>header img{width:150px!important;height:150px!important;object-fit:contain}.clan-center .organisation-dashboard{grid-column:1/-1;width:100%;box-sizing:border-box}.clan-center .organisation-dashboard-card{box-sizing:border-box}.clan-center .organisation-dashboard-card h3{margin:0!important;line-height:1.2}
|
||||
.organisation-activity-feed{list-style:none;padding:0;margin:0}.organisation-activity-feed li{padding:14px 0;border-bottom:1px solid #b49b5138}.organisation-activity-feed strong{display:block;font:700 15px Arial,sans-serif!important;color:#ead29a}.organisation-activity-feed p{margin:7px 0}.organisation-activity-feed time{font-size:11px;color:#aebdac}
|
||||
/* Shared illustrated cards: scoped above inherited legacy article styles. */
|
||||
.clan-center .organisation-dashboard,.organisation-dashboard{padding:24px;margin:0;box-sizing:border-box;gap:22px;min-width:0}
|
||||
.clan-center .organisation-dashboard-card,.organisation-dashboard .organisation-dashboard-card{--dashboard-wash:#102f27d9;position:relative;overflow:hidden;background:linear-gradient(115deg,#0b241eef,var(--dashboard-wash)),var(--dashboard-art) center/cover;box-shadow:inset 0 0 0 4px #d4b7660d,0 6px 18px #0002}
|
||||
.organisation-dashboard [data-dashboard-card=members]{--dashboard-wash:#1d5949b8}.organisation-dashboard [data-dashboard-card=applications]{--dashboard-wash:#594235c9}.organisation-dashboard [data-dashboard-card=news-activity]{--dashboard-wash:#25475ac4}.organisation-dashboard [data-dashboard-card=events]{--dashboard-wash:#4b355ac4}.organisation-dashboard [data-dashboard-card=treasury]{--dashboard-wash:#153b51c7}.organisation-dashboard [data-dashboard-card=land-claims]{--dashboard-wash:#47562cbd}.organisation-dashboard [data-dashboard-card=mailbox]{--dashboard-wash:#483b23c4}.organisation-dashboard [data-dashboard-card=subhouses-subsidiaries]{--dashboard-wash:#30485abf}
|
||||
.organisation-welcome-boxes{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;margin-top:20px}.organisation-welcome-subbox{min-width:0;padding:20px;border:1px solid #b7a06888;border-radius:12px;background:#0b241dd9;box-sizing:border-box}.organisation-welcome-subbox h4{margin:0 0 12px;font:700 17px Georgia,serif;color:#e8cc8c}.organisation-welcome-subbox p{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}.organisation-dashboard-card a{overflow-wrap:anywhere}.organisation-dashboard-card table{table-layout:fixed;overflow-wrap:anywhere}
|
||||
@media(max-width:760px){.clan-center .organisation-dashboard,.organisation-dashboard{padding:14px;gap:16px}.organisation-welcome-boxes{grid-template-columns:minmax(0,1fr);gap:14px}.organisation-welcome-subbox{padding:16px}}
|
||||
|
|
|
|||
|
|
@ -5,15 +5,18 @@ const assets='https://www.dunerealms.com/assets/';
|
|||
export function createOrganisationDashboard({kind='clan',organisation,members=[],role,canReview=false,requests=[],onMembers,onRequests,loadMailbox,loadTreasury,activity=[],activityStatus}={}){
|
||||
if(!document.querySelector('link[data-organisation-dashboard]')){const css=el('link');css.rel='stylesheet';css.href=new URL('./organisation-dashboard.css',import.meta.url).href;css.dataset.organisationDashboard='';document.head.append(css);}
|
||||
const company=kind==='company',noun=company?'Company':'Clan',root=el('div',undefined,'organisation-dashboard');
|
||||
function card(title,art,{pending=false}={}){const box=el('article',undefined,'organisation-dashboard-card'),header=el('header'),image=el('img');image.src=assets+art;image.alt='';image.width=image.height=48;header.append(image,el('h3',title));if(pending)header.append(el('span','Coming soon','organisation-dashboard-status'));box.append(header);root.append(box);return box;}
|
||||
const backgrounds={'Members':'guild.webp','Applications':'political-small-council-v1.png','News & activity':'political-imperial-chamber-v1.png','Events':'clan-atelier-v1.webp','Treasury':'postbank-transfer-hall-v1.png','Land & claims':'guild.webp','Mailbox':'imperial-post-office-v1.png','Needs attention':'political-small-council-v1.png','Subhouses & subsidiaries':'clan-atelier-v1.webp'};
|
||||
function card(title,art,{pending=false}={}){const box=el('article',undefined,'organisation-dashboard-card'),header=el('header'),image=el('img');image.src=assets+art;image.alt='';image.width=image.height=48;box.dataset.dashboardCard=title.toLowerCase().replaceAll(/[^a-z]+/g,'-');box.style.setProperty('--dashboard-art','url("'+assets+(backgrounds[title]||'political-imperial-chamber-v1.png')+'")');header.append(image,el('h3',title));if(pending)header.append(el('span','Coming soon','organisation-dashboard-status'));box.append(header);root.append(box);return box;}
|
||||
function action(box,label,handler){const button=el('button',label);button.type='button';button.onclick=handler;box.append(button);}
|
||||
const welcome=card('Welcome to '+organisation.name,company?'clans/vaerkring-v1.png':'nav-clan-v2.webp');welcome.classList.add('organisation-dashboard-welcome');const emblem=welcome.querySelector('header img');if(organisation.emblem)emblem.src=organisation.emblem;welcome.append(el('small','YOUR '+noun.toUpperCase()+' · YOUR PEOPLE · YOUR NEXT CHAPTER'),el('small',noun.toUpperCase()+' DESCRIPTION'),el('p',organisation.description||'No introduction has been published yet.'),el('small','MESSAGE OF THE DAY'),el('p',organisation.motd||'The separate MOTD service is coming soon. No message is connected yet.'),el('p','['+organisation.tag+'] · '+(organisation.homeworldName||'Homeworld not selected')+' · '+({owner:noun+' owner',officer:'Officer',member:'Member'}[role]||'Visitor')));
|
||||
const welcome=card('Welcome to '+organisation.name,company?'clans/vaerkring-v1.png':'nav-clan-v2.webp');welcome.classList.add('organisation-dashboard-welcome');const emblem=welcome.querySelector('header img');if(organisation.emblem)emblem.src=organisation.emblem;welcome.append(el('small','YOUR '+noun.toUpperCase()+' · YOUR PEOPLE · YOUR NEXT CHAPTER'));const welcomeBoxes=el('div',undefined,'organisation-welcome-boxes');for(const [title,message] of [[noun+' description',organisation.description||'No introduction has been published yet.'],['Message of the day',organisation.motd||'Your separate MOTD will appear here. Coming soon.']]){const box=el('section',undefined,'organisation-welcome-subbox');box.append(el('h4',title),el('p',message));welcomeBoxes.append(box);}welcome.append(welcomeBoxes,el('p','['+organisation.tag+'] · '+(organisation.homeworldName||'Homeworld not selected')+' · '+({owner:noun+' owner',officer:'Officer',member:'Member'}[role]||'Visitor')));
|
||||
|
||||
const people=card('Members','nav-account-v2.webp'),faces=el('div',undefined,'organisation-dashboard-members');people.append(el('p',members.length+' '+(members.length===1?'member':'members')+' in the register'));
|
||||
for(const member of members.slice(0,8)){const link=el('a',undefined,'organisation-dashboard-member'),image=el('img'),copy=el('span');image.src='https://cp.dunerealms.com/api/avatars/face/roster/'+encodeURIComponent(member.username);image.alt='';image.width=image.height=44;image.loading='lazy';copy.append(el('strong',member.username),el('small',({owner:noun+' owner',officer:'Officer',member:'Member'})[member.clan_role||member.role]||'Member'));link.href='https://www.dunerealms.com/people/'+encodeURIComponent(member.username);link.target='_top';link.append(image,copy);faces.append(link);}people.append(faces);if(onMembers)action(people,'View all members →',onMembers);
|
||||
const applications=card('Applications','nav-support-v2.webp');applications.append(el('p',canReview?(requests.length?requests.length+' '+(requests.length===1?'application awaits':'applications await')+' review.':'No applications are waiting for review.'):'Applications are reviewed by the owner and authorised officers.'));
|
||||
if(canReview){for(const request of requests.slice(0,3))applications.append(el('p',request.username,'organisation-dashboard-request'));if(onRequests)action(applications,'Review applications →',onRequests);}
|
||||
const news=card('News & activity','nav-manual-v2.webp');news.append(createActivityFeed(activity,{emptyMessage:activityStatus==='restricted'?'Activity is visible to organisation members.':activityStatus==='unavailable'?'Activity could not be loaded.':'No clan activity has been recorded yet.'}));
|
||||
for(const [title,art,message] of [['Events','nav-manual-full-v2.webp','Upcoming activities, dates and participation will appear here.'],['Treasury','imperial-postbank-v2.png','Available funds and the account reference will appear here once the authorised bank summary is connected.'],['Land & claims','clans/house-veyr-v1.png','Territory, estate anchors and claim summaries will appear here.']]){const box=card(title,art,{pending:title==='Treasury'?false:true});box.append(el('p',message),el('small','Not connected yet · no records are shown.'));if(title==='Treasury'){const table=el('table');for(const [label,value] of [['Available funds','Not connected'],['Account','Authorised view required']]){const row=el('tr');row.append(el('th',label),el('td',value));table.append(row);}box.append(table);if(loadTreasury){box.querySelectorAll('p,small').forEach(n=>n.remove());table.replaceChildren();const note=el('p','Checking authorised clan funds…');box.append(note);Promise.resolve().then(loadTreasury).then(entity=>{if(!root.isConnected)return;note.textContent=entity.state==='not_activated'?'Clan banking has not been activated.':'Current accounts · Imperial Postbank';table.replaceChildren();for(const account of entity.accounts){const row=el('tr'),link=el('a',account.number);link.href='https://cp.dunerealms.com/#bank/bank-statements/'+encodeURIComponent(account.id);link.target='_top';const cell=el('td');cell.append(link);row.append(cell,el('td',account.available+' DM available'));table.append(row);}if(!entity.accounts.length&&entity.state!=='not_activated')note.textContent='No active current accounts are visible with your bank permissions.';}).catch(()=>{if(root.isConnected){table.replaceChildren();note.textContent='Clan funds could not be confirmed. Open Imperial Postbank to check your access.';}});}else{table.replaceChildren();box.querySelector('p').textContent='Clan funds are available only with authorised banking access.';}const bank=el('a','Open Imperial Postbank →');bank.href='https://cp.dunerealms.com/#bank/bank-overview';bank.target='_top';box.append(bank);}}
|
||||
const children=card('Subhouses & subsidiaries','clans/vaerkring-v1.png',{pending:true});children.append(el('p','Clans and companies under your organisation will appear here.'));const relations=el('table'),head=el('thead'),heading=el('tr');for(const label of ['Organisation','Type','Relationship']){const cell=el('th',label);cell.scope='col';heading.append(cell);}head.append(heading);const body=el('tbody'),row=el('tr'),empty=el('td','Hierarchy records are not connected yet.');empty.colSpan=3;row.append(empty);body.append(row);relations.append(head,body);children.append(relations);
|
||||
const mail=card('Mailbox','imperial-post-office-v1.png'),mailStatus=el('p',loadMailbox?'Checking unread clan mail…':'Clan mail is available to the owner and authorised officers.');mailStatus.setAttribute('role','status');mail.append(mailStatus);if(loadMailbox){const link=el('a','Open clan mailbox →');link.href='https://clans.dunerealms.com/#clan/clan-mail';link.target='_top';mail.append(link);Promise.resolve().then(loadMailbox).then(count=>{if(root.isConnected)mailStatus.textContent=Number.isSafeInteger(count)&&count>=0?'You have '+count+' unread '+(count===1?'message.':'messages.'):'Unread count is unavailable.';}).catch(()=>{if(root.isConnected)mailStatus.textContent='Mail service unavailable. Open the mailbox to retry.';});}
|
||||
const attention=card('Needs attention','nav-support-v2.webp');attention.append(el('p',canReview&&requests.length?requests.length+' pending '+(requests.length===1?'application needs':'applications need')+' your attention.':'No additional dashboard alerts are connected yet.'));if(canReview&&requests.length&&onRequests)action(attention,'Open pending applications →',onRequests);return root;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff