mirror of
https://github.com/pcvolkmer/osc-variant.git
synced 2025-04-19 11:46:50 +00:00
Extract method to apply form field profile part
This commit is contained in:
parent
1e7a95bb09
commit
3ec51099c7
@ -30,8 +30,9 @@ 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, FolderContent, FormEntry,
|
||||
FormEntryContainer, Listable, MenuCategory, PlausibilityRules, RefEntries, Script, Sortable,
|
||||
apply_profile_to_form_entry, apply_profile_to_form_field, Ansichten, Comparable, Entries,
|
||||
Filter, FolderContent, FormEntry, FormEntryContainer, Listable, MenuCategory,
|
||||
PlausibilityRules, RefEntries, Script, Sortable,
|
||||
};
|
||||
use crate::model::{Haeufigkeiten, Ordner};
|
||||
use crate::profile::Profile;
|
||||
@ -170,11 +171,10 @@ impl FormEntryContainer for DataForm {
|
||||
});
|
||||
|
||||
// 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()
|
||||
}
|
||||
});
|
||||
profile_form
|
||||
.form_fields
|
||||
.iter()
|
||||
.for_each(|form_field| apply_profile_to_form_field(entry, form_field));
|
||||
|
||||
if let Some(menu_category) = &profile_form.menu_category {
|
||||
self.menu_category = Some(MenuCategory {
|
||||
|
@ -28,7 +28,7 @@ use std::hash::{Hash, Hasher};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::profile::{FormReference, Profile};
|
||||
use crate::profile::{FormField, FormReference, Profile};
|
||||
|
||||
pub mod data_catalogue;
|
||||
pub mod data_form;
|
||||
@ -232,6 +232,15 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_profile_to_form_field<E>(entry: &mut E, form_field: &FormField)
|
||||
where
|
||||
E: FormEntry,
|
||||
{
|
||||
if entry.get_name() == form_field.name && form_field.hide {
|
||||
entry.hide()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait FormEntryContainer {
|
||||
fn apply_profile(&mut self, profile: &Profile);
|
||||
}
|
||||
|
@ -30,8 +30,9 @@ 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, FolderContent, FormEntry,
|
||||
FormEntryContainer, Listable, MenuCategory, PlausibilityRules, RefEntries, Script, Sortable,
|
||||
apply_profile_to_form_entry, apply_profile_to_form_field, Ansichten, Comparable, Entries,
|
||||
Filter, FolderContent, FormEntry, FormEntryContainer, Listable, MenuCategory,
|
||||
PlausibilityRules, RefEntries, Script, Sortable,
|
||||
};
|
||||
use crate::model::{Haeufigkeiten, Ordner};
|
||||
use crate::profile::Profile;
|
||||
@ -181,11 +182,10 @@ impl FormEntryContainer for Unterformular {
|
||||
});
|
||||
|
||||
// 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()
|
||||
}
|
||||
});
|
||||
profile_form
|
||||
.form_fields
|
||||
.iter()
|
||||
.for_each(|form_field| apply_profile_to_form_field(entry, form_field));
|
||||
|
||||
if let Some(menu_category) = &profile_form.menu_category {
|
||||
self.menu_category = Some(MenuCategory {
|
||||
|
Loading…
x
Reference in New Issue
Block a user