MC/website/control-panel/public/organisation-settings.mjs

6 lines
1.1 KiB
JavaScript

// Internal settings-page template. Adapters supply existing authorised forms.
export function createOrganisationSettings(sections){
if(!document.querySelector('link[data-organisation-settings]')){const css=document.createElement('link');css.rel='stylesheet';css.href=new URL('./organisation-settings.css',import.meta.url).href;css.dataset.organisationSettings='';document.head.append(css);}
const root=document.createElement('div');root.className='organisation-settings-grid';
for(const {title,description,content,pending=false,danger=false} of sections){const card=document.createElement('section');card.className='organisation-settings-card'+(danger?' organisation-settings-danger':'');const heading=document.createElement('h3');heading.textContent=title;card.append(heading);if(pending){const badge=document.createElement('span');badge.className='organisation-settings-status';badge.textContent='Coming soon';card.append(badge);}const copy=document.createElement('p');copy.textContent=description;card.append(copy);if(content){if(content.tagName==='FORM')content.querySelector(':scope > h3')?.remove();card.append(content);}root.append(card);}return root;
}