mirror of
https://github.com/pcvolkmer/osc-variant.git
synced 2025-07-03 09:12:54 +00:00
Set filter to "false" if form field should be hidden
This commit is contained in:
@ -31,7 +31,7 @@ use crate::model::onkostar_editor::OnkostarEditor;
|
||||
use crate::model::requirements::{Requirement, Requires};
|
||||
use crate::model::{
|
||||
apply_profile_to_form_entry, Ansichten, Comparable, Entries, Filter, FolderContent, FormEntry,
|
||||
FormEntryContainer, Listable, MenuCategory, PlausibilityRules, Script, Sortable,
|
||||
FormEntryContainer, Listable, MenuCategory, PlausibilityRules, RefEntries, Script, Sortable,
|
||||
};
|
||||
use crate::model::{Haeufigkeiten, Ordner};
|
||||
use crate::profile::Profile;
|
||||
@ -169,6 +169,13 @@ impl FormEntryContainer for DataForm {
|
||||
apply_profile_to_form_entry(entry, form_reference)
|
||||
});
|
||||
|
||||
// Hide form field using filter set to "false" if requested
|
||||
profile_form.form_fields.iter().for_each(|form_field| {
|
||||
if entry.name == form_field.name && form_field.hide {
|
||||
entry.hide()
|
||||
}
|
||||
});
|
||||
|
||||
if let Some(menu_category) = &profile_form.menu_category {
|
||||
self.menu_category = Some(MenuCategory {
|
||||
name: menu_category.name.clone(),
|
||||
@ -525,6 +532,14 @@ impl FormEntry for Entry {
|
||||
valid: true,
|
||||
});
|
||||
}
|
||||
|
||||
fn hide(&mut self) {
|
||||
self.filter = Some(Filter {
|
||||
condition: "false".into(),
|
||||
valid: true,
|
||||
ref_entries: Some(RefEntries { ref_entry: None }),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Sortable for Entry {
|
||||
|
@ -267,6 +267,7 @@ pub trait FormEntry {
|
||||
fn update_anzeige(&mut self, value: String);
|
||||
fn update_anzeige_auswahl(&mut self, value: String);
|
||||
fn update_scripts_code(&mut self, value: String);
|
||||
fn hide(&mut self);
|
||||
}
|
||||
|
||||
pub trait FolderContent {
|
||||
|
@ -31,7 +31,7 @@ use crate::model::onkostar_editor::OnkostarEditor;
|
||||
use crate::model::requirements::{Requirement, Requires};
|
||||
use crate::model::{
|
||||
apply_profile_to_form_entry, Ansichten, Comparable, Entries, Filter, FolderContent, FormEntry,
|
||||
FormEntryContainer, Listable, MenuCategory, PlausibilityRules, Script, Sortable,
|
||||
FormEntryContainer, Listable, MenuCategory, PlausibilityRules, RefEntries, Script, Sortable,
|
||||
};
|
||||
use crate::model::{Haeufigkeiten, Ordner};
|
||||
use crate::profile::Profile;
|
||||
@ -180,6 +180,13 @@ impl FormEntryContainer for Unterformular {
|
||||
apply_profile_to_form_entry(entry, form_reference)
|
||||
});
|
||||
|
||||
// Hide form field using filter set to "false" if requested
|
||||
profile_form.form_fields.iter().for_each(|form_field| {
|
||||
if entry.name == form_field.name && form_field.hide {
|
||||
entry.hide()
|
||||
}
|
||||
});
|
||||
|
||||
if let Some(menu_category) = &profile_form.menu_category {
|
||||
self.menu_category = Some(MenuCategory {
|
||||
name: menu_category.name.clone(),
|
||||
@ -548,6 +555,14 @@ impl FormEntry for Entry {
|
||||
valid: true,
|
||||
});
|
||||
}
|
||||
|
||||
fn hide(&mut self) {
|
||||
self.filter = Some(Filter {
|
||||
condition: "false".into(),
|
||||
valid: true,
|
||||
ref_entries: Some(RefEntries { ref_entry: None }),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Sortable for Entry {
|
||||
|
Reference in New Issue
Block a user