forked from Plugin-JF-Onkostar/osc-variant
Apply exported sorting to items itself and nested items
This commit is contained in:
@@ -192,6 +192,29 @@ impl Sortable for DataForm {
|
||||
fn sorting_key(&self) -> String {
|
||||
self.name.clone()
|
||||
}
|
||||
|
||||
fn sorted(&mut self) -> &Self {
|
||||
self.data_catalogues.data_catalogue.sort_unstable();
|
||||
|
||||
self.entries
|
||||
.entry
|
||||
.sort_unstable_by_key(|item| item.sorting_key());
|
||||
|
||||
self.entries.entry.iter_mut().for_each(|item| {
|
||||
item.sorted();
|
||||
});
|
||||
|
||||
if let Some(ref mut plausibility_rule) = self.plausibility_rules.plausibility_rule {
|
||||
plausibility_rule.sort_unstable_by_key(|item| item.bezeichnung.clone());
|
||||
|
||||
plausibility_rule.iter_mut().for_each(|item| {
|
||||
if let Some(ref mut data_form_entry_names) = item.data_form_entries.entry_name {
|
||||
data_form_entry_names.sort_unstable();
|
||||
}
|
||||
});
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Comparable for DataForm {
|
||||
@@ -433,6 +456,26 @@ impl FormEntry for Entry {
|
||||
}
|
||||
}
|
||||
|
||||
impl Sortable for Entry {
|
||||
fn sorting_key(&self) -> String {
|
||||
self.name.clone()
|
||||
}
|
||||
|
||||
fn sorted(&mut self) -> &Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
if let Some(ref mut filter) = self.filter {
|
||||
if let Some(ref mut ref_entries) = filter.ref_entries {
|
||||
if let Some(ref mut ref_entry) = ref_entries.ref_entry {
|
||||
ref_entry.sort_unstable()
|
||||
}
|
||||
}
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct DataFormEntries {
|
||||
|
||||
Reference in New Issue
Block a user