Add filter option for linked/unlinked TUs (#20)

* forward linked status to ts

* Add filter check for linked/unlinked TUs

* functions reflect linking status of TU

* use correct ts boolean type
This commit is contained in:
roeming
2026-01-31 19:02:48 -07:00
committed by GitHub
parent 573262f1d5
commit 220619d01d
3 changed files with 15 additions and 0 deletions
+7
View File
@@ -77,6 +77,7 @@ pub struct ReportTemplateUnit<'a> {
pub y: f32,
pub w: f32,
pub h: f32,
pub is_linked: bool,
}
#[derive(Serialize, Clone)]
@@ -584,6 +585,7 @@ fn apply_scope<'a>(
}
let (w, h) = query.size();
let mut units = if let Some(unit) = current_unit {
let linked = unit.metadata.as_ref().is_some_and(|m| m.complete.is_some_and(|c| c));
unit.functions
.iter()
.filter_map(|f| {
@@ -603,6 +605,7 @@ fn apply_scope<'a>(
y: 0.0,
w: 0.0,
h: 0.0,
is_linked: linked,
})
})
.collect::<Vec<_>>()
@@ -633,6 +636,10 @@ fn apply_scope<'a>(
y: 0.0,
w: 0.0,
h: 0.0,
is_linked: unit
.metadata
.as_ref()
.is_some_and(|m| m.complete.is_some_and(|c| c)),
})
})
.collect::<Vec<_>>()
Vendored
+1
View File
@@ -9,6 +9,7 @@ type Unit = {
y: number;
w: number;
h: number;
is_linked: boolean;
// Runtime fields
filtered: boolean;
};
+7
View File
@@ -409,7 +409,14 @@ const SPECIAL_TERM_REGEXP = new RegExp(
);
const checkFilterTermMatches = (term: string, unit: Unit): boolean => {
if (term === "is:linked") {
return unit.is_linked;
} else if (term === "is:unlinked") {
return !unit.is_linked;
}
const match = term.match(SPECIAL_TERM_REGEXP);
if (match) {
// Filter based on match percent or size.
const operator = match[1];