feat(dashboard): fold the Lieferkette's components in no product (#1050)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 5m43s
CI / Check (pull_request) Successful in 21m41s
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 5m43s
CI / Check (pull_request) Successful in 21m41s
On stage the workspace has 32 components, 26 of them in no product, and the
components' column ran 3700 px down the page. Once a workspace has a
product, its components in no product, and the suppliers that supply only
those, now fold into one box at the end of the components ("26 Prüfobjekte
ohne Produkt"); a click unfolds them into the graph and folds them back.
Nothing folds without a product.
The arrangement now keeps only the boxes someone placed; every other box
takes its computed place each time, so unfolding (or a new box) never
freezes the columns around it. Reset clears what was placed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
This commit is contained in:
1 parent
1376efa249
commit
cc1f13485c
4 files changed
+199
-12
No files matched your search
@@ -8943,3 +8943,34 @@ span.repo-crumb-name {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
.chain-fold {
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
color: var(--text-primary);
|
||||
background: var(--bg-elevated);
|
||||
border: 1px solid var(--border-bright);
|
||||
border-radius: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.chain-fold:hover { border-color: var(--border-accent); }
|
||||
.chain-fold-count {
|
||||
flex: none;
|
||||
min-width: 34px;
|
||||
height: 34px;
|
||||
padding: 0 6px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 9px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: var(--bg-card);
|
||||
background: var(--text-tertiary);
|
||||
}
|
||||
@@ -7799,6 +7799,25 @@ pub mod supply_chain {
|
||||
de: "Upload-Link aktiv",
|
||||
en: "Upload link active",
|
||||
};
|
||||
pub const UNFOLD: Text = Text {
|
||||
de: "aufklappen",
|
||||
en: "show them",
|
||||
};
|
||||
pub const FOLD: Text = Text {
|
||||
de: "einklappen",
|
||||
en: "fold them away",
|
||||
};
|
||||
|
||||
/// "26 Prüfobjekte ohne Produkt".
|
||||
pub fn folded(n: usize, lang: Lang) -> String {
|
||||
match (lang, n) {
|
||||
(Lang::De, 1) => "1 Prüfobjekt ohne Produkt".to_string(),
|
||||
(Lang::De, n) => format!("{n} Prüfobjekte ohne Produkt"),
|
||||
(Lang::En, 1) => "1 target in no product".to_string(),
|
||||
(Lang::En, n) => format!("{n} targets in no product"),
|
||||
}
|
||||
}
|
||||
|
||||
pub const DOCUMENTS: Text = Text {
|
||||
de: "Unterlagen",
|
||||
en: "Documents",
|
||||
|
||||
@@ -247,6 +247,11 @@ fn delivery_label(
|
||||
Some((class, text))
|
||||
}
|
||||
|
||||
/// Where the box of the components in no product sits: the components'
|
||||
/// column, and its size.
|
||||
const FOLD_X: i32 = 420;
|
||||
const FOLD_SIZE: (i32, i32) = (210, 64);
|
||||
|
||||
/// Up to how many components the graph offers its next steps as ghost
|
||||
/// boxes: the first-component state (#1050).
|
||||
const EARLY_COMPONENTS: usize = 2;
|
||||
@@ -353,6 +358,60 @@ fn ghost_boxes(
|
||||
ghosts
|
||||
}
|
||||
|
||||
/// The boxes folded away while the workspace has a product: its components
|
||||
/// in no product, and the suppliers that supply only those. Nothing folds
|
||||
/// without a product, as there would be nothing left to show.
|
||||
fn folded_keys(chain: &SupplyChainDto) -> HashSet<String> {
|
||||
if !chain.nodes.iter().any(|n| n.kind == NodeKind::Project) {
|
||||
return HashSet::new();
|
||||
}
|
||||
let in_product: HashSet<&str> = chain
|
||||
.edges
|
||||
.iter()
|
||||
.filter(|e| e.kind == EdgeKind::PartOf)
|
||||
.map(|e| e.from.as_str())
|
||||
.collect();
|
||||
let mut folded: HashSet<String> = chain
|
||||
.nodes
|
||||
.iter()
|
||||
.filter(|n| n.kind == NodeKind::Target && !in_product.contains(n.key.as_str()))
|
||||
.map(|n| n.key.clone())
|
||||
.collect();
|
||||
let suppliers: Vec<String> = chain
|
||||
.nodes
|
||||
.iter()
|
||||
.filter(|n| n.kind == NodeKind::Supplier)
|
||||
.filter(|n| {
|
||||
chain
|
||||
.edges
|
||||
.iter()
|
||||
.filter(|e| e.from == n.key)
|
||||
.all(|e| folded.contains(&e.to))
|
||||
})
|
||||
.map(|n| n.key.clone())
|
||||
.collect();
|
||||
folded.extend(suppliers);
|
||||
folded
|
||||
}
|
||||
|
||||
/// `chain` without the boxes `keys` and their edges.
|
||||
fn without(chain: &SupplyChainDto, keys: &HashSet<String>) -> SupplyChainDto {
|
||||
SupplyChainDto {
|
||||
nodes: chain
|
||||
.nodes
|
||||
.iter()
|
||||
.filter(|n| !keys.contains(&n.key))
|
||||
.cloned()
|
||||
.collect(),
|
||||
edges: chain
|
||||
.edges
|
||||
.iter()
|
||||
.filter(|e| !keys.contains(&e.from) && !keys.contains(&e.to))
|
||||
.cloned()
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
/// A drag in progress: the box, where the pointer started and where the box was.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
struct Drag {
|
||||
@@ -404,16 +463,16 @@ fn ChainView(chain: SupplyChainDto, layout: LayoutDto) -> Element {
|
||||
let can_write = use_can_write();
|
||||
let portal_url = use_context::<Signal<AuthInfo>>().read().portal_url.clone();
|
||||
let mut toasts = use_context::<Toasts>();
|
||||
let defaults = use_hook(|| default_positions(&chain));
|
||||
// The boxes someone placed; every other box takes its computed place, so
|
||||
// unfolding or a new box never freezes the columns around it.
|
||||
let mut pos = use_signal(|| {
|
||||
let mut p = defaults.clone();
|
||||
for saved in &layout.positions {
|
||||
if let Some(slot) = p.get_mut(&saved.key) {
|
||||
*slot = (saved.x, saved.y);
|
||||
}
|
||||
}
|
||||
p
|
||||
layout
|
||||
.positions
|
||||
.iter()
|
||||
.map(|p| (p.key.clone(), (p.x, p.y)))
|
||||
.collect::<HashMap<String, (i32, i32)>>()
|
||||
});
|
||||
let mut unfolded = use_signal(|| false);
|
||||
let first = chain
|
||||
.nodes
|
||||
.iter()
|
||||
@@ -442,8 +501,20 @@ fn ChainView(chain: SupplyChainDto, layout: LayoutDto) -> Element {
|
||||
};
|
||||
|
||||
let now = chrono::Utc::now();
|
||||
let folded = folded_keys(&chain);
|
||||
let loose = folded.iter().filter(|k| k.starts_with("target:")).count();
|
||||
let chain = if unfolded() {
|
||||
chain.clone()
|
||||
} else {
|
||||
without(&chain, &folded)
|
||||
};
|
||||
let rel = related(&chain, &selected.read());
|
||||
let p = pos.read().clone();
|
||||
let mut p = default_positions(&chain);
|
||||
for (key, at) in pos.read().iter() {
|
||||
if let Some(slot) = p.get_mut(key) {
|
||||
*slot = *at;
|
||||
}
|
||||
}
|
||||
let by_key: HashMap<&str, &NodeDto> = chain.nodes.iter().map(|n| (n.key.as_str(), n)).collect();
|
||||
// Read-only roles add nothing, so they see no next steps.
|
||||
let ghosts = if can_write {
|
||||
@@ -451,11 +522,23 @@ fn ChainView(chain: SupplyChainDto, layout: LayoutDto) -> Element {
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
// The folded box sits last in the components' column.
|
||||
let fold_at = (loose > 0).then(|| {
|
||||
let bottom = chain
|
||||
.nodes
|
||||
.iter()
|
||||
.filter(|n| n.kind == NodeKind::Target)
|
||||
.filter_map(|n| p.get(&n.key).map(|(_, y)| y + size(n).1))
|
||||
.chain(ghosts.iter().filter(|g| g.x == FOLD_X).map(|g| g.y + g.h))
|
||||
.max();
|
||||
(FOLD_X, bottom.map_or(TOP, |b| b + GAP))
|
||||
});
|
||||
let boxes = chain
|
||||
.nodes
|
||||
.iter()
|
||||
.map(|n| (p.get(&n.key).copied().unwrap_or((0, 0)), size(n)))
|
||||
.chain(ghosts.iter().map(|g| ((g.x, g.y), (g.w, g.h))));
|
||||
.chain(ghosts.iter().map(|g| ((g.x, g.y), (g.w, g.h))))
|
||||
.chain(fold_at.map(|at| (at, FOLD_SIZE)));
|
||||
let (width, height) = boxes.fold((0, 0), |(w, h), ((x, y), (nw, nh))| {
|
||||
(w.max(x + nw + MARGIN), h.max(y + nh + MARGIN))
|
||||
});
|
||||
@@ -498,7 +581,6 @@ fn ChainView(chain: SupplyChainDto, layout: LayoutDto) -> Element {
|
||||
|
||||
let sel = selected.read().clone();
|
||||
let picked = by_key.get(sel.as_str()).copied();
|
||||
let reset_chain = chain.clone();
|
||||
|
||||
rsx! {
|
||||
div { class: "chain-toolbar",
|
||||
@@ -513,7 +595,7 @@ fn ChainView(chain: SupplyChainDto, layout: LayoutDto) -> Element {
|
||||
class: "btn btn-secondary",
|
||||
r#type: "button",
|
||||
onclick: move |_| {
|
||||
pos.set(default_positions(&reset_chain));
|
||||
pos.set(HashMap::new());
|
||||
spawn(async move {
|
||||
if reset_supply_chain_layout().await.is_err() {
|
||||
toasts.push(ToastType::Error, tx::SAVE_FAILED.get(lang).to_string());
|
||||
@@ -581,6 +663,22 @@ fn ChainView(chain: SupplyChainDto, layout: LayoutDto) -> Element {
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some((fx, fy)) = fold_at {
|
||||
button {
|
||||
class: "chain-fold",
|
||||
r#type: "button",
|
||||
style: "left: {fx}px; top: {fy}px; width: {FOLD_SIZE.0}px; height: {FOLD_SIZE.1}px;",
|
||||
"aria-expanded": if unfolded() { "true" } else { "false" },
|
||||
onclick: move |_| unfolded.set(!unfolded()),
|
||||
span { class: "chain-fold-count", "{loose}" }
|
||||
span { class: "chain-node-text",
|
||||
span { class: "chain-node-name", {tx::folded(loose, lang)} }
|
||||
span { class: "chain-node-sub",
|
||||
if unfolded() { {tx::FOLD.get(lang)} } else { {tx::UNFOLD.get(lang)} }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for g in ghosts.iter().cloned() {
|
||||
{
|
||||
let style = format!("left: {}px; top: {}px; width: {}px; height: {}px;", g.x, g.y, g.w, g.h);
|
||||
@@ -1006,6 +1104,38 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn components_in_no_product_fold_with_their_own_suppliers() {
|
||||
use EdgeKind::Supplies;
|
||||
let mut c = chain();
|
||||
c.nodes.push(node("target:loose", NodeKind::Target, None));
|
||||
c.nodes.push(node("target:loose2", NodeKind::Target, None));
|
||||
c.nodes.push(node("supplier:C", NodeKind::Supplier, None));
|
||||
c.edges.push(edge("supplier:C", "target:loose", Supplies));
|
||||
// A supplies a component in a product and a loose one: it stays.
|
||||
c.edges.push(edge("supplier:A", "target:loose2", Supplies));
|
||||
|
||||
let folded = folded_keys(&c);
|
||||
|
||||
let expected: HashSet<String> = ["target:loose", "target:loose2", "supplier:C"]
|
||||
.map(String::from)
|
||||
.into();
|
||||
assert_eq!(folded, expected);
|
||||
let shown = without(&c, &folded);
|
||||
assert!(shown.nodes.iter().any(|n| n.key == "supplier:A"));
|
||||
assert!(!shown.edges.iter().any(|e| e.to == "target:loose2"));
|
||||
assert_eq!(shown.edges.len(), c.edges.len() - 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nothing_folds_without_a_product() {
|
||||
let c = SupplyChainDto {
|
||||
nodes: vec![node("target:a", NodeKind::Target, None)],
|
||||
edges: Vec::new(),
|
||||
};
|
||||
assert!(folded_keys(&c).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_file_size_reads_in_the_language() {
|
||||
assert_eq!(size_text(1_258_291, Lang::De), "1,2 MB");
|
||||
|
||||
@@ -35,6 +35,13 @@ Die Linie vom Zulieferer zur Komponente sagt, wie deren SBOM ankommt:
|
||||
SBOM hochgeladen.
|
||||
- **noch keine SBOM** (gestrichelt).
|
||||
|
||||
## Prüfobjekte ohne Produkt
|
||||
|
||||
Sobald Ihr Workspace ein Produkt hat, sind Prüfobjekte, die zu keinem
|
||||
Produkt gehören, in einem Kasten am Ende der Komponenten zusammengefasst
|
||||
(„26 Prüfobjekte ohne Produkt“), mit den Zulieferern, die nur sie
|
||||
beliefern. Ein Klick klappt sie auf und wieder ein.
|
||||
|
||||
## Anordnen
|
||||
|
||||
Ziehen Sie die Kästen mit der Maus, oder wählen Sie einen Kasten mit der
|
||||
|
||||
Reference in new issue
Block a user