diff --git a/sos21-domain/src/model/form/item.rs b/sos21-domain/src/model/form/item.rs index 006f3fc46..7076cf3b5 100644 --- a/sos21-domain/src/model/form/item.rs +++ b/sos21-domain/src/model/form/item.rs @@ -617,7 +617,7 @@ impl CheckFormItems { #[cfg(test)] mod tests { use super::{ - radio::{RadioFormItem, RadioFormItemButtons, RadioId}, + radio::{Appearance, RadioFormItem, RadioFormItemButtons, RadioId}, CheckAnswerErrorKind, CheckAnswerItemErrorKind, CheckFormItems, FormItemBody, FormItemCondition, FormItemId, FormItems, FromItemsErrorKind, }; @@ -828,6 +828,7 @@ mod tests { buttons: RadioFormItemButtons::from_buttons(vec![radio1.clone(), radio2.clone()]) .unwrap(), is_required: true, + appearance: Appearance::RadioButton, })); let condition = FormItemCondition::RadioSelected { item_id: item1.id, diff --git a/sos21-domain/src/model/form/item/radio.rs b/sos21-domain/src/model/form/item/radio.rs index 0a0d752dc..c4cc6283c 100644 --- a/sos21-domain/src/model/form/item/radio.rs +++ b/sos21-domain/src/model/form/item/radio.rs @@ -16,6 +16,13 @@ pub use radio::{Radio, RadioId, RadioLabel}; #[serde(transparent)] pub struct RadioFormItemButtons(LengthBoundedVec); +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[serde(untagged)] +pub enum Appearance { + DropDown, + RadioButton, +} + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum FromButtonsErrorKind { Empty, @@ -93,6 +100,7 @@ impl<'de> Deserialize<'de> for RadioFormItemButtons { pub struct RadioFormItem { pub buttons: RadioFormItemButtons, pub is_required: bool, + pub appearance: Appearance, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -146,7 +154,7 @@ impl RadioFormItem { #[cfg(test)] mod tests { - use super::{CheckAnswerErrorKind, RadioFormItem, RadioFormItemButtons}; + use super::{Appearance, CheckAnswerErrorKind, RadioFormItem, RadioFormItemButtons}; use crate::test::model as test_model; #[test] @@ -158,6 +166,7 @@ mod tests { buttons: RadioFormItemButtons::from_buttons(vec![button1.clone(), button2.clone()]) .unwrap(), is_required: true, + appearance: Appearance::RadioButton, } .check_answer(Some(button1.id)) .unwrap(); @@ -166,6 +175,7 @@ mod tests { buttons: RadioFormItemButtons::from_buttons(vec![button1.clone(), button2.clone()]) .unwrap(), is_required: false, + appearance: Appearance::RadioButton, } .check_answer(None) .unwrap(); @@ -181,6 +191,7 @@ mod tests { buttons: RadioFormItemButtons::from_buttons(vec![button1.clone(), button2.clone()]) .unwrap(), is_required: true, + appearance: Appearance::RadioButton } .check_answer(None) .unwrap_err() @@ -200,6 +211,7 @@ mod tests { buttons: RadioFormItemButtons::from_buttons(vec![button1.clone(), button2.clone()]) .unwrap(), is_required: true, + appearance: Appearance::RadioButton } .check_answer(Some(button3.id)) .unwrap_err() diff --git a/sos21-domain/src/test/model/form/item.rs b/sos21-domain/src/test/model/form/item.rs index a8374d5b0..33b0e0843 100644 --- a/sos21-domain/src/test/model/form/item.rs +++ b/sos21-domain/src/test/model/form/item.rs @@ -4,7 +4,7 @@ use crate::model::form::item::{ GridRadioColumn, GridRadioColumnId, GridRadioColumnLabel, GridRadioRow, GridRadioRowId, GridRadioRowLabel, }, - radio::{Radio, RadioFormItemButtons, RadioId, RadioLabel}, + radio::{Appearance, Radio, RadioFormItemButtons, RadioId, RadioLabel}, FormItem, FormItemBody, FormItemCondition, FormItemConditions, FormItemDescription, FormItemId, FormItemName, FormItems, RadioFormItem, }; @@ -85,6 +85,7 @@ pub fn new_radio_form_item_body_with_button(button: Radio) -> FormItemBody { FormItemBody::Radio(RadioFormItem { buttons: RadioFormItemButtons::from_buttons(vec![button]).unwrap(), is_required: true, + appearance: Appearance::RadioButton, }) } diff --git a/sos21-use-case/src/interface/form/item.rs b/sos21-use-case/src/interface/form/item.rs index 1a01b44e2..36122682a 100644 --- a/sos21-use-case/src/interface/form/item.rs +++ b/sos21-use-case/src/interface/form/item.rs @@ -244,6 +244,7 @@ pub fn to_form_item(item: FormItem) -> Result { FormItemBody::Radio { buttons, is_required, + appearance, } => { let buttons = buttons .into_iter() @@ -254,6 +255,7 @@ pub fn to_form_item(item: FormItem) -> Result { let radio_item = item::RadioFormItem { buttons, is_required, + appearance, }; item::FormItemBody::Radio(radio_item) }