1
0
mirror of https://github.com/pcvolkmer/osc-variant.git synced 2025-04-19 19:56:50 +00:00

Mark system library content

This commit is contained in:
Paul-Christian Volkmer 2023-08-31 11:32:51 +02:00
parent 0b0188bd30
commit a8851c5e4f
6 changed files with 77 additions and 20 deletions

View File

@ -29,7 +29,7 @@ use serde::{Deserialize, Serialize};
use crate::model::onkostar_editor::OnkostarEditor; use crate::model::onkostar_editor::OnkostarEditor;
use crate::model::requirements::{Requirement, Requires}; 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)] #[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
@ -63,7 +63,11 @@ pub struct DataCatalogue {
impl Listable for DataCatalogue { impl Listable for DataCatalogue {
fn to_listed_string(&self) -> String { fn to_listed_string(&self) -> String {
format!( 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.name).yellow(),
style(&self.revision).yellow() style(&self.revision).yellow()
) )
@ -116,9 +120,8 @@ impl Requires for DataCatalogue {
fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String { fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String {
format!( format!(
"Datenkatalog '{}' in Revision '{}'\n{}", "{}\n{}",
style(&self.name).yellow(), self.to_listed_string(),
style(&self.revision).yellow(),
self.get_required_entries(all) self.get_required_entries(all)
.iter() .iter()
.map(|entry| match entry { .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)] #[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct Entries { pub struct Entries {

View File

@ -30,7 +30,7 @@ use serde::{Deserialize, Serialize};
use crate::model::onkostar_editor::OnkostarEditor; use crate::model::onkostar_editor::OnkostarEditor;
use crate::model::requirements::{Requirement, Requires}; use crate::model::requirements::{Requirement, Requires};
use crate::model::{ 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, FormEntryContainer, Listable, MenuCategory, PlausibilityRules, Script, Sortable,
}; };
use crate::model::{Haeufigkeiten, Ordner}; use crate::model::{Haeufigkeiten, Ordner};
@ -185,7 +185,11 @@ impl FormEntryContainer for DataForm {
impl Listable for DataForm { impl Listable for DataForm {
fn to_listed_string(&self) -> String { fn to_listed_string(&self) -> String {
format!( 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.name).yellow(),
style(&self.revision).yellow() style(&self.revision).yellow()
) )
@ -246,9 +250,8 @@ impl Requires for DataForm {
fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String { fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String {
format!( format!(
"Formular '{}' in Revision '{}'\n{}", "{}\n{}",
style(&self.name).yellow(), self.to_listed_string(),
style(&self.revision).yellow(),
self.get_required_entries(all) self.get_required_entries(all)
.iter() .iter()
.map(|entry| match entry { .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)] #[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct DataCatalogues { pub struct DataCatalogues {

View File

@ -268,3 +268,11 @@ pub trait FormEntry {
fn update_anzeige_auswahl(&mut self, value: String); fn update_anzeige_auswahl(&mut self, value: String);
fn update_scripts_code(&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()
}
}

View File

@ -97,7 +97,11 @@ impl OnkostarEditor {
} }
fn print_items(title: &str, list: &[impl Listable]) { 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() list.iter()
.for_each(|entry| println!("{}", entry.to_listed_string())); .for_each(|entry| println!("{}", entry.to_listed_string()));
} }
@ -117,7 +121,11 @@ impl OnkostarEditor {
} }
fn print_items_tree(&self, title: &str, list: &[impl Requires]) { 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() list.iter()
.for_each(|entry| println!("{}", entry.to_requirement_string(self))); .for_each(|entry| println!("{}", entry.to_requirement_string(self)));
} }

View File

@ -25,7 +25,7 @@
use console::style; use console::style;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::model::{Comparable, Listable, Ordner, Sortable}; use crate::model::{Comparable, FolderContent, Listable, Ordner, Sortable};
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
@ -56,7 +56,11 @@ pub struct PropertyCatalogue {
impl Listable for PropertyCatalogue { impl Listable for PropertyCatalogue {
fn to_listed_string(&self) -> String { fn to_listed_string(&self) -> String {
format!( 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.name).yellow(),
style(&self.revision).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)] #[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct Versions { pub struct Versions {

View File

@ -30,7 +30,7 @@ use serde::{Deserialize, Serialize};
use crate::model::onkostar_editor::OnkostarEditor; use crate::model::onkostar_editor::OnkostarEditor;
use crate::model::requirements::{Requirement, Requires}; use crate::model::requirements::{Requirement, Requires};
use crate::model::{ 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, FormEntryContainer, Listable, MenuCategory, PlausibilityRules, Script, Sortable,
}; };
use crate::model::{Haeufigkeiten, Ordner}; use crate::model::{Haeufigkeiten, Ordner};
@ -197,14 +197,22 @@ impl Listable for Unterformular {
fn to_listed_string(&self) -> String { fn to_listed_string(&self) -> String {
if self.hat_unterformulare { if self.hat_unterformulare {
return format!( 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.name).yellow(),
style(&self.revision).yellow(), style(&self.revision).yellow(),
style("Unterformular mit Markierung 'hat Unterformulare'!").red() style("Unterformular mit Markierung 'hat Unterformulare'!").red()
); );
} }
format!( 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.name).yellow(),
style(&self.revision).yellow() style(&self.revision).yellow()
) )
@ -265,9 +273,8 @@ impl Requires for Unterformular {
fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String { fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String {
format!( format!(
"Unterformular '{}' in Revision '{}'\n{}", "{}\n{}",
style(&self.name).yellow(), self.to_listed_string(),
style(&self.revision).yellow(),
self.get_required_entries(all) self.get_required_entries(all)
.iter() .iter()
.map(|entry| match entry { .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)] #[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct DataCatalogues { pub struct DataCatalogues {