widget: bump to 0.1.5-alpha2

* typo cleanup
* temporary disable mail-cc combobox
* correct mail_cc address

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2021-03-08 04:23:39 +01:00
parent a5dae6e397
commit 8abdef6e44
6 changed files with 164 additions and 139 deletions

View File

@@ -19,6 +19,7 @@ pub static PROP_MAIL_TO_1: &str = "allianz@ponschab-partner.com";
pub static PROP_MAIL_TO_2: &str = "kontakt@chevalier.law";
pub static PROP_MAIL_TO_3: &str = "kontakt@metamedlaw.de";
pub static PROP_MAIL_TO_4: &str = "sekretariat@m2-mediation.de";
pub static PROP_MAIL_TO_5: &str = "ralf.zerres@networkx.de";
pub static PROP_POLICY_CHECK: &str = "policy_check";
pub static PROP_POLICY_PROGRESS_COUNT: &str = "policy_progress_count";

View File

@@ -59,11 +59,11 @@ pub fn sendticketdata(email: &Email, lang: &str) -> Result<(), Box<dyn Error>> {
let message = Message::builder()
//.reply_to("Kanzlei Hiedemann <info@hiedemann.de>".parse().unwrap())
.to("Kanzlei Hiedemann <info@hiedemann.de>".parse().unwrap())
.cc(" <ralf.zerres@networkx.de>".parse().unwrap())
.reply_to((email.mail_reply).parse().unwrap())
//.to((email.mail_to).parse().unwrap())
//.cc((email.mail_cc).parse().unwrap())
//.to("Kanzlei Hiedemann <info@hiedemann.de>".parse().unwrap())
//.cc(" <ralf.zerres@networkx.de>".parse().unwrap())
//.reply_to((email.mail_reply).parse().unwrap())
.to((email.mail_to).parse().unwrap())
.cc((email.mail_cc).parse().unwrap())
//.bcc((email.mail_bcc).parse().unwrap())
.from((email.mail_from).parse().unwrap())
.subject(String::new()
@@ -98,8 +98,6 @@ pub fn sendticketdata(email: &Email, lang: &str) -> Result<(), Box<dyn Error>> {
// WIP: get credentials from config file / cli
let creds = Credentials::new("info@kanzlei.hiedemann.de".to_string(), "17info67$".to_string());
// Open a remote connection to relay server (port 2525)
// WIP: get relay address from config file / cli
let mailer = SmtpTransport::relay("hiedemannsbs.kanzlei.hiedemann.de")

View File

@@ -6,6 +6,7 @@
*/
use orbtk::prelude::*;
use tracing::info;
use crate::widgets::localization::localization_view::LocalizationView;
@@ -26,8 +27,10 @@ impl State for LocalizationState {
return;
}
// get value of activ selected combo_box item
let index = *LocalizationView::selected_index_ref(&ctx.widget()) as usize;
let selected_language = LocalizationView::languages_ref(&ctx.widget())[index].clone();
info!("New selected language item: {:?}", selected_language);
match selected_language.as_str() {
"English" => ctx.set_language("en_US"),

View File

@@ -18,7 +18,7 @@ use crate::{
data::{constants::*, structures::Email},
widgets::global_state::GlobalState,
services::exports::send_ticketdata::sendticketdata,
//widgets::ticketdata::ticketdata_view::TicketdataView,
widgets::ticketdata::ticketdata_view::TicketdataView,
widgets::policycheck::policycheck_state::PolicycheckAction,
};
@@ -39,7 +39,9 @@ pub enum TicketdataAction {
SetEntry(Entity),
SetVisibility(Entity),
TextChanged(Entity, usize),
UpdatePolicyCode(String)
UpdatePolicyCode(String),
UpdateSelectedIndex(String)
}
/// Define valid environment variables provided via .env files
@@ -91,34 +93,14 @@ impl TicketdataState {
info!("child({:?}) name: {:?}",
i, child_id);
// TODO: check the orbtk type
// if let child_type: bool = child.get::<String>("id") = std::any::type_name::<TextBox>().to_string() {
match child_name {
"TextBox" => TextBox::text_set(child, ""),
"ticket_data_policy_code" => TextBox::text_set(child, ""),
_ => info!("don't act on types other than 'TextBox'"),
}
}
}
}
// switch back to parent entity
ctx.change_into(entity) }
}
//let child_type: String = std::any::type_name::<TextBox>().to_string();
//if let child_type: bool = child.get::<String>("id") = std::any::type_name::<TextBox>().to_string() {
//match {
// "orbtk_widgets::text_box::TextBox" => TextBox::text_set(child, ""),
// _ => info!("don't act on typ {:?}", child_type),
//}
// match child_name {
// "TextBox" => TextBox::text_set(child, ""),
// "ticket_data_policy_code" => TextBox::text_set(child, ""),
// _ => info!("don't act on types other than 'TextBox'"),
// }
// info!("child({:?}) id: {:?}",
// i, child_id);
// match child_id {
// "ticket_data_policy_code" => TextBox::text_set(child, ""),
// "ticket_data_policy_holder" => TextBox::text_set(child, ""),
@@ -129,25 +111,26 @@ impl TicketdataState {
// "ticket_data_policy_callback_ivr_comment" => TextBox::text_set(child, ""),
// _ => info!("don't act on child_id '{:?}", child_id),
// }
//}
}
}
}
// switch back to parent entity
ctx.change_into(entity) }
}
pub fn send_form(_entity: Entity, ctx: &mut Context<'_>, lang: &str) {
// type conversion (String -> u64)
//let policy_code = ctx.child(ID_TICKET_DATA_POLICY_CODE).get::<String>("text").unwrap().parse::<u64>().unwrap();
pub fn send_form(entity: Entity, ctx: &mut Context<'_>, lang: &str) {
info!("TicketdataState: processing entity[{:?}]", entity);
// WIP: get selected items ComboBox'es
//let mail_cc_index = *TicketdataView::selected_index_ref(&ctx.widget()) as usize;
//let mail_cc_selected = TicketdataView::mail_cc_ref(&ctx.widget())[mail_cc_index].clone();
let mail_to_index = *TicketdataView::selected_index_ref(&ctx.widget()) as usize;
let mail_to_item = TicketdataView::mail_to_ref(&ctx.widget())[mail_to_index].clone();
info!("mail_to item[{:?}]: {:?}]", mail_to_index, mail_to_item);
// create Email structures
let email = Email {
// WIP: mail_to -> selected index auslesen
//mail_to: ctx.child(ID_TICKET_DATA_MAIL_TO).get::<String>("text").to_string(),
// WIP: mail_cc -> selected index auslesen
//mail_cc: ctx.child(ID_TICKET_DATA_MAIL_CC).get::<String>("text").to_string(),
mail_to: PROP_MAIL_TO_1.to_string(),
//mail_to: PROP_MAIL_TO_1.to_string(),
mail_to: mail_to_item.to_string(),
mail_cc: PROP_MAIL_CC_1.to_string(),
mail_bcc: PROP_MAIL_BCC_1.to_string(),
mail_from: PROP_MAIL_FROM.to_string(),
@@ -170,6 +153,21 @@ impl TicketdataState {
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_CLEAR);
};
}
pub fn update_selected_index(entity: Entity, id: &str, ctx: &mut Context<'_>) {
info!("TicketdataState: processing entity[{:?}]: id: {:?}]", entity, id);
if ctx.entity_of_child(id).is_some() {
let combobox_entity = ctx.entity_of_child(id).unwrap();
let combobox_container: WidgetContainer<'_> = ctx.get_widget(combobox_entity);
info!("combobox name: {:?}", combobox_container.get::<String>("id"));
info!("combobox selected_index: {:?}", combobox_container.get::<i32>("selected_index"));
//let mail_index = *ComboBox::selected_index_ref(&combobox_container) as usize;
//let mail_item = ComboBox::mail_to_ref(&combobox_container)[mail_index].clone();
//info!("selected mail_to item[{:?}]: {:?}]", mail_index, mail_item);
}
}
}
/// Supported methods handled inside the `TicketState`
@@ -209,14 +207,16 @@ impl State for TicketdataState {
match message {
TicketdataAction::ClearForm(id) => {
info!("message: {:?} recieved", id);
// change into the context of the given form
TicketdataState::clear_form(ctx.entity(), &id, ctx);
}
TicketdataAction::SendForm() => {
info!("message: {:?} recieved", message);
TicketdataState::send_form(ctx.entity(), ctx, &self.lang);
}
TicketdataAction::UpdateSelectedIndex(id) => {
info!("message: UpdateSelectedIndex for {:?} recieved", id);
TicketdataState::update_selected_index(ctx.entity(), &id, ctx);
}
_ => { println!("messages: action not implemented!"); }
}
}
@@ -238,13 +238,17 @@ impl State for TicketdataState {
for action in actions {
match action {
TicketdataAction::ClearForm(ref id) => {
info!("update: send_message {:?}", action);
info!("update: got send_message {:?}", action);
ctx.send_message(TicketdataAction::ClearForm(id.to_string()), self.target);
}
TicketdataAction::SendForm() => {
//ctx.send_message(TicketdataAction::SendForm(), self.ID_TICKETDATA_FORM);
info!("update: send_message {:?}", action);
info!("update: got send_message {:?}", action);
}
//TicketdataAction::UpdateSelectedIndex(ref id) => {
// info!("update: got send_message {:?}", action);
// ctx.send_message(TicketdataAction::UpdateSelectedIndex(id.to_string()), self.target);
//}
_ => { println!("TicketdataAction: action not implemented!"); }
}
}

View File

@@ -21,10 +21,12 @@ widget!(
TicketdataView<TicketdataState> {
// language used inside the widget
lang: String,
// list capturing the mail recipients (mail_to)
// mail recipients (mail_to) saved in a vector
mail_to: List,
// list capturing the carbo copy recipients (mail_to)
// carbo copy recipients (mail_to) saved in a vector
mail_cc: List,
// active seleced index of combo box
selected_index: i32,
// title used in the header
ticket_data_title: String,
// entity id that will receive the messages
@@ -42,6 +44,7 @@ impl Template for TicketdataView {
PROP_MAIL_TO_2.to_string(),
PROP_MAIL_TO_3.to_string(),
PROP_MAIL_TO_4.to_string(),
PROP_MAIL_TO_5.to_string(),
];
let count_mail_to = mail_to.len();
@@ -50,7 +53,7 @@ impl Template for TicketdataView {
PROP_MAIL_CC_1.to_string(),
PROP_MAIL_CC_2.to_string(),
];
let count_mail_cc = mail_cc.len();
let _count_mail_cc = mail_cc.len();
let tenent_logo = Container::new()
.margin((16, 16, 0, 0))
@@ -303,7 +306,6 @@ impl Template for TicketdataView {
.id(ID_TICKET_DATA_ACTION_BUTTON_SEND)
.style(STYLE_BUTTON_ACTION)
.text("Send")
//.visibility(Visibility::Collapsed)
.on_click(move |states, _entity| {
states.send_message(TicketdataAction::SendForm(), id);
false
@@ -355,7 +357,8 @@ impl Template for TicketdataView {
.attach(Grid::column(3))
.style(STYLE_MAIL_TO)
.count(count_mail_to)
// create the items builder context (ibc) for the mail to items
// create the items builder context (ibc) for the `mail_to` vector-items
.selected_index(id)
.items_builder(move |ibc, index| {
let text = TicketdataView::mail_to_ref(&ibc.get_widget(id))[index].clone();
TextBlock::new()
@@ -364,8 +367,10 @@ impl Template for TicketdataView {
.text(text)
.build(ibc)
})
.selected_index(1)
.build(ctx),
//.on_changed("selected_index", move |states, _entity| {
// states.send_message(TicketdataAction::UpdateSelectedIndex(ID_TICKET_DATA_COMBO_BOX_MAIL_TO.to_string()), id);
//})
.build(ctx)
)
.child(
TextBlock::new()
@@ -377,28 +382,41 @@ impl Template for TicketdataView {
.build(ctx),
)
.child(
ComboBox::new()
TextBlock::new()
.id(ID_TICKET_DATA_COMBO_BOX_MAIL_CC)
.attach(Grid::row(2))
.attach(Grid::column(3))
.style(STYLE_MAIL_CC)
.count(count_mail_cc)
// create the items builder context (ibc) for the mail cc items
.items_builder(move |ibc, index| {
let text = TicketdataView::mail_cc_ref(&ibc.get_widget(id))[index].clone();
TextBlock::new()
//.name(ID_TICKET_DATA_MAIL_CC)
.text(text)
.v_align("center")
.build(ibc)
})
.selected_index(0)
// .on_changed("selected_mail_cc_index", move |states, _| {
// states.get_mut::<TicketdataState>(id).change_mail_cc();
//})
.build(ctx),
.name(ID_TICKET_DATA_MAIL_CC)
.margin((12, 0, 0, 0))
.text("service@hiedemann.de")
.build(ctx)
)
.build(ctx),
// .child(
// ComboBox::new()
// .id(ID_TICKET_DATA_COMBO_BOX_MAIL_CC)
// .attach(Grid::row(2))
// .attach(Grid::column(3))
// .style(STYLE_MAIL_CC)
// .count(count_mail_cc)
// // create the items builder context (ibc) for the `mail_cc` vector-items
// .items_builder(move |ibc, index| {
// // let text = ibc.get_widget(id)
// // .get::<Vec<String>>("mail_cc")[index]
// // .clone();
// let text = TicketdataView::mail_cc_ref(&ibc.get_widget(id))[index].clone();
// TextBlock::new()
// .name(ID_TICKET_DATA_MAIL_CC)
// .text(text)
// .v_align("center")
// .build(ibc)
// })
// .selected_index(id)
// .on_changed("selected_index", move |states, _entity| {
// states.send_message(TicketdataAction::UpdateSelectedIndex(ID_TICKET_DATA_COMBO_BOX_MAIL_CC.to_string()), id);
// })
// .build(ctx)
// )
.build(ctx)
)
.build(ctx);
@@ -424,6 +442,9 @@ impl Template for TicketdataView {
.name(ID_TICKET_DATA_VIEW)
.mail_to(mail_to)
.mail_cc(mail_cc)
.selected_index(0)
//.selected_index_mail_to(0)
//.selected_index_mail_cc(0)
.min_height(410.0)
.child(
Grid::new()

View File

@@ -9,9 +9,7 @@ use viperus::Viperus;
/// The given Viperus structure will be muted according to the
/// processed default, environment and commandline arguments
pub fn parse_args(v: &mut Viperus) -> Result<(), Box<dyn std::error::Error>> {
//use log::{debug, info, trace, warn};
//use log::trace;
use tracing::{trace, Level};
use tracing::trace;
use std::env;
if cfg!(feature = "yaml") {