policycheck: introduce policy_check_button_result
* after validation, show suitables glyph and corresponding text * improve user feedback with corresponding color Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::services::imports::allianzdirectcall::import;
|
||||
|
||||
use crate::{
|
||||
callbacks::global_state::GlobalState,
|
||||
data::structures::{PolicyCheck, PolicyCode, PolicyDataList, PolicyList},
|
||||
data::structures::{PolicyCode, PolicyDataList, PolicyList},
|
||||
data::keys::*,
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ pub struct PolicyCheckState {
|
||||
last_focused: Option<Entity>,
|
||||
menu_button: Entity,
|
||||
//policy_check_clean_button: Entity,
|
||||
policy_check: PolicyCheck,
|
||||
//policy_check: PolicyCheck,
|
||||
policy_data_count: usize,
|
||||
//policy_number_text_box: Entity,
|
||||
policy_numbers: HashMap<usize, PolicyCode>
|
||||
@@ -122,58 +122,66 @@ impl PolicyCheckState {
|
||||
// Parse policy code: "AS-123456789"
|
||||
// DION VERS POLLFNR
|
||||
// 1 AS 1515735810
|
||||
button(ctx.child("policy_check_button_result")).set_visibility(Visibility::Collapsed);
|
||||
button(ctx.child("policy_check_button_result")).set_background("transparent");
|
||||
|
||||
if policy_number_length == 10 {
|
||||
// needs to be an integer
|
||||
match policy_string.parse::<usize>() {
|
||||
Ok(p) => {
|
||||
println!(" ... verify policy Number {:?}", p);
|
||||
let mut label_wrapper : TextBlockCtx<'_> = text_block(ctx.child("policy_check_label_result"));
|
||||
let string_label = "Prüfungsergebnis:".to_string();
|
||||
label_wrapper.set_text(string_label);
|
||||
label_wrapper.set_visibility(Visibility::Visible);
|
||||
label_wrapper.set_enabled(true);
|
||||
let mut result_wrapper: TextBlockCtx<'_> = text_block(ctx.child("policy_check_result"));
|
||||
result_wrapper.set_text("Prüfung läuft ...");
|
||||
result_wrapper.set_text("");
|
||||
match self.policy_numbers.get(&p) {
|
||||
// check hashmap value field
|
||||
Some(policy_code) => {
|
||||
trace!(target: "advotracker", state = "success",
|
||||
policy_number = ?p, policy_code = ?policy_code);
|
||||
result_wrapper.set_enabled(true);
|
||||
let string_result = format!("gütig! => vollständig: 1-{:?}-{}",
|
||||
let string_result = format!("1-{:?}-{}",
|
||||
policy_code, p);
|
||||
result_wrapper.set_text(string_result);
|
||||
button(ctx.child("policy_check_button_result")).set_icon(material_icons_font::MD_CHECK);
|
||||
button(ctx.child("policy_check_button_result")).set_icon_brush("#008000");
|
||||
button(ctx.child("policy_check_button_result")).set_text("gültig!");
|
||||
button(ctx.child("policy_check_button_result")).set_visibility(Visibility::Visible);
|
||||
button(ctx.child("policy_check_button_result")).set_foreground("#008000");
|
||||
button(ctx.child("policy_check_button_result")).set_background("transparent");
|
||||
}
|
||||
_ => {
|
||||
//let res = t!("policy.validation.failed", lang);
|
||||
//println!("{:?}", res);
|
||||
trace!(target: "advotracker", state = "failed",
|
||||
policy_number = ?p);
|
||||
println!("Noop! Number isn't valid!");
|
||||
result_wrapper.set_enabled(true);
|
||||
result_wrapper.set_text("noop, ungültig!");
|
||||
button(ctx.child("policy_check_button_result")).set_icon(material_icons_font::MD_CLEAR);
|
||||
button(ctx.child("policy_check_button_result")).set_icon_brush("#FF0000");
|
||||
button(ctx.child("policy_check_button_result")).set_text("ungültig!");
|
||||
button(ctx.child("policy_check_button_result")).set_visibility(Visibility::Visible);
|
||||
button(ctx.child("policy_check_button_result")).set_foreground("#FF0000");
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
trace!(target: "advotracker", state = "error", error_type = "invalid type");
|
||||
println!("invalid: {}", e);
|
||||
// Feedback
|
||||
println!("Please enter an integer!");
|
||||
trace!(target: "advotracker", state = "error", error_type = "invalid type", error = ?e);
|
||||
button(ctx.child("policy_check_button_result")).set_icon(material_icons_font::MD_CLEAR);
|
||||
button(ctx.child("policy_check_button_result")).set_icon_brush("#FF0000");
|
||||
button(ctx.child("policy_check_button_result")).set_text("ungültig!");
|
||||
button(ctx.child("policy_check_button_result")).set_visibility(Visibility::Visible);
|
||||
button(ctx.child("policy_check_button_result")).set_foreground("#FF0000");
|
||||
let mut text_block_wrapper: TextBlockCtx<'_> = text_block(ctx.child("policy_check_result"));
|
||||
text_block_wrapper.set_enabled(true);
|
||||
text_block_wrapper.set_text("Nur Nummern sind zulässig!");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if policy_number_length < 10 {
|
||||
println!("Policy number is to short!");
|
||||
//println!("Policy number is to short!");
|
||||
let mut text_block_wrapper: TextBlockCtx<'_> = text_block(ctx.child("policy_check_result"));
|
||||
text_block_wrapper.set_enabled(true);
|
||||
text_block_wrapper.set_text("zu kurz!");
|
||||
//ctx.get_widget(policy_check_policy_number).set("policy_check_result", true);
|
||||
//ctx.child(ID_POLICY_CHECK_POLICY_NUMBER).set("text", String::from(""));
|
||||
}
|
||||
if policy_number_length > 10 {
|
||||
println!("Policy number is to big!");
|
||||
//println!("Policy number is to big!");
|
||||
let mut text_block_wrapper: TextBlockCtx<'_> = text_block(ctx.child("policy_check_result"));
|
||||
text_block_wrapper.set_enabled(true);
|
||||
text_block_wrapper.set_text("zu lang!");
|
||||
@@ -214,15 +222,17 @@ impl PolicyCheckState {
|
||||
}
|
||||
|
||||
/// Change visibility of the result label
|
||||
fn set_visibility(&self, entity: Entity, ctx: &mut Context<'_>) {
|
||||
if ctx.get_widget(entity).get::<String16>("text").is_empty() {
|
||||
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_visibility(Visibility::Visible);
|
||||
} else {
|
||||
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_visibility(Visibility::Collapsed);
|
||||
//ctx.get_widget(self.policy_check_label_policy_number).set("enabled", false);
|
||||
}
|
||||
fn set_visibility(&self, entity: Entity, ctx: &mut Context<'_>) {
|
||||
if ctx.get_widget(entity).get::<String16>("text").is_empty() {
|
||||
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_visibility(Visibility::Visible);
|
||||
text_block(ctx.child(ID_POLICY_CHECK_BUTTON_RESULT)).set_visibility(Visibility::Visible);
|
||||
} else {
|
||||
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_visibility(Visibility::Collapsed);
|
||||
text_block(ctx.child(ID_POLICY_CHECK_BUTTON_RESULT)).set_visibility(Visibility::Collapsed);
|
||||
//ctx.get_widget(self.policy_check_label_policy_number).set("enabled", false);
|
||||
}
|
||||
|
||||
ctx.get_widget(self.label_result_text_block).update_theme_by_state(true);
|
||||
ctx.get_widget(self.label_result_text_block).update_theme_by_state(true);
|
||||
}
|
||||
|
||||
// Update count of elements in the policy data list.
|
||||
@@ -237,11 +247,8 @@ impl PolicyCheckState {
|
||||
impl State for PolicyCheckState {
|
||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
self.menu_button = ctx
|
||||
.entity_of_child(ID_POLICY_CHECK_MENU_BUTTON)
|
||||
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
|
||||
.expect("PolicyCheckState.init: Can't find entity id defined as resource 'ID_POLICY_CHECK_POLICY_MENU_BUTTON'.");
|
||||
// self.policy_number_text_box = ctx
|
||||
// .entity_of_child(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
// .expect("PolicyCheckState.init: Can't find entity id defined as resource 'ID_POLICY_CHECK_POLICY_NUMBER'.");
|
||||
|
||||
// import data
|
||||
// WIP: for now, only import once per session
|
||||
@@ -327,6 +334,8 @@ impl State for PolicyCheckState {
|
||||
}
|
||||
Action::SetVisibility(entity) => {
|
||||
//text_block(ctx.child(entity).set_visibility(Visibility::Visible));
|
||||
println!("Entity: {:?}", entity);
|
||||
//text_block(ctx.child(entity).set_visibility(Visibility::Collapsed));
|
||||
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_visibility(Visibility::Collapsed);
|
||||
}
|
||||
Action::TextChanged(entity, _index) => {
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
// https://github.com/ron-rs/ronRon
|
||||
|
||||
// Classes
|
||||
pub static CLASS_BOTTOM_BAR: &str = "bottom_bar";
|
||||
pub static CLASS_HEADER: &str = ".my_header";
|
||||
pub static CLASS_ICON_ONLY: &str = "icon_only";
|
||||
pub static CLASS_FOOTER: &str = "footer";
|
||||
pub static CLASS_HEADER: &str = "header";
|
||||
pub static CLASS_ITEM_BUTTON: &str = "item_button";
|
||||
pub static CLASS_MENU: &str = "menu";
|
||||
pub static CLASS_MENU_BUTTON: &str = "menu_button";
|
||||
pub static CLASS_POLICY_CHECK_FORM: &str = "check_form";
|
||||
pub static CLASS_TEXT_BOX: &str = "text_box";
|
||||
pub static CLASS_TEXT_BLOCK: &str = "text_block";
|
||||
@@ -17,12 +16,13 @@ pub static CLASS_SEPERATOR: &str = "seperator";
|
||||
// Widget IDs (DCES: Entity[id] => [Component1, .. , Component<n>] -> data or state)
|
||||
pub static ID_POLICY_CHECK_FORM: &str = "policy_check_form";
|
||||
pub static ID_POLICY_CHECK_HEADER: &str = "policy_check_header";
|
||||
//pub static ID_POLICY_CHECK_ITEMS_WIDGET: &str = "policy_check_items_widget";
|
||||
pub static ID_POLICY_CHECK_CLEAR_BUTTON: &str = "policy_check_clear_button";
|
||||
pub static ID_POLICY_CHECK_MENU_BUTTON: &str = "policy_check_menu_button";
|
||||
pub static ID_POLICY_CHECK_ITEMS_WIDGET: &str = "policy_check_items_widget";
|
||||
pub static ID_POLICY_CHECK_BUTTON_MENU: &str = "policy_check_button_menu";
|
||||
pub static ID_POLICY_CHECK_BUTTON_RESULT: &str = "policy_check_button_result";
|
||||
pub static ID_POLICY_CHECK_LABEL_POLICY_NUMBER: &str = "policy_check_label_policy_number";
|
||||
pub static ID_POLICY_CHECK_LABEL_RESULT: &str = "policy_check_label_result";
|
||||
pub static ID_POLICY_CHECK_MENU_TEXT_BLOCK: &str = "policy_check_menu_text_block";
|
||||
pub static ID_POLICY_CHECK_TEXT_BLOCK_MENU: &str = "policy_check_text_block_menu";
|
||||
pub static ID_POLICY_CHECK_POLICY_NUMBER: &str = "policy_check_policy_number";
|
||||
pub static ID_POLICY_CHECK_RESULT: &str = "policy_check_result";
|
||||
pub static ID_POLICY_CHECK_POLICY_NUMBER: &str = "policy_check_policy_number";
|
||||
pub static ID_POLICY_CHECK_WIDGET: &str = "policy_check_widget";
|
||||
|
||||
@@ -36,12 +36,11 @@ struct Environment {
|
||||
}
|
||||
|
||||
//#[cfg(feature = "light-theme")]
|
||||
//static STYLESHEET: &'static str = include_str!("../resources/stylesheets/advotracker.css");
|
||||
static STYLESHEET: &'static str = include_str!("../resources/stylesheets/policyholder-check.css");
|
||||
static STYLESHEET: &'static str = include_str!("../resources/stylesheets/advotracker.css");
|
||||
|
||||
fn get_theme() -> ThemeValue {
|
||||
//ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
||||
ThemeValue::create_from_css(DEFAULT_THEME_CSS)
|
||||
//ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
||||
.extension_css(STYLESHEET)
|
||||
.build()
|
||||
}
|
||||
@@ -75,9 +74,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut lang = env::var("LANG").unwrap_or("en".to_string());
|
||||
let mut res = t!("parse.environment", lang);
|
||||
let mut state = t!("state.started", lang);
|
||||
trace!(target: "csv-test", message = ?res, state = ?state);
|
||||
trace!(target: "advotracker", message = ?res, state = ?state);
|
||||
//debug!(message = ?res, state = ?state);
|
||||
trace!(target: "csv-test", environment = "system", lang = ?lang);
|
||||
trace!(target: "advotracker", environment = "system", lang = ?lang);
|
||||
|
||||
// testing environment: read from .env file
|
||||
dotenv().ok();
|
||||
@@ -89,9 +88,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
// how to handle unumplemented lang resources??
|
||||
res = t!("parse.environment", lang);
|
||||
trace!(target: "csv-test", environment = "envy", lang = ?lang);
|
||||
trace!(target: "advotracker", environment = "envy", lang = ?lang);
|
||||
state = t!("state.finished", lang);
|
||||
trace!(target: "csv-test", message = ?res, state = ?state);
|
||||
trace!(target: "advotracker", message = ?res, state = ?state);
|
||||
|
||||
// initialize viperus structure
|
||||
let mut viperus = Viperus::new();
|
||||
@@ -112,17 +111,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// parse commandline arguments
|
||||
res = t!("parse.arguments", lang);
|
||||
state = t!("state.started", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
|
||||
let _ = parse_args(&mut viperus);
|
||||
state = t!("state.finished", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
//trace!(target: "Viperus", "Count of Config parameters: {:?}", VIPERUS_COUNT);
|
||||
|
||||
// main tasks
|
||||
res = t!("main.started", lang);
|
||||
state = t!("state.started", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
|
||||
// moved to callback: checkview_state.rs
|
||||
// // importing policy code elements from csv-file
|
||||
@@ -141,14 +140,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// println!("Imported {:?} records", count);
|
||||
// }
|
||||
// Err(err) => {
|
||||
// println!("error running Csv-Test: {}", err);
|
||||
// println!("error running Advotracker: {}", err);
|
||||
// process::exit(1);
|
||||
// }
|
||||
//}
|
||||
|
||||
// // test if policy_number is_valid
|
||||
// let test_policy_number = VIPERUS.get::<i32>("test_policy_number").unwrap() as usize;
|
||||
// trace!(target: "csv-test", test_policy_number = ?test_policy_number);
|
||||
// trace!(target: "advotracker", test_policy_number = ?test_policy_number);
|
||||
// match policy_numbers.get(&test_policy_number) {
|
||||
// Some(&policy_code) => {
|
||||
// let res = t!("policy.validation.success", lang);
|
||||
@@ -165,11 +164,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
|
||||
|
||||
Application::from_name("rzerres.advotracker")
|
||||
Application::from_name("nwx.advotracker")
|
||||
.window(move |ctx| {
|
||||
Window::new()
|
||||
//.title("OrbTk - Policyholder checker")
|
||||
.title("AdvoTracker - Versicherungsnummern")
|
||||
.title("AdvoTracker - DirectCall")
|
||||
.position((500.0, 100.0))
|
||||
.size(580.0, 320.0)
|
||||
.min_width(460.0)
|
||||
@@ -183,7 +181,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("main.finished", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
});
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -40,16 +40,15 @@ impl Template for PolicyCheckView {
|
||||
.id(ID_POLICY_CHECK_MENU_BUTTON)
|
||||
.margin((0.0, 0.0, 12.0, 12.0))
|
||||
.icon(material_icons_font::MD_MENU)
|
||||
.class(CLASS_ICON_ONLY)
|
||||
//.attach(Grid::row(0))
|
||||
.class("menu_button")
|
||||
.attach(Grid::column(2))
|
||||
.margin((8.0, 0.0, 2.0, 0.0))
|
||||
//.text("Menu Button")
|
||||
//.min_size(8.0, 8.0)
|
||||
//.min_size(8.0, 8.0)
|
||||
.min_size(16.0, 16.0)
|
||||
.h_align("end")
|
||||
//.v_align("center")
|
||||
//.enabled(true)
|
||||
//.v_align("center")
|
||||
//.enabled(true)
|
||||
.on_mouse_down(|_, _| true)
|
||||
//.child(policycheck_menu_container)
|
||||
.on_click(move |ctx, _| {
|
||||
@@ -59,20 +58,24 @@ impl Template for PolicyCheckView {
|
||||
})
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_result_button = Button::new()
|
||||
.id(ID_POLICY_CHECK_BUTTON_RESULT)
|
||||
.class("single_content")
|
||||
.h_align("start")
|
||||
.v_align("center")
|
||||
.visibility(Visibility::Collapsed)
|
||||
.enabled(false)
|
||||
.build(ctx);
|
||||
|
||||
let policy_data_count_block = TextBlock::new()
|
||||
.id(ID_POLICY_DATA_COUNT_BLOCK)
|
||||
//.class(CLASS_TEXT_BLOCK)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.margin((0., 0., 0., 16.))
|
||||
.attach(Grid::row(1))
|
||||
.attach(Grid::column(1))
|
||||
.margin((0., 4., 0., 0.))
|
||||
.h_align("end")
|
||||
.v_align("end")
|
||||
.enabled(true)
|
||||
.min_width(250.0)
|
||||
.min_height(45.0)
|
||||
.text("Anzahl Prüfsätze:")
|
||||
.build(ctx);
|
||||
|
||||
// let policy_check_menu_container = Container::new()
|
||||
@@ -108,7 +111,7 @@ impl Template for PolicyCheckView {
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_POLICY_CHECK_WIDGET)
|
||||
.background("#fafafa")
|
||||
//.background("#fafafa")
|
||||
.columns(
|
||||
Columns::new()
|
||||
.add(84.0)
|
||||
@@ -118,17 +121,14 @@ impl Template for PolicyCheckView {
|
||||
)
|
||||
.rows(
|
||||
Rows::new()
|
||||
// Top Bar
|
||||
.add("auto")
|
||||
.add(1.0)
|
||||
// Content
|
||||
.add("5.")
|
||||
.add("*")
|
||||
.add(1.0)
|
||||
// Bottom Bar
|
||||
.add(52.0)
|
||||
/* .add("auto") */
|
||||
.add("18.")
|
||||
.add("auto")
|
||||
.build(),
|
||||
)
|
||||
|
||||
// Header Bar
|
||||
.child(
|
||||
//.border_color("transparent")
|
||||
@@ -165,6 +165,7 @@ impl Template for PolicyCheckView {
|
||||
.attach(Grid::column_span(3))
|
||||
.build(ctx),
|
||||
)
|
||||
|
||||
// Policy Check Form
|
||||
.child(
|
||||
Container::new()
|
||||
@@ -321,7 +322,8 @@ impl Template for PolicyCheckView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(policy_data_count_block)
|
||||
// Bottom bar
|
||||
|
||||
// Bottom bar
|
||||
.child(
|
||||
Container::new()
|
||||
.class(CLASS_BOTTOM_BAR)
|
||||
|
||||
Reference in New Issue
Block a user