Show subform entries in tree subcommand

This commit is contained in:
2023-09-28 17:19:14 +02:00
parent c514005182
commit 1f51d3e994
3 changed files with 68 additions and 0 deletions

View File

@@ -289,6 +289,27 @@ impl Requires for DataForm {
.collect::<Vec<_>>();
result.append(referenced_forms);
let sub_forms = &mut self
.entries
.entry
.iter()
.filter(|&entry| entry.get_type() == "subform")
.filter_map(|entry| match &entry.referenced_data_form {
Some(name) => Some(name),
None => None,
})
.collect::<HashSet<_>>()
.into_iter()
.map(|entry| match all.find_data_form(entry.as_str()) {
Some(contained) => Requirement::DataFormSubform(contained),
None => match all.find_unterformular(entry.as_str()) {
Some(contained) => Requirement::UnterformularSubform(contained),
None => Requirement::ExternalUnterformularSubform(entry.to_string()),
},
})
.collect::<Vec<_>>();
result.append(sub_forms);
result
}
@@ -331,6 +352,12 @@ impl Requires for DataForm {
| Requirement::ExternalUnterformularReference(_) => {
Some(format!(" > {}\n", entry.to_string()))
}
Requirement::DataFormSubform(_)
| Requirement::ExternalDataFormSubform(_)
| Requirement::UnterformularSubform(_)
| Requirement::ExternalUnterformularSubform(_) => {
Some(format!(" $ {}\n", entry.to_string()))
}
_ => None,
})
.filter(Option::is_some)