@@ -7,11 +7,10 @@
|
|||||||
|
|
||||||
// use orbtk::prelude::*;
|
// use orbtk::prelude::*;
|
||||||
|
|
||||||
// /*
|
// /* * WidgetContainer = entity */
|
||||||
// * WidgetContainer = entity
|
// associated functions: get, get_mut, try_get, try_get_mut and clone
|
||||||
// */
|
// ctx.widget() returns a WidgetContainer object, that wraps
|
||||||
// // methods get, get_mut, try_get, try_get_mut and clone
|
// the current state of that widget (i.e properties)
|
||||||
// // ctx.widget returns a WidgetContainer that wraps the current widget of the state
|
|
||||||
// let mut widget_container: WidgetContainer = ctx.widget();
|
// let mut widget_container: WidgetContainer = ctx.widget();
|
||||||
|
|
||||||
// // property handling (componets)
|
// // property handling (componets)
|
||||||
@@ -23,7 +22,6 @@
|
|||||||
// // .set<PropertyType>("property_name", property_value);
|
// // .set<PropertyType>("property_name", property_value);
|
||||||
// widget_container.set::<String16>("text", "my_text");
|
// widget_container.set::<String16>("text", "my_text");
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// * Child WidgetContainer = child entity
|
// * Child WidgetContainer = child entity
|
||||||
// */
|
// */
|
||||||
@@ -48,11 +46,9 @@
|
|||||||
// // set child field attributes
|
// // set child field attributes
|
||||||
// text_box.set_text("My new text");
|
// text_box.set_text("My new text");
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// * Registry handling
|
// * Registry handling
|
||||||
// */
|
// */
|
||||||
|
|
||||||
// // register service
|
// // register service
|
||||||
// fn update(registry: &mut Registry, _: &mut Context) {
|
// fn update(registry: &mut Registry, _: &mut Context) {
|
||||||
// registry.register("my_db_serve", MyDBServie::new());
|
// registry.register("my_db_serve", MyDBServie::new());
|
||||||
@@ -62,8 +58,6 @@
|
|||||||
// let mut my_db_service: MyDBSerivce = registry.get_mut("my_db_service");
|
// let mut my_db_service: MyDBSerivce = registry.get_mut("my_db_service");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// API Update: access properties of widgets in states
|
// API Update: access properties of widgets in states
|
||||||
|
|
||||||
// Old style (associated functions)
|
// Old style (associated functions)
|
||||||
@@ -85,5 +79,4 @@
|
|||||||
// or
|
// or
|
||||||
// ctx.get_widget(self.text_block).set("offset", offset);
|
// ctx.get_widget(self.text_block).set("offset", offset);
|
||||||
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|||||||
@@ -8,25 +8,25 @@
|
|||||||
// suppress creation of a new console window on window
|
// suppress creation of a new console window on window
|
||||||
#![windows_subsystem = "windows"]
|
#![windows_subsystem = "windows"]
|
||||||
|
|
||||||
|
use cfg_if::cfg_if;
|
||||||
use locales::t;
|
use locales::t;
|
||||||
use orbtk::{
|
use orbtk::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
theme_default::{THEME_DEFAULT, THEME_DEFAULT_COLORS_DARK, THEME_DEFAULT_FONTS},
|
theme_default::{THEME_DEFAULT, THEME_DEFAULT_COLORS_DARK, THEME_DEFAULT_FONTS},
|
||||||
theming::config::ThemeConfig,
|
theming::config::ThemeConfig,
|
||||||
};
|
};
|
||||||
use cfg_if::cfg_if;
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
use tracing::{Level, info, trace};
|
use tracing::{info, trace, Level};
|
||||||
|
|
||||||
use advotracker::{
|
use advotracker::{
|
||||||
data::{constants::*, structures::Email},
|
data::{constants::*, structures::Email},
|
||||||
widgets::global_state::GlobalState,
|
widgets::global_state::GlobalState,
|
||||||
|
widgets::main_view,
|
||||||
//services::exports::send_ticketdata::sendticketdata,
|
//services::exports::send_ticketdata::sendticketdata,
|
||||||
widgets::policycheck::*,
|
widgets::policycheck::*,
|
||||||
widgets::policycheck_state::*,
|
widgets::policycheck_state::*,
|
||||||
widgets::main_view,
|
|
||||||
widgets::ticketdata::*,
|
widgets::ticketdata::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ use orbtk::theme_fluent::{THEME_FLUENT, THEME_FLUENT_COLORS_DARK, THEME_FLUENT_F
|
|||||||
pub enum TicketdataAction {
|
pub enum TicketdataAction {
|
||||||
ClearForm(),
|
ClearForm(),
|
||||||
SendForm(),
|
SendForm(),
|
||||||
UpdatePolicyCode(String)
|
UpdatePolicyCode(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
// German localization file.
|
// German localization file.
|
||||||
@@ -46,7 +46,7 @@ static ADVOTRACKER_DE_DE: &str = include_str!("../assets/advotracker/advotracker
|
|||||||
fn get_lang() -> String {
|
fn get_lang() -> String {
|
||||||
// get system environment
|
// get system environment
|
||||||
let mut lang = env::var("LANG").unwrap_or_else(|_| "C".to_string());
|
let mut lang = env::var("LANG").unwrap_or_else(|_| "C".to_string());
|
||||||
lang = lang.substring(0,5).to_string(); // "de_DE.UTF-8" -> "de_DE"
|
lang = lang.substring(0, 5).to_string(); // "de_DE.UTF-8" -> "de_DE"
|
||||||
info!("GUI-Language: preset to {:?}", lang);
|
info!("GUI-Language: preset to {:?}", lang);
|
||||||
|
|
||||||
// return the active language
|
// return the active language
|
||||||
@@ -92,7 +92,6 @@ cfg_if! {
|
|||||||
|
|
||||||
// Main
|
// Main
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
// initialize the tracing subsystem
|
// initialize the tracing subsystem
|
||||||
// a drop in replacement for classical logging
|
// a drop in replacement for classical logging
|
||||||
// reference: https://tokio.rs/blog/2019-08-tracing/
|
// reference: https://tokio.rs/blog/2019-08-tracing/
|
||||||
@@ -167,18 +166,13 @@ widget!(MainView {
|
|||||||
policycheck_view: PolicyCheck
|
policycheck_view: PolicyCheck
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
impl Template for MainView {
|
impl Template for MainView {
|
||||||
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||||
let ticketdata_view = TicketdataView::new()
|
let ticketdata_view = TicketdataView::new().build(ctx);
|
||||||
.build(ctx);
|
|
||||||
|
|
||||||
let policycheck_view = PolicycheckView::new()
|
let policycheck_view = PolicycheckView::new().target(ticketdata_view.0).build(ctx);
|
||||||
.target(ticketdata_view.0)
|
|
||||||
.build(ctx);
|
|
||||||
|
|
||||||
self.name("MainView")
|
self.name("MainView").child(
|
||||||
.child(
|
|
||||||
TabWidget::new()
|
TabWidget::new()
|
||||||
.tab(ID_POLICY_CHECK_VIEW, policycheck_view)
|
.tab(ID_POLICY_CHECK_VIEW, policycheck_view)
|
||||||
.tab(ID_TICKET_DATA_VIEW, ticketdata_view)
|
.tab(ID_TICKET_DATA_VIEW, ticketdata_view)
|
||||||
@@ -232,7 +226,7 @@ impl Template for TicketdataView {
|
|||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.margin((0, 9, 48, 0))
|
.margin((0, 9, 48, 0))
|
||||||
.text("©Networkx GmbH")
|
.text("©Networkx GmbH")
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
@@ -263,7 +257,7 @@ impl Template for TicketdataView {
|
|||||||
.push("auto") // Label
|
.push("auto") // Label
|
||||||
.push(16) // Delimiter
|
.push(16) // Delimiter
|
||||||
.push("*") // Data
|
.push("*") // Data
|
||||||
.push(32) // Delimiter (2x margin)
|
.push(32), // Delimiter (2x margin)
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
@@ -280,7 +274,7 @@ impl Template for TicketdataView {
|
|||||||
.push("auto") // Row 10
|
.push("auto") // Row 10
|
||||||
.push(14) // Seperator
|
.push(14) // Seperator
|
||||||
.push("auto") // Row 12
|
.push("auto") // Row 12
|
||||||
.push(14) // Seperator
|
.push(14), // Seperator
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
@@ -470,10 +464,7 @@ impl Template for TicketdataView {
|
|||||||
let items_mail_to_count = items_mail_to.len();
|
let items_mail_to_count = items_mail_to.len();
|
||||||
|
|
||||||
// vector with valid carbon copy recipients addresses (mail_to)
|
// vector with valid carbon copy recipients addresses (mail_to)
|
||||||
let items_mail_cc = vec![
|
let items_mail_cc = vec![PROP_MAIL_CC_1, PROP_MAIL_CC_2];
|
||||||
PROP_MAIL_CC_1,
|
|
||||||
PROP_MAIL_CC_2,
|
|
||||||
];
|
|
||||||
let items_mail_cc_count = items_mail_cc.len();
|
let items_mail_cc_count = items_mail_cc.len();
|
||||||
|
|
||||||
let ticket_data_form_mail = Container::new()
|
let ticket_data_form_mail = Container::new()
|
||||||
@@ -490,14 +481,14 @@ impl Template for TicketdataView {
|
|||||||
.push("stretch") // Label
|
.push("stretch") // Label
|
||||||
.push(16) // Delimiter
|
.push(16) // Delimiter
|
||||||
.push("auto") // MailAddress
|
.push("auto") // MailAddress
|
||||||
.push("32") // Delimiter (2x margin)
|
.push("32"), // Delimiter (2x margin)
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
.push("auto") // Row 0
|
.push("auto") // Row 0
|
||||||
.push(2) // Seperator
|
.push(2) // Seperator
|
||||||
.push("auto") // Row 2
|
.push("auto") // Row 2
|
||||||
.push(2) // Seperator
|
.push(2), // Seperator
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
@@ -517,7 +508,9 @@ impl Template for TicketdataView {
|
|||||||
.style(STYLE_MAIL_TO)
|
.style(STYLE_MAIL_TO)
|
||||||
.count(items_mail_to_count)
|
.count(items_mail_to_count)
|
||||||
.items_builder(move |ibc, index| {
|
.items_builder(move |ibc, index| {
|
||||||
let text_mail_to = TicketdataView::items_mail_to_ref(&ibc.get_widget(id))[index].clone();
|
let text_mail_to =
|
||||||
|
TicketdataView::items_mail_to_ref(&ibc.get_widget(id))[index]
|
||||||
|
.clone();
|
||||||
TextBox::new()
|
TextBox::new()
|
||||||
.text(text_mail_to)
|
.text(text_mail_to)
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
@@ -543,7 +536,9 @@ impl Template for TicketdataView {
|
|||||||
.style(STYLE_MAIL_CC)
|
.style(STYLE_MAIL_CC)
|
||||||
.count(items_mail_cc_count)
|
.count(items_mail_cc_count)
|
||||||
.items_builder(move |ibc, index| {
|
.items_builder(move |ibc, index| {
|
||||||
let text_mail_cc = TicketdataView::items_mail_cc_ref(&ibc.get_widget(id))[index].clone();
|
let text_mail_cc =
|
||||||
|
TicketdataView::items_mail_cc_ref(&ibc.get_widget(id))[index]
|
||||||
|
.clone();
|
||||||
TextBox::new()
|
TextBox::new()
|
||||||
.text(text_mail_cc)
|
.text(text_mail_cc)
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
@@ -584,7 +579,7 @@ impl Template for TicketdataView {
|
|||||||
Columns::create()
|
Columns::create()
|
||||||
.push(50) // Left margin
|
.push(50) // Left margin
|
||||||
.push("*") // Content
|
.push("*") // Content
|
||||||
.push(50) // Right margin
|
.push(50), // Right margin
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
@@ -592,9 +587,8 @@ impl Template for TicketdataView {
|
|||||||
.push("auto") // Mail_Form
|
.push("auto") // Mail_Form
|
||||||
.push("*") // Input_Form
|
.push("*") // Input_Form
|
||||||
.push("auto") // Action
|
.push("auto") // Action
|
||||||
.push("auto") // Bottom_Bar
|
.push("auto"), // Bottom_Bar
|
||||||
)
|
)
|
||||||
|
|
||||||
.child(ticket_data_header_bar) // row 0
|
.child(ticket_data_header_bar) // row 0
|
||||||
.child(ticket_data_form_mail) // row 1
|
.child(ticket_data_form_mail) // row 1
|
||||||
.child(ticket_data_form) // row 2
|
.child(ticket_data_form) // row 2
|
||||||
@@ -613,14 +607,26 @@ impl TicketdataState {
|
|||||||
/// Clear the text property of all children of the given form entity
|
/// Clear the text property of all children of the given form entity
|
||||||
pub fn clear_form(entity: Entity, ctx: &mut Context<'_>) {
|
pub fn clear_form(entity: Entity, ctx: &mut Context<'_>) {
|
||||||
if let Some(count) = ctx.get_widget(entity).children_count() {
|
if let Some(count) = ctx.get_widget(entity).children_count() {
|
||||||
info!("Widget name: {:?}", ctx.get_widget(entity).get::<String>("name"));
|
info!(
|
||||||
info!("Widget id: {:?}", ctx.get_widget(entity).get::<String>("id"));
|
"Widget name: {:?}",
|
||||||
|
ctx.get_widget(entity).get::<String>("name")
|
||||||
|
);
|
||||||
|
info!(
|
||||||
|
"Widget id: {:?}",
|
||||||
|
ctx.get_widget(entity).get::<String>("id")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// identify the form by its id
|
// identify the form by its id
|
||||||
if let form_entity = ctx.child(ID_TICKET_DATA_GRID).entity() {
|
if let form_entity = ctx.child(ID_TICKET_DATA_GRID).entity() {
|
||||||
info!("Form id: {:?}", ctx.get_widget(form_entity).get::<String>("id"));
|
info!(
|
||||||
info!("Form node name: {:?}", ctx.get_widget(form_entity).get::<String>("name"));
|
"Form id: {:?}",
|
||||||
|
ctx.get_widget(form_entity).get::<String>("id")
|
||||||
|
);
|
||||||
|
info!(
|
||||||
|
"Form node name: {:?}",
|
||||||
|
ctx.get_widget(form_entity).get::<String>("name")
|
||||||
|
);
|
||||||
|
|
||||||
// Loop through children
|
// Loop through children
|
||||||
if let Some(count) = ctx.get_widget(form_entity).children_count() {
|
if let Some(count) = ctx.get_widget(form_entity).children_count() {
|
||||||
@@ -633,7 +639,6 @@ impl TicketdataState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_form(entity: Entity, ctx: &mut Context<'_>, lang: &str) {
|
pub fn send_form(entity: Entity, ctx: &mut Context<'_>, lang: &str) {
|
||||||
|
|
||||||
// type conversion (String -> u64)
|
// type conversion (String -> u64)
|
||||||
//let policy_code = ctx.child(ID_TICKET_DATA_POLICY_CODE).get::<String>("text").unwrap().parse::<u64>().unwrap();
|
//let policy_code = ctx.child(ID_TICKET_DATA_POLICY_CODE).get::<String>("text").unwrap().parse::<u64>().unwrap();
|
||||||
|
|
||||||
@@ -647,20 +652,40 @@ impl TicketdataState {
|
|||||||
//mail_to: ctx.child(ID_TICKET_DATA_MAIL_TO).get::<String>("text").to_string(),
|
//mail_to: ctx.child(ID_TICKET_DATA_MAIL_TO).get::<String>("text").to_string(),
|
||||||
// WIP: mail_cc -> selected index auslesen
|
// WIP: mail_cc -> selected index auslesen
|
||||||
//mail_cc: ctx.child(ID_TICKET_DATA_MAIL_CC).get::<String>("text").to_string(),
|
//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_cc: PROP_MAIL_CC_1.to_string(),
|
mail_cc: PROP_MAIL_CC_1.to_string(),
|
||||||
mail_bcc: PROP_MAIL_BCC_1.to_string(),
|
mail_bcc: PROP_MAIL_BCC_1.to_string(),
|
||||||
mail_from: PROP_MAIL_FROM.to_string(),
|
mail_from: PROP_MAIL_FROM.to_string(),
|
||||||
mail_reply: PROP_MAIL_REPLY.to_string(),
|
mail_reply: PROP_MAIL_REPLY.to_string(),
|
||||||
subject: PROP_MAIL_SUBJECT.to_string(),
|
subject: PROP_MAIL_SUBJECT.to_string(),
|
||||||
policy_code: ctx.child(ID_TICKET_DATA_POLICY_CODE).get::<String>("text").to_string(),
|
policy_code: ctx
|
||||||
policy_holder: ctx.child(ID_TICKET_DATA_POLICY_HOLDER).get::<String>("text").to_string(),
|
.child(ID_TICKET_DATA_POLICY_CODE)
|
||||||
deductible: ctx.child(ID_TICKET_DATA_DEDUCTIBLE).get::<String>("text").to_string(),
|
.get::<String>("text")
|
||||||
callback_number: ctx.child(ID_TICKET_DATA_CALLBACK_NUMBER).get::<String>("text").to_string(),
|
.to_string(),
|
||||||
callback_date: ctx.child(ID_TICKET_DATA_CALLBACK_DATE).get::<String>("text").to_string(),
|
policy_holder: ctx
|
||||||
harm_type: ctx.child(ID_TICKET_DATA_HARM_TYPE).get::<String>("text").to_string(),
|
.child(ID_TICKET_DATA_POLICY_HOLDER)
|
||||||
ivr_comment: ctx.child(ID_TICKET_DATA_IVR_COMMENT).get::<String>("text").to_string(),
|
.get::<String>("text")
|
||||||
|
.to_string(),
|
||||||
|
deductible: ctx
|
||||||
|
.child(ID_TICKET_DATA_DEDUCTIBLE)
|
||||||
|
.get::<String>("text")
|
||||||
|
.to_string(),
|
||||||
|
callback_number: ctx
|
||||||
|
.child(ID_TICKET_DATA_CALLBACK_NUMBER)
|
||||||
|
.get::<String>("text")
|
||||||
|
.to_string(),
|
||||||
|
callback_date: ctx
|
||||||
|
.child(ID_TICKET_DATA_CALLBACK_DATE)
|
||||||
|
.get::<String>("text")
|
||||||
|
.to_string(),
|
||||||
|
harm_type: ctx
|
||||||
|
.child(ID_TICKET_DATA_HARM_TYPE)
|
||||||
|
.get::<String>("text")
|
||||||
|
.to_string(),
|
||||||
|
ivr_comment: ctx
|
||||||
|
.child(ID_TICKET_DATA_IVR_COMMENT)
|
||||||
|
.get::<String>("text")
|
||||||
|
.to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("WIP: Sending form to construct eMail to {:?}", email);
|
info!("WIP: Sending form to construct eMail to {:?}", email);
|
||||||
@@ -673,7 +698,7 @@ impl TicketdataState {
|
|||||||
impl State for TicketdataState {
|
impl State for TicketdataState {
|
||||||
/// Initialize the state of widgets inside `TicketState`
|
/// Initialize the state of widgets inside `TicketState`
|
||||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||||
let time_start= SystemTime::now();
|
let time_start = SystemTime::now();
|
||||||
|
|
||||||
trace!(target: "advotracker", ticketdata_state = "init", status = "started");
|
trace!(target: "advotracker", ticketdata_state = "init", status = "started");
|
||||||
|
|
||||||
@@ -682,8 +707,11 @@ impl State for TicketdataState {
|
|||||||
.entity_of_child(ID_TICKET_DATA_BUTTON_MENU)
|
.entity_of_child(ID_TICKET_DATA_BUTTON_MENU)
|
||||||
.expect("TicketState.init: Can't find resource entity 'ID_TICKET_DATA_BUTTON_MENU'.");
|
.expect("TicketState.init: Can't find resource entity 'ID_TICKET_DATA_BUTTON_MENU'.");
|
||||||
|
|
||||||
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
self.target = Entity::from(
|
||||||
.expect("TicketState.init: Can't find resource entity 'target'."));
|
ctx.widget()
|
||||||
|
.try_clone::<u32>("target")
|
||||||
|
.expect("TicketState.init: Can't find resource entity 'target'."),
|
||||||
|
);
|
||||||
|
|
||||||
// Get language from environment
|
// Get language from environment
|
||||||
self.lang = TicketdataState::get_lang();
|
self.lang = TicketdataState::get_lang();
|
||||||
@@ -710,7 +738,9 @@ impl State for TicketdataState {
|
|||||||
info!("message: {:?} recieved", message);
|
info!("message: {:?} recieved", message);
|
||||||
TicketdataState::send_form(ctx.entity(), ctx, &self.lang);
|
TicketdataState::send_form(ctx.entity(), ctx, &self.lang);
|
||||||
}
|
}
|
||||||
_ => { println!("messages: action not implemented!"); }
|
_ => {
|
||||||
|
println!("messages: action not implemented!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for message in messages.read::<PolicycheckAction>() {
|
for message in messages.read::<PolicycheckAction>() {
|
||||||
@@ -719,7 +749,9 @@ impl State for TicketdataState {
|
|||||||
info!("Message received: 'PolicycheckAction::UpdatePolicyCode'");
|
info!("Message received: 'PolicycheckAction::UpdatePolicyCode'");
|
||||||
TextBlock::text_set(&mut ctx.child(ID_TICKET_DATA_POLICY_CODE), policy_code);
|
TextBlock::text_set(&mut ctx.child(ID_TICKET_DATA_POLICY_CODE), policy_code);
|
||||||
}
|
}
|
||||||
_ => { println!("messages: action not implemented!"); }
|
_ => {
|
||||||
|
println!("messages: action not implemented!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -737,13 +769,14 @@ impl State for TicketdataState {
|
|||||||
//ctx.send_message(TicketdataAction::SendForm(), self.ID_TICKETDATA_FORM);
|
//ctx.send_message(TicketdataAction::SendForm(), self.ID_TICKETDATA_FORM);
|
||||||
info!("update: send_message {:?}", action);
|
info!("update: send_message {:?}", action);
|
||||||
}
|
}
|
||||||
_ => { println!("TicketdataAction: action not implemented!"); }
|
_ => {
|
||||||
|
println!("TicketdataAction: action not implemented!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// send ticket data via eMail
|
/// send ticket data via eMail
|
||||||
pub fn sendticketdata(email: &Email, lang: &str) -> Result<(), Box<dyn Error>> {
|
pub fn sendticketdata(email: &Email, lang: &str) -> Result<(), Box<dyn Error>> {
|
||||||
let mut res = t!("sendticketdata.export.started", lang);
|
let mut res = t!("sendticketdata.export.started", lang);
|
||||||
@@ -751,13 +784,27 @@ pub fn sendticketdata(email: &Email, lang: &str) -> Result<(), Box<dyn Error>> {
|
|||||||
trace!(target: "sendticketdata", process = ?res, state = ?state);
|
trace!(target: "sendticketdata", process = ?res, state = ?state);
|
||||||
|
|
||||||
let ascii_body = String::new()
|
let ascii_body = String::new()
|
||||||
+ &"Vers.-Schein/Schadennummer".to_string() + &(email.policy_code) + &"\n"
|
+ &"Vers.-Schein/Schadennummer".to_string()
|
||||||
+ &"Versicherungsnehmer: ".to_string() + &(email.policy_holder) + &"\n"
|
+ &(email.policy_code)
|
||||||
+ &"Selbstbehalt: ".to_string() + &(email.deductible) + &"\n"
|
+ &"\n"
|
||||||
+ &"Rückrufnummer: ".to_string()+ &(email.callback_number) + &"\n"
|
+ &"Versicherungsnehmer: ".to_string()
|
||||||
+ &"Erreichbarkeit: ".to_string() + &(email.callback_date) + &"\n"
|
+ &(email.policy_holder)
|
||||||
+ &"Rechtsproblem: ".to_string() + &(email.harm_type) + &"\n"
|
+ &"\n"
|
||||||
+ &"Rechtsrat: ".to_string() + &(email.ivr_comment) + &"\n";
|
+ &"Selbstbehalt: ".to_string()
|
||||||
|
+ &(email.deductible)
|
||||||
|
+ &"\n"
|
||||||
|
+ &"Rückrufnummer: ".to_string()
|
||||||
|
+ &(email.callback_number)
|
||||||
|
+ &"\n"
|
||||||
|
+ &"Erreichbarkeit: ".to_string()
|
||||||
|
+ &(email.callback_date)
|
||||||
|
+ &"\n"
|
||||||
|
+ &"Rechtsproblem: ".to_string()
|
||||||
|
+ &(email.harm_type)
|
||||||
|
+ &"\n"
|
||||||
|
+ &"Rechtsrat: ".to_string()
|
||||||
|
+ &(email.ivr_comment)
|
||||||
|
+ &"\n";
|
||||||
|
|
||||||
info!("email body: {:?}", ascii_body);
|
info!("email body: {:?}", ascii_body);
|
||||||
|
|
||||||
@@ -770,11 +817,12 @@ pub fn sendticketdata(email: &Email, lang: &str) -> Result<(), Box<dyn Error>> {
|
|||||||
//.cc((email.mail_cc).parse().unwrap())
|
//.cc((email.mail_cc).parse().unwrap())
|
||||||
//.bcc((email.mail_bcc).parse().unwrap())
|
//.bcc((email.mail_bcc).parse().unwrap())
|
||||||
.from((email.mail_from).parse().unwrap())
|
.from((email.mail_from).parse().unwrap())
|
||||||
.subject(String::new()
|
.subject(
|
||||||
|
String::new()
|
||||||
+ &email.subject.to_string()
|
+ &email.subject.to_string()
|
||||||
+ &" (".to_string()
|
+ &" (".to_string()
|
||||||
+ &email.policy_code.to_string()
|
+ &email.policy_code.to_string()
|
||||||
+ &")".to_string()
|
+ &")".to_string(),
|
||||||
)
|
)
|
||||||
.multipart(
|
.multipart(
|
||||||
MultiPart::alternative() // This is composed of two parts.
|
MultiPart::alternative() // This is composed of two parts.
|
||||||
@@ -784,11 +832,10 @@ pub fn sendticketdata(email: &Email, lang: &str) -> Result<(), Box<dyn Error>> {
|
|||||||
"text/plain; charset=utf8".parse().unwrap(),
|
"text/plain; charset=utf8".parse().unwrap(),
|
||||||
))
|
))
|
||||||
.body(String::from(ascii_body)),
|
.body(String::from(ascii_body)),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.expect("failed to build email");
|
.expect("failed to build email");
|
||||||
|
|
||||||
|
|
||||||
info!("message: {:?}", message);
|
info!("message: {:?}", message);
|
||||||
|
|
||||||
trace!(target: "sendticketdata", email = ?email);
|
trace!(target: "sendticketdata", email = ?email);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use chrono::{Local, DateTime};
|
use chrono::{DateTime, Local};
|
||||||
use locales::t;
|
use locales::t;
|
||||||
//use serde::{Deserialize, Serialize};
|
//use serde::{Deserialize, Serialize};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
@@ -17,7 +17,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
use tracing::{debug, trace, Level};
|
use tracing::{debug, trace, Level};
|
||||||
|
|
||||||
use advotracker::data::structures::{PolicyCode, PolicyList, PolicyDataList, PolicyData};
|
use advotracker::data::structures::{PolicyCode, PolicyData, PolicyDataList, PolicyList};
|
||||||
|
|
||||||
// include modules
|
// include modules
|
||||||
mod parse_args;
|
mod parse_args;
|
||||||
@@ -77,12 +77,15 @@ fn export(p: &mut String, lang: &String) -> Result<u64, Box<dyn Error>> {
|
|||||||
/// import from csv format
|
/// import from csv format
|
||||||
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
||||||
/// https://blog.burntsushi.net/csv/
|
/// https://blog.burntsushi.net/csv/
|
||||||
fn import(p: &mut String, data_list: &mut PolicyDataList,
|
fn import(
|
||||||
policy_numbers: &mut HashMap<u64, PolicyCode>, lang: &String)
|
p: &mut String,
|
||||||
-> Result<u64, Box<dyn Error>> {
|
data_list: &mut PolicyDataList,
|
||||||
|
policy_numbers: &mut HashMap<u64, PolicyCode>,
|
||||||
|
lang: &String,
|
||||||
|
) -> Result<u64, Box<dyn Error>> {
|
||||||
|
use std::ffi::OsStr;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::ffi::OsStr;
|
|
||||||
|
|
||||||
let mut res = t!("csv.import.started", lang);
|
let mut res = t!("csv.import.started", lang);
|
||||||
let mut state = t!("state.started", lang);
|
let mut state = t!("state.started", lang);
|
||||||
@@ -142,7 +145,7 @@ fn import(p: &mut String, data_list: &mut PolicyDataList,
|
|||||||
// push record as new vector elements
|
// push record as new vector elements
|
||||||
data_list.push(record);
|
data_list.push(record);
|
||||||
|
|
||||||
count +=1;
|
count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
let dt_end: DateTime<Local> = Local::now();
|
let dt_end: DateTime<Local> = Local::now();
|
||||||
@@ -163,10 +166,12 @@ fn import(p: &mut String, data_list: &mut PolicyDataList,
|
|||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
/// validate a given policy number
|
/// validate a given policy number
|
||||||
/// result will return true or false
|
/// result will return true or false
|
||||||
fn is_valid(policy_number: &u64, policy_list: &PolicyDataList,
|
fn is_valid(
|
||||||
policy_numbers: &mut HashMap<u64, PolicyCode>, lang: &String)
|
policy_number: &u64,
|
||||||
-> Result<bool, Box<dyn std::error::Error>> {
|
policy_list: &PolicyDataList,
|
||||||
|
policy_numbers: &mut HashMap<u64, PolicyCode>,
|
||||||
|
lang: &String,
|
||||||
|
) -> Result<bool, Box<dyn std::error::Error>> {
|
||||||
let mut res = t!("policy.validation.started", lang);
|
let mut res = t!("policy.validation.started", lang);
|
||||||
let mut state = t!("state.started", lang);
|
let mut state = t!("state.started", lang);
|
||||||
let dt_start: DateTime<Local> = Local::now();
|
let dt_start: DateTime<Local> = Local::now();
|
||||||
@@ -186,7 +191,6 @@ fn is_valid(policy_number: &u64, policy_list: &PolicyDataList,
|
|||||||
// println!("policy_list: {:?} (with {:?} elements)",
|
// println!("policy_list: {:?} (with {:?} elements)",
|
||||||
// policy_list.name, policy_list.policy_data.len());
|
// policy_list.name, policy_list.policy_data.len());
|
||||||
|
|
||||||
|
|
||||||
// policy_list.into_iter()
|
// policy_list.into_iter()
|
||||||
// .filter(|num| matches(w, w1))
|
// .filter(|num| matches(w, w1))
|
||||||
// .clone
|
// .clone
|
||||||
@@ -230,14 +234,13 @@ fn is_valid(policy_number: &u64, policy_list: &PolicyDataList,
|
|||||||
match policy_numbers.get(&policy_number) {
|
match policy_numbers.get(&policy_number) {
|
||||||
Some(&policy_code) => {
|
Some(&policy_code) => {
|
||||||
let res = t!("policy.validation.success", lang);
|
let res = t!("policy.validation.success", lang);
|
||||||
println!("policy_number: {} ({:?})",
|
println!("policy_number: {} ({:?})", policy_number, policy_code);
|
||||||
policy_number, policy_code);
|
|
||||||
result = true;
|
result = true;
|
||||||
trace!(target: "csv-test",
|
trace!(target: "csv-test",
|
||||||
policy_number = ?policy_number,
|
policy_number = ?policy_number,
|
||||||
validation = ?res,
|
validation = ?res,
|
||||||
policy_code = ?policy_code);
|
policy_code = ?policy_code);
|
||||||
},
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let res = t!("policy.validation.failed", lang);
|
let res = t!("policy.validation.failed", lang);
|
||||||
//println!("Noop! Number isn't valid!");
|
//println!("Noop! Number isn't valid!");
|
||||||
@@ -245,9 +248,8 @@ fn is_valid(policy_number: &u64, policy_list: &PolicyDataList,
|
|||||||
trace!(target: "csv-test",
|
trace!(target: "csv-test",
|
||||||
policy_number = ?policy_number,
|
policy_number = ?policy_number,
|
||||||
validation = ?res);
|
validation = ?res);
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let dt_end: DateTime<Local> = Local::now();
|
let dt_end: DateTime<Local> = Local::now();
|
||||||
let duration = dt_end.signed_duration_since(dt_start);
|
let duration = dt_end.signed_duration_since(dt_start);
|
||||||
@@ -296,9 +298,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
match envy::from_env::<Environment>() {
|
match envy::from_env::<Environment>() {
|
||||||
Ok(environment) => {
|
Ok(environment) => {
|
||||||
if environment.test_lang != lang { lang = environment.test_lang; }
|
if environment.test_lang != lang {
|
||||||
},
|
lang = environment.test_lang;
|
||||||
Err(e) => { debug!(target: "csv-test", "{}", e); }
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
debug!(target: "csv-test", "{}", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// how to handle unumplemented lang resources??
|
// how to handle unumplemented lang resources??
|
||||||
res = t!("parse.environment", lang);
|
res = t!("parse.environment", lang);
|
||||||
@@ -331,11 +337,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let mut policy_data = PolicyDataList::new("Allianz-Import 20200628");
|
let mut policy_data = PolicyDataList::new("Allianz-Import 20200628");
|
||||||
println!("Policy Data List {:?} ", policy_data.name);
|
println!("Policy Data List {:?} ", policy_data.name);
|
||||||
|
|
||||||
let mut policy_numbers : HashMap<u64, PolicyCode> = HashMap::new();
|
let mut policy_numbers: HashMap<u64, PolicyCode> = HashMap::new();
|
||||||
|
|
||||||
let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
||||||
match import(&mut csv_import_path, &mut policy_data,
|
match import(
|
||||||
&mut policy_numbers, &lang) {
|
&mut csv_import_path,
|
||||||
|
&mut policy_data,
|
||||||
|
&mut policy_numbers,
|
||||||
|
&lang,
|
||||||
|
) {
|
||||||
Ok(count) => {
|
Ok(count) => {
|
||||||
println!("Imported {:?} records", count);
|
println!("Imported {:?} records", count);
|
||||||
}
|
}
|
||||||
@@ -347,7 +357,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
// test if policy_number is_valid
|
// test if policy_number is_valid
|
||||||
// type conversion (viperus String -> u64)
|
// type conversion (viperus String -> u64)
|
||||||
let test_policy_number = v.get::<String>("test_policy_number").unwrap().parse::<u64>().unwrap();
|
let test_policy_number = v
|
||||||
|
.get::<String>("test_policy_number")
|
||||||
|
.unwrap()
|
||||||
|
.parse::<u64>()
|
||||||
|
.unwrap();
|
||||||
trace!(target: "csv-test", test_policy_number = ?test_policy_number);
|
trace!(target: "csv-test", test_policy_number = ?test_policy_number);
|
||||||
//match is_valid(&policy_number, &policy_data, &mut policy_numbers, &lang) {
|
//match is_valid(&policy_number, &policy_data, &mut policy_numbers, &lang) {
|
||||||
// Ok(true) => {
|
// Ok(true) => {
|
||||||
@@ -356,14 +370,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
Some(&policy_code) => {
|
Some(&policy_code) => {
|
||||||
let res = t!("policy.validation.success", lang);
|
let res = t!("policy.validation.success", lang);
|
||||||
println!("{:?}", res);
|
println!("{:?}", res);
|
||||||
println!("policy_number: {} ({:?})",
|
println!("policy_number: {} ({:?})", test_policy_number, policy_code);
|
||||||
test_policy_number, policy_code);
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let res = t!("policy.validation.failed", lang);
|
let res = t!("policy.validation.failed", lang);
|
||||||
println!("{:?}", res);
|
println!("{:?}", res);
|
||||||
//println!("Nuup! Number isn't valid!");
|
//println!("Nuup! Number isn't valid!");
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// export policy code elements to csv-file
|
// export policy code elements to csv-file
|
||||||
@@ -389,21 +402,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_policy_number() {
|
fn test_policy_number() {
|
||||||
// Takes a reference and returns Option<&V>
|
// Takes a reference and returns Option<&V>
|
||||||
let my_policy_numbers : [u64; 2] = [1511111111, 9999999993];
|
let my_policy_numbers: [u64; 2] = [1511111111, 9999999993];
|
||||||
assert_eq!(my_policy_numbers, [1511111111, 9999999993]);
|
assert_eq!(my_policy_numbers, [1511111111, 9999999993]);
|
||||||
|
|
||||||
//let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
//let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
||||||
let mut csv_import_path = String::from("data/POLLFNR_TEST.txt");
|
let mut csv_import_path = String::from("data/POLLFNR_TEST.txt");
|
||||||
|
|
||||||
let mut policy_data = PolicyDataList::new("PolicyDataList");
|
let mut policy_data = PolicyDataList::new("PolicyDataList");
|
||||||
let mut policy_numbers : HashMap<u64, PolicyCode> = HashMap::new();
|
let mut policy_numbers: HashMap<u64, PolicyCode> = HashMap::new();
|
||||||
let lang = "en".to_string();
|
let lang = "en".to_string();
|
||||||
|
|
||||||
println!("import with Path: {:?} PolicyData: {:?} PolicyNumbers: {:?}, Lang: {:?}",
|
println!(
|
||||||
csv_import_path, policy_data, policy_numbers, lang);
|
"import with Path: {:?} PolicyData: {:?} PolicyNumbers: {:?}, Lang: {:?}",
|
||||||
let count = import(&mut csv_import_path, &mut policy_data,
|
csv_import_path, policy_data, policy_numbers, lang
|
||||||
&mut policy_numbers, &lang);
|
);
|
||||||
|
let count = import(
|
||||||
|
&mut csv_import_path,
|
||||||
|
&mut policy_data,
|
||||||
|
&mut policy_numbers,
|
||||||
|
&lang,
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(count.unwrap(), 15498);
|
assert_eq!(count.unwrap(), 15498);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,24 +26,31 @@ pub fn parse_args(v: &mut Viperus) -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
v.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
|
v.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
|
||||||
v.add_default("export_file", String::from(""));
|
v.add_default("export_file", String::from(""));
|
||||||
v.add_default("test_policy_number", String::from("9999999992"));
|
v.add_default("test_policy_number", String::from("9999999992"));
|
||||||
v.add_default("to_email_address_file", String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"));
|
v.add_default(
|
||||||
v.add_default("from_email_address_file", String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>"));
|
"to_email_address_file",
|
||||||
|
String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"),
|
||||||
|
);
|
||||||
|
v.add_default(
|
||||||
|
"from_email_address_file",
|
||||||
|
String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>"),
|
||||||
|
);
|
||||||
//v.add_default("username", String::from("nctalkbot"));
|
//v.add_default("username", String::from("nctalkbot"));
|
||||||
//v.add_default("password", String::from("botpassword"));
|
//v.add_default("password", String::from("botpassword"));
|
||||||
v.add_default("verbose", 0);
|
v.add_default("verbose", 0);
|
||||||
|
|
||||||
|
|
||||||
// CLI arguments are defined inline
|
// CLI arguments are defined inline
|
||||||
let matches = App::new("csv-test")
|
let matches = App::new("csv-test")
|
||||||
.name(crate_name!())
|
.name(crate_name!())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.author(crate_authors!())
|
.author(crate_authors!())
|
||||||
.about(crate_description!())
|
.about(crate_description!())
|
||||||
.after_help("
|
.after_help(
|
||||||
|
"
|
||||||
Testprogramm: Allianz Online-Beratung Im/Export CSV-Daten
|
Testprogramm: Allianz Online-Beratung Im/Export CSV-Daten
|
||||||
Direct-Call via IVR-System (Interactive Voice Response)
|
Direct-Call via IVR-System (Interactive Voice Response)
|
||||||
SMR Deckungssummen-Prüfung: 089 92529 60211
|
SMR Deckungssummen-Prüfung: 089 92529 60211
|
||||||
SMR Unerledigt: 089 92529 60222")
|
SMR Unerledigt: 089 92529 60222",
|
||||||
|
)
|
||||||
.template(
|
.template(
|
||||||
"\
|
"\
|
||||||
{bin} v{version}
|
{bin} v{version}
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
// SPDX-License-Identifier: (0BSD or MIT)
|
// SPDX-License-Identifier: (0BSD or MIT)
|
||||||
/*
|
/*
|
||||||
* advotracker - Hotline tackingtool for Advocats
|
* advotracker - Hotline tackingtool for Advocats
|
||||||
|
|
||||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use lettre::{
|
use lettre::{transport::smtp::authentication::Credentials, Message, SmtpTransport, Transport};
|
||||||
transport::smtp::authentication::Credentials,
|
|
||||||
Message, SmtpTransport, Transport,
|
|
||||||
};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let email = Message::builder()
|
let email = Message::builder()
|
||||||
@@ -21,7 +18,10 @@ fn main() {
|
|||||||
|
|
||||||
// Create credential for remote authentication (username, password)
|
// Create credential for remote authentication (username, password)
|
||||||
//let creds = Credentials::new("ralf.zerres@networkx.de".to_string(), "dekifjgh".to_string());
|
//let creds = Credentials::new("ralf.zerres@networkx.de".to_string(), "dekifjgh".to_string());
|
||||||
let creds = Credentials::new("ralf.zerres.de@gmail.com".to_string(), "20jacara03".to_string());
|
let creds = Credentials::new(
|
||||||
|
"ralf.zerres.de@gmail.com".to_string(),
|
||||||
|
"20jacara03".to_string(),
|
||||||
|
);
|
||||||
|
|
||||||
// Open a remote connection to relay server
|
// Open a remote connection to relay server
|
||||||
//let mailer = SmtpTransport::relay("nwxex.networkx.de")
|
//let mailer = SmtpTransport::relay("nwxex.networkx.de")
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ static ID_CHECK_POLICY_NUMBER: &'static str = "ID_CHECK_POLICY_NUMBER";
|
|||||||
static ID_PROGRESS_BAR: &'static str = "ID_PROGRESS_BAR";
|
static ID_PROGRESS_BAR: &'static str = "ID_PROGRESS_BAR";
|
||||||
|
|
||||||
enum Action {
|
enum Action {
|
||||||
ParsePolicyNumber
|
ParsePolicyNumber,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, AsAny)]
|
#[derive(Default, AsAny)]
|
||||||
@@ -16,15 +16,18 @@ struct MainViewState {
|
|||||||
action: Option<Action>,
|
action: Option<Action>,
|
||||||
progress_bar: Entity,
|
progress_bar: Entity,
|
||||||
text_box: Entity,
|
text_box: Entity,
|
||||||
progress_counter: f64
|
progress_counter: f64, //records: HashMap::<String, String>,
|
||||||
//records: HashMap::<String, String>,
|
|
||||||
//record_counter: u64
|
//record_counter: u64
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State for MainViewState {
|
impl State for MainViewState {
|
||||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||||
self.text_box = ctx.entity_of_child(ID_CHECK_POLICY_NUMBER).expect("Cannot get TextBox!");
|
self.text_box = ctx
|
||||||
self.progress_bar = ctx.entity_of_child(ID_PROGRESS_BAR).expect("Cannot get progress bar !");
|
.entity_of_child(ID_CHECK_POLICY_NUMBER)
|
||||||
|
.expect("Cannot get TextBox!");
|
||||||
|
self.progress_bar = ctx
|
||||||
|
.entity_of_child(ID_PROGRESS_BAR)
|
||||||
|
.expect("Cannot get progress bar !");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
|
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||||
@@ -32,7 +35,10 @@ impl State for MainViewState {
|
|||||||
if let Some(action) = &self.action {
|
if let Some(action) = &self.action {
|
||||||
match action {
|
match action {
|
||||||
Action::ParsePolicyNumber => {
|
Action::ParsePolicyNumber => {
|
||||||
let value_to_parse = ctx.get_widget(self.text_box).get::<String16>("text").clone();
|
let value_to_parse = ctx
|
||||||
|
.get_widget(self.text_box)
|
||||||
|
.get::<String16>("text")
|
||||||
|
.clone();
|
||||||
self.parse_policy_number(value_to_parse, ctx);
|
self.parse_policy_number(value_to_parse, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,9 +87,7 @@ widget!(MainView<MainViewState>);
|
|||||||
|
|
||||||
impl Template for MainView {
|
impl Template for MainView {
|
||||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||||
self
|
self.margin(32.0).child(
|
||||||
.margin(32.0)
|
|
||||||
.child(
|
|
||||||
Stack::new()
|
Stack::new()
|
||||||
.orientation("vertical")
|
.orientation("vertical")
|
||||||
.h_align("center")
|
.h_align("center")
|
||||||
@@ -95,16 +99,14 @@ impl Template for MainView {
|
|||||||
.water_mark("Mut value and type <Return>")
|
.water_mark("Mut value and type <Return>")
|
||||||
.on_activate(move |states, _entity| {
|
.on_activate(move |states, _entity| {
|
||||||
// you have to fire a new event to be able to get in the update() with access to Context
|
// you have to fire a new event to be able to get in the update() with access to Context
|
||||||
states.get_mut::<MainViewState>(id).action(Action::ParsePolicyNumber);
|
states
|
||||||
|
.get_mut::<MainViewState>(id)
|
||||||
|
.action(Action::ParsePolicyNumber);
|
||||||
})
|
})
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(ProgressBar::new().id(ID_PROGRESS_BAR).build(ctx))
|
||||||
ProgressBar::new()
|
.build(ctx),
|
||||||
.id(ID_PROGRESS_BAR)
|
|
||||||
.build(ctx)
|
|
||||||
)
|
|
||||||
.build(ctx)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,7 @@
|
|||||||
|
|
||||||
use orbtk::prelude::*;
|
use orbtk::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{receiver::receiver_view::ReceiverView, sender::sender_view::SenderView};
|
||||||
receiver::receiver_view::ReceiverView,
|
|
||||||
sender::sender_view::SenderView,
|
|
||||||
};
|
|
||||||
|
|
||||||
// constants
|
// constants
|
||||||
pub static ID_SENDER_VIEW: &str = "sender_view";
|
pub static ID_SENDER_VIEW: &str = "sender_view";
|
||||||
@@ -23,20 +20,18 @@ widget!(MainView {
|
|||||||
|
|
||||||
impl Template for MainView {
|
impl Template for MainView {
|
||||||
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||||
let receiver_view = ReceiverView::new()
|
let receiver_view = ReceiverView::new().build(ctx);
|
||||||
.build(ctx);
|
|
||||||
|
|
||||||
let sender_view = SenderView::new()
|
let sender_view = SenderView::new()
|
||||||
.target(receiver_view.0) // entity of the target
|
.target(receiver_view.0) // entity of the target
|
||||||
.build(ctx);
|
.build(ctx);
|
||||||
|
|
||||||
self.name("MainView")
|
self.name("MainView").child(
|
||||||
.child(
|
|
||||||
Stack::new()
|
Stack::new()
|
||||||
.orientation("vertical")
|
.orientation("vertical")
|
||||||
.child(sender_view)
|
.child(sender_view)
|
||||||
.child(receiver_view)
|
.child(receiver_view)
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
// .child(
|
// .child(
|
||||||
// TabWidget::new()
|
// TabWidget::new()
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use crate::sender::sender_state::{SenderAction, SenderState};
|
|||||||
/// state changes for the `SenderView` widget.
|
/// state changes for the `SenderView` widget.
|
||||||
pub enum TestMessageAction {
|
pub enum TestMessageAction {
|
||||||
// Toggle visibility of a message TextBox.
|
// Toggle visibility of a message TextBox.
|
||||||
ToggleMessageBox
|
ToggleMessageBox,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Valid `structure members` of the `ReceiverState` used to react on
|
/// Valid `structure members` of the `ReceiverState` used to react on
|
||||||
@@ -21,7 +21,7 @@ pub enum TestMessageAction {
|
|||||||
#[derive(Default, AsAny)]
|
#[derive(Default, AsAny)]
|
||||||
pub struct ReceiverState {
|
pub struct ReceiverState {
|
||||||
message_box: Option<Entity>,
|
message_box: Option<Entity>,
|
||||||
progress_bar: Entity
|
progress_bar: Entity,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Method definitions, we provide inside the `ReceiverState`.
|
/// Method definitions, we provide inside the `ReceiverState`.
|
||||||
@@ -38,7 +38,8 @@ impl ReceiverState {
|
|||||||
impl State for ReceiverState {
|
impl State for ReceiverState {
|
||||||
// initialize the view entities
|
// initialize the view entities
|
||||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||||
self.progress_bar = ctx.entity_of_child("progress_bar")
|
self.progress_bar = ctx
|
||||||
|
.entity_of_child("progress_bar")
|
||||||
.expect("Cannot find ProgressBar!");
|
.expect("Cannot find ProgressBar!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ impl State for ReceiverState {
|
|||||||
&mut self,
|
&mut self,
|
||||||
mut messages: MessageReader,
|
mut messages: MessageReader,
|
||||||
_registry: &mut Registry,
|
_registry: &mut Registry,
|
||||||
ctx: &mut Context
|
ctx: &mut Context,
|
||||||
) {
|
) {
|
||||||
for message in messages.read::<SenderAction>() {
|
for message in messages.read::<SenderAction>() {
|
||||||
match message {
|
match message {
|
||||||
|
|||||||
@@ -7,31 +7,26 @@
|
|||||||
|
|
||||||
use orbtk::prelude::*;
|
use orbtk::prelude::*;
|
||||||
|
|
||||||
use crate::receiver::receiver_state::{TestMessageAction, ReceiverState};
|
use crate::receiver::receiver_state::{ReceiverState, TestMessageAction};
|
||||||
|
|
||||||
widget!(ReceiverView<ReceiverState>);
|
widget!(ReceiverView<ReceiverState>);
|
||||||
|
|
||||||
impl Template for ReceiverView {
|
impl Template for ReceiverView {
|
||||||
fn template(self, _id: Entity, bc: &mut BuildContext) -> Self {
|
fn template(self, _id: Entity, bc: &mut BuildContext) -> Self {
|
||||||
self.name("ReceiverView")
|
self.name("ReceiverView").child(
|
||||||
.child(
|
|
||||||
Stack::new()
|
Stack::new()
|
||||||
.orientation("vertical")
|
.orientation("vertical")
|
||||||
.spacing(16)
|
.spacing(16)
|
||||||
.child(
|
.child(ProgressBar::new().id("progress_bar").build(bc))
|
||||||
ProgressBar::new()
|
|
||||||
.id("progress_bar")
|
|
||||||
.build(bc)
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
TextBox::new()
|
TextBox::new()
|
||||||
.id("message_box")
|
.id("message_box")
|
||||||
.h_align("center")
|
.h_align("center")
|
||||||
.text("message received. Box toggled!")
|
.text("message received. Box toggled!")
|
||||||
.visibility("hidden")
|
.visibility("hidden")
|
||||||
.build(bc)
|
.build(bc),
|
||||||
)
|
)
|
||||||
.build(bc)
|
.build(bc),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub struct SenderState {
|
|||||||
// actions
|
// actions
|
||||||
actions: Vec<SenderAction>,
|
actions: Vec<SenderAction>,
|
||||||
// entity that will receive the message
|
// entity that will receive the message
|
||||||
target: Entity
|
target: Entity,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Method definitions, we provide inside the `SenderState`.
|
/// Method definitions, we provide inside the `SenderState`.
|
||||||
@@ -38,8 +38,11 @@ impl State for SenderState {
|
|||||||
// initialize the view entities
|
// initialize the view entities
|
||||||
fn init(&mut self, _registry: &mut Registry, ctx: &mut Context) {
|
fn init(&mut self, _registry: &mut Registry, ctx: &mut Context) {
|
||||||
// create the target entity, that receives the Sender messages
|
// create the target entity, that receives the Sender messages
|
||||||
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
self.target = Entity::from(
|
||||||
.expect("ERROR: SenderState::init(): target entity not found!"));
|
ctx.widget()
|
||||||
|
.try_clone::<u32>("target")
|
||||||
|
.expect("ERROR: SenderState::init(): target entity not found!"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update entities, before we render the view
|
// update entities, before we render the view
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ widget!(SenderView<SenderState> {
|
|||||||
|
|
||||||
impl Template for SenderView {
|
impl Template for SenderView {
|
||||||
fn template(self, id: Entity, bc: &mut BuildContext) -> Self {
|
fn template(self, id: Entity, bc: &mut BuildContext) -> Self {
|
||||||
self.name("SenderView")
|
self.name("SenderView").child(
|
||||||
.child(
|
|
||||||
Button::new()
|
Button::new()
|
||||||
.text("Click me to send a message!")
|
.text("Click me to send a message!")
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
@@ -28,7 +27,7 @@ impl Template for SenderView {
|
|||||||
//ctx.send_message(TestMessageAction::ToggleMessageBox, id);
|
//ctx.send_message(TestMessageAction::ToggleMessageBox, id);
|
||||||
false
|
false
|
||||||
})
|
})
|
||||||
.build(bc)
|
.build(bc),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ widget!(SenderWidget<SenderState> {
|
|||||||
|
|
||||||
impl Template for SenderWidget {
|
impl Template for SenderWidget {
|
||||||
fn template(self, id: Entity, bc: &mut BuildContext) -> Self {
|
fn template(self, id: Entity, bc: &mut BuildContext) -> Self {
|
||||||
self.name("SenderWidget")
|
self.name("SenderWidget").child(
|
||||||
.child(
|
|
||||||
Button::new()
|
Button::new()
|
||||||
.text("Click me to send a message!")
|
.text("Click me to send a message!")
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
@@ -23,7 +22,7 @@ impl Template for SenderWidget {
|
|||||||
states.get_mut::<SenderState>(id).send_message();
|
states.get_mut::<SenderState>(id).send_message();
|
||||||
false
|
false
|
||||||
})
|
})
|
||||||
.build(bc)
|
.build(bc),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,13 +30,13 @@ impl Template for SenderWidget {
|
|||||||
// States
|
// States
|
||||||
|
|
||||||
enum Action {
|
enum Action {
|
||||||
UpdateProgress(f64)
|
UpdateProgress(f64),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, AsAny)]
|
#[derive(Default, AsAny)]
|
||||||
struct SenderState {
|
struct SenderState {
|
||||||
actions: Vec<Action>,
|
actions: Vec<Action>,
|
||||||
target: Entity
|
target: Entity,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SenderState {
|
impl SenderState {
|
||||||
@@ -48,8 +47,11 @@ impl SenderState {
|
|||||||
|
|
||||||
impl State for SenderState {
|
impl State for SenderState {
|
||||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||||
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
self.target = Entity::from(
|
||||||
.expect("ERROR: SenderState::init(): target entity not found!"));
|
ctx.widget()
|
||||||
|
.try_clone::<u32>("target")
|
||||||
|
.expect("ERROR: SenderState::init(): target entity not found!"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
|
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||||
@@ -77,11 +79,7 @@ widget!(ReceiverWidget<ReceiverState>);
|
|||||||
impl Template for ReceiverWidget {
|
impl Template for ReceiverWidget {
|
||||||
fn template(self, _id: Entity, bc: &mut BuildContext) -> Self {
|
fn template(self, _id: Entity, bc: &mut BuildContext) -> Self {
|
||||||
self.name("ReceiverWidget")
|
self.name("ReceiverWidget")
|
||||||
.child(
|
.child(ProgressBar::new().id("progress_bar").build(bc))
|
||||||
ProgressBar::new()
|
|
||||||
.id("progress_bar")
|
|
||||||
.build(bc)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,15 +87,22 @@ impl Template for ReceiverWidget {
|
|||||||
|
|
||||||
#[derive(Default, AsAny)]
|
#[derive(Default, AsAny)]
|
||||||
struct ReceiverState {
|
struct ReceiverState {
|
||||||
progress_bar: Entity
|
progress_bar: Entity,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State for ReceiverState {
|
impl State for ReceiverState {
|
||||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||||
self.progress_bar = ctx.entity_of_child("progress_bar").expect("Cannot find ProgressBar!");
|
self.progress_bar = ctx
|
||||||
|
.entity_of_child("progress_bar")
|
||||||
|
.expect("Cannot find ProgressBar!");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn messages(&mut self, mut messages: MessageReader, _registry: &mut Registry, ctx: &mut Context) {
|
fn messages(
|
||||||
|
&mut self,
|
||||||
|
mut messages: MessageReader,
|
||||||
|
_registry: &mut Registry,
|
||||||
|
ctx: &mut Context,
|
||||||
|
) {
|
||||||
for action in messages.read::<Action>() {
|
for action in messages.read::<Action>() {
|
||||||
match action {
|
match action {
|
||||||
Action::UpdateProgress(amount) => {
|
Action::UpdateProgress(amount) => {
|
||||||
@@ -135,7 +140,7 @@ pub fn main() {
|
|||||||
.orientation("vertical")
|
.orientation("vertical")
|
||||||
.child(sender)
|
.child(sender)
|
||||||
.child(receiver)
|
.child(receiver)
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ struct Config {
|
|||||||
nested: Nested,
|
nested: Nested,
|
||||||
var: Variant,
|
var: Variant,
|
||||||
array: Vec<()>,
|
array: Vec<()>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
|||||||
@@ -21,11 +21,9 @@ fn main() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
widget!(
|
widget!(MainView {
|
||||||
MainView {
|
|
||||||
policy_number: String16
|
policy_number: String16
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
impl Template for MainView {
|
impl Template for MainView {
|
||||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||||
@@ -51,9 +49,7 @@ impl Template for MainView {
|
|||||||
//.child(ticket_data_button_menu)
|
//.child(ticket_data_button_menu)
|
||||||
.build(ctx);
|
.build(ctx);
|
||||||
|
|
||||||
let ticket_data_form_row_0 = Stack::new()
|
let ticket_data_form_row_0 = Stack::new().name("Row 0").build(ctx);
|
||||||
.name("Row 0")
|
|
||||||
.build(ctx);
|
|
||||||
|
|
||||||
let ticket_data_form = Container::new()
|
let ticket_data_form = Container::new()
|
||||||
//.id(ID_TICKET_DATA_FORM)
|
//.id(ID_TICKET_DATA_FORM)
|
||||||
@@ -72,7 +68,7 @@ impl Template for MainView {
|
|||||||
.push("auto") // Label
|
.push("auto") // Label
|
||||||
.push(14) // Delimiter
|
.push(14) // Delimiter
|
||||||
.push("*") // Data
|
.push("*") // Data
|
||||||
.push(4) // Delimiter
|
.push(4), // Delimiter
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
@@ -88,14 +84,12 @@ impl Template for MainView {
|
|||||||
.push(14) // Seperator
|
.push(14) // Seperator
|
||||||
.push("auto") // Row 10
|
.push("auto") // Row 10
|
||||||
.push(14) // Seperator
|
.push(14) // Seperator
|
||||||
.push("auto") // Row 12
|
.push("auto"), // Row 12
|
||||||
)
|
)
|
||||||
|
|
||||||
//.child(ticket_data_form_row_0)
|
//.child(ticket_data_form_row_0)
|
||||||
//.child(ticket_data_form_row_1)
|
//.child(ticket_data_form_row_1)
|
||||||
//.child(ticket_data_form_row_2)
|
//.child(ticket_data_form_row_2)
|
||||||
//.build(ctx),
|
//.build(ctx),
|
||||||
|
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.attach(Grid::row(0))
|
.attach(Grid::row(0))
|
||||||
@@ -237,7 +231,6 @@ impl Template for MainView {
|
|||||||
.orientation("horizontal")
|
.orientation("horizontal")
|
||||||
.visibility(Visibility::Collapsed)
|
.visibility(Visibility::Collapsed)
|
||||||
//.spacing("4")
|
//.spacing("4")
|
||||||
|
|
||||||
.child(
|
.child(
|
||||||
Button::new()
|
Button::new()
|
||||||
.margin(14)
|
.margin(14)
|
||||||
@@ -255,25 +248,18 @@ impl Template for MainView {
|
|||||||
.build(ctx);
|
.build(ctx);
|
||||||
|
|
||||||
// Starter page: Ticket Data Widget
|
// Starter page: Ticket Data Widget
|
||||||
self.name("TicketdataView")
|
self.name("TicketdataView").child(
|
||||||
.child(
|
|
||||||
Grid::new()
|
Grid::new()
|
||||||
//.id(ID_TICKET_DATA_WIDGET)
|
//.id(ID_TICKET_DATA_WIDGET)
|
||||||
.columns(
|
.columns(Columns::create().push(50).push("*").push(50))
|
||||||
Columns::create()
|
|
||||||
.push(50)
|
|
||||||
.push("*")
|
|
||||||
.push(50)
|
|
||||||
)
|
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
.push("auto") // Header
|
.push("auto") // Header
|
||||||
.push(28) // Seperator
|
.push(28) // Seperator
|
||||||
.push("*") // InputForm
|
.push("*") // InputForm
|
||||||
.push("auto") // ActionSend
|
.push("auto"), // ActionSend
|
||||||
//.push("auto") // Bottom )
|
//.push("auto") // Bottom )
|
||||||
)
|
)
|
||||||
|
|
||||||
.child(ticket_data_header_bar) // row 0
|
.child(ticket_data_header_bar) // row 0
|
||||||
.child(ticket_data_form) // row 2
|
.child(ticket_data_form) // row 2
|
||||||
.child(ticket_data_action) // row 3
|
.child(ticket_data_action) // row 3
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#[cfg(windows)] extern crate winapi;
|
#[cfg(windows)]
|
||||||
|
extern crate winapi;
|
||||||
use std::io::Error;
|
use std::io::Error;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@@ -7,13 +8,14 @@ fn print_message(msg: &str) -> Result<i32, Error> {
|
|||||||
use std::iter::once;
|
use std::iter::once;
|
||||||
use std::os::windows::ffi::OsStrExt;
|
use std::os::windows::ffi::OsStrExt;
|
||||||
use std::ptr::null_mut;
|
use std::ptr::null_mut;
|
||||||
use winapi::um::winuser::{MB_OK, MessageBoxW};
|
use winapi::um::winuser::{MessageBoxW, MB_OK};
|
||||||
let wide: Vec<u16> = OsStr::new(msg).encode_wide().chain(once(0)).collect();
|
let wide: Vec<u16> = OsStr::new(msg).encode_wide().chain(once(0)).collect();
|
||||||
let ret = unsafe {
|
let ret = unsafe { MessageBoxW(null_mut(), wide.as_ptr(), wide.as_ptr(), MB_OK) };
|
||||||
MessageBoxW(null_mut(), wide.as_ptr(), wide.as_ptr(), MB_OK)
|
if ret == 0 {
|
||||||
};
|
Err(Error::last_os_error())
|
||||||
if ret == 0 { Err(Error::last_os_error()) }
|
} else {
|
||||||
else { Ok(ret) }
|
Ok(ret)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use orbtk::prelude::*;
|
|||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
enum Action {
|
enum Action {
|
||||||
EntryActivated(Entity),
|
EntryActivated(Entity),
|
||||||
EntryChanged(Entity)
|
EntryChanged(Entity),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(AsAny)]
|
#[derive(AsAny)]
|
||||||
@@ -66,10 +66,7 @@ impl State for MainViewState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
|
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
|
||||||
TextBlock::new()
|
TextBlock::new().text(text).style("header").build(ctx)
|
||||||
.text(text)
|
|
||||||
.style("header")
|
|
||||||
.build(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
widget!(
|
widget!(
|
||||||
@@ -85,19 +82,8 @@ impl Template for MainView {
|
|||||||
self.name("MainView").child(
|
self.name("MainView").child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.background("#fafafa")
|
.background("#fafafa")
|
||||||
.columns(
|
.columns(Columns::create().push(150.0).push("*").push(150.0).build())
|
||||||
Columns::create()
|
.rows(Rows::create().push("*").push("*").build())
|
||||||
.push(150.0)
|
|
||||||
.push("*")
|
|
||||||
.push(150.0)
|
|
||||||
.build(),
|
|
||||||
)
|
|
||||||
.rows(
|
|
||||||
Rows::create()
|
|
||||||
.push("*")
|
|
||||||
.push("*")
|
|
||||||
.build(),
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
//.element("policyholder_check")
|
//.element("policyholder_check")
|
||||||
@@ -146,7 +132,7 @@ impl Template for MainView {
|
|||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ pub static PROP_MAIL_TO_4: &str = "sekretariat@m2-mediation.de";
|
|||||||
/// Mail header 5th List-Entry 'Recpt-To': recipient name
|
/// Mail header 5th List-Entry 'Recpt-To': recipient name
|
||||||
pub static PROP_MAIL_TO_5: &str = "kooperation@rightmart.de";
|
pub static PROP_MAIL_TO_5: &str = "kooperation@rightmart.de";
|
||||||
/// Mail header 6th List-Entry 'Recpt-To': recipient name
|
/// Mail header 6th List-Entry 'Recpt-To': recipient name
|
||||||
pub static PROP_MAIL_TO_6: &str = "ralf.zerres@networkx.de";
|
pub static PROP_MAIL_TO_6: &str = "allianz@legalhero.de";
|
||||||
|
/// Mail header 7th List-Entry 'Recpt-To': recipient name
|
||||||
|
pub static PROP_MAIL_TO_7: &str = "ralf.zerres@networkx.de";
|
||||||
|
|
||||||
/// Property: policy_check
|
/// Property: policy_check
|
||||||
pub static PROP_POLICY_CHECK: &str = "policy_check";
|
pub static PROP_POLICY_CHECK: &str = "policy_check";
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/// provides orbtk widgets constants
|
/// provides orbtk widgets constants
|
||||||
pub mod constants;
|
pub mod constants;
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,13 @@ use serde::{Deserialize, Serialize};
|
|||||||
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Serialize)]
|
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Serialize)]
|
||||||
pub enum PolicyCode {
|
pub enum PolicyCode {
|
||||||
/// Allianz Sachversicherung
|
/// Allianz Sachversicherung
|
||||||
AS
|
AS,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for PolicyCode {
|
impl Default for PolicyCode {
|
||||||
fn default() -> Self { PolicyCode::AS }
|
fn default() -> Self {
|
||||||
|
PolicyCode::AS
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Classifier of the Allinaz DirectCall communication type.
|
/// Classifier of the Allinaz DirectCall communication type.
|
||||||
@@ -59,11 +61,13 @@ pub enum CommunicationType {
|
|||||||
/// Zeugins
|
/// Zeugins
|
||||||
ZE,
|
ZE,
|
||||||
/// Typ is unspecified
|
/// Typ is unspecified
|
||||||
XX
|
XX,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for CommunicationType {
|
impl Default for CommunicationType {
|
||||||
fn default() -> Self { CommunicationType::XX }
|
fn default() -> Self {
|
||||||
|
CommunicationType::XX
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Status of a given policy data element.
|
/// Status of a given policy data element.
|
||||||
@@ -72,11 +76,13 @@ pub enum Status {
|
|||||||
/// Active -> the policy is active an supported
|
/// Active -> the policy is active an supported
|
||||||
Active,
|
Active,
|
||||||
/// Inactive -> the policy is inactive or resigned
|
/// Inactive -> the policy is inactive or resigned
|
||||||
Inactive
|
Inactive,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Status {
|
impl Default for Status {
|
||||||
fn default() -> Self { Status::Active }
|
fn default() -> Self {
|
||||||
|
Status::Active
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A communication type describes possible classifications of customer calls.
|
/// A communication type describes possible classifications of customer calls.
|
||||||
@@ -86,7 +92,7 @@ pub struct CommunicationData {
|
|||||||
/// pub communication_type: CommunicationType,
|
/// pub communication_type: CommunicationType,
|
||||||
pub communication_type: String,
|
pub communication_type: String,
|
||||||
/// A literal name describing the selected communication type
|
/// A literal name describing the selected communication type
|
||||||
pub communication_name: String
|
pub communication_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CSV Export
|
/// CSV Export
|
||||||
@@ -139,7 +145,7 @@ pub struct Email {
|
|||||||
/// Body type harm type
|
/// Body type harm type
|
||||||
pub harm_type: String,
|
pub harm_type: String,
|
||||||
/// Body type ivr comment
|
/// Body type ivr comment
|
||||||
pub ivr_comment: String
|
pub ivr_comment: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Email {}
|
impl Email {}
|
||||||
@@ -151,7 +157,7 @@ pub struct HarmData {
|
|||||||
pub harm_data: Vec<HarmType>,
|
pub harm_data: Vec<HarmType>,
|
||||||
/// Status der Schadenliste
|
/// Status der Schadenliste
|
||||||
//pub name: String,
|
//pub name: String,
|
||||||
pub selected: bool
|
pub selected: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Harm types are destincted by a type code.
|
/// Harm types are destincted by a type code.
|
||||||
@@ -186,7 +192,7 @@ pub struct PolicyCheck {
|
|||||||
/// Referenz zur Versicherungsschein-Nummer
|
/// Referenz zur Versicherungsschein-Nummer
|
||||||
pub policy_number: u64,
|
pub policy_number: u64,
|
||||||
/// Validitätsergebnis
|
/// Validitätsergebnis
|
||||||
pub policy_number_status: Status
|
pub policy_number_status: Status,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PolicyCheck {}
|
impl PolicyCheck {}
|
||||||
@@ -256,7 +262,7 @@ pub struct PolicyDataList {
|
|||||||
/// Name der Versicherungsliste
|
/// Name der Versicherungsliste
|
||||||
pub name: String,
|
pub name: String,
|
||||||
/// Status der Versicherungsliste
|
/// Status der Versicherungsliste
|
||||||
pub selected: bool
|
pub selected: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// implements the helper methods, to manage policy data collections.
|
/// implements the helper methods, to manage policy data collections.
|
||||||
@@ -335,7 +341,7 @@ pub struct PolicyData {
|
|||||||
#[serde(rename = "POLLFNR")]
|
#[serde(rename = "POLLFNR")]
|
||||||
pub policy_number: u64,
|
pub policy_number: u64,
|
||||||
/// Status des Versicherungsscheins
|
/// Status des Versicherungsscheins
|
||||||
pub status: Option<Status>
|
pub status: Option<Status>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Policy Number Set
|
/// Policy Number Set
|
||||||
@@ -350,7 +356,7 @@ pub struct AllianzPolicyNumber {
|
|||||||
pub policy_code: String,
|
pub policy_code: String,
|
||||||
/// 10-stellige Versicherungsscheinnummer (numerisch)
|
/// 10-stellige Versicherungsscheinnummer (numerisch)
|
||||||
#[serde(rename = "POLLFNR")]
|
#[serde(rename = "POLLFNR")]
|
||||||
pub policy_number: usize
|
pub policy_number: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// List of Allianz Policy Number records
|
// /// List of Allianz Policy Number records
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#![crate_name = "advotracker_client"]
|
#![crate_name = "advotracker_client"]
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
#![warn(missing_docs, rust_2018_idioms, rust_2018_compatibility)]
|
#![warn(missing_docs, rust_2018_idioms, rust_2018_compatibility)]
|
||||||
|
|
||||||
//! advotracker
|
//! advotracker
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
#![windows_subsystem = "windows"]
|
#![windows_subsystem = "windows"]
|
||||||
|
|
||||||
//use chrono::{Local, DateTime};
|
//use chrono::{Local, DateTime};
|
||||||
use dotenv::dotenv;
|
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
|
use dotenv::dotenv;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::env;
|
use std::env;
|
||||||
//use std::process;
|
//use std::process;
|
||||||
@@ -42,11 +42,13 @@ struct Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Style extension
|
// Style extension
|
||||||
static DEFAULT_DARK_EXT: &str = include_str!("../assets/advotracker/default_dark.ron");
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(windows)] {
|
if #[cfg(windows)] {
|
||||||
static FLUENT_DARK_EXT: &str = include_str!("../assets/advotracker/fluent_dark.ron");
|
static DEFAULT_DARK_EXT: &str = include_str!("../assets/advotracker/default_dark.ron");
|
||||||
static FLUENT_LIGHT_EXT: &str = include_str!("../assets/advotracker/fluent_light.ron");
|
//static FLUENT_DARK_EXT: &str = include_str!("../assets/advotracker/fluent_dark.ron");
|
||||||
|
//static FLUENT_LIGHT_EXT: &str = include_str!("../assets/advotracker/fluent_light.ron");
|
||||||
|
} else {
|
||||||
|
static DEFAULT_DARK_EXT: &str = include_str!("../assets/advotracker/default_dark.ron");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +63,8 @@ fn get_lang() -> String {
|
|||||||
|
|
||||||
// prepare lang_id to represent twine language prefix
|
// prepare lang_id to represent twine language prefix
|
||||||
// env: "de_DE.UTF-8" -> "De"
|
// env: "de_DE.UTF-8" -> "De"
|
||||||
lang_id = lang_id.substring(0,2).to_string();
|
lang_id = lang_id.substring(0, 2).to_string();
|
||||||
lang_id.replace_range(..1, &lang_id.substring(0,1).to_string().to_uppercase() );
|
lang_id.replace_range(..1, &lang_id.substring(0, 1).to_string().to_uppercase());
|
||||||
|
|
||||||
// handle testing environment variables (.env file) with precedence
|
// handle testing environment variables (.env file) with precedence
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
@@ -71,11 +73,13 @@ fn get_lang() -> String {
|
|||||||
if environment.test_lang != lang_id {
|
if environment.test_lang != lang_id {
|
||||||
info!("GUI-Language: preset from .env to {:?}", lang_id);
|
info!("GUI-Language: preset from .env to {:?}", lang_id);
|
||||||
lang_id = environment.test_lang;
|
lang_id = environment.test_lang;
|
||||||
lang_id = lang_id.substring(0,2).to_string();
|
lang_id = lang_id.substring(0, 2).to_string();
|
||||||
lang_id.replace_range(..1, &lang_id.substring(0,1).to_string().to_uppercase() );
|
lang_id.replace_range(..1, &lang_id.substring(0, 1).to_string().to_uppercase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
info!(target: "advotracker", "{}", e)
|
||||||
}
|
}
|
||||||
},
|
|
||||||
Err(e) => { info!(target: "advotracker", "{}", e) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let lang = format!("Lang::{}(\"{}\")", lang_id, lang_variant);
|
let lang = format!("Lang::{}(\"{}\")", lang_id, lang_variant);
|
||||||
@@ -96,19 +100,22 @@ cfg_if! {
|
|||||||
.extend(ThemeConfig::from(THEME_DEFAULT_FONTS)),
|
.extend(ThemeConfig::from(THEME_DEFAULT_FONTS)),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
fn theme_fluent() -> Theme {
|
// fn theme_fluent_dark() -> Theme {
|
||||||
orbtk::widgets::themes::theme_fluent::register_fluent_fonts(Theme::from_config(
|
// orbtk::widgets::themes::theme_fluent::register_fluent_fonts(Theme::from_config(
|
||||||
ThemeConfig::from(FLUENT_DARK_EXT)
|
// ThemeConfig::from(FLUENT_DARK_EXT)
|
||||||
.extend(ThemeConfig::from(THEME_FLUENT))
|
|
||||||
.extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
|
|
||||||
.extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
|
||||||
))
|
|
||||||
// orbtk::widgets::themes::theme_orbtk::register_fluent_fonts(Theme::from_config(
|
|
||||||
// ThemeConfig::from(FLUENT_LIGHT_EXT)
|
|
||||||
// .extend(ThemeConfig::from(THEME_FLUENT))
|
// .extend(ThemeConfig::from(THEME_FLUENT))
|
||||||
// .extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
|
// .extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
|
||||||
// .extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
// .extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
||||||
}
|
// ))
|
||||||
|
// }
|
||||||
|
// fn theme_fluent_light() -> Theme {
|
||||||
|
// orbtk::widgets::themes::theme_fluent::register_fluent_fonts(Theme::from_config(
|
||||||
|
// ThemeConfig::from(FLUENT_LIGHT_EXT)
|
||||||
|
// .extend(ThemeConfig::from(THEME_FLUENT))
|
||||||
|
// .extend(ThemeConfig::from(THEME_FLUENT_COLORS_LIGHT))
|
||||||
|
// .extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
||||||
|
// ))
|
||||||
|
// }
|
||||||
} else {
|
} else {
|
||||||
/// Extend and register theme assets.
|
/// Extend and register theme assets.
|
||||||
fn theme() -> Theme {
|
fn theme() -> Theme {
|
||||||
@@ -181,7 +188,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||||
|
|
||||||
// type conversion (viperus String -> u64)
|
// type conversion (viperus String -> u64)
|
||||||
let test_policy_number = viperus.get::<String>("test_policy_number").unwrap().parse::<u64>().unwrap();
|
let test_policy_number = viperus
|
||||||
|
.get::<String>("test_policy_number")
|
||||||
|
.unwrap()
|
||||||
|
.parse::<u64>()
|
||||||
|
.unwrap();
|
||||||
trace!(target: "advotracker", test_policy_number = ?test_policy_number);
|
trace!(target: "advotracker", test_policy_number = ?test_policy_number);
|
||||||
|
|
||||||
// main tasks
|
// main tasks
|
||||||
@@ -201,9 +212,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.dictionary("de_DE", ADVOTRACKER_DE_DE)
|
.dictionary("de_DE", ADVOTRACKER_DE_DE)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
cfg_if! {
|
||||||
|
if #[cfg(windows)] {
|
||||||
Application::from_name("nwx.advotracker")
|
Application::from_name("nwx.advotracker")
|
||||||
.localization(localization)
|
.localization(localization)
|
||||||
.theme(theme())
|
.theme(theme())
|
||||||
|
//.theme(theme_fluent_light())
|
||||||
.window(|ctx| {
|
.window(|ctx| {
|
||||||
Window::new()
|
Window::new()
|
||||||
.title("AdvoTracker - DirectCall")
|
.title("AdvoTracker - DirectCall")
|
||||||
@@ -216,6 +230,24 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.build(ctx)
|
.build(ctx)
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
|
} else{
|
||||||
|
Application::from_name("nwx.advotracker")
|
||||||
|
.localization(localization)
|
||||||
|
.theme(theme())
|
||||||
|
.window(|ctx| {
|
||||||
|
Window::new()
|
||||||
|
.title("AdvoTracker - DirectCall")
|
||||||
|
.position((500.0, 100.0))
|
||||||
|
.size(800.0, 620.0)
|
||||||
|
//.min_width(460.0)
|
||||||
|
//.min_height(380.0)
|
||||||
|
.resizeable(true)
|
||||||
|
.child(main_view::MainView::new().build(ctx))
|
||||||
|
.build(ctx)
|
||||||
|
})
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
state = t!(state_finished => lang);
|
state = t!(state_finished => lang);
|
||||||
res = t!(main_finished => lang);
|
res = t!(main_finished => lang);
|
||||||
|
|||||||
@@ -45,8 +45,14 @@ pub fn parse_args(viperus: &mut Viperus) -> Result<(), Box<dyn std::error::Error
|
|||||||
viperus.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
|
viperus.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
|
||||||
viperus.add_default("export_file", String::from(""));
|
viperus.add_default("export_file", String::from(""));
|
||||||
viperus.add_default("test_policy_number", String::from("9999999992"));
|
viperus.add_default("test_policy_number", String::from("9999999992"));
|
||||||
viperus.add_default("to_email_address_file", String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"));
|
viperus.add_default(
|
||||||
viperus.add_default("from_email_address_file", String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>"));
|
"to_email_address_file",
|
||||||
|
String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"),
|
||||||
|
);
|
||||||
|
viperus.add_default(
|
||||||
|
"from_email_address_file",
|
||||||
|
String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>"),
|
||||||
|
);
|
||||||
//viperus.add_default("username", String::from("nctalkbot"));
|
//viperus.add_default("username", String::from("nctalkbot"));
|
||||||
//viperus.add_default("password", String::from("botpassword"));
|
//viperus.add_default("password", String::from("botpassword"));
|
||||||
viperus.add_default("verbose", 0);
|
viperus.add_default("verbose", 0);
|
||||||
@@ -57,11 +63,13 @@ pub fn parse_args(viperus: &mut Viperus) -> Result<(), Box<dyn std::error::Error
|
|||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.author(crate_authors!())
|
.author(crate_authors!())
|
||||||
.about(crate_description!())
|
.about(crate_description!())
|
||||||
.after_help("
|
.after_help(
|
||||||
|
"
|
||||||
Testprogramm: Allianz Online-Beratung Im/Export CSV-Daten
|
Testprogramm: Allianz Online-Beratung Im/Export CSV-Daten
|
||||||
Direct-Call via IVR-System (Interactive Voice Response)
|
Direct-Call via IVR-System (Interactive Voice Response)
|
||||||
SMR Deckungssummen-Prüfung: 089 92529 60211
|
SMR Deckungssummen-Prüfung: 089 92529 60211
|
||||||
SMR Unerledigt: 089 92529 60222")
|
SMR Unerledigt: 089 92529 60222",
|
||||||
|
)
|
||||||
.template(
|
.template(
|
||||||
"\
|
"\
|
||||||
{bin} v{version}
|
{bin} v{version}
|
||||||
|
|||||||
@@ -7,18 +7,15 @@
|
|||||||
|
|
||||||
use lettre::{
|
use lettre::{
|
||||||
message::{header, MultiPart, SinglePart},
|
message::{header, MultiPart, SinglePart},
|
||||||
Message, SmtpTransport, Transport,
|
|
||||||
transport::smtp::authentication::Credentials,
|
transport::smtp::authentication::Credentials,
|
||||||
|
Message, SmtpTransport, Transport,
|
||||||
};
|
};
|
||||||
use maud::html;
|
use maud::html;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
//use std::process;
|
//use std::process;
|
||||||
use tracing::{info, trace};
|
use tracing::{info, trace};
|
||||||
|
|
||||||
use crate::{
|
use crate::{data::structures::Email, Lang};
|
||||||
data::structures::Email,
|
|
||||||
Lang,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// send ticket data via eMail
|
/// send ticket data via eMail
|
||||||
pub fn sendticketdata(email: &Email, lang: &Lang) -> Result<(), Box<dyn Error>> {
|
pub fn sendticketdata(email: &Email, lang: &Lang) -> Result<(), Box<dyn Error>> {
|
||||||
@@ -49,13 +46,27 @@ pub fn sendticketdata(email: &Email, lang: &Lang) -> Result<(), Box<dyn Error>>
|
|||||||
};
|
};
|
||||||
|
|
||||||
let ascii_body = String::new()
|
let ascii_body = String::new()
|
||||||
+ &"Vers.-Schein/Schadennummer".to_string() + &(email.policy_code) + &"\n"
|
+ &"Vers.-Schein/Schadennummer".to_string()
|
||||||
+ &"Versicherungsnehmer: ".to_string() + &(email.policy_holder) + &"\n"
|
+ &(email.policy_code)
|
||||||
+ &"Selbstbehalt: ".to_string() + &(email.deductible) + &"\n"
|
+ &"\n"
|
||||||
+ &"Rückrufnummer: ".to_string()+ &(email.callback_number) + &"\n"
|
+ &"Versicherungsnehmer: ".to_string()
|
||||||
+ &"Erreichbarkeit: ".to_string() + &(email.callback_date) + &"\n"
|
+ &(email.policy_holder)
|
||||||
+ &"Rechtsproblem: ".to_string() + &(email.harm_type) + &"\n"
|
+ &"\n"
|
||||||
+ &"Rechtsrat: ".to_string() + &(email.ivr_comment) + &"\n";
|
+ &"Selbstbehalt: ".to_string()
|
||||||
|
+ &(email.deductible)
|
||||||
|
+ &"\n"
|
||||||
|
+ &"Rückrufnummer: ".to_string()
|
||||||
|
+ &(email.callback_number)
|
||||||
|
+ &"\n"
|
||||||
|
+ &"Erreichbarkeit: ".to_string()
|
||||||
|
+ &(email.callback_date)
|
||||||
|
+ &"\n"
|
||||||
|
+ &"Rechtsproblem: ".to_string()
|
||||||
|
+ &(email.harm_type)
|
||||||
|
+ &"\n"
|
||||||
|
+ &"Rechtsrat: ".to_string()
|
||||||
|
+ &(email.ivr_comment)
|
||||||
|
+ &"\n";
|
||||||
|
|
||||||
info!("email body: {:?}", ascii_body);
|
info!("email body: {:?}", ascii_body);
|
||||||
|
|
||||||
@@ -66,11 +77,12 @@ pub fn sendticketdata(email: &Email, lang: &Lang) -> Result<(), Box<dyn Error>>
|
|||||||
.cc((email.mail_cc).parse().unwrap())
|
.cc((email.mail_cc).parse().unwrap())
|
||||||
// we do not use bcc yet
|
// we do not use bcc yet
|
||||||
//.bcc((email.mail_bcc).parse().unwrap())
|
//.bcc((email.mail_bcc).parse().unwrap())
|
||||||
.subject(String::new()
|
.subject(
|
||||||
|
String::new()
|
||||||
+ &email.subject.to_string()
|
+ &email.subject.to_string()
|
||||||
+ &" (".to_string()
|
+ &" (".to_string()
|
||||||
+ &email.policy_code.to_string()
|
+ &email.policy_code.to_string()
|
||||||
+ &")".to_string()
|
+ &")".to_string(),
|
||||||
)
|
)
|
||||||
.multipart(
|
.multipart(
|
||||||
MultiPart::alternative() // This is composed of two parts.
|
MultiPart::alternative() // This is composed of two parts.
|
||||||
@@ -87,12 +99,14 @@ pub fn sendticketdata(email: &Email, lang: &Lang) -> Result<(), Box<dyn Error>>
|
|||||||
)
|
)
|
||||||
.expect("failed to build email");
|
.expect("failed to build email");
|
||||||
|
|
||||||
|
|
||||||
info!("message: {:?}", message);
|
info!("message: {:?}", message);
|
||||||
|
|
||||||
// Create credential for remote authentication (username, password)
|
// Create credential for remote authentication (username, password)
|
||||||
// WIP: get credentials from config file / cli
|
// WIP: get credentials from config file / cli
|
||||||
let credentials = Credentials::new("service@hiedemann.de".to_string(), "88service99$".to_string());
|
let credentials = Credentials::new(
|
||||||
|
"service@hiedemann.de".to_string(),
|
||||||
|
"88service99$".to_string(),
|
||||||
|
);
|
||||||
|
|
||||||
// standard smtp client connection
|
// standard smtp client connection
|
||||||
//let mailer = SmtpTransport::starttls_relay("hiedemannsbs.kanzlei.hiedemann.de")
|
//let mailer = SmtpTransport::starttls_relay("hiedemannsbs.kanzlei.hiedemann.de")
|
||||||
|
|||||||
@@ -5,15 +5,15 @@
|
|||||||
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use chrono::{Local, DateTime};
|
use chrono::{DateTime, Local};
|
||||||
use std::error::Error;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::error::Error;
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
|
||||||
//use crate::db::redis;
|
//use crate::db::redis;
|
||||||
use crate::{
|
use crate::{
|
||||||
data::structures::{PolicyCode, PolicyDataList, PolicyData},
|
data::structures::{PolicyCode, PolicyData, PolicyDataList},
|
||||||
Lang,
|
Lang,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -21,13 +21,15 @@ use crate::{
|
|||||||
/// save records to redis backend
|
/// save records to redis backend
|
||||||
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
||||||
/// https://blog.burntsushi.net/csv/
|
/// https://blog.burntsushi.net/csv/
|
||||||
pub fn import(path: &mut String, data_list: &mut PolicyDataList,
|
pub fn import(
|
||||||
|
path: &mut String,
|
||||||
|
data_list: &mut PolicyDataList,
|
||||||
policy_numbers: &mut HashMap<u64, PolicyCode>,
|
policy_numbers: &mut HashMap<u64, PolicyCode>,
|
||||||
policy_data_count: &mut u64)
|
policy_data_count: &mut u64,
|
||||||
-> Result<(u64, Duration), Box<dyn Error>> {
|
) -> Result<(u64, Duration), Box<dyn Error>> {
|
||||||
|
use std::ffi::OsStr;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::ffi::OsStr;
|
|
||||||
|
|
||||||
let lang = Lang::De("");
|
let lang = Lang::De("");
|
||||||
let mut res = t!(csv_import_started => lang);
|
let mut res = t!(csv_import_started => lang);
|
||||||
@@ -66,7 +68,7 @@ pub fn import(path: &mut String, data_list: &mut PolicyDataList,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over each record, deserialize und write to our structures
|
// Iterate over each record, deserialize und write to our structures
|
||||||
let mut count : u64 = 0;
|
let mut count: u64 = 0;
|
||||||
for result in csv_reader.deserialize() {
|
for result in csv_reader.deserialize() {
|
||||||
// The iterator yields Result<StringRecord, Error>, so we check the
|
// The iterator yields Result<StringRecord, Error>, so we check the
|
||||||
// error here.
|
// error here.
|
||||||
@@ -82,12 +84,13 @@ pub fn import(path: &mut String, data_list: &mut PolicyDataList,
|
|||||||
// push record as new vector elements
|
// push record as new vector elements
|
||||||
data_list.push(record);
|
data_list.push(record);
|
||||||
|
|
||||||
count +=1;
|
count += 1;
|
||||||
*policy_data_count = count;
|
*policy_data_count = count;
|
||||||
};
|
}
|
||||||
|
|
||||||
let time_end = SystemTime::now();
|
let time_end = SystemTime::now();
|
||||||
let duration = time_end.duration_since(time_start)
|
let duration = time_end
|
||||||
|
.duration_since(time_start)
|
||||||
.expect("Clock may have gone backwards");
|
.expect("Clock may have gone backwards");
|
||||||
trace!(target: "csv-import", record_count = ?count, duration = ?duration);
|
trace!(target: "csv-import", record_count = ?count, duration = ?duration);
|
||||||
|
|
||||||
@@ -102,18 +105,22 @@ pub fn import(path: &mut String, data_list: &mut PolicyDataList,
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_import() {
|
fn test_import() {
|
||||||
// Takes a reference and returns Option<&V>
|
// Takes a reference and returns Option<&V>
|
||||||
let my_policy_numbers : [u64; 2] = [1511111111, 9999999993];
|
let my_policy_numbers: [u64; 2] = [1511111111, 9999999993];
|
||||||
assert_eq!(my_policy_numbers, [1511111111, 9999999993]);
|
assert_eq!(my_policy_numbers, [1511111111, 9999999993]);
|
||||||
|
|
||||||
let mut csv_import_path = String::from("data/POLLFNR_TEST.txt");
|
let mut csv_import_path = String::from("data/POLLFNR_TEST.txt");
|
||||||
let mut policy_data = PolicyDataList::new("PolicyDataList");
|
let mut policy_data = PolicyDataList::new("PolicyDataList");
|
||||||
let mut policy_numbers : HashMap<u64, PolicyCode> = HashMap::new();
|
let mut policy_numbers: HashMap<u64, PolicyCode> = HashMap::new();
|
||||||
let mut policy_data_count: u64 = 0;
|
let mut policy_data_count: u64 = 0;
|
||||||
let lang = "en".to_string();
|
let lang = "en".to_string();
|
||||||
|
|
||||||
match import(&mut csv_import_path, &mut policy_data,
|
match import(
|
||||||
&mut policy_numbers, &mut policy_data_count,
|
&mut csv_import_path,
|
||||||
&lang) {
|
&mut policy_data,
|
||||||
|
&mut policy_numbers,
|
||||||
|
&mut policy_data_count,
|
||||||
|
&lang,
|
||||||
|
) {
|
||||||
Ok((count, duration)) => {
|
Ok((count, duration)) => {
|
||||||
println!("import {:?} records. Duration: {:?}", count, duration);
|
println!("import {:?} records. Duration: {:?}", count, duration);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ pub enum ConfigurationAction {
|
|||||||
/// Define valid configuration data.
|
/// Define valid configuration data.
|
||||||
/// This structure is serialized and saved inside the OS dependent settings file.
|
/// This structure is serialized and saved inside the OS dependent settings file.
|
||||||
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
||||||
struct ConfigurationData(
|
struct ConfigurationData(pub String, pub String);
|
||||||
pub String,
|
|
||||||
pub String
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Valid `structures` that are handled inside the state of the `Configuration` widget.
|
/// Valid `structures` that are handled inside the state of the `Configuration` widget.
|
||||||
#[derive(Debug, Default, AsAny)]
|
#[derive(Debug, Default, AsAny)]
|
||||||
@@ -45,20 +42,17 @@ impl State for ConfigurationState {
|
|||||||
registry
|
registry
|
||||||
.get::<Settings>("settings")
|
.get::<Settings>("settings")
|
||||||
.load_async::<ConfigurationData>(
|
.load_async::<ConfigurationData>(
|
||||||
"configuration_data".to_string(), ctx.entity()
|
"configuration_data".to_string(),
|
||||||
|
ctx.entity(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ConfigurationAction::SaveConfiguration => {
|
ConfigurationAction::SaveConfiguration => {
|
||||||
let configuration_file: String = ConfigurationView::configuration_file_clone(&ctx.widget());
|
let configuration_file: String =
|
||||||
|
ConfigurationView::configuration_file_clone(&ctx.widget());
|
||||||
let language_id: String = ConfigurationView::language_id_clone(&ctx.widget());
|
let language_id: String = ConfigurationView::language_id_clone(&ctx.widget());
|
||||||
registry
|
registry.get::<Settings>("settings").save_async(
|
||||||
.get::<Settings>("settings")
|
|
||||||
.save_async(
|
|
||||||
"configuration_data".to_string(),
|
"configuration_data".to_string(),
|
||||||
ConfigurationData(
|
ConfigurationData(configuration_file, language_id),
|
||||||
configuration_file,
|
|
||||||
language_id
|
|
||||||
),
|
|
||||||
ctx.entity(),
|
ctx.entity(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,13 +31,9 @@ impl Template for ConfigurationView {
|
|||||||
Grid::new()
|
Grid::new()
|
||||||
.id(ID_CONFIGURATION_FORM)
|
.id(ID_CONFIGURATION_FORM)
|
||||||
.style("configuration_form")
|
.style("configuration_form")
|
||||||
.columns(
|
.columns(Columns::create().push(120).push(12).push("auto"))
|
||||||
Columns::create()
|
.rows(
|
||||||
.push(120)
|
Rows::create()
|
||||||
.push(12)
|
|
||||||
.push("auto")
|
|
||||||
)
|
|
||||||
.rows(Rows::create()
|
|
||||||
.push("auto") // Header_Bar
|
.push("auto") // Header_Bar
|
||||||
.push(4) // Seperator
|
.push(4) // Seperator
|
||||||
.push("auto") // Configuartion_File
|
.push("auto") // Configuartion_File
|
||||||
@@ -101,15 +97,8 @@ impl Template for ConfigurationView {
|
|||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(6))
|
.attach(Grid::row(6))
|
||||||
.attach(Grid::column_span(3))
|
.attach(Grid::column_span(3))
|
||||||
.columns(
|
.columns(Columns::create().push("auto").push(8).push("auto"))
|
||||||
Columns::create()
|
.rows(Rows::create().push("auto"))
|
||||||
.push("auto")
|
|
||||||
.push(8)
|
|
||||||
.push("auto")
|
|
||||||
)
|
|
||||||
.rows(Rows::create()
|
|
||||||
.push("auto")
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
Button::new()
|
Button::new()
|
||||||
.style("button_single_content")
|
.style("button_single_content")
|
||||||
|
|||||||
@@ -13,10 +13,7 @@ use tracing::{info, trace};
|
|||||||
|
|
||||||
use orbtk::prelude::*;
|
use orbtk::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{data::constants::*, data::structures::PolicyList};
|
||||||
data::constants::*,
|
|
||||||
data::structures::PolicyList
|
|
||||||
};
|
|
||||||
|
|
||||||
/// define valid environment variables provided via .env files
|
/// define valid environment variables provided via .env files
|
||||||
/// located in the current call directory
|
/// located in the current call directory
|
||||||
@@ -33,16 +30,20 @@ pub trait GlobalState {
|
|||||||
fn get_lang() -> String {
|
fn get_lang() -> String {
|
||||||
// get system environment
|
// get system environment
|
||||||
let mut lang = env::var("LANG").unwrap_or_else(|_| "C".to_string());
|
let mut lang = env::var("LANG").unwrap_or_else(|_| "C".to_string());
|
||||||
lang = lang.substring(0,5).to_string(); // "de_DE.UTF-8" -> "de_DE"
|
lang = lang.substring(0, 5).to_string(); // "de_DE.UTF-8" -> "de_DE"
|
||||||
info!("GUI-Language: preset to {:?}", lang);
|
info!("GUI-Language: preset to {:?}", lang);
|
||||||
|
|
||||||
// testing environment: read from .env file
|
// testing environment: read from .env file
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
match envy::from_env::<Environment>() {
|
match envy::from_env::<Environment>() {
|
||||||
Ok(environment) => {
|
Ok(environment) => {
|
||||||
if environment.test_lang != lang { lang = environment.test_lang; }
|
if environment.test_lang != lang {
|
||||||
},
|
lang = environment.test_lang;
|
||||||
Err(e) => { info!(target: "advotracker", "{}", e) }
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
info!(target: "advotracker", "{}", e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
trace!(target: "advotracker", lang = ?lang);
|
trace!(target: "advotracker", lang = ?lang);
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,7 @@
|
|||||||
|
|
||||||
use orbtk::prelude::*;
|
use orbtk::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{data::constants::*, widgets::localization::localization_state::LocalizationState};
|
||||||
data::constants::*,
|
|
||||||
widgets::localization::localization_state::LocalizationState,
|
|
||||||
};
|
|
||||||
|
|
||||||
type List = Vec<String>;
|
type List = Vec<String>;
|
||||||
|
|
||||||
@@ -31,19 +28,13 @@ impl Template for LocalizationView {
|
|||||||
let languages = vec!["English".to_string(), "German".to_string()];
|
let languages = vec!["English".to_string(), "German".to_string()];
|
||||||
let count = languages.len();
|
let count = languages.len();
|
||||||
|
|
||||||
self.languages(languages)
|
self.languages(languages).selected_index(1).child(
|
||||||
.selected_index(1)
|
|
||||||
.child(
|
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.id(ID_LOCALIZATION_FORM)
|
.id(ID_LOCALIZATION_FORM)
|
||||||
.margin(4)
|
.margin(4)
|
||||||
.columns(
|
.columns(Columns::create().push(120).push(12).push(150))
|
||||||
Columns::create()
|
.rows(
|
||||||
.push(120)
|
Rows::create()
|
||||||
.push(12)
|
|
||||||
.push(150)
|
|
||||||
)
|
|
||||||
.rows(Rows::create()
|
|
||||||
.push("auto")
|
.push("auto")
|
||||||
.push(4)
|
.push(4)
|
||||||
.push("auto")
|
.push("auto")
|
||||||
@@ -80,9 +71,8 @@ impl Template for LocalizationView {
|
|||||||
.attach(Grid::column(2))
|
.attach(Grid::column(2))
|
||||||
.attach(Grid::row(2))
|
.attach(Grid::row(2))
|
||||||
.items_builder(move |bc, index| {
|
.items_builder(move |bc, index| {
|
||||||
let text = bc.get_widget(id)
|
let text =
|
||||||
.get::<Vec<String>>("languages")[index]
|
bc.get_widget(id).get::<Vec<String>>("languages")[index].clone();
|
||||||
.clone();
|
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.id(ID_LOCALIZATION_LANGUAGE_NAME)
|
.id(ID_LOCALIZATION_LANGUAGE_NAME)
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
|
|||||||
@@ -8,13 +8,10 @@
|
|||||||
use orbtk::prelude::*;
|
use orbtk::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::{
|
data::{constants::*, structures::PolicyCheck},
|
||||||
constants::*,
|
|
||||||
structures::PolicyCheck,
|
|
||||||
},
|
|
||||||
widgets::configuration::configuration_view::ConfigurationView,
|
widgets::configuration::configuration_view::ConfigurationView,
|
||||||
widgets::policycheck::policycheck_view::PolicycheckView,
|
|
||||||
widgets::localization::localization_view::LocalizationView,
|
widgets::localization::localization_view::LocalizationView,
|
||||||
|
widgets::policycheck::policycheck_view::PolicycheckView,
|
||||||
//widgets::menu::menu_view::MenuView,
|
//widgets::menu::menu_view::MenuView,
|
||||||
widgets::ticketdata::ticketdata_view::TicketdataView,
|
widgets::ticketdata::ticketdata_view::TicketdataView,
|
||||||
};
|
};
|
||||||
@@ -29,14 +26,13 @@ widget!(
|
|||||||
// policylist_view: u32,
|
// policylist_view: u32,
|
||||||
// policydata_view: u32,
|
// policydata_view: u32,
|
||||||
/// The policycheck view
|
/// The policycheck view
|
||||||
policycheck_view: PolicyCheck
|
policycheck_view: PolicyCheck //ticketdata_view: TicketData
|
||||||
//ticketdata_view: TicketData
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
impl Template for MainView {
|
impl Template for MainView {
|
||||||
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||||
let ticketdata_view = TicketdataView::new()
|
let ticketdata_view = TicketdataView::new().build(ctx);
|
||||||
.build(ctx);
|
|
||||||
|
|
||||||
let policycheck_view = PolicycheckView::new()
|
let policycheck_view = PolicycheckView::new()
|
||||||
.target(ticketdata_view.0)
|
.target(ticketdata_view.0)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
use orbtk::{prelude::*, shell::*, widgets::themes::* };
|
use orbtk::{prelude::*, shell::*, widgets::themes::*};
|
||||||
use tracing::{info, trace};
|
use tracing::{info, trace};
|
||||||
|
|
||||||
use std::process;
|
use std::process;
|
||||||
@@ -31,7 +31,7 @@ pub enum MenuAction {
|
|||||||
/// Set the active theme
|
/// Set the active theme
|
||||||
SetTheme,
|
SetTheme,
|
||||||
/// Update the relative position inside the menu
|
/// Update the relative position inside the menu
|
||||||
UpdateMenuRelativePosition
|
UpdateMenuRelativePosition,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Valid `structures` that are handled inside the state of the `Menu` widget.
|
/// Valid `structures` that are handled inside the state of the `Menu` widget.
|
||||||
@@ -43,7 +43,7 @@ pub struct MenuState {
|
|||||||
menu: Option<Entity>,
|
menu: Option<Entity>,
|
||||||
//menu_toggle_theme: Option<Entity>
|
//menu_toggle_theme: Option<Entity>
|
||||||
/// Entity-id of the toggled theme
|
/// Entity-id of the toggled theme
|
||||||
menu_toggle_theme: Entity
|
menu_toggle_theme: Entity,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Method definitions, that react on any given state change inside the `Menu` widget.
|
/// Method definitions, that react on any given state change inside the `Menu` widget.
|
||||||
@@ -116,7 +116,9 @@ impl State for MenuState {
|
|||||||
// append the child to target (overlay stays on top of the main tree)
|
// append the child to target (overlay stays on top of the main tree)
|
||||||
ctx.build_context()
|
ctx.build_context()
|
||||||
.append_child_to_overlay(menu_popup)
|
.append_child_to_overlay(menu_popup)
|
||||||
.expect("Failed create an overlay that consumes popup `menu` as its child.");
|
.expect(
|
||||||
|
"Failed create an overlay that consumes popup `menu` as its child.",
|
||||||
|
);
|
||||||
self.menu = Some(menu_popup);
|
self.menu = Some(menu_popup);
|
||||||
|
|
||||||
trace!(menu = ?self.menu);
|
trace!(menu = ?self.menu);
|
||||||
@@ -124,7 +126,10 @@ impl State for MenuState {
|
|||||||
// open: is the default
|
// open: is the default
|
||||||
//ctx.get_widget(menu).set("open", true);
|
//ctx.get_widget(menu).set("open", true);
|
||||||
|
|
||||||
info!("CreateMenu: parent {:?}, target: {:?}, popup: {:?}", parent, target, self.menu);
|
info!(
|
||||||
|
"CreateMenu: parent {:?}, target: {:?}, popup: {:?}",
|
||||||
|
parent, target, self.menu
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuAction::SetTheme => {
|
MenuAction::SetTheme => {
|
||||||
@@ -160,21 +165,26 @@ impl State for MenuState {
|
|||||||
if let Some(action) = self.action {
|
if let Some(action) = self.action {
|
||||||
match action {
|
match action {
|
||||||
MenuAction::CreateMenuToggleTheme => {
|
MenuAction::CreateMenuToggleTheme => {
|
||||||
let menu_target = ctx
|
let menu_target = ctx.entity_of_child(ID_MENU_LABEL_TOGGLE_THEME).expect(
|
||||||
.entity_of_child(ID_MENU_LABEL_TOGGLE_THEME)
|
"MenuState: Can't find entity of resource 'ID_MENU_LABEL_TOGGLE_THEME'.",
|
||||||
.expect("MenuState: Can't find entity of resource 'ID_MENU_LABEL_TOGGLE_THEME'.");
|
);
|
||||||
let current_entity = ctx.entity();
|
let current_entity = ctx.entity();
|
||||||
let build_context = &mut ctx.build_context();
|
let build_context = &mut ctx.build_context();
|
||||||
|
|
||||||
// create a new menu popup
|
// create a new menu popup
|
||||||
self.menu_toggle_theme = create_menu_toggle_theme_popup(current_entity, build_context);
|
self.menu_toggle_theme =
|
||||||
|
create_menu_toggle_theme_popup(current_entity, build_context);
|
||||||
|
|
||||||
// create a menu_popup widget as a child of entity "ID_POPUP_MENU"
|
// create a menu_popup widget as a child of entity "ID_POPUP_MENU"
|
||||||
build_context.append_child(menu_target, self.menu_toggle_theme);
|
build_context.append_child(menu_target, self.menu_toggle_theme);
|
||||||
|
|
||||||
ctx.get_widget(self.menu_toggle_theme).clone::<Visibility>("visibility");
|
ctx.get_widget(self.menu_toggle_theme)
|
||||||
|
.clone::<Visibility>("visibility");
|
||||||
|
|
||||||
println!("Popup Menu Toggle Theme created: {:?}", self.menu_toggle_theme);
|
println!(
|
||||||
|
"Popup Menu Toggle Theme created: {:?}",
|
||||||
|
self.menu_toggle_theme
|
||||||
|
);
|
||||||
}
|
}
|
||||||
MenuAction::RemoveMenu => {
|
MenuAction::RemoveMenu => {
|
||||||
self.remove_menu(ctx);
|
self.remove_menu(ctx);
|
||||||
@@ -226,23 +236,22 @@ fn create_menu_popup(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
|||||||
//.style("popup_menu")
|
//.style("popup_menu")
|
||||||
.width(300.0)
|
.width(300.0)
|
||||||
.height(100.0)
|
.height(100.0)
|
||||||
|
.on_key_down(move |ctx, key_event| {
|
||||||
.on_key_down(move | ctx, key_event | {
|
|
||||||
match key_event.key {
|
match key_event.key {
|
||||||
Key::Q(..) => {
|
Key::Q(..) => {
|
||||||
//if is_ctrl_home_down(ctx)
|
//if is_ctrl_home_down(ctx)
|
||||||
println!("KeyHandler: got Ctrl+Q");
|
println!("KeyHandler: got Ctrl+Q");
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
//}
|
//}
|
||||||
},
|
}
|
||||||
Key::Escape => {
|
Key::Escape => {
|
||||||
println!("KeyHandler: got Escape");
|
println!("KeyHandler: got Escape");
|
||||||
ctx.get_mut::<MenuState>(target)
|
ctx.get_mut::<MenuState>(target)
|
||||||
.set_action(MenuAction::RemoveMenu);
|
.set_action(MenuAction::RemoveMenu);
|
||||||
},
|
}
|
||||||
_ => {
|
_ => {
|
||||||
println!("KeyHandler: got {:?}", key_event.key);
|
println!("KeyHandler: got {:?}", key_event.key);
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
@@ -266,14 +275,9 @@ fn create_menu_popup(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
|||||||
Columns::create()
|
Columns::create()
|
||||||
.push("180") // Menu Button
|
.push("180") // Menu Button
|
||||||
.push("1") // Seperator
|
.push("1") // Seperator
|
||||||
.push("auto") // Keyboard Shortcut
|
.push("auto"), // Keyboard Shortcut
|
||||||
)
|
|
||||||
.rows(
|
|
||||||
Rows::create()
|
|
||||||
.push("auto")
|
|
||||||
.push("auto")
|
|
||||||
.push("auto")
|
|
||||||
)
|
)
|
||||||
|
.rows(Rows::create().push("auto").push("auto").push("auto"))
|
||||||
.child(
|
.child(
|
||||||
Button::new()
|
Button::new()
|
||||||
.id(ID_MENU_LABEL_ACCOUNT)
|
.id(ID_MENU_LABEL_ACCOUNT)
|
||||||
@@ -339,7 +343,6 @@ fn create_menu_popup(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
|||||||
.build(ctx)
|
.build(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn _create_popup(target: Entity, text: &str, ctx: &mut BuildContext<'_>) -> Entity {
|
fn _create_popup(target: Entity, text: &str, ctx: &mut BuildContext<'_>) -> Entity {
|
||||||
Popup::new()
|
Popup::new()
|
||||||
.id("test_popup")
|
.id("test_popup")
|
||||||
@@ -368,8 +371,6 @@ fn _create_popup(target: Entity, text: &str, ctx: &mut BuildContext<'_>) -> Enti
|
|||||||
.build(ctx)
|
.build(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Create a new popup submenu to toogle the active theme
|
/// Create a new popup submenu to toogle the active theme
|
||||||
fn create_menu_toggle_theme_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
fn create_menu_toggle_theme_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
@@ -400,16 +401,16 @@ fn create_menu_toggle_theme_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Ent
|
|||||||
.style("container_menu")
|
.style("container_menu")
|
||||||
.width(280)
|
.width(280)
|
||||||
.height(140)
|
.height(140)
|
||||||
.on_key_down(move | _ctx, key_event | {
|
.on_key_down(move |_ctx, key_event| {
|
||||||
match key_event.key {
|
match key_event.key {
|
||||||
Key::Escape => {
|
Key::Escape => {
|
||||||
println!("KeyHandler: got Escape");
|
println!("KeyHandler: got Escape");
|
||||||
//ctx.get_mut::<MenuState>(id)
|
//ctx.get_mut::<MenuState>(id)
|
||||||
// .set_action(MenuAction::RemoveMenuToggleTheme);
|
// .set_action(MenuAction::RemoveMenuToggleTheme);
|
||||||
},
|
}
|
||||||
_ => {
|
_ => {
|
||||||
println!("KeyHandler: got {:?}", key_event.key);
|
println!("KeyHandler: got {:?}", key_event.key);
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
@@ -420,9 +421,11 @@ fn create_menu_toggle_theme_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Ent
|
|||||||
.count(themes_count)
|
.count(themes_count)
|
||||||
.style("combo_box_form")
|
.style("combo_box_form")
|
||||||
.items_builder(move |ctx, index| {
|
.items_builder(move |ctx, index| {
|
||||||
let theme_name =
|
let theme_name = MenuView::themes_ref(&ctx.get_widget(id))[index].clone();
|
||||||
MenuView::themes_ref(&ctx.get_widget(id))[index].clone();
|
TextBlock::new()
|
||||||
TextBlock::new().v_align("center").text(theme_name).build(ctx)
|
.v_align("center")
|
||||||
|
.text(theme_name)
|
||||||
|
.build(ctx)
|
||||||
})
|
})
|
||||||
.on_changed("selected_index", move |states, _entity| {
|
.on_changed("selected_index", move |states, _entity| {
|
||||||
states.send_message(MenuAction::SetTheme, id);
|
states.send_message(MenuAction::SetTheme, id);
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ impl Template for MenuView {
|
|||||||
.v_align("end")
|
.v_align("end")
|
||||||
.child(
|
.child(
|
||||||
Container::new()
|
Container::new()
|
||||||
.child( Container::new()
|
.child(
|
||||||
|
Container::new()
|
||||||
.margin((0, 16, 16, 0))
|
.margin((0, 16, 16, 0))
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
.child(
|
.child(
|
||||||
@@ -60,7 +61,7 @@ impl Template for MenuView {
|
|||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.margin((0, 9, 48, 0))
|
.margin((0, 9, 48, 0))
|
||||||
.text("©Networkx GmbH")
|
.text("©Networkx GmbH")
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
@@ -104,24 +105,22 @@ impl Template for MenuView {
|
|||||||
.build(ctx);
|
.build(ctx);
|
||||||
|
|
||||||
//self.themes(themes).child(MenuState::create_menu(ID_MENU_POPUP, ctx))
|
//self.themes(themes).child(MenuState::create_menu(ID_MENU_POPUP, ctx))
|
||||||
self.name("MenuView")
|
self.name("MenuView").child(
|
||||||
.child(
|
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.id(ID_MENU_VIEW)
|
.id(ID_MENU_VIEW)
|
||||||
.columns(
|
.columns(
|
||||||
Columns::create()
|
Columns::create()
|
||||||
.push(50) // Left margin
|
.push(50) // Left margin
|
||||||
.push("*") // Content
|
.push("*") // Content
|
||||||
.push(50) // Right margin
|
.push(50), // Right margin
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
.push("auto") // Header_Bar
|
.push("auto") // Header_Bar
|
||||||
.push(28) // Seperator
|
.push(28) // Seperator
|
||||||
.push("*") // InputForm
|
.push("*") // InputForm
|
||||||
.push("auto") // Bottom_Bar
|
.push("auto"), // Bottom_Bar
|
||||||
)
|
)
|
||||||
|
|
||||||
.child(menu_header_bar) // Row 0
|
.child(menu_header_bar) // Row 0
|
||||||
.child(menu_bottom_bar) // Row 3
|
.child(menu_bottom_bar) // Row 3
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
|
|||||||
@@ -5,26 +5,26 @@
|
|||||||
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use orbtk::{prelude::*, widgets::themes::* };
|
use orbtk::{prelude::*, widgets::themes::*};
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::process;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::process;
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
use tracing::{error, info, trace};
|
use tracing::{error, info, trace};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::{
|
data::{
|
||||||
structures::{PolicyCode, PolicyDataList, PolicyList},
|
|
||||||
constants::*,
|
constants::*,
|
||||||
|
structures::{PolicyCode, PolicyDataList, PolicyList},
|
||||||
},
|
},
|
||||||
Lang,
|
|
||||||
//services::imports::allianzdirectcall::import,
|
//services::imports::allianzdirectcall::import,
|
||||||
services::imports::allianzdirectcall,
|
services::imports::allianzdirectcall,
|
||||||
widgets::global_state::GlobalState,
|
widgets::global_state::GlobalState,
|
||||||
//widgets::menu::menu_view::MenuView,
|
//widgets::menu::menu_view::MenuView,
|
||||||
//widgets::policycheck::policycheck_view::PolicycheckView,
|
//widgets::policycheck::policycheck_view::PolicycheckView,
|
||||||
//widgets::ticketdata::ticketdata_state::TicketdataAction,
|
//widgets::ticketdata::ticketdata_state::TicketdataAction,
|
||||||
|
Lang,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Enumeration of valid `action variants` that need to be handled as
|
/// Enumeration of valid `action variants` that need to be handled as
|
||||||
@@ -68,7 +68,7 @@ pub enum PolicycheckAction {
|
|||||||
/// Update the given policy code
|
/// Update the given policy code
|
||||||
UpdatePolicyCode,
|
UpdatePolicyCode,
|
||||||
/// Update the process status to given value
|
/// Update the process status to given value
|
||||||
UpdateProgress(f64)
|
UpdateProgress(f64),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Define valid environment variables provided via .env files
|
/// Define valid environment variables provided via .env files
|
||||||
@@ -96,7 +96,7 @@ pub struct PolicycheckState {
|
|||||||
progress_popup: Entity,
|
progress_popup: Entity,
|
||||||
// target that recieves messages
|
// target that recieves messages
|
||||||
target: Entity,
|
target: Entity,
|
||||||
ticketdata_view: Entity
|
ticketdata_view: Entity,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalState for PolicycheckState {}
|
impl GlobalState for PolicycheckState {}
|
||||||
@@ -104,8 +104,10 @@ impl GlobalState for PolicycheckState {}
|
|||||||
/// Method definitions, that react on any given state change inside the `Policycheck` widget.
|
/// Method definitions, that react on any given state change inside the `Policycheck` widget.
|
||||||
impl PolicycheckState {
|
impl PolicycheckState {
|
||||||
/// Create a hashmap (key: policy number, value: policy type).
|
/// Create a hashmap (key: policy number, value: policy type).
|
||||||
pub fn create_hashmap(&mut self, _ctx: &mut Context<'_>)
|
pub fn create_hashmap(
|
||||||
-> Result<(), Box<dyn std::error::Error>> {
|
&mut self,
|
||||||
|
_ctx: &mut Context<'_>,
|
||||||
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
trace!(target: "advotracker", create_hashmap = "started");
|
trace!(target: "advotracker", create_hashmap = "started");
|
||||||
|
|
||||||
let policy_list = PolicyList::new("policy list");
|
let policy_list = PolicyList::new("policy list");
|
||||||
@@ -116,13 +118,17 @@ impl PolicycheckState {
|
|||||||
let mut policy_data = PolicyDataList::new(res);
|
let mut policy_data = PolicyDataList::new(res);
|
||||||
trace!(target: "advotracker", policy_data = ?policy_data);
|
trace!(target: "advotracker", policy_data = ?policy_data);
|
||||||
|
|
||||||
let mut policy_numbers : HashMap<u64, PolicyCode> = HashMap::new();
|
let mut policy_numbers: HashMap<u64, PolicyCode> = HashMap::new();
|
||||||
|
|
||||||
// Wip: use cli parameter stored in viperus ...
|
// Wip: use cli parameter stored in viperus ...
|
||||||
//let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
//let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
||||||
let mut csv_import_path = String::from("POLLFNR_WOECHENTLICH.txt");
|
let mut csv_import_path = String::from("POLLFNR_WOECHENTLICH.txt");
|
||||||
match allianzdirectcall::import(&mut csv_import_path, &mut policy_data,
|
match allianzdirectcall::import(
|
||||||
&mut policy_numbers, &mut self.policy_data_count) {
|
&mut csv_import_path,
|
||||||
|
&mut policy_data,
|
||||||
|
&mut policy_numbers,
|
||||||
|
&mut self.policy_data_count,
|
||||||
|
) {
|
||||||
Ok((count, duration)) => {
|
Ok((count, duration)) => {
|
||||||
self.policy_data_count = count;
|
self.policy_data_count = count;
|
||||||
self.duration = duration;
|
self.duration = duration;
|
||||||
@@ -145,15 +151,26 @@ impl PolicycheckState {
|
|||||||
|
|
||||||
/// Clear text in text box.
|
/// Clear text in text box.
|
||||||
pub fn clear_policy_number(&mut self, ctx: &mut Context<'_>) {
|
pub fn clear_policy_number(&mut self, ctx: &mut Context<'_>) {
|
||||||
TextBox::text_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from(""));
|
TextBox::text_set(
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER),
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
String::from(""),
|
||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Collapsed);
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
Stack::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Import policy numbers into hashmap
|
/// Import policy numbers into hashmap
|
||||||
fn import_data(&mut self, ctx: &mut Context<'_>)
|
fn import_data(&mut self, ctx: &mut Context<'_>) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
-> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
// WIP: for now, only import once per session
|
// WIP: for now, only import once per session
|
||||||
if self.policy_data_count == 0 {
|
if self.policy_data_count == 0 {
|
||||||
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), true);
|
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), true);
|
||||||
@@ -167,7 +184,10 @@ impl PolicycheckState {
|
|||||||
for _ in 1..4 {
|
for _ in 1..4 {
|
||||||
self.progress_count += 0.33;
|
self.progress_count += 0.33;
|
||||||
self.update_progress_bar(ctx);
|
self.update_progress_bar(ctx);
|
||||||
ctx.send_message(PolicycheckAction::UpdateProgress(self.progress_count), self.progress_popup);
|
ctx.send_message(
|
||||||
|
PolicycheckAction::UpdateProgress(self.progress_count),
|
||||||
|
self.progress_popup,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// importing policy code elements from csv-file
|
// importing policy code elements from csv-file
|
||||||
@@ -181,7 +201,6 @@ impl PolicycheckState {
|
|||||||
|
|
||||||
self.progress_count = 1.;
|
self.progress_count = 1.;
|
||||||
self.update_progress_bar(ctx);
|
self.update_progress_bar(ctx);
|
||||||
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let res = t!(policy_hashmap_failed => self.lang);
|
let res = t!(policy_hashmap_failed => self.lang);
|
||||||
@@ -208,8 +227,7 @@ impl PolicycheckState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parse validity of the given policy number.
|
/// Parse validity of the given policy number.
|
||||||
pub fn parse_entry(&mut self, policy_check_policy_number: Entity,
|
pub fn parse_entry(&mut self, policy_check_policy_number: Entity, ctx: &mut Context<'_>) {
|
||||||
ctx: &mut Context<'_>) {
|
|
||||||
trace!(target: "advotracker", parse_entry = "started");
|
trace!(target: "advotracker", parse_entry = "started");
|
||||||
|
|
||||||
let policy_number_string = TextBox::text_clone(&ctx.get_widget(policy_check_policy_number));
|
let policy_number_string = TextBox::text_clone(&ctx.get_widget(policy_check_policy_number));
|
||||||
@@ -220,12 +238,20 @@ impl PolicycheckState {
|
|||||||
match self.import_data(ctx) {
|
match self.import_data(ctx) {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
trace!(target: "advotracker", policycheck_state = "init", import_data = "success");
|
trace!(target: "advotracker", policycheck_state = "init", import_data = "success");
|
||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_DATA_STACK), Visibility::Visible);
|
Stack::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_DATA_STACK),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
let policy_data_count_string = format!("{:?}", &self.policy_data_count);
|
let policy_data_count_string = format!("{:?}", &self.policy_data_count);
|
||||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_DATA_COUNT), String::from(&policy_data_count_string));
|
TextBlock::text_set(
|
||||||
},
|
&mut ctx.child(ID_POLICY_DATA_COUNT),
|
||||||
|
String::from(&policy_data_count_string),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Err(e) => trace!(target: "advotracker", policycheck_state = "init", import_data = ?e),
|
Err(e) => {
|
||||||
|
trace!(target: "advotracker", policycheck_state = "init", import_data = ?e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,14 +260,23 @@ impl PolicycheckState {
|
|||||||
// Parse policy code: "AS-123456789"
|
// Parse policy code: "AS-123456789"
|
||||||
// DION VERS POLLFNR
|
// DION VERS POLLFNR
|
||||||
// 1 AS 1515735810
|
// 1 AS 1515735810
|
||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Collapsed);
|
Stack::visibility_set(
|
||||||
Button::background_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("transparent"));
|
&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
Button::background_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
String::from("transparent"),
|
||||||
|
);
|
||||||
|
|
||||||
if policy_number_length == 10 {
|
if policy_number_length == 10 {
|
||||||
// cast policy_number_sting to <u64>
|
// cast policy_number_sting to <u64>
|
||||||
match policy_number_string.parse::<u64>() {
|
match policy_number_string.parse::<u64>() {
|
||||||
Ok(p) => {
|
Ok(p) => {
|
||||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), String::from(""));
|
TextBlock::text_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||||
|
String::from(""),
|
||||||
|
);
|
||||||
|
|
||||||
// match hashmap's key
|
// match hashmap's key
|
||||||
match self.policy_numbers.get(&p) {
|
match self.policy_numbers.get(&p) {
|
||||||
@@ -250,62 +285,157 @@ impl PolicycheckState {
|
|||||||
trace!(target: "advotracker", state = "success",
|
trace!(target: "advotracker", state = "success",
|
||||||
policy_number = ?p, policy_code = ?policy_code);
|
policy_number = ?p, policy_code = ?policy_code);
|
||||||
|
|
||||||
let string_result = format!("1-{:?}-{}",
|
let string_result = format!("1-{:?}-{}", policy_code, p);
|
||||||
policy_code, p);
|
|
||||||
|
|
||||||
// adapt the view properties
|
// adapt the view properties
|
||||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), string_result);
|
TextBlock::text_set(
|
||||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#008000"));
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||||
|
string_result,
|
||||||
|
);
|
||||||
|
TextBox::foreground_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER),
|
||||||
|
String::from("#008000"),
|
||||||
|
);
|
||||||
|
|
||||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
|
Button::icon_brush_set(
|
||||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CHECK);
|
String::from("#008000"),
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
);
|
||||||
|
Button::foreground_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
String::from("#008000"),
|
||||||
|
);
|
||||||
|
Button::icon_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
material_icons_font::MD_CHECK,
|
||||||
|
);
|
||||||
|
Button::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
|
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
TextBlock::visibility_set(
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Visible);
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
Visibility::Visible,
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
|
||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Visible);
|
Stack::visibility_set(
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_BUTTON_CLEAR), Visibility::Visible);
|
&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
|
Button::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_ACTION_BUTTON_CLEAR),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// no matching key
|
// no matching key
|
||||||
let res = t!(policy_validation_failed => self.lang);
|
let res = t!(policy_validation_failed => self.lang);
|
||||||
trace!(target: "advotracker", state = ?res, policy_number = ?p);
|
trace!(target: "advotracker", state = ?res, policy_number = ?p);
|
||||||
|
|
||||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
TextBox::foreground_set(
|
||||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("The given policy number is invalid"));
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER),
|
||||||
|
String::from("#FF0000"),
|
||||||
|
);
|
||||||
|
TextBlock::text_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||||
|
String::from("The given policy number is invalid"),
|
||||||
|
);
|
||||||
|
|
||||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
Button::icon_brush_set(
|
||||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
String::from("#FF0000"),
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
);
|
||||||
|
Button::foreground_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
String::from("#FF0000"),
|
||||||
|
);
|
||||||
|
Button::icon_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
material_icons_font::MD_CLEAR,
|
||||||
|
);
|
||||||
|
Button::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
|
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
TextBlock::visibility_set(
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
Visibility::Collapsed,
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
trace!(target: "advotracker", state = "error", error_type = "invalid type", error = ?e);
|
trace!(target: "advotracker", state = "error", error_type = "invalid type", error = ?e);
|
||||||
|
|
||||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
TextBox::foreground_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER),
|
||||||
|
String::from("#FF0000"),
|
||||||
|
);
|
||||||
|
|
||||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("Only numbers are valid"));
|
TextBlock::text_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||||
|
String::from("Only numbers are valid"),
|
||||||
|
);
|
||||||
|
|
||||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
Button::icon_brush_set(
|
||||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
String::from("#FF0000"),
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
);
|
||||||
|
Button::foreground_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
String::from("#FF0000"),
|
||||||
|
);
|
||||||
|
Button::icon_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
material_icons_font::MD_CLEAR,
|
||||||
|
);
|
||||||
|
Button::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
|
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
TextBlock::visibility_set(
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
Visibility::Collapsed,
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,41 +443,101 @@ impl PolicycheckState {
|
|||||||
let res = t!(policy_validation_failed => self.lang);
|
let res = t!(policy_validation_failed => self.lang);
|
||||||
trace!(target: "advotracker", state = ?res, reason = "number to short");
|
trace!(target: "advotracker", state = ?res, reason = "number to short");
|
||||||
|
|
||||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
TextBox::foreground_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER),
|
||||||
|
String::from("#FF0000"),
|
||||||
|
);
|
||||||
|
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("Policy number is to short"));
|
TextBlock::text_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||||
|
String::from("Policy number is to short"),
|
||||||
|
);
|
||||||
|
|
||||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
Button::icon_brush_set(
|
||||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
String::from("#FF0000"),
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
);
|
||||||
|
Button::foreground_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
String::from("#FF0000"),
|
||||||
|
);
|
||||||
|
Button::icon_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
material_icons_font::MD_CLEAR,
|
||||||
|
);
|
||||||
|
Button::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
|
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
TextBlock::visibility_set(
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if policy_number_length > 10 {
|
if policy_number_length > 10 {
|
||||||
let res = t!(policy_validation_failed => self.lang);
|
let res = t!(policy_validation_failed => self.lang);
|
||||||
trace!(target: "advotracker", state = ?res, reason = "number to long");
|
trace!(target: "advotracker", state = ?res, reason = "number to long");
|
||||||
|
|
||||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
TextBox::foreground_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER),
|
||||||
|
String::from("#FF0000"),
|
||||||
|
);
|
||||||
|
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
TextBlock::visibility_set(
|
||||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("Policy number is to long"));
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
|
TextBlock::text_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_HINT),
|
||||||
|
String::from("Policy number is to long"),
|
||||||
|
);
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||||
|
|
||||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
Button::icon_brush_set(
|
||||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
String::from("#FF0000"),
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
);
|
||||||
|
Button::foreground_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
String::from("#FF0000"),
|
||||||
|
);
|
||||||
|
Button::icon_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
material_icons_font::MD_CLEAR,
|
||||||
|
);
|
||||||
|
Button::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
|
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
TextBlock::visibility_set(
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
trace!(target: "advotracker", parse_entry = "finished");
|
trace!(target: "advotracker", parse_entry = "finished");
|
||||||
@@ -355,7 +545,8 @@ impl PolicycheckState {
|
|||||||
|
|
||||||
/// parse message 'ParseEntry'
|
/// parse message 'ParseEntry'
|
||||||
pub fn parse_policy_number(&mut self, entity: Entity) {
|
pub fn parse_policy_number(&mut self, entity: Entity) {
|
||||||
self.actions.push(PolicycheckAction::ParsePolicyNumber(entity));
|
self.actions
|
||||||
|
.push(PolicycheckAction::ParsePolicyNumber(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove the popup box
|
/// Remove the popup box
|
||||||
@@ -389,51 +580,84 @@ impl PolicycheckState {
|
|||||||
/// Change status of given text box to edit mode.
|
/// Change status of given text box to edit mode.
|
||||||
fn set_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) {
|
fn set_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) {
|
||||||
if ctx.get_widget(text_box).get::<String16>("text").is_empty() {
|
if ctx.get_widget(text_box).get::<String16>("text").is_empty() {
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
TextBlock::visibility_set(
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
TextBlock::visibility_set(
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Visible);
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set a progress popup that updates the import status in a progress bar
|
/// Set a progress popup that updates the import status in a progress bar
|
||||||
fn set_popup_progress(&mut self, ctx: &mut Context<'_>) {
|
fn set_popup_progress(&mut self, ctx: &mut Context<'_>) {
|
||||||
// create a stack as a child of entity "ID_POLICY_CHECK_POLICY_NUMBER"
|
// create a stack as a child of entity "ID_POLICY_CHECK_POLICY_NUMBER"
|
||||||
let stack = ctx
|
let stack = ctx.entity_of_child(ID_POLICY_CHECK_POLICY_NUMBER).expect(
|
||||||
.entity_of_child(ID_POLICY_CHECK_POLICY_NUMBER)
|
"PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_POLICY_NUMBER'.",
|
||||||
.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_POLICY_NUMBER'.");
|
);
|
||||||
let current_entity = ctx.entity();
|
let current_entity = ctx.entity();
|
||||||
let build_context = &mut ctx.build_context();
|
let build_context = &mut ctx.build_context();
|
||||||
|
|
||||||
// create the progress_popup widget
|
// create the progress_popup widget
|
||||||
self.progress_popup = create_popup_progress(current_entity, build_context);
|
self.progress_popup = create_popup_progress(current_entity, build_context);
|
||||||
info!("set_popup_progress: New entity 'popup_progress' {:?} created", self.progress_popup);
|
info!(
|
||||||
|
"set_popup_progress: New entity 'popup_progress' {:?} created",
|
||||||
|
self.progress_popup
|
||||||
|
);
|
||||||
|
|
||||||
// append the stack inside the progress_popup
|
// append the stack inside the progress_popup
|
||||||
build_context.append_child(stack, self.progress_popup);
|
build_context.append_child(stack, self.progress_popup);
|
||||||
|
|
||||||
// make sure we have a progress bar
|
// make sure we have a progress bar
|
||||||
self.progress_bar = ctx
|
self.progress_bar = ctx.entity_of_child(ID_POLICY_CHECK_PROGRESS_BAR).expect(
|
||||||
.entity_of_child(ID_POLICY_CHECK_PROGRESS_BAR)
|
"PolicycheckState.init: Can't find entity of resource 'ID_POLICY_CHECK_PROGRESS_BAR'.",
|
||||||
.expect("PolicycheckState.init: Can't find entity of resource 'ID_POLICY_CHECK_PROGRESS_BAR'.");
|
);
|
||||||
info!("set_popup_progress: New entity 'progress_bar' created: {:?}", self.progress_bar);
|
info!(
|
||||||
|
"set_popup_progress: New entity 'progress_bar' created: {:?}",
|
||||||
|
self.progress_bar
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Change visibility of the result label.
|
/// Change visibility of the result label.
|
||||||
fn _set_visibility(&self, entity: Entity, ctx: &mut Context<'_>) {
|
fn _set_visibility(&self, entity: Entity, ctx: &mut Context<'_>) {
|
||||||
if ctx.get_widget(entity).get::<String16>("text").is_empty() {
|
if ctx.get_widget(entity).get::<String16>("text").is_empty() {
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
TextBlock::visibility_set(
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Collapsed);
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
TextBlock::visibility_set(
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update count of elements in the policy data list.
|
/// Update count of elements in the policy data list.
|
||||||
fn _update_data_count(&self, ctx: &mut Context<'_>) {
|
fn _update_data_count(&self, ctx: &mut Context<'_>) {
|
||||||
let data_list_count = ctx.widget().get::<PolicyDataList>(PROP_POLICY_DATA_LIST).len();
|
let data_list_count = ctx
|
||||||
|
.widget()
|
||||||
|
.get::<PolicyDataList>(PROP_POLICY_DATA_LIST)
|
||||||
|
.len();
|
||||||
ctx.widget().set(PROP_POLICY_DATA_COUNT, data_list_count);
|
ctx.widget().set(PROP_POLICY_DATA_COUNT, data_list_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,7 +665,10 @@ impl PolicycheckState {
|
|||||||
let res = t!(policy_string_progress_time => self.lang);
|
let res = t!(policy_string_progress_time => self.lang);
|
||||||
let string_duration = format!("{}: {:?}", res, self.duration);
|
let string_duration = format!("{}: {:?}", res, self.duration);
|
||||||
|
|
||||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_TIME), string_duration);
|
TextBlock::text_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_PROGRESS_TIME),
|
||||||
|
string_duration,
|
||||||
|
);
|
||||||
|
|
||||||
let mut progress_bar = ctx.child(ID_POLICY_CHECK_PROGRESS_BAR);
|
let mut progress_bar = ctx.child(ID_POLICY_CHECK_PROGRESS_BAR);
|
||||||
progress_bar.set::<f64>("val", self.progress_count);
|
progress_bar.set::<f64>("val", self.progress_count);
|
||||||
@@ -453,14 +680,13 @@ impl PolicycheckState {
|
|||||||
//let policy_code = ctx.widget().get::<PolicycheckState>(ID_POLICY_CHECK_POLICY_CODE);
|
//let policy_code = ctx.widget().get::<PolicycheckState>(ID_POLICY_CHECK_POLICY_CODE);
|
||||||
//ctx.widget().set(PROP_POLICY_DATA_COUNT, policy_code);
|
//ctx.widget().set(PROP_POLICY_DATA_COUNT, policy_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Supported methods handled inside the `PolicycheckState`
|
/// Supported methods handled inside the `PolicycheckState`
|
||||||
impl State for PolicycheckState {
|
impl State for PolicycheckState {
|
||||||
/// Initialize the state of widgets inside `PolicycheckState`
|
/// Initialize the state of widgets inside `PolicycheckState`
|
||||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||||
let time_start= SystemTime::now();
|
let time_start = SystemTime::now();
|
||||||
|
|
||||||
trace!(target: "advotracker", policycheck_state = "init", status = "started");
|
trace!(target: "advotracker", policycheck_state = "init", status = "started");
|
||||||
|
|
||||||
@@ -469,27 +695,41 @@ impl State for PolicycheckState {
|
|||||||
self.lang = Lang::De("");
|
self.lang = Lang::De("");
|
||||||
|
|
||||||
// Initialize required entities
|
// Initialize required entities
|
||||||
self.button_menu = ctx
|
self.button_menu = ctx.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU).expect(
|
||||||
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
|
"PolicycheckState::init: Can't find resource entity 'ID_POLICY_CHECK_BUTTON_MENU'.",
|
||||||
.expect("PolicycheckState::init: Can't find resource entity 'ID_POLICY_CHECK_BUTTON_MENU'.");
|
);
|
||||||
|
|
||||||
self.label_result = ctx
|
self.label_result = ctx.entity_of_child(ID_POLICY_CHECK_LABEL_RESULT).expect(
|
||||||
.entity_of_child(ID_POLICY_CHECK_LABEL_RESULT)
|
"PolicycheckState::init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'.",
|
||||||
.expect("PolicycheckState::init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'.");
|
);
|
||||||
|
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
TextBlock::visibility_set(
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
||||||
|
|
||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Collapsed);
|
Stack::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
|
||||||
//self.policy_number = Entity::from(ctx.widget().try_clone::<u32>(ID_POLICY_CHECK_POLICY_NUMBER)
|
//self.policy_number = Entity::from(ctx.widget().try_clone::<u32>(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||||
// .expect("PolicycheckState::init(): Can't find resource entity 'ID_POLICY_CHECK_POLICY_NUMBER'."));
|
// .expect("PolicycheckState::init(): Can't find resource entity 'ID_POLICY_CHECK_POLICY_NUMBER'."));
|
||||||
|
|
||||||
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
self.target = Entity::from(
|
||||||
.expect("PolicycheckState::init(): Can't find resource entity 'target'."));
|
ctx.widget()
|
||||||
|
.try_clone::<u32>("target")
|
||||||
|
.expect("PolicycheckState::init(): Can't find resource entity 'target'."),
|
||||||
|
);
|
||||||
|
|
||||||
//self.ticketdata_view = (*ctx.widget().get::<u32>("ticketdata_view")).into();
|
//self.ticketdata_view = (*ctx.widget().get::<u32>("ticketdata_view")).into();
|
||||||
//self.ticketdata = Entity::from(ctx.widget().try_clone::<u32>(ID_TICKET_DATA_VIEW)
|
//self.ticketdata = Entity::from(ctx.widget().try_clone::<u32>(ID_TICKET_DATA_VIEW)
|
||||||
@@ -532,18 +772,24 @@ impl State for PolicycheckState {
|
|||||||
self.update_policy_code(ctx);
|
self.update_policy_code(ctx);
|
||||||
}
|
}
|
||||||
PolicycheckAction::UpdateProgress(increment) => {
|
PolicycheckAction::UpdateProgress(increment) => {
|
||||||
let old_width = ProgressBar::val_clone(&ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
|
let old_width =
|
||||||
|
ProgressBar::val_clone(&ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
|
||||||
|
|
||||||
let new_width = old_width + increment;
|
let new_width = old_width + increment;
|
||||||
// Set the ProgressBar's val property to the calculated percentage
|
// Set the ProgressBar's val property to the calculated percentage
|
||||||
// (whereas 0.0 means 0%, and 1.0 means 100%)
|
// (whereas 0.0 means 0%, and 1.0 means 100%)
|
||||||
if new_width <= 1. {
|
if new_width <= 1. {
|
||||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), new_width);
|
ProgressBar::val_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR),
|
||||||
|
new_width,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 1.);
|
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 1.);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => { println!("PolicycheckAction: action not implemented!"); }
|
_ => {
|
||||||
|
println!("PolicycheckAction: action not implemented!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -570,10 +816,12 @@ impl State for PolicycheckState {
|
|||||||
self.clear_policy_number(ctx);
|
self.clear_policy_number(ctx);
|
||||||
}
|
}
|
||||||
PolicycheckAction::InputTextChanged(entity) => {
|
PolicycheckAction::InputTextChanged(entity) => {
|
||||||
println!("entry changed: {}", TextBox::text_clone(&ctx.get_widget(entity)));
|
println!(
|
||||||
|
"entry changed: {}",
|
||||||
|
TextBox::text_clone(&ctx.get_widget(entity))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
PolicycheckAction::ImportData => {
|
PolicycheckAction::ImportData => match self.import_data(ctx) {
|
||||||
match self.import_data(ctx) {
|
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
trace!(target: "advotracker", import_data = "success");
|
trace!(target: "advotracker", import_data = "success");
|
||||||
}
|
}
|
||||||
@@ -581,8 +829,7 @@ impl State for PolicycheckState {
|
|||||||
error!("Importing data failed!");
|
error!("Importing data failed!");
|
||||||
trace!(target: "advotracker", import_data = "failed");
|
trace!(target: "advotracker", import_data = "failed");
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
|
||||||
PolicycheckAction::NewTicket => {
|
PolicycheckAction::NewTicket => {
|
||||||
self.new_ticket(ctx);
|
self.new_ticket(ctx);
|
||||||
}
|
}
|
||||||
@@ -590,7 +837,8 @@ impl State for PolicycheckState {
|
|||||||
self.parse_entry(text_box, ctx);
|
self.parse_entry(text_box, ctx);
|
||||||
}
|
}
|
||||||
PolicycheckAction::RemoveFocus(policy_check_policy_number) => {
|
PolicycheckAction::RemoveFocus(policy_check_policy_number) => {
|
||||||
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
ctx.get_widget(policy_check_policy_number)
|
||||||
|
.set("enabled", false);
|
||||||
//ctx.EventAdapter(FocusEvent::RemoveFocus(policy_check_policy_number));
|
//ctx.EventAdapter(FocusEvent::RemoveFocus(policy_check_policy_number));
|
||||||
}
|
}
|
||||||
PolicycheckAction::RemovePopup(entity) => {
|
PolicycheckAction::RemovePopup(entity) => {
|
||||||
@@ -608,12 +856,16 @@ impl State for PolicycheckState {
|
|||||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), value);
|
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), value);
|
||||||
} else {
|
} else {
|
||||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 0.);
|
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 0.);
|
||||||
} }
|
}
|
||||||
|
}
|
||||||
PolicycheckAction::SetProgressPopup(_entity) => {
|
PolicycheckAction::SetProgressPopup(_entity) => {
|
||||||
self.set_popup_progress(ctx);
|
self.set_popup_progress(ctx);
|
||||||
}
|
}
|
||||||
PolicycheckAction::SetVisibility(_entity) => {
|
PolicycheckAction::SetVisibility(_entity) => {
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
TextBlock::visibility_set(
|
||||||
|
&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT),
|
||||||
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
PolicycheckAction::TextChanged(entity, _index) => {
|
PolicycheckAction::TextChanged(entity, _index) => {
|
||||||
self.set_entry(entity, ctx);
|
self.set_entry(entity, ctx);
|
||||||
@@ -677,7 +929,7 @@ fn create_popup_progress(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
|||||||
.id(ID_POLICY_CHECK_PROGRESS_TEXT)
|
.id(ID_POLICY_CHECK_PROGRESS_TEXT)
|
||||||
.style("textblock_progress")
|
.style("textblock_progress")
|
||||||
.text("Importing data")
|
.text("Importing data")
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
ProgressBar::new()
|
ProgressBar::new()
|
||||||
@@ -685,7 +937,7 @@ fn create_popup_progress(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
|||||||
.style("progress_bar")
|
.style("progress_bar")
|
||||||
.val(0)
|
.val(0)
|
||||||
//.width(250)
|
//.width(250)
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
@@ -693,11 +945,11 @@ fn create_popup_progress(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
|||||||
.style("textblock_progress")
|
.style("textblock_progress")
|
||||||
.h_align("end")
|
.h_align("end")
|
||||||
.text("Processing time")
|
.text("Processing time")
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,10 @@
|
|||||||
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use orbtk::{prelude::*, shell::*, widgets::themes::* };
|
use orbtk::{prelude::*, shell::*, widgets::themes::*};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::{
|
data::{constants::*, structures::PolicyCheck},
|
||||||
constants::*,
|
|
||||||
structures::PolicyCheck,
|
|
||||||
},
|
|
||||||
//widgets::menu::menu_state::{MenuAction, MenuState},
|
//widgets::menu::menu_state::{MenuAction, MenuState},
|
||||||
widgets::policycheck::policycheck_state::{PolicycheckAction, PolicycheckState},
|
widgets::policycheck::policycheck_state::{PolicycheckAction, PolicycheckState},
|
||||||
};
|
};
|
||||||
@@ -69,7 +66,7 @@ impl Template for PolicycheckView {
|
|||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.margin((0, 9, 48, 0))
|
.margin((0, 9, 48, 0))
|
||||||
.text("©Networkx GmbH")
|
.text("©Networkx GmbH")
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
@@ -181,7 +178,7 @@ impl Template for PolicycheckView {
|
|||||||
.push("200") // Data
|
.push("200") // Data
|
||||||
.push("16") // Delimiter
|
.push("16") // Delimiter
|
||||||
.push("32") // Result-Button
|
.push("32") // Result-Button
|
||||||
.push("4") // Delimeter
|
.push("4"), // Delimeter
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
@@ -189,9 +186,8 @@ impl Template for PolicycheckView {
|
|||||||
.push("14") // Seperator
|
.push("14") // Seperator
|
||||||
.push("auto") // Row 2
|
.push("auto") // Row 2
|
||||||
.push("14") // Seperator
|
.push("14") // Seperator
|
||||||
.push("auto") // Row 3
|
.push("auto"), // Row 3
|
||||||
)
|
)
|
||||||
|
|
||||||
//.child(policy_check_form_row_0)
|
//.child(policy_check_form_row_0)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
@@ -215,7 +211,9 @@ impl Template for PolicycheckView {
|
|||||||
.water_mark("10-stellig")
|
.water_mark("10-stellig")
|
||||||
.on_activate(move |states, entity| {
|
.on_activate(move |states, entity| {
|
||||||
// Entity is entered/activated via Mouse/Keyboard
|
// Entity is entered/activated via Mouse/Keyboard
|
||||||
states.get_mut::<PolicycheckState>(id).parse_policy_number(entity);
|
states
|
||||||
|
.get_mut::<PolicycheckState>(id)
|
||||||
|
.parse_policy_number(entity);
|
||||||
})
|
})
|
||||||
.on_key_down(move |_, key_event| {
|
.on_key_down(move |_, key_event| {
|
||||||
if key_event.key == Key::A(true) {
|
if key_event.key == Key::A(true) {
|
||||||
@@ -225,10 +223,9 @@ impl Template for PolicycheckView {
|
|||||||
// .set_action(Action::ImportData);
|
// .set_action(Action::ImportData);
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(policy_check_button_result)
|
.child(policy_check_button_result)
|
||||||
|
|
||||||
//.child(policy_check_form_row_2)
|
//.child(policy_check_form_row_2)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
@@ -242,7 +239,6 @@ impl Template for PolicycheckView {
|
|||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(policy_check_policy_code)
|
.child(policy_check_policy_code)
|
||||||
|
|
||||||
//.child(policy_check_form_row_2)
|
//.child(policy_check_form_row_2)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
@@ -268,7 +264,6 @@ impl Template for PolicycheckView {
|
|||||||
)
|
)
|
||||||
.build(ctx);
|
.build(ctx);
|
||||||
|
|
||||||
|
|
||||||
// row3: only shown, if we read in `policy numbers` in
|
// row3: only shown, if we read in `policy numbers` in
|
||||||
// a hashmap as values
|
// a hashmap as values
|
||||||
let policy_data_stack = Stack::new()
|
let policy_data_stack = Stack::new()
|
||||||
@@ -285,7 +280,7 @@ impl Template for PolicycheckView {
|
|||||||
.margin((0, 4, 0, 0))
|
.margin((0, 4, 0, 0))
|
||||||
.enabled(true)
|
.enabled(true)
|
||||||
.text("Checklist elements: ")
|
.text("Checklist elements: ")
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
@@ -293,7 +288,7 @@ impl Template for PolicycheckView {
|
|||||||
.margin((0, 4, 0, 0))
|
.margin((0, 4, 0, 0))
|
||||||
.enabled(true)
|
.enabled(true)
|
||||||
.text("0")
|
.text("0")
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx);
|
.build(ctx);
|
||||||
|
|
||||||
@@ -308,7 +303,7 @@ impl Template for PolicycheckView {
|
|||||||
Columns::create()
|
Columns::create()
|
||||||
.push(50) // Left margin
|
.push(50) // Left margin
|
||||||
.push("*") // Content
|
.push("*") // Content
|
||||||
.push(50) // Right margin
|
.push(50), // Right margin
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
@@ -316,9 +311,8 @@ impl Template for PolicycheckView {
|
|||||||
.push(28) // Seperator
|
.push(28) // Seperator
|
||||||
.push("*") // InputForm
|
.push("*") // InputForm
|
||||||
.push("auto") // Data_Result
|
.push("auto") // Data_Result
|
||||||
.push("auto") // Bottom_Bar
|
.push("auto"), // Bottom_Bar
|
||||||
)
|
)
|
||||||
|
|
||||||
.child(policy_check_header_bar) // row 0
|
.child(policy_check_header_bar) // row 0
|
||||||
.child(policy_check_form) // row 2
|
.child(policy_check_form) // row 2
|
||||||
.child(policy_data_stack) // row 3
|
.child(policy_data_stack) // row 3
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use orbtk::{prelude::*, widgets::themes::* };
|
use orbtk::{prelude::*, widgets::themes::*};
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
//use std::process;
|
//use std::process;
|
||||||
@@ -15,8 +15,8 @@ use tracing::{error, info, trace};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::{constants::*, structures::Email},
|
data::{constants::*, structures::Email},
|
||||||
widgets::global_state::GlobalState,
|
|
||||||
services::exports::send_ticketdata::sendticketdata,
|
services::exports::send_ticketdata::sendticketdata,
|
||||||
|
widgets::global_state::GlobalState,
|
||||||
widgets::ticketdata::ticketdata_view::TicketdataView,
|
widgets::ticketdata::ticketdata_view::TicketdataView,
|
||||||
//widgets::policycheck::policycheck_state::PolicycheckAction,
|
//widgets::policycheck::policycheck_state::PolicycheckAction,
|
||||||
Lang,
|
Lang,
|
||||||
@@ -32,8 +32,7 @@ pub enum TicketdataAction {
|
|||||||
/// Send Email with form data
|
/// Send Email with form data
|
||||||
SendForm(),
|
SendForm(),
|
||||||
/// Update the policycode
|
/// Update the policycode
|
||||||
UpdatePolicyCode(String)
|
UpdatePolicyCode(String),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Define valid environment variables provided via .env files
|
/// Define valid environment variables provided via .env files
|
||||||
@@ -45,13 +44,13 @@ struct Environment {
|
|||||||
rust_log: String,
|
rust_log: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Valid `structures` that are handled inside the state of the `Ticket` widget.
|
/// Valid `structures` that are handled inside the state of the `Ticketdata` widget.
|
||||||
#[derive(AsAny, Default)]
|
#[derive(AsAny, Default)]
|
||||||
pub struct TicketdataState {
|
pub struct TicketdataState {
|
||||||
actions: Vec<TicketdataAction>,
|
actions: Vec<TicketdataAction>,
|
||||||
button_menu: Entity,
|
button_menu: Entity,
|
||||||
lang: Lang,
|
lang: Lang,
|
||||||
target: Entity
|
target: Entity,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalState for TicketdataState {}
|
impl GlobalState for TicketdataState {}
|
||||||
@@ -78,11 +77,9 @@ impl TicketdataState {
|
|||||||
for i in 0..count {
|
for i in 0..count {
|
||||||
if let Some(child) = &mut ctx.try_child_from_index(i) {
|
if let Some(child) = &mut ctx.try_child_from_index(i) {
|
||||||
let child_name: &str = child.get::<String>("name");
|
let child_name: &str = child.get::<String>("name");
|
||||||
info!("child({:?}) name: {:?}",
|
info!("child({:?}) name: {:?}", i, child_name);
|
||||||
i, child_name);
|
|
||||||
let child_id: &str = child.get::<String>("id");
|
let child_id: &str = child.get::<String>("id");
|
||||||
info!("child({:?}) name: {:?}",
|
info!("child({:?}) name: {:?}", i, child_id);
|
||||||
i, child_id);
|
|
||||||
|
|
||||||
// TODO: check the orbtk type
|
// TODO: check the orbtk type
|
||||||
// if let child_type: bool = child.get::<String>("id") = std::any::type_name::<TextBox>().to_string() {
|
// if let child_type: bool = child.get::<String>("id") = std::any::type_name::<TextBox>().to_string() {
|
||||||
@@ -102,7 +99,6 @@ impl TicketdataState {
|
|||||||
// "ticket_data_policy_callback_ivr_comment" => TextBox::text_set(child, ""),
|
// "ticket_data_policy_callback_ivr_comment" => TextBox::text_set(child, ""),
|
||||||
// _ => info!("don't act on child_id '{:?}", child_id),
|
// _ => info!("don't act on child_id '{:?}", child_id),
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,9 +106,18 @@ impl TicketdataState {
|
|||||||
// switch back to parent entity
|
// switch back to parent entity
|
||||||
ctx.change_into(entity);
|
ctx.change_into(entity);
|
||||||
|
|
||||||
Stack::visibility_set(&mut ctx.child(ID_TICKET_DATA_ACTION_STACK), Visibility::Collapsed);
|
Stack::visibility_set(
|
||||||
Button::background_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#008000"));
|
&mut ctx.child(ID_TICKET_DATA_ACTION_STACK),
|
||||||
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_SEND);
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
Button::background_set(
|
||||||
|
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||||
|
String::from("#008000"),
|
||||||
|
);
|
||||||
|
Button::icon_set(
|
||||||
|
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||||
|
material_icons_font::MD_SEND,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,13 +137,34 @@ impl TicketdataState {
|
|||||||
mail_from: PROP_MAIL_FROM.to_string(),
|
mail_from: PROP_MAIL_FROM.to_string(),
|
||||||
mail_reply: PROP_MAIL_REPLY.to_string(),
|
mail_reply: PROP_MAIL_REPLY.to_string(),
|
||||||
subject: PROP_MAIL_SUBJECT.to_string(),
|
subject: PROP_MAIL_SUBJECT.to_string(),
|
||||||
policy_code: ctx.child(ID_TICKET_DATA_POLICY_CODE).get::<String>("text").to_string(),
|
policy_code: ctx
|
||||||
policy_holder: ctx.child(ID_TICKET_DATA_POLICY_HOLDER).get::<String>("text").to_string(),
|
.child(ID_TICKET_DATA_POLICY_CODE)
|
||||||
deductible: ctx.child(ID_TICKET_DATA_DEDUCTIBLE).get::<String>("text").to_string(),
|
.get::<String>("text")
|
||||||
callback_number: ctx.child(ID_TICKET_DATA_CALLBACK_NUMBER).get::<String>("text").to_string(),
|
.to_string(),
|
||||||
callback_date: ctx.child(ID_TICKET_DATA_CALLBACK_DATE).get::<String>("text").to_string(),
|
policy_holder: ctx
|
||||||
harm_type: ctx.child(ID_TICKET_DATA_HARM_TYPE).get::<String>("text").to_string(),
|
.child(ID_TICKET_DATA_POLICY_HOLDER)
|
||||||
ivr_comment: ctx.child(ID_TICKET_DATA_IVR_COMMENT).get::<String>("text").to_string(),
|
.get::<String>("text")
|
||||||
|
.to_string(),
|
||||||
|
deductible: ctx
|
||||||
|
.child(ID_TICKET_DATA_DEDUCTIBLE)
|
||||||
|
.get::<String>("text")
|
||||||
|
.to_string(),
|
||||||
|
callback_number: ctx
|
||||||
|
.child(ID_TICKET_DATA_CALLBACK_NUMBER)
|
||||||
|
.get::<String>("text")
|
||||||
|
.to_string(),
|
||||||
|
callback_date: ctx
|
||||||
|
.child(ID_TICKET_DATA_CALLBACK_DATE)
|
||||||
|
.get::<String>("text")
|
||||||
|
.to_string(),
|
||||||
|
harm_type: ctx
|
||||||
|
.child(ID_TICKET_DATA_HARM_TYPE)
|
||||||
|
.get::<String>("text")
|
||||||
|
.to_string(),
|
||||||
|
ivr_comment: ctx
|
||||||
|
.child(ID_TICKET_DATA_IVR_COMMENT)
|
||||||
|
.get::<String>("text")
|
||||||
|
.to_string(),
|
||||||
};
|
};
|
||||||
trace!("eMail fields: {:?}", email);
|
trace!("eMail fields: {:?}", email);
|
||||||
|
|
||||||
@@ -146,22 +172,43 @@ impl TicketdataState {
|
|||||||
let lang = Lang::De("");
|
let lang = Lang::De("");
|
||||||
if let Err(err) = sendticketdata(&email, &lang) {
|
if let Err(err) = sendticketdata(&email, &lang) {
|
||||||
error!("sendticketdata error: {:?}", err);
|
error!("sendticketdata error: {:?}", err);
|
||||||
Button::icon_brush_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#008000"));
|
Button::icon_brush_set(
|
||||||
|
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||||
|
String::from("#008000"),
|
||||||
|
);
|
||||||
//Button::foreground_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#CC000000"));
|
//Button::foreground_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#CC000000"));
|
||||||
Button::background_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#CC000000"));
|
Button::background_set(
|
||||||
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_THUMB_DOWN);
|
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||||
|
String::from("#CC000000"),
|
||||||
|
);
|
||||||
|
Button::icon_set(
|
||||||
|
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||||
|
material_icons_font::MD_THUMB_DOWN,
|
||||||
|
);
|
||||||
//Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_ERROR);
|
//Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_ERROR);
|
||||||
} else {
|
} else {
|
||||||
Button::icon_brush_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#FF0000"));
|
Button::icon_brush_set(
|
||||||
|
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||||
|
String::from("#FF0000"),
|
||||||
|
);
|
||||||
//Button::foreground_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#FF0000"));
|
//Button::foreground_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#FF0000"));
|
||||||
Button::background_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#FF0000"));
|
Button::background_set(
|
||||||
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_THUMB_UP);
|
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||||
|
String::from("#FF0000"),
|
||||||
|
);
|
||||||
|
Button::icon_set(
|
||||||
|
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||||
|
material_icons_font::MD_THUMB_UP,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update the policy code
|
/// Update the policy code
|
||||||
pub fn update_policy_code(_entity: Entity, _id: &str, ctx: &mut Context<'_>) {
|
pub fn update_policy_code(_entity: Entity, _id: &str, ctx: &mut Context<'_>) {
|
||||||
Stack::visibility_set(&mut ctx.child(ID_TICKET_DATA_ACTION_STACK), Visibility::Visible);
|
Stack::visibility_set(
|
||||||
|
&mut ctx.child(ID_TICKET_DATA_ACTION_STACK),
|
||||||
|
Visibility::Visible,
|
||||||
|
);
|
||||||
//self.actions.push(TicketdataAction::UpdatePolicyCode(entity));
|
//self.actions.push(TicketdataAction::UpdatePolicyCode(entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,7 +217,7 @@ impl TicketdataState {
|
|||||||
impl State for TicketdataState {
|
impl State for TicketdataState {
|
||||||
/// Initialize the state of widgets inside `TicketState`
|
/// Initialize the state of widgets inside `TicketState`
|
||||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||||
let time_start= SystemTime::now();
|
let time_start = SystemTime::now();
|
||||||
|
|
||||||
trace!(target: "advotracker", ticketdata_state = "init", status = "started");
|
trace!(target: "advotracker", ticketdata_state = "init", status = "started");
|
||||||
|
|
||||||
@@ -180,16 +227,28 @@ impl State for TicketdataState {
|
|||||||
.expect("TicketState.init: Can't find resource entity 'ID_TICKET_DATA_BUTTON_MENU'.");
|
.expect("TicketState.init: Can't find resource entity 'ID_TICKET_DATA_BUTTON_MENU'.");
|
||||||
|
|
||||||
// initialize the entity object, that will receive messages
|
// initialize the entity object, that will receive messages
|
||||||
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
self.target = Entity::from(
|
||||||
.expect("TicketState.init: Can't find resource entity 'target'."));
|
ctx.widget()
|
||||||
|
.try_clone::<u32>("target")
|
||||||
|
.expect("TicketState.init: Can't find resource entity 'target'."),
|
||||||
|
);
|
||||||
|
|
||||||
// Get language from environment
|
// Get language from environment
|
||||||
//self.lang = TicketdataState::get_lang();
|
//self.lang = TicketdataState::get_lang();
|
||||||
//let self.lang = Lang::De("");
|
//let self.lang = Lang::De("");
|
||||||
|
|
||||||
Stack::visibility_set(&mut ctx.child(ID_TICKET_DATA_ACTION_STACK), Visibility::Collapsed);
|
Stack::visibility_set(
|
||||||
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_CLEAR), material_icons_font::MD_CLEAR);
|
&mut ctx.child(ID_TICKET_DATA_ACTION_STACK),
|
||||||
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_SEND);
|
Visibility::Collapsed,
|
||||||
|
);
|
||||||
|
Button::icon_set(
|
||||||
|
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_CLEAR),
|
||||||
|
material_icons_font::MD_CLEAR,
|
||||||
|
);
|
||||||
|
Button::icon_set(
|
||||||
|
&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND),
|
||||||
|
material_icons_font::MD_SEND,
|
||||||
|
);
|
||||||
|
|
||||||
let time_end = SystemTime::now();
|
let time_end = SystemTime::now();
|
||||||
let duration = time_end.duration_since(time_start);
|
let duration = time_end.duration_since(time_start);
|
||||||
@@ -215,7 +274,9 @@ impl State for TicketdataState {
|
|||||||
TicketdataAction::UpdatePolicyCode(id) => {
|
TicketdataAction::UpdatePolicyCode(id) => {
|
||||||
TicketdataState::update_policy_code(ctx.entity(), &id, ctx);
|
TicketdataState::update_policy_code(ctx.entity(), &id, ctx);
|
||||||
}
|
}
|
||||||
_ => { println!("messages: action not implemented!"); }
|
_ => {
|
||||||
|
println!("messages: action not implemented!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -232,7 +293,9 @@ impl State for TicketdataState {
|
|||||||
// //ctx.send_message(TicketdataAction::SendForm(), self.ID_TICKETDATA_FORM);
|
// //ctx.send_message(TicketdataAction::SendForm(), self.ID_TICKETDATA_FORM);
|
||||||
// info!("update: got send_message {:?}", action);
|
// info!("update: got send_message {:?}", action);
|
||||||
// }
|
// }
|
||||||
_ => { println!("TicketdataAction: action not implemented!"); }
|
_ => {
|
||||||
|
println!("TicketdataAction: action not implemented!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use orbtk::{prelude::*, widgets::themes::* };
|
use orbtk::{prelude::*, widgets::themes::*};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::constants::*,
|
data::constants::*,
|
||||||
@@ -46,14 +46,12 @@ impl Template for TicketdataView {
|
|||||||
PROP_MAIL_TO_4.to_string(),
|
PROP_MAIL_TO_4.to_string(),
|
||||||
PROP_MAIL_TO_5.to_string(),
|
PROP_MAIL_TO_5.to_string(),
|
||||||
PROP_MAIL_TO_6.to_string(),
|
PROP_MAIL_TO_6.to_string(),
|
||||||
|
PROP_MAIL_TO_7.to_string(),
|
||||||
];
|
];
|
||||||
let count_mail_to = mail_to.len();
|
let count_mail_to = mail_to.len();
|
||||||
|
|
||||||
// vector with valid carbon copy recipients addresses (mail_to)
|
// vector with valid carbon copy recipients addresses (mail_to)
|
||||||
let mail_cc = vec![
|
let mail_cc = vec![PROP_MAIL_CC_1.to_string(), PROP_MAIL_CC_2.to_string()];
|
||||||
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()
|
let tenent_logo = Container::new()
|
||||||
@@ -84,7 +82,7 @@ impl Template for TicketdataView {
|
|||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.margin((0, 9, 48, 0))
|
.margin((0, 9, 48, 0))
|
||||||
.text("©Networkx GmbH")
|
.text("©Networkx GmbH")
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
@@ -121,7 +119,7 @@ impl Template for TicketdataView {
|
|||||||
.push("auto") // Label
|
.push("auto") // Label
|
||||||
.push(16) // Delimiter
|
.push(16) // Delimiter
|
||||||
.push("*") // Data
|
.push("*") // Data
|
||||||
.push(32) // Delimiter (2x margin)
|
.push(32), // Delimiter (2x margin)
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
@@ -138,7 +136,7 @@ impl Template for TicketdataView {
|
|||||||
.push("auto") // Row 10
|
.push("auto") // Row 10
|
||||||
.push(14) // Seperator
|
.push(14) // Seperator
|
||||||
.push("auto") // Row 12
|
.push("auto") // Row 12
|
||||||
.push(14) // Seperator
|
.push(14), // Seperator
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
@@ -159,7 +157,12 @@ impl Template for TicketdataView {
|
|||||||
.v_align("center")
|
.v_align("center")
|
||||||
.water_mark("ID, bzw. Nummer")
|
.water_mark("ID, bzw. Nummer")
|
||||||
.on_activate(move |states, _entity| {
|
.on_activate(move |states, _entity| {
|
||||||
states.send_message(TicketdataAction::UpdatePolicyCode(ID_TICKET_DATA_POLICY_CODE.to_string()), id);
|
states.send_message(
|
||||||
|
TicketdataAction::UpdatePolicyCode(
|
||||||
|
ID_TICKET_DATA_POLICY_CODE.to_string(),
|
||||||
|
),
|
||||||
|
id,
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
@@ -302,7 +305,12 @@ impl Template for TicketdataView {
|
|||||||
.style(STYLE_BUTTON_ACTION)
|
.style(STYLE_BUTTON_ACTION)
|
||||||
.text("Clear")
|
.text("Clear")
|
||||||
.on_click(move |states, _entity| {
|
.on_click(move |states, _entity| {
|
||||||
states.send_message(TicketdataAction::ClearForm(ID_TICKET_DATA_FORM_GRID.to_string()), id);
|
states.send_message(
|
||||||
|
TicketdataAction::ClearForm(
|
||||||
|
ID_TICKET_DATA_FORM_GRID.to_string(),
|
||||||
|
),
|
||||||
|
id,
|
||||||
|
);
|
||||||
false
|
false
|
||||||
})
|
})
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
@@ -324,13 +332,11 @@ impl Template for TicketdataView {
|
|||||||
|
|
||||||
let ticket_data_form_mail = Container::new()
|
let ticket_data_form_mail = Container::new()
|
||||||
.id(ID_TICKET_DATA_CONTAINER_MAIL)
|
.id(ID_TICKET_DATA_CONTAINER_MAIL)
|
||||||
|
|
||||||
.name(ID_TICKET_DATA_CONTAINER_MAIL)
|
.name(ID_TICKET_DATA_CONTAINER_MAIL)
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(1))
|
||||||
.attach(Grid::column(1))
|
.attach(Grid::column(1))
|
||||||
.style(STYLE_CONTAINER_MAIL)
|
.style(STYLE_CONTAINER_MAIL)
|
||||||
.child(
|
.child(
|
||||||
|
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.columns(
|
.columns(
|
||||||
Columns::create()
|
Columns::create()
|
||||||
@@ -338,14 +344,14 @@ impl Template for TicketdataView {
|
|||||||
.push("stretch") // Label
|
.push("stretch") // Label
|
||||||
.push(16) // Delimiter
|
.push(16) // Delimiter
|
||||||
.push("auto") // MailAddress
|
.push("auto") // MailAddress
|
||||||
.push("32") // Delimiter (2x margin)
|
.push("32"), // Delimiter (2x margin)
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
.push("auto") // Row 0
|
.push("auto") // Row 0
|
||||||
.push(2) // Seperator
|
.push(2) // Seperator
|
||||||
.push("auto") // Row 2
|
.push("auto") // Row 2
|
||||||
.push(2) // Seperator
|
.push(2), // Seperator
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
@@ -366,7 +372,8 @@ impl Template for TicketdataView {
|
|||||||
// create the items builder context (ibc) for the `mail_to` vector-items
|
// create the items builder context (ibc) for the `mail_to` vector-items
|
||||||
.selected_index(id)
|
.selected_index(id)
|
||||||
.items_builder(move |ibc, index| {
|
.items_builder(move |ibc, index| {
|
||||||
let text = TicketdataView::mail_to_ref(&ibc.get_widget(id))[index].clone();
|
let text =
|
||||||
|
TicketdataView::mail_to_ref(&ibc.get_widget(id))[index].clone();
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.name(ID_TICKET_DATA_MAIL_TO)
|
.name(ID_TICKET_DATA_MAIL_TO)
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
@@ -376,7 +383,7 @@ impl Template for TicketdataView {
|
|||||||
//.on_changed("selected_index", move |states, _entity| {
|
//.on_changed("selected_index", move |states, _entity| {
|
||||||
// states.send_message(TicketdataAction::UpdateSelectedIndex(ID_TICKET_DATA_COMBO_BOX_MAIL_TO.to_string()), id);
|
// states.send_message(TicketdataAction::UpdateSelectedIndex(ID_TICKET_DATA_COMBO_BOX_MAIL_TO.to_string()), id);
|
||||||
//})
|
//})
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
@@ -395,7 +402,7 @@ impl Template for TicketdataView {
|
|||||||
.name(ID_TICKET_DATA_MAIL_CC)
|
.name(ID_TICKET_DATA_MAIL_CC)
|
||||||
.margin((12, 0, 0, 0))
|
.margin((12, 0, 0, 0))
|
||||||
.text("service@hiedemann.de")
|
.text("service@hiedemann.de")
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
// .child(
|
// .child(
|
||||||
// ComboBox::new()
|
// ComboBox::new()
|
||||||
@@ -422,7 +429,7 @@ impl Template for TicketdataView {
|
|||||||
// })
|
// })
|
||||||
// .build(ctx)
|
// .build(ctx)
|
||||||
// )
|
// )
|
||||||
.build(ctx)
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx);
|
.build(ctx);
|
||||||
|
|
||||||
@@ -459,7 +466,7 @@ impl Template for TicketdataView {
|
|||||||
Columns::create()
|
Columns::create()
|
||||||
.push(50) // Left margin
|
.push(50) // Left margin
|
||||||
.push("*") // Content
|
.push("*") // Content
|
||||||
.push(50) // Right margin
|
.push(50), // Right margin
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
@@ -467,9 +474,8 @@ impl Template for TicketdataView {
|
|||||||
.push("auto") // Mail_Form
|
.push("auto") // Mail_Form
|
||||||
.push("*") // Input_Form
|
.push("*") // Input_Form
|
||||||
.push("auto") // Action
|
.push("auto") // Action
|
||||||
.push("auto") // Bottom_Bar
|
.push("auto"), // Bottom_Bar
|
||||||
)
|
)
|
||||||
|
|
||||||
.child(ticket_data_header_bar) // row 0
|
.child(ticket_data_header_bar) // row 0
|
||||||
.child(ticket_data_form_mail) // row 1
|
.child(ticket_data_form_mail) // row 1
|
||||||
.child(ticket_data_form) // row 2
|
.child(ticket_data_form) // row 2
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
//!
|
//!
|
||||||
//!
|
//!
|
||||||
|
|
||||||
|
|
||||||
// eperimental features
|
// eperimental features
|
||||||
//#![feature(extern_doc)]
|
//#![feature(extern_doc)]
|
||||||
//#[doc(include="../README.md")]
|
//#[doc(include="../README.md")]
|
||||||
|
|||||||
Reference in New Issue
Block a user