v0.1.11 - Editor
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import { clientSession, sessionHydrated } from '$lib/session';
|
||||
import Skeleton from '$lib/components/Skeleton.svelte';
|
||||
import type { DashboardSummary } from '$lib/types';
|
||||
import { getWorkspaceHomeHref } from '$lib/workspace-access';
|
||||
import { canOpenEditor, getWorkspaceHomeHref } from '$lib/workspace-access';
|
||||
import packageInfo from '../../package.json';
|
||||
import { Sunrise, Sun, Sunset, Moon } from 'lucide-svelte';
|
||||
import { tick } from 'svelte';
|
||||
@@ -464,7 +464,9 @@
|
||||
<h2>{greeting.label}, {firstName($clientSession?.name)}</h2>
|
||||
</div>
|
||||
<div class="intro-actions">
|
||||
<a class="primary-button" href="/products">Review Delivered Pricing</a>
|
||||
{#if canOpenEditor($clientSession)}
|
||||
<a class="primary-button" href="/editor">Open Editor</a>
|
||||
{/if}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { api } from '$lib/api';
|
||||
import { getStoredClientSession, hasStoredClientSession } from '$lib/session';
|
||||
import { canOpenEditor, getWorkspaceHomeHref } from '$lib/workspace-access';
|
||||
|
||||
export async function load({ fetch }) {
|
||||
if (!hasStoredClientSession()) {
|
||||
return { rows: [] };
|
||||
}
|
||||
|
||||
const session = getStoredClientSession();
|
||||
if (!canOpenEditor(session)) {
|
||||
throw redirect(307, getWorkspaceHomeHref(session));
|
||||
}
|
||||
|
||||
try {
|
||||
const [rows, rawMaterials] = await Promise.all([
|
||||
api.editorProducts({ limit: 1000 }, fetch),
|
||||
api.rawMaterials(fetch)
|
||||
]);
|
||||
|
||||
return {
|
||||
rows,
|
||||
rawMaterials
|
||||
};
|
||||
} catch {
|
||||
return { rows: [], rawMaterials: [] };
|
||||
}
|
||||
}
|
||||
@@ -105,40 +105,40 @@
|
||||
</script>
|
||||
|
||||
<section class="page-actions">
|
||||
<a class="primary-button" href="/mixes/new">New Mix Worksheet</a>
|
||||
<a class="ui-button primary" href="/mixes/new">New Mix Worksheet</a>
|
||||
</section>
|
||||
|
||||
<section class="metric-row">
|
||||
<article class="metric-card">
|
||||
<section class="ui-metric-row module-section">
|
||||
<article class="ui-metric-card">
|
||||
<span>Total Mixes</span>
|
||||
<strong>{data.mixes.length}</strong>
|
||||
<p>Saved mix definitions</p>
|
||||
</article>
|
||||
|
||||
<article class="metric-card">
|
||||
<article class="ui-metric-card">
|
||||
<span>Average Cost / Kg</span>
|
||||
<strong>{currency(averageCost, 4)}</strong>
|
||||
<p>Across all saved mixes</p>
|
||||
</article>
|
||||
|
||||
<article class="metric-card">
|
||||
<article class="ui-metric-card">
|
||||
<span>Warnings</span>
|
||||
<strong>{warningCount}</strong>
|
||||
<p>Mixes needing review</p>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="table-card">
|
||||
<div class="section-heading">
|
||||
<section class="ui-panel module-section">
|
||||
<div class="ui-section-heading">
|
||||
<div>
|
||||
<p class="eyebrow">Table View</p>
|
||||
<p class="ui-eyebrow">Table View</p>
|
||||
<h3>Saved mixes</h3>
|
||||
</div>
|
||||
<span class="soft-pill">Open any mix to edit</span>
|
||||
<span class="ui-pill positive">Open any mix to edit</span>
|
||||
</div>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<div class="ui-table-wrap">
|
||||
<table class="ui-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Mix</th>
|
||||
@@ -155,8 +155,8 @@
|
||||
{#each data.mixes as mix}
|
||||
<tr>
|
||||
<td data-label="Mix">
|
||||
<div class="table-item">
|
||||
<span class="row-badge">MX</span>
|
||||
<div class="ui-table-identity">
|
||||
<span class="ui-row-mark">MX</span>
|
||||
<div>
|
||||
<strong>{mix.name}</strong>
|
||||
<span>v{mix.version ?? 1}</span>
|
||||
@@ -169,14 +169,14 @@
|
||||
<td data-label="Total Cost">{currency(mix.total_mix_cost)}</td>
|
||||
<td data-label="Cost / Kg">{currency(mix.mix_cost_per_kg, 4)}</td>
|
||||
<td data-label="Status">
|
||||
<span class={`status-pill ${mix.warnings.length ? 'warning' : 'positive'}`}>{mix.status}</span>
|
||||
<span class={`ui-pill ${mix.warnings.length ? 'warning' : 'positive'}`}>{mix.status}</span>
|
||||
</td>
|
||||
<td class="menu-cell" data-label="Actions">
|
||||
<div class="menu-wrap">
|
||||
<button
|
||||
aria-expanded={activeMenuId === mix.id}
|
||||
aria-haspopup="menu"
|
||||
class="menu-trigger"
|
||||
class="ui-button secondary menu-trigger"
|
||||
type="button"
|
||||
onclick={(event) => toggleMenu(mix.id, event)}
|
||||
>
|
||||
@@ -199,218 +199,21 @@
|
||||
</section>
|
||||
|
||||
<style>
|
||||
h2,
|
||||
h3,
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
color: #7f8e85;
|
||||
font-size: 0.74rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.page-actions,
|
||||
.metric-row,
|
||||
.table-card {
|
||||
.module-section {
|
||||
margin-bottom: 1.12rem;
|
||||
}
|
||||
|
||||
.page-actions {
|
||||
margin-bottom: 1.12rem;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.metric-card,
|
||||
.table-card {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 1.16rem;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.page-intro,
|
||||
.table-card {
|
||||
padding: 1.08rem;
|
||||
}
|
||||
|
||||
.page-intro,
|
||||
.section-heading,
|
||||
.intro-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.68rem;
|
||||
}
|
||||
|
||||
.page-intro {
|
||||
align-items: end;
|
||||
}
|
||||
|
||||
.page-intro h2 {
|
||||
margin: 0.3rem 0 0.4rem;
|
||||
font-size: clamp(1.56rem, 3vw, 2.02rem);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.page-intro p:last-child,
|
||||
.metric-card p,
|
||||
.table-item span:last-child {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.primary-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 0.82rem;
|
||||
padding: 0.74rem 0.9rem;
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
background: var(--color-brand);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.metric-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 0.9rem;
|
||||
}
|
||||
|
||||
.metric-card {
|
||||
padding: 1.04rem 1.08rem;
|
||||
}
|
||||
|
||||
.metric-card span {
|
||||
display: block;
|
||||
color: var(--muted);
|
||||
font-size: 0.84rem;
|
||||
}
|
||||
|
||||
.metric-card strong {
|
||||
display: block;
|
||||
margin: 0.48rem 0 0.26rem;
|
||||
font-size: 1.72rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.section-heading {
|
||||
align-items: flex-start;
|
||||
margin-bottom: 0.9rem;
|
||||
}
|
||||
|
||||
.section-heading h3 {
|
||||
font-size: 1.02rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.soft-pill {
|
||||
padding: 0.42rem 0.72rem;
|
||||
border-radius: 999px;
|
||||
color: var(--green-deep);
|
||||
background: var(--green-soft);
|
||||
font-size: 0.82rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
min-width: 48rem;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0 0.54rem;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
padding: 0.88rem 0.92rem;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
th {
|
||||
color: var(--muted);
|
||||
font-size: 0.74rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
tbody td {
|
||||
background: var(--panel-soft);
|
||||
border-top: 1px solid var(--line);
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
tbody td:first-child {
|
||||
border-left: 1px solid var(--line);
|
||||
border-radius: 0.92rem 0 0 0.92rem;
|
||||
}
|
||||
|
||||
tbody td:last-child {
|
||||
border-right: 1px solid var(--line);
|
||||
border-radius: 0 0.92rem 0.92rem 0;
|
||||
}
|
||||
|
||||
.table-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.74rem;
|
||||
}
|
||||
|
||||
.table-item strong {
|
||||
display: block;
|
||||
font-size: 0.94rem;
|
||||
}
|
||||
|
||||
.table-item span:last-child {
|
||||
display: block;
|
||||
margin-top: 0.15rem;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.row-badge {
|
||||
width: 2.04rem;
|
||||
height: 2.04rem;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
border-radius: 0.72rem;
|
||||
color: #fff;
|
||||
background: var(--color-brand);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.status-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0.38rem 0.7rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.status-pill.positive {
|
||||
color: var(--green-deep);
|
||||
background: var(--green-soft);
|
||||
}
|
||||
|
||||
.status-pill.warning {
|
||||
color: #a9681d;
|
||||
background: #fff6e6;
|
||||
}
|
||||
|
||||
.menu-cell {
|
||||
width: 1%;
|
||||
}
|
||||
@@ -421,16 +224,8 @@
|
||||
}
|
||||
|
||||
.menu-trigger {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px solid var(--line-strong);
|
||||
border-radius: 0.76rem;
|
||||
padding: 0.6rem 0.74rem;
|
||||
color: #304038;
|
||||
background: #fff;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
min-height: 2.25rem;
|
||||
padding: 0.52rem 0.72rem;
|
||||
}
|
||||
|
||||
.menu-panel {
|
||||
@@ -456,82 +251,7 @@
|
||||
background: var(--panel-soft);
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.metric-row {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.page-intro,
|
||||
.section-heading {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.table-card {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
table,
|
||||
thead,
|
||||
tbody,
|
||||
tr,
|
||||
td {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table {
|
||||
min-width: 0;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
thead {
|
||||
display: none;
|
||||
}
|
||||
|
||||
tbody {
|
||||
display: grid;
|
||||
gap: 0.9rem;
|
||||
}
|
||||
|
||||
tbody tr {
|
||||
padding: 0.3rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 1rem;
|
||||
background: var(--panel-soft);
|
||||
}
|
||||
|
||||
tbody td {
|
||||
padding: 0.78rem 0.8rem;
|
||||
white-space: normal;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
tbody td:first-child,
|
||||
tbody td:last-child {
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
tbody td + td {
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
tbody td::before {
|
||||
content: attr(data-label);
|
||||
display: block;
|
||||
margin-bottom: 0.35rem;
|
||||
color: var(--muted);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.menu-wrap,
|
||||
.menu-trigger {
|
||||
width: 100%;
|
||||
|
||||
@@ -264,20 +264,20 @@
|
||||
|
||||
<div class="panel-body">
|
||||
{#if activeView === 'overview'}
|
||||
<section class="metric-row">
|
||||
<article class="metric-card">
|
||||
<section class="ui-metric-row metric-row">
|
||||
<article class="ui-metric-card metric-card">
|
||||
<span>Total Spend Tracked</span>
|
||||
<strong>{currency(totalSpend)}</strong>
|
||||
<p>Across current market values</p>
|
||||
</article>
|
||||
|
||||
<article class="metric-card">
|
||||
<article class="ui-metric-card metric-card">
|
||||
<span>Average Waste</span>
|
||||
<strong>{(averageWaste * 100).toFixed(1)}%</strong>
|
||||
<p>Current blended input loss</p>
|
||||
</article>
|
||||
|
||||
<article class="metric-card">
|
||||
<article class="ui-metric-card metric-card">
|
||||
<span>Latest Price Update</span>
|
||||
<strong>{formatDate(latestEffectiveDate)}</strong>
|
||||
<p>Most recent effective date on file</p>
|
||||
@@ -286,10 +286,10 @@
|
||||
|
||||
<section class="top-grid">
|
||||
<div class="summary-stack">
|
||||
<article class="surface-card">
|
||||
<div class="section-heading">
|
||||
<article class="ui-panel surface-card">
|
||||
<div class="ui-section-heading section-heading">
|
||||
<div>
|
||||
<p class="eyebrow">Downstream Snapshot</p>
|
||||
<p class="ui-eyebrow eyebrow">Downstream Snapshot</p>
|
||||
<h3>Mixes affected by current inputs</h3>
|
||||
</div>
|
||||
</div>
|
||||
@@ -318,10 +318,10 @@
|
||||
{/if}
|
||||
</article>
|
||||
|
||||
<article class="surface-card">
|
||||
<div class="section-heading">
|
||||
<article class="ui-panel surface-card">
|
||||
<div class="ui-section-heading section-heading">
|
||||
<div>
|
||||
<p class="eyebrow">Product Exposure</p>
|
||||
<p class="ui-eyebrow eyebrow">Product Exposure</p>
|
||||
<h3>Finished outputs linked to live pricing</h3>
|
||||
</div>
|
||||
</div>
|
||||
@@ -354,53 +354,53 @@
|
||||
|
||||
{:else if activeView === 'create'}
|
||||
<section class="top-grid create-grid">
|
||||
<article class="surface-card form-card">
|
||||
<div class="section-heading">
|
||||
<article class="ui-panel surface-card form-card">
|
||||
<div class="ui-section-heading section-heading">
|
||||
<div>
|
||||
<p class="eyebrow">Create Input</p>
|
||||
<p class="ui-eyebrow eyebrow">Create Input</p>
|
||||
<h3>Add a new raw material</h3>
|
||||
</div>
|
||||
<span class="soft-pill">Live costing source</span>
|
||||
<span class="ui-pill positive soft-pill">Live costing source</span>
|
||||
</div>
|
||||
|
||||
<form class="material-form" onsubmit={handleCreateMaterial}>
|
||||
<div class="form-grid">
|
||||
<label>
|
||||
<div class="ui-form-grid form-grid">
|
||||
<label class="ui-field">
|
||||
Name
|
||||
<input name="name" required />
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<label class="ui-field">
|
||||
Supplier
|
||||
<input name="supplier" />
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<label class="ui-field">
|
||||
Unit of measure
|
||||
<input name="unit_of_measure" value="tonne" required />
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<label class="ui-field">
|
||||
Kg per unit
|
||||
<input name="kg_per_unit" type="number" min="0.0001" step="0.0001" value="1000" required />
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<label class="ui-field">
|
||||
Market value
|
||||
<input name="market_value" type="number" min="0.0001" step="0.0001" required />
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<label class="ui-field">
|
||||
Waste percentage
|
||||
<input name="waste_percentage" type="number" min="0" max="1" step="0.0001" value="0" required />
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<label class="ui-field">
|
||||
Effective date
|
||||
<input name="effective_date" type="date" value={today} required />
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<label class="ui-field">
|
||||
Status
|
||||
<select name="status">
|
||||
<option value="active">Active</option>
|
||||
@@ -410,29 +410,29 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-grid single">
|
||||
<label>
|
||||
<div class="ui-form-grid form-grid single">
|
||||
<label class="ui-field">
|
||||
Material notes
|
||||
<textarea name="notes" rows="3"></textarea>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<label class="ui-field">
|
||||
Price notes
|
||||
<textarea name="price_notes" rows="3"></textarea>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button class="primary-button" type="submit" disabled={isCreating}>
|
||||
<button class="ui-button primary primary-button" type="submit" disabled={isCreating}>
|
||||
{isCreating ? 'Creating material...' : 'Create raw material'}
|
||||
</button>
|
||||
</form>
|
||||
</article>
|
||||
|
||||
<div class="summary-stack">
|
||||
<article class="surface-card mini-metric-card">
|
||||
<div class="section-heading">
|
||||
<article class="ui-panel surface-card mini-metric-card">
|
||||
<div class="ui-section-heading section-heading">
|
||||
<div>
|
||||
<p class="eyebrow">Portfolio Health</p>
|
||||
<p class="ui-eyebrow eyebrow">Portfolio Health</p>
|
||||
<h3>Current input coverage</h3>
|
||||
</div>
|
||||
</div>
|
||||
@@ -470,7 +470,7 @@
|
||||
{@const impactedMixes = getImpactedMixes(material.id)}
|
||||
{@const impactedProducts = getImpactedProducts(material.id)}
|
||||
|
||||
<article class="surface-card material-card">
|
||||
<article class="ui-panel material-card">
|
||||
<div class="material-header">
|
||||
<div class="material-title">
|
||||
<span class={`material-icon ${material.status === 'active' ? 'active' : 'muted'}`}>RM</span>
|
||||
@@ -480,7 +480,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span class={`status-pill ${material.status === 'active' ? 'positive' : 'neutral'}`}>{material.status}</span>
|
||||
<span class={`ui-pill ${material.status === 'active' ? 'positive' : 'neutral'}`}>{material.status}</span>
|
||||
</div>
|
||||
|
||||
<div class="material-grid">
|
||||
@@ -505,37 +505,37 @@
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<form class="price-card" onsubmit={(event) => handleAddPrice(event, material.id)}>
|
||||
<div class="section-heading">
|
||||
<form class="ui-panel-soft price-card" onsubmit={(event) => handleAddPrice(event, material.id)}>
|
||||
<div class="ui-section-heading section-heading">
|
||||
<div>
|
||||
<p class="eyebrow">New Version</p>
|
||||
<p class="ui-eyebrow eyebrow">New Version</p>
|
||||
<h4>Record a fresh price</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-grid compact">
|
||||
<label>
|
||||
<div class="ui-form-grid compact form-grid">
|
||||
<label class="ui-field">
|
||||
Market value
|
||||
<input name="market_value" type="number" min="0.0001" step="0.0001" required />
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<label class="ui-field">
|
||||
Waste percentage
|
||||
<input name="waste_percentage" type="number" min="0" max="1" step="0.0001" value="0" required />
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<label class="ui-field">
|
||||
Effective date
|
||||
<input name="effective_date" type="date" value={today} required />
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label>
|
||||
<label class="ui-field">
|
||||
Notes
|
||||
<textarea name="notes" rows="2"></textarea>
|
||||
</label>
|
||||
|
||||
<button class="primary-button" type="submit" disabled={pendingMaterialId === material.id}>
|
||||
<button class="ui-button primary primary-button" type="submit" disabled={pendingMaterialId === material.id}>
|
||||
{pendingMaterialId === material.id ? 'Saving price...' : 'Save price version'}
|
||||
</button>
|
||||
</form>
|
||||
@@ -592,7 +592,7 @@
|
||||
{/each}
|
||||
|
||||
{#if data.rawMaterials.length > pageSize}
|
||||
<div class="pagination surface-card library-pagination">
|
||||
<div class="pagination ui-panel library-pagination">
|
||||
<span class="pagination-summary">Showing {Math.min((materialLibraryPage - 1) * pageSize + 1, data.rawMaterials.length)}-{Math.min(materialLibraryPage * pageSize, data.rawMaterials.length)} of {data.rawMaterials.length}</span>
|
||||
<div class="pagination-actions">
|
||||
<button type="button" class="pagination-button" onclick={() => (materialLibraryPage -= 1)} disabled={materialLibraryPage === 1}>Previous</button>
|
||||
|
||||
@@ -11,270 +11,141 @@
|
||||
const approvedCount = $derived(scenarioRows.filter((scenario) => scenario.status === 'approved').length);
|
||||
</script>
|
||||
|
||||
<section class="metric-row">
|
||||
<article class="metric-card">
|
||||
<section class="ui-metric-row module-section">
|
||||
<article class="ui-metric-card">
|
||||
<span>Total Scenarios</span>
|
||||
<strong>{scenarioRows.length}</strong>
|
||||
<p>Saved planning workspaces</p>
|
||||
</article>
|
||||
|
||||
<article class="metric-card">
|
||||
<article class="ui-metric-card">
|
||||
<span>Approved</span>
|
||||
<strong>{approvedCount}</strong>
|
||||
<p>Ready for pricing reference</p>
|
||||
</article>
|
||||
|
||||
<article class="metric-card">
|
||||
<article class="ui-metric-card">
|
||||
<span>Overrides In Use</span>
|
||||
<strong>{scenarioRows.reduce((sum, row) => sum + row.overrideKeys.length, 0)}</strong>
|
||||
<p>Total override keys across all scenarios</p>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="scenario-list">
|
||||
{#each scenarioRows as scenario}
|
||||
<article class="surface-card">
|
||||
<div class="scenario-header">
|
||||
<div>
|
||||
<p class="eyebrow">Scenario</p>
|
||||
<h3>{scenario.name}</h3>
|
||||
<p>{scenario.description ?? 'No description provided yet.'}</p>
|
||||
</div>
|
||||
<section class="ui-panel module-section">
|
||||
<div class="ui-section-heading">
|
||||
<div>
|
||||
<p class="ui-eyebrow">Scenario Library</p>
|
||||
<h3>Planning scenarios</h3>
|
||||
</div>
|
||||
<span class="ui-pill neutral">{scenarioRows.length} saved</span>
|
||||
</div>
|
||||
|
||||
<span class={`status-pill ${scenario.status === 'approved' ? 'positive' : 'neutral'}`}>{scenario.status}</span>
|
||||
</div>
|
||||
|
||||
<div class="scenario-grid">
|
||||
<section class="detail-card">
|
||||
<div class="detail-row">
|
||||
<span>Override count</span>
|
||||
<strong>{scenario.overrideKeys.length}</strong>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span>Primary state</span>
|
||||
<strong>{scenario.status}</strong>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="detail-card">
|
||||
<p class="eyebrow">Override Keys</p>
|
||||
{#if scenario.overrideKeys.length}
|
||||
<div class="chip-list">
|
||||
{#each scenario.overrideKeys as key}
|
||||
<span>{key}</span>
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<p class="empty">No overrides have been defined yet.</p>
|
||||
{/if}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section class="json-card">
|
||||
<div class="json-header">
|
||||
<h4>Scenario payload</h4>
|
||||
<span>JSON view</span>
|
||||
</div>
|
||||
<pre>{JSON.stringify(scenario.overrides, null, 2)}</pre>
|
||||
</section>
|
||||
</article>
|
||||
{/each}
|
||||
<div class="ui-table-wrap">
|
||||
<table class="ui-table scenario-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Scenario</th>
|
||||
<th>Status</th>
|
||||
<th>Overrides</th>
|
||||
<th>Payload</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each scenarioRows as scenario}
|
||||
<tr>
|
||||
<td data-label="Scenario">
|
||||
<div class="ui-table-identity scenario-identity">
|
||||
<span class="ui-row-mark">SC</span>
|
||||
<div>
|
||||
<strong>{scenario.name}</strong>
|
||||
<span>{scenario.description ?? 'No description provided yet.'}</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td data-label="Status">
|
||||
<span class={`ui-pill ${scenario.status === 'approved' ? 'positive' : 'neutral'}`}>{scenario.status}</span>
|
||||
</td>
|
||||
<td data-label="Overrides">
|
||||
{#if scenario.overrideKeys.length}
|
||||
<div class="chip-list">
|
||||
{#each scenario.overrideKeys as key}
|
||||
<span>{key}</span>
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<span class="ui-muted">No overrides</span>
|
||||
{/if}
|
||||
</td>
|
||||
<td data-label="Payload">
|
||||
<details class="payload-details">
|
||||
<summary>View JSON</summary>
|
||||
<pre>{JSON.stringify(scenario.overrides, null, 2)}</pre>
|
||||
</details>
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<style>
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
p,
|
||||
pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
color: #7f8e85;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.page-intro,
|
||||
.metric-row,
|
||||
.scenario-list {
|
||||
.module-section {
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.page-intro h2 {
|
||||
margin: 0.35rem 0 0.45rem;
|
||||
max-width: 18ch;
|
||||
font-size: clamp(1.7rem, 3vw, 2.2rem);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.page-intro p:last-child,
|
||||
.metric-card p,
|
||||
.scenario-header p:last-child,
|
||||
.empty,
|
||||
.json-header span,
|
||||
pre {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.metric-row,
|
||||
.scenario-grid {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.metric-row {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.metric-card,
|
||||
.surface-card,
|
||||
.detail-card,
|
||||
.json-card {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 1.35rem;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.metric-card {
|
||||
padding: 1.15rem 1.2rem;
|
||||
}
|
||||
|
||||
.metric-card span {
|
||||
display: block;
|
||||
color: var(--muted);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.metric-card strong {
|
||||
display: block;
|
||||
margin: 0.55rem 0 0.3rem;
|
||||
font-size: 1.9rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.scenario-list {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.surface-card {
|
||||
padding: 1.2rem;
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.scenario-header,
|
||||
.detail-row,
|
||||
.json-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.scenario-header h3 {
|
||||
margin: 0.3rem 0 0.4rem;
|
||||
font-size: 1.15rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.status-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0.42rem 0.78rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.84rem;
|
||||
font-weight: 600;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.status-pill.positive {
|
||||
color: var(--green-deep);
|
||||
background: var(--green-soft);
|
||||
}
|
||||
|
||||
.status-pill.neutral {
|
||||
color: #5a6c63;
|
||||
background: #edf2ef;
|
||||
}
|
||||
|
||||
.scenario-grid {
|
||||
grid-template-columns: 0.7fr 1.3fr;
|
||||
}
|
||||
|
||||
.detail-card,
|
||||
.json-card {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.detail-row + .detail-row {
|
||||
margin-top: 0.9rem;
|
||||
}
|
||||
|
||||
.detail-row span {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.detail-row strong {
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.chip-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.6rem;
|
||||
margin-top: 0.7rem;
|
||||
gap: 0.42rem;
|
||||
max-width: 28rem;
|
||||
}
|
||||
|
||||
.chip-list span {
|
||||
padding: 0.45rem 0.7rem;
|
||||
padding: 0.36rem 0.62rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
background: var(--panel-soft);
|
||||
color: #365044;
|
||||
font-size: 0.84rem;
|
||||
color: var(--color-text-secondary);
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.json-header {
|
||||
margin-bottom: 0.8rem;
|
||||
.scenario-table {
|
||||
min-width: 58rem;
|
||||
}
|
||||
|
||||
.json-header h4 {
|
||||
font-size: 1rem;
|
||||
.scenario-identity {
|
||||
min-width: 22rem;
|
||||
}
|
||||
|
||||
.payload-details {
|
||||
max-width: 24rem;
|
||||
}
|
||||
|
||||
.payload-details summary {
|
||||
width: fit-content;
|
||||
color: var(--green-deep);
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 1rem;
|
||||
border-radius: 1rem;
|
||||
background: var(--panel-soft);
|
||||
border: 1px solid var(--line);
|
||||
.payload-details pre {
|
||||
max-height: 14rem;
|
||||
margin-top: 0.7rem;
|
||||
padding: 0.9rem;
|
||||
overflow: auto;
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.metric-row,
|
||||
.scenario-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.scenario-header,
|
||||
.detail-row,
|
||||
.json-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 0.82rem;
|
||||
background: var(--panel);
|
||||
color: var(--muted);
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user