diff --git a/src/model/data_catalogue.rs b/src/model/data_catalogue.rs index 231be2e..ca5b270 100644 --- a/src/model/data_catalogue.rs +++ b/src/model/data_catalogue.rs @@ -29,7 +29,7 @@ use serde::{Deserialize, Serialize}; use crate::model::onkostar_editor::OnkostarEditor; use crate::model::requirements::{Requirement, Requires}; -use crate::model::{Comparable, Listable, Ordner, Sortable}; +use crate::model::{Comparable, FolderContent, Listable, Ordner, Sortable}; #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] @@ -63,7 +63,11 @@ pub struct DataCatalogue { impl Listable for DataCatalogue { fn to_listed_string(&self) -> String { format!( - "Datenkatalog '{}' in Revision '{}'", + "Datenkatalog ({}) '{}' in Revision '{}'", + match self.is_system_library_content() { + true => style("S").yellow(), + _ => style("u"), + }, style(&self.name).yellow(), style(&self.revision).yellow() ) @@ -116,9 +120,8 @@ impl Requires for DataCatalogue { fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String { format!( - "Datenkatalog '{}' in Revision '{}'\n{}", - style(&self.name).yellow(), - style(&self.revision).yellow(), + "{}\n{}", + self.to_listed_string(), self.get_required_entries(all) .iter() .map(|entry| match entry { @@ -135,6 +138,12 @@ impl Requires for DataCatalogue { } } +impl FolderContent for DataCatalogue { + fn get_library_folder(&self) -> String { + self.ordner.bibliothek.name.to_string() + } +} + #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct Entries { diff --git a/src/model/data_form.rs b/src/model/data_form.rs index 27cab99..ffb7432 100644 --- a/src/model/data_form.rs +++ b/src/model/data_form.rs @@ -30,7 +30,7 @@ use serde::{Deserialize, Serialize}; use crate::model::onkostar_editor::OnkostarEditor; use crate::model::requirements::{Requirement, Requires}; use crate::model::{ - apply_profile_to_form_entry, Ansichten, Comparable, Entries, Filter, FormEntry, + apply_profile_to_form_entry, Ansichten, Comparable, Entries, Filter, FolderContent, FormEntry, FormEntryContainer, Listable, MenuCategory, PlausibilityRules, Script, Sortable, }; use crate::model::{Haeufigkeiten, Ordner}; @@ -185,7 +185,11 @@ impl FormEntryContainer for DataForm { impl Listable for DataForm { fn to_listed_string(&self) -> String { format!( - "Formular '{}' in Revision '{}'", + "Formular ({}) '{}' in Revision '{}'", + match self.is_system_library_content() { + true => style("S").yellow(), + _ => style("u"), + }, style(&self.name).yellow(), style(&self.revision).yellow() ) @@ -246,9 +250,8 @@ impl Requires for DataForm { fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String { format!( - "Formular '{}' in Revision '{}'\n{}", - style(&self.name).yellow(), - style(&self.revision).yellow(), + "{}\n{}", + self.to_listed_string(), self.get_required_entries(all) .iter() .map(|entry| match entry { @@ -281,6 +284,12 @@ impl Requires for DataForm { } } +impl FolderContent for DataForm { + fn get_library_folder(&self) -> String { + self.ordner.bibliothek.name.to_string() + } +} + #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct DataCatalogues { diff --git a/src/model/mod.rs b/src/model/mod.rs index 37865cf..18f8094 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -268,3 +268,11 @@ pub trait FormEntry { fn update_anzeige_auswahl(&mut self, value: String); fn update_scripts_code(&mut self, value: String); } + +pub trait FolderContent { + fn get_library_folder(&self) -> String; + + fn is_system_library_content(&self) -> bool { + "ONKOSTAR Bibliothek" == self.get_library_folder() + } +} diff --git a/src/model/onkostar_editor.rs b/src/model/onkostar_editor.rs index 8e2748c..68bee7c 100644 --- a/src/model/onkostar_editor.rs +++ b/src/model/onkostar_editor.rs @@ -97,7 +97,11 @@ impl OnkostarEditor { } fn print_items(title: &str, list: &[impl Listable]) { - println!("\n{} {}", list.len(), style(title).underlined()); + print!("\n{} {}", list.len(), style(title).underlined()); + println!( + " - Inhalte der Systembibliothek sind mit ({}) markiert", + style("S").yellow() + ); list.iter() .for_each(|entry| println!("{}", entry.to_listed_string())); } @@ -117,7 +121,11 @@ impl OnkostarEditor { } fn print_items_tree(&self, title: &str, list: &[impl Requires]) { - println!("\n{} {}", list.len(), style(title).underlined()); + print!("\n{} {}", list.len(), style(title).underlined()); + println!( + " - Inhalte der Systembibliothek sind mit ({}) markiert", + style("S").yellow() + ); list.iter() .for_each(|entry| println!("{}", entry.to_requirement_string(self))); } diff --git a/src/model/property_catalogue.rs b/src/model/property_catalogue.rs index 3d59850..4d31b9e 100644 --- a/src/model/property_catalogue.rs +++ b/src/model/property_catalogue.rs @@ -25,7 +25,7 @@ use console::style; use serde::{Deserialize, Serialize}; -use crate::model::{Comparable, Listable, Ordner, Sortable}; +use crate::model::{Comparable, FolderContent, Listable, Ordner, Sortable}; #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] @@ -56,7 +56,11 @@ pub struct PropertyCatalogue { impl Listable for PropertyCatalogue { fn to_listed_string(&self) -> String { format!( - "Merkmalskatalog '{}' in Revision '{}'", + "Merkmalskatalog ({}) '{}' in Revision '{}'", + match self.is_system_library_content() { + true => style("S").yellow(), + _ => style("u"), + }, style(&self.name).yellow(), style(&self.revision).yellow() ) @@ -89,6 +93,12 @@ impl Comparable for PropertyCatalogue { } } +impl FolderContent for PropertyCatalogue { + fn get_library_folder(&self) -> String { + self.ordner.bibliothek.name.to_string() + } +} + #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct Versions { diff --git a/src/model/unterformular.rs b/src/model/unterformular.rs index be8c721..d08fa39 100644 --- a/src/model/unterformular.rs +++ b/src/model/unterformular.rs @@ -30,7 +30,7 @@ use serde::{Deserialize, Serialize}; use crate::model::onkostar_editor::OnkostarEditor; use crate::model::requirements::{Requirement, Requires}; use crate::model::{ - apply_profile_to_form_entry, Ansichten, Comparable, Entries, Filter, FormEntry, + apply_profile_to_form_entry, Ansichten, Comparable, Entries, Filter, FolderContent, FormEntry, FormEntryContainer, Listable, MenuCategory, PlausibilityRules, Script, Sortable, }; use crate::model::{Haeufigkeiten, Ordner}; @@ -197,14 +197,22 @@ impl Listable for Unterformular { fn to_listed_string(&self) -> String { if self.hat_unterformulare { return format!( - "Unterformular '{}' in Revision '{}' {}", + "Unterformular ({}) '{}' in Revision '{}' {}", + match self.is_system_library_content() { + true => style("S").yellow(), + _ => style("u"), + }, style(&self.name).yellow(), style(&self.revision).yellow(), style("Unterformular mit Markierung 'hat Unterformulare'!").red() ); } format!( - "Unterformular '{}' in Revision '{}'", + "Unterformular ({}) '{}' in Revision '{}'", + match self.is_system_library_content() { + true => style("S").yellow(), + _ => style("u"), + }, style(&self.name).yellow(), style(&self.revision).yellow() ) @@ -265,9 +273,8 @@ impl Requires for Unterformular { fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String { format!( - "Unterformular '{}' in Revision '{}'\n{}", - style(&self.name).yellow(), - style(&self.revision).yellow(), + "{}\n{}", + self.to_listed_string(), self.get_required_entries(all) .iter() .map(|entry| match entry { @@ -300,6 +307,12 @@ impl Requires for Unterformular { } } +impl FolderContent for Unterformular { + fn get_library_folder(&self) -> String { + self.ordner.bibliothek.name.to_string() + } +} + #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct DataCatalogues {