use crate::application::student_information::StudentInformationApplication;
use crate::client::USaintClient;
use serde::{Deserialize, Serialize};
use wdpe::command::WebDynproCommandExecutor;
use wdpe::element::parser::ElementParser;
use wdpe::{
command::element::{
layout::TabStripTabSelectEventCommand, selection::ComboBoxValueCommand,
text::InputFieldValueCommand,
},
define_elements,
element::{
action::Button, layout::tab_strip::item::TabStripItem, selection::ComboBox,
text::InputField,
},
error::WebDynproError,
};
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
pub struct StudentBankAccount {
bank: Option<String>,
account_number: Option<String>,
holder: Option<String>,
}
impl<'a> StudentBankAccount {
define_elements! {
TAB_BANK_CP: TabStripItem<'a> = "ZCMW1001.ID_0001:VIW_MAIN.TAB_BANK_CP";
LIST_BANKS: ComboBox<'a> = "ZCMW1001.ID_0001:VIW_TAB_BANK_CP.LIST_BANKS";
BANKN: InputField<'a> = "ZCMW1001.ID_0001:VIW_TAB_BANK_CP.BANKN";
ZKOINH: InputField<'a> = "ZCMW1001.ID_0001:VIW_TAB_BANK_CP.ZKOINH";
#[allow(unused)]
MODIFY_BUTTON: Button<'a> = "ZCMW1001.ID_0001:VIW_TAB_BANK_CP.MODIFY_BUTTON";
#[allow(unused)]
SAVE_BUTTON: Button<'a> = "ZCMW1001.ID_0001:VIW_TAB_BANK_CP.SAVE_BUTTON";
}
pub(crate) async fn with_client(client: &mut USaintClient) -> Result<Self, WebDynproError> {
let mut parser = ElementParser::new(client.body());
let event = parser.read(TabStripTabSelectEventCommand::new(
StudentInformationApplication::TAB_ADDITION,
Self::TAB_BANK_CP,
4,
0,
))?;
client.process_event(false, event).await?;
parser = ElementParser::new(client.body());
Ok(Self {
bank: parser
.read(ComboBoxValueCommand::new(Self::LIST_BANKS))
.ok(),
account_number: parser.read(InputFieldValueCommand::new(Self::BANKN)).ok(),
holder: parser.read(InputFieldValueCommand::new(Self::ZKOINH)).ok(),
})
}
pub fn bank(&self) -> Option<&str> {
self.bank.as_deref()
}
pub fn account_number(&self) -> Option<&str> {
self.account_number.as_deref()
}
pub fn holder(&self) -> Option<&str> {
self.holder.as_deref()
}
}