mirror of
https://github.com/pcvolkmer/osc-variant.git
synced 2025-07-03 09:12:54 +00:00
Add optional sorted listing of file contents
This commit is contained in:
@ -24,7 +24,7 @@
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::model::{Listable, Ordner};
|
||||
use crate::model::{Listable, Ordner, Sortable};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
@ -64,6 +64,12 @@ impl Listable for DataCatalogue {
|
||||
}
|
||||
}
|
||||
|
||||
impl Sortable for DataCatalogue {
|
||||
fn sorting_key(&self) -> String {
|
||||
self.name.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Entries {
|
||||
|
@ -26,7 +26,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::model::{
|
||||
apply_profile_to_form_entry, Ansichten, Entries, Filter, FormEntry, FormEntryContainer,
|
||||
Listable, MenuCategory, PlausibilityRules, Script,
|
||||
Listable, MenuCategory, PlausibilityRules, Script, Sortable,
|
||||
};
|
||||
use crate::model::{Haeufigkeiten, Ordner};
|
||||
use crate::profile::Profile;
|
||||
@ -183,6 +183,12 @@ impl Listable for DataForm {
|
||||
}
|
||||
}
|
||||
|
||||
impl Sortable for DataForm {
|
||||
fn sorting_key(&self) -> String {
|
||||
self.name.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct DataCatalogues {
|
||||
|
@ -234,6 +234,10 @@ pub trait Listable {
|
||||
fn to_listed_string(&self) -> String;
|
||||
}
|
||||
|
||||
pub trait Sortable {
|
||||
fn sorting_key(&self) -> String;
|
||||
}
|
||||
|
||||
pub trait FormEntry {
|
||||
fn get_name(&self) -> String;
|
||||
fn get_type(&self) -> String;
|
||||
|
@ -31,7 +31,7 @@ use crate::model::data_catalogue::DataCatalogue;
|
||||
use crate::model::data_form::DataForm;
|
||||
use crate::model::property_catalogue::PropertyCatalogue;
|
||||
use crate::model::unterformular::Unterformular;
|
||||
use crate::model::{FormEntryContainer, Listable};
|
||||
use crate::model::{FormEntryContainer, Listable, Sortable};
|
||||
use crate::profile::Profile;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
@ -71,6 +71,24 @@ impl OnkostarEditor {
|
||||
list.iter()
|
||||
.for_each(|entry| println!("{}", entry.to_listed_string()));
|
||||
}
|
||||
|
||||
pub fn sorted(&mut self) {
|
||||
self.editor
|
||||
.property_catalogue
|
||||
.sort_unstable_by_key(|e| e.sorting_key());
|
||||
|
||||
self.editor
|
||||
.data_catalogue
|
||||
.sort_unstable_by_key(|e| e.sorting_key());
|
||||
|
||||
self.editor
|
||||
.data_form
|
||||
.sort_unstable_by_key(|e| e.sorting_key());
|
||||
|
||||
self.editor
|
||||
.unterformular
|
||||
.sort_unstable_by_key(|e| e.sorting_key());
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for OnkostarEditor {
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::model::{Listable, Ordner};
|
||||
use crate::model::{Listable, Ordner, Sortable};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
@ -61,6 +61,12 @@ impl Listable for PropertyCatalogue {
|
||||
}
|
||||
}
|
||||
|
||||
impl Sortable for PropertyCatalogue {
|
||||
fn sorting_key(&self) -> String {
|
||||
self.name.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Versions {
|
||||
|
@ -27,7 +27,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::model::{
|
||||
apply_profile_to_form_entry, Ansichten, Entries, Filter, FormEntry, FormEntryContainer,
|
||||
Listable, MenuCategory, PlausibilityRules, Script,
|
||||
Listable, MenuCategory, PlausibilityRules, Script, Sortable,
|
||||
};
|
||||
use crate::model::{Haeufigkeiten, Ordner};
|
||||
use crate::profile::Profile;
|
||||
@ -206,6 +206,12 @@ impl Listable for Unterformular {
|
||||
}
|
||||
}
|
||||
|
||||
impl Sortable for Unterformular {
|
||||
fn sorting_key(&self) -> String {
|
||||
self.name.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct DataCatalogues {
|
||||
|
Reference in New Issue
Block a user