]> saetta.ns0.it Git - rust/zakform/commitdiff
Field: added get/set_to_load/save.
authorAndrea Zagli <azagli@libero.it>
Sat, 4 Mar 2023 14:11:23 +0000 (15:11 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 4 Mar 2023 14:11:23 +0000 (15:11 +0100)
src/fields.rs

index 38f16b14c363f025fb4849ef4ac93125a92ae987..62e68b002b6c46f1c8700eeb664c4f20fe68ac81 100644 (file)
@@ -12,6 +12,8 @@ struct Field {
        invisible: bool,
        help: String,
        value: String,
+       to_load: bool,
+       to_save: bool,
        tmpl: tera::Tera,
        filters: Vec<super::filters::Filter>,
 }
@@ -34,6 +36,12 @@ pub trait TField {
        fn get_value(&self) -> String;
        fn set_value(&mut self, value: &str);
 
+       fn get_to_load(&self) -> bool;
+       fn set_to_load(&mut self, to_load: bool);
+
+       fn get_to_save(&self) -> bool;
+       fn set_to_save(&mut self, to_save: bool);
+
        fn add_filter(&mut self, filter: super::filters::Filter);
 
        fn filter(&mut self);
@@ -94,6 +102,22 @@ impl TField for FieldText {
                self.field.value = String::from(value);
        }
 
+       fn get_to_load(&self) -> bool {
+               self.field.to_load
+       }
+
+       fn set_to_load(&mut self, load: bool) {
+               self.field.to_load = load;
+       }
+
+       fn get_to_save(&self) -> bool {
+               self.field.to_save
+       }
+
+       fn set_to_save(&mut self, save: bool) {
+               self.field.to_save = save;
+       }
+
        fn add_filter(&mut self, filter: super::filters::Filter) {
                self.field.filters.push(filter);
        }
@@ -205,6 +229,22 @@ impl TField for FieldTextArea {
                self.field.value = String::from(value);
        }
 
+       fn get_to_load(&self) -> bool {
+               self.field.to_load
+       }
+
+       fn set_to_load(&mut self, load: bool) {
+               self.field.to_load = load;
+       }
+
+       fn get_to_save(&self) -> bool {
+               self.field.to_save
+       }
+
+       fn set_to_save(&mut self, save: bool) {
+               self.field.to_save = save;
+       }
+
        fn add_filter(&mut self, filter: super::filters::Filter) {
                self.field.filters.push(filter);
        }
@@ -333,6 +373,22 @@ impl TField for FieldRadio {
                self.field.value = String::from(value);
        }
 
+       fn get_to_load(&self) -> bool {
+               self.field.to_load
+       }
+
+       fn set_to_load(&mut self, load: bool) {
+               self.field.to_load = load;
+       }
+
+       fn get_to_save(&self) -> bool {
+               self.field.to_save
+       }
+
+       fn set_to_save(&mut self, save: bool) {
+               self.field.to_save = save;
+       }
+
        fn add_filter(&mut self, filter: super::filters::Filter) {
                self.field.filters.push(filter);
        }
@@ -477,6 +533,22 @@ impl TField for FieldSelect {
                self.field.value = String::from(value);
        }
 
+       fn get_to_load(&self) -> bool {
+               self.field.to_load
+       }
+
+       fn set_to_load(&mut self, load: bool) {
+               self.field.to_load = load;
+       }
+
+       fn get_to_save(&self) -> bool {
+               self.field.to_save
+       }
+
+       fn set_to_save(&mut self, save: bool) {
+               self.field.to_save = save;
+       }
+
        fn add_filter(&mut self, filter: super::filters::Filter) {
                self.field.filters.push(filter);
        }
@@ -586,6 +658,22 @@ impl TField for FieldCheck {
                self.field.value = String::from(value);
        }
 
+       fn get_to_load(&self) -> bool {
+               self.field.to_load
+       }
+
+       fn set_to_load(&mut self, load: bool) {
+               self.field.to_load = load;
+       }
+
+       fn get_to_save(&self) -> bool {
+               self.field.to_save
+       }
+
+       fn set_to_save(&mut self, save: bool) {
+               self.field.to_save = save;
+       }
+
        fn add_filter(&mut self, filter: super::filters::Filter) {
                self.field.filters.push(filter);
        }