policycheck: functionality update

* show count of active hashmap members in GUI
* move import call to init function
* show results of policy_number validation in GUI
* improve tracing information
* disable stdout messages via println!()

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2020-07-03 01:12:25 +02:00
parent 1d48f294dc
commit a89e400029
2 changed files with 416 additions and 372 deletions

View File

@@ -1,17 +1,17 @@
use locales::t; //use locales::t;
use dotenv::dotenv; use dotenv::dotenv;
use orbtk::prelude::*; use orbtk::prelude::*;
use serde::Deserialize; use serde::Deserialize;
use std::{env, process}; use std::{env, process};
use std::collections::HashMap; use std::collections::HashMap;
use tracing::{debug, trace}; use tracing::{debug, error, info, trace};
use crate::services::imports::allianzdirectcall::import; use crate::services::imports::allianzdirectcall::import;
use crate::callbacks::policy_check::is_valid; //use crate::callbacks::policy_check::is_valid;
use crate::{ use crate::{
callbacks::global_state::GlobalState, callbacks::global_state::GlobalState,
data::structures::{PolicyCode, PolicyDataList, PolicyData, PolicyList}, data::structures::{PolicyCheck, PolicyCode, PolicyDataList, PolicyList},
data::keys::*, data::keys::*,
}; };
@@ -24,6 +24,7 @@ pub enum Action {
ParseEntry(Entity), ParseEntry(Entity),
RemoveFocus(Entity), RemoveFocus(Entity),
SetEntry(Entity), SetEntry(Entity),
SetVisibility(Entity),
TextChanged(Entity, usize), TextChanged(Entity, usize),
} }
@@ -37,16 +38,19 @@ struct Environment {
#[derive(Default, AsAny)] #[derive(Default, AsAny)]
pub struct PolicyCheckState { pub struct PolicyCheckState {
action: Option<Action>, action: Option<Action>,
label_result_text_block: Entity,
last_focused: Option<Entity>, last_focused: Option<Entity>,
pub text_box: Entity,
menu_button: Entity, menu_button: Entity,
policy_number_valid: bool, //policy_check_clean_button: Entity,
policy_number_count: usize, policy_check: PolicyCheck,
policy_numbers: HashMap<usize, PolicyCode>, policy_data_count: usize,
//policy_number_text_box: Entity,
policy_numbers: HashMap<usize, PolicyCode>
} }
impl GlobalState for PolicyCheckState {} impl GlobalState for PolicyCheckState {}
/// method definitions, that react on any given state change inside the view
impl PolicyCheckState { impl PolicyCheckState {
/// Sets a new action. /// Sets a new action.
pub fn action(&mut self, action: Action) { pub fn action(&mut self, action: Action) {
@@ -74,14 +78,15 @@ impl PolicyCheckState {
let mut policy_numbers : HashMap<usize, PolicyCode> = HashMap::new(); let mut policy_numbers : HashMap<usize, PolicyCode> = HashMap::new();
// 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");
println!("Importing from: {:?}", csv_import_path); println!("Importing from: {:?}", csv_import_path);
match import(&mut csv_import_path, &mut policy_data, match import(&mut csv_import_path, &mut policy_data,
&mut policy_numbers, &lang) { &mut policy_numbers, &lang) {
Ok(count) => { Ok(count) => {
self.policy_number_count = count; self.policy_data_count = count;
println!("Imported {:?} records", self.policy_number_count); println!("Imported {:?} records", self.policy_data_count);
} }
Err(err) => { Err(err) => {
println!("error running CSV-Import: {}", err); println!("error running CSV-Import: {}", err);
@@ -94,24 +99,26 @@ impl PolicyCheckState {
} }
/// Clear text in text box. /// Clear text in text box.
pub fn clear_entry(&mut self, text_box: Entity, ctx: &mut Context) { pub fn clear_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) {
let mut text_box = TextBox::get(ctx.get_widget(text_box)); let mut text_box = TextBox::get(ctx.get_widget(text_box));
let text = text_box.text_mut(); let text = text_box.text_mut();
println!("reset {}", text); println!("reset {}", text);
} }
/// Open menu. /// Open menu.
pub fn open_menu(&mut self, text_block: Entity, ctx: &mut Context) { pub fn open_menu(&mut self, text_block: Entity, ctx: &mut Context<'_>) {
let mut text_block = TextBlock::get(ctx.get_widget(text_block)); let mut text_block = TextBlock::get(ctx.get_widget(text_block));
let text = text_block.text_mut(); let text = text_block.text_mut();
println!("Menu text: {}", text); println!("Menu text: {}", text);
} }
fn parse_entry(&mut self, policy_check_policy_number: Entity, fn parse_entry(&mut self, policy_check_policy_number: Entity,
ctx: &mut Context) { ctx: &mut Context<'_>) {
let policy_string = ctx.get_widget(policy_check_policy_number).get::<String16>("text").as_string(); let policy_string = ctx.get_widget(policy_check_policy_number).get::<String16>("text").as_string();
let policy_number_length = policy_string.len(); let policy_number_length = policy_string.len();
trace!(target: "advotracker", state = "parsing", policy_number = ?policy_string);
// Parse policy code: "AS-123456789" // Parse policy code: "AS-123456789"
// DION VERS POLLFNR // DION VERS POLLFNR
// 1 AS 1515735810 // 1 AS 1515735810
@@ -119,107 +126,84 @@ impl PolicyCheckState {
// needs to be an integer // needs to be an integer
match policy_string.parse::<usize>() { match policy_string.parse::<usize>() {
Ok(p) => { Ok(p) => {
trace!(target: "advotracker", policy_number = ?p);
// WIP: for now, only import once per session
if self.policy_number_count == 0 {
match self.create_hashmap() {
Ok(()) => {
//let res = t!("policy.hashmap.success", lang);
//println!("{:?}", res);
println!("hashmap has: {:?} entries", self.policy_number_count);
}
_ => {
// let res = t!("policy.hashmap.failed", lang);
// println
// !("{:?}", res);
println!("Creation of a hashmap failed!");
}
}
} else {
println!("Already imported {} records.", self.policy_number_count);
}
println!(" ... verify policy Number {:?}", 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 ...");
match self.policy_numbers.get(&p) { match self.policy_numbers.get(&p) {
// check hashmaps value field // check hashmap value field
Some(policy_code) => { Some(policy_code) => {
//let res = t!("policy.validation.success", lang); trace!(target: "advotracker", state = "success",
//println!("{:?}", res); policy_number = ?p, policy_code = ?policy_code);
println!("policy_number: {} ({:?})", result_wrapper.set_enabled(true);
p, policy_code); let string_result = format!("gütig! => vollständig: 1-{:?}-{}",
policy_code, p);
result_wrapper.set_text(string_result);
} }
_ => { _ => {
//let res = t!("policy.validation.failed", lang); //let res = t!("policy.validation.failed", lang);
//println!("{:?}", res); //println!("{:?}", res);
println!("Nuup! Number isn't valid!"); 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!");
} }
} }
}, },
Err(e) => { Err(e) => {
trace!(target: "advotracker", state = "error", error_type = "invalid type");
println!("invalid: {}", e); println!("invalid: {}", e);
// Feedback // Feedback
println!("Please enter an integer!"); println!("Please enter an integer!");
} }
} }
//ctx.get_widget(text_box).set("policy_number_valid", true);
//ctx.get_widget(policy_check_policy_number).set("policy_check_result", true);
//TextBox::get(ctx.child("policy_check_result")).set_foreground(colors::LINK_WATER_COLOR);
} }
if policy_number_length < 10 { if policy_number_length < 10 {
println!("Policy number is to short!"); println!("Policy number is to short!");
ctx.child(ID_POLICY_CHECK_POLICY_NUMBER).set("text", String::from("")); let mut text_block_wrapper: TextBlockCtx<'_> = text_block(ctx.child("policy_check_result"));
//ctx.child(ID_POLICY_CHECK_RESULT).set("text", String::from("Policy number is to short!")); text_block_wrapper.set_enabled(true);
// ctx.get_widget(policy_check_policy_number).set("policy_number_valid", true); text_block_wrapper.set_text("zu kurz!");
//policy_check_view(ctx.widget()) //ctx.get_widget(policy_check_policy_number).set("policy_check_result", true);
// .set_policy_check_result(String16::from(format!("Given Number is to small: {}", policy_number_length))); //ctx.child(ID_POLICY_CHECK_POLICY_NUMBER).set("text", String::from(""));
//let mut text_box = text_box(ctx.get_widget(Entity));
//let text = text_box.text;
//println!("submitting {}", text);
//text.clear();
// TextBock: set "visibility", "text"
//policycheck_view(ctx.widget())
// .list_mut()
// .push(format!("Item {}", len + 1));
//ctx.child("items").set::<usize>("blub", len + 1);
//TextBox::get(ctx.child("policy_check_result")).set_foreground("#ffffff");
//text_block::get(ctx.child(policy_check_result)).set_background("#5b0f22");
//policy_check_result(ctx.child("items")).set_count(len + 1);
} }
if policy_number_length > 10 { if policy_number_length > 10 {
println!("Policy number is to big!"); println!("Policy number is to big!");
//TextBox::get(ctx.child("text_box")).set_foreground("#ffffff"); let mut text_block_wrapper: TextBlockCtx<'_> = text_block(ctx.child("policy_check_result"));
//TextBox::get(ctx.child("text_box")).set_background("#5b0f22"); text_block_wrapper.set_enabled(true);
text_block_wrapper.set_text("zu lang!");
} }
//if let policy_number = policy_check_policy_number.text() {
// match policy_number {
// _ => {
// println!("policynumber: {} is valid!", policy_number);
// }
// }
//}
} }
/// If TextBox 'policy_check_policy_number' is empty, disable button "clear" /// If TextBox 'policy_check_policy_number' is empty, disable button "clear"
/// otherwise enabled it. /// otherwise enabled it.
// fn set_check_button(&self, text_box: Entity, ctx: &mut Context) { // fn set_policy_check_clear_button(&self, policy_check_policy_number: Entity, ctx: &mut Context<' >) {
// if ctx.get_widget(clear_button).get::<String>("policy_check_policy_number").is_empty() { // if ctx.get_widget(clear_button).get::<String>("policy_check_policy_number").is_empty() {
// ctx.get_widget(self.policy_check_clear_button).set("enabled", false); // ctx.get_widget(self.policy_check_clear_button).set("enabled", false);
// } else { // } else {
// ctx.get_widget(self.policy_check_clear_button).set("enabled", true); // ctx.get_widget(self.policy_check_clear_button).set("enabled", true);
// } // }
// ctx.get_widget(self.text_box).update_theme_by_state(true); // ctx.get_widget(self.policy_check_policy_number).update_theme_by_state(true);
// } // }
/// Change status of given text box to edit mode. /// Change status of given text box to edit mode.
fn set_entry(&self, text_box: Entity, ctx: &mut Context) { fn set_entry(&self, policy_check_policy_number: Entity, ctx: &mut Context<'_>) {
if *ctx.get_widget(text_box).get::<bool>("focused") { if *ctx.get_widget(policy_check_policy_number).get::<bool>("focused") {
ctx.get_widget(text_box).set("enabled", false); //let mut my_ctx: WidgetContainer<'_> = ctx.widget();
ctx.push_event_by_window(FocusEvent::RemoveFocus(text_box)); //let mut child: WidgetContainer<'_> = ctx.get_widget(policy_check_policy_number);
//ctx.get_widget(policy_check_policy_number).set("enabled", true);
let mut text_box_wrapper: TextBoxCtx<'_> = text_box(ctx.child("policy_check_policy_number"));
//ctx.push_event_by_window(FocusEvent::RemoveFocus(policy_check_policy_number));
text_box_wrapper.set_visibility( Visibility::Visible);
text_box_wrapper.set_enabled(true);
text_box_wrapper.set_text("");
text_box_wrapper.set_water_mark("Neue Eingabe ...");
return; return;
} }
@@ -227,36 +211,88 @@ impl PolicyCheckState {
ctx.push_event_by_window(FocusEvent::RemoveFocus(old_focused_element)); ctx.push_event_by_window(FocusEvent::RemoveFocus(old_focused_element));
} }
ctx.get_widget(text_box).set("enabled", true);
// select all
ctx.get_widget(text_box)
.get_mut::<TextSelection>("text_selection")
.start_index = 0;
ctx.get_widget(text_box)
.get_mut::<TextSelection>("text_selection")
.length = ctx.get_widget(text_box).get::<String>("policy_number").len();
ctx.push_event_by_window(FocusEvent::RequestFocus(text_box));
} }
/// 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);
}
ctx.get_widget(self.label_result_text_block).update_theme_by_state(true);
}
// Update count of elements in the policy data list.
fn update_data_count(&self, ctx: &mut Context<'_>) {
// old api syntax
let data_list_count = ctx.widget().get::<PolicyDataList>(PROP_POLICY_DATA_LIST).len();
ctx.widget().set(PROP_POLICY_DATA_COUNT, data_list_count);
}
} }
/// upported states for our view
impl State for PolicyCheckState { impl State for PolicyCheckState {
fn init(&mut self, _: &mut Registry, ctx: &mut Context) { fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
// self.button = ctx self.menu_button = ctx
// .entity_of_child(ID_POLICY_CHECK_MENU_BUTTON) .entity_of_child(ID_POLICY_CHECK_MENU_BUTTON)
// .expect("PolicyCheckState.init: Can't find child 'Menu button'."); .expect("PolicyCheckState.init: Can't find entity id defined as resource 'ID_POLICY_CHECK_POLICY_MENU_BUTTON'.");
self.text_box = ctx // self.policy_number_text_box = ctx
.entity_of_child(ID_POLICY_CHECK_POLICY_NUMBER) // .entity_of_child(ID_POLICY_CHECK_POLICY_NUMBER)
.expect("PolicyCheckState.init: Can't find child 'Text Box'."); // .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
if self.policy_data_count == 0 {
match self.create_hashmap() {
Ok(()) => {
//let res = t!("policy.hashmap.success", lang);
//println!("{:?}", res);
info!("hashmap has: {:?} entries", self.policy_data_count);
trace!(target: "advotracker",
hashmap_status = "new import",
hashmap_entries = ?self.policy_data_count);
}
_ => {
// let res = t!("policy.hashmap.failed", lang);
// println
// !("{:?}", res);
error!("Creation of a hashmap failed!");
trace!(target: "advotracker", hashmap_status = "failed");
}
}
} else {
println!("Already imported {} records.", self.policy_data_count);
trace!(target: "advotracker",
hashmap_status = "consume",
hashmap_entries = ?self.policy_data_count);
}
// // Load the saved data from a file in 'ron' format into our data structure.
// // The cargo package identifier (default: 'nwx.advotracker') is used as the
// // app directory name. The directory location is OS dependant
// // (Windows: AppData, Unix: XDG_CONFIG_HOME, MacOS: $HOME/Library/Preferences).
// // The filename is taken from the propertey PROP_ADVOTRACKER (default: 'advotracker'.ron).
// if let Ok(policy_data) = registry
// .get::<Settings>("settings")
// .load::<PolicyDataList>(PROP_ADVOTRACKER)
// {
// ctx.widget().set(PROP_ADVOTRACKER, policy_data);
// }
// number of elements in the restored policy data
//policy_data_count = policy_data.len().clone;
//self.update_data_count(ctx);
} }
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context) { fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
// clear focus on focus moved // clear focus on focus moved
if self.last_focused != ctx.window().get::<Global>("global").focused_widget { if self.last_focused != ctx.window().get::<Global>("global").focused_widget {
if let Some(last_focused) = self.last_focused { if let Some(last_focused) = self.last_focused {
ctx.get_widget(last_focused).set("focused", false); ctx.get_widget(last_focused).set("focused", false);
// widget is unvisible, but takes space to be considered
ctx.get_widget(last_focused) ctx.get_widget(last_focused)
.set("visibility", Visibility::Collapsed); .set("visibility", Visibility::Collapsed);
} }
@@ -264,27 +300,34 @@ impl State for PolicyCheckState {
if let Some(action) = self.action { if let Some(action) = self.action {
match action { match action {
Action::ClearEntry(text_box) => { Action::ClearEntry(policy_check_policy_number) => {
self.clear_entry(text_box, ctx); ctx.get_widget(policy_check_policy_number).set("enabled", false);
} }
Action::InputTextChanged(text_box) => { Action::InputTextChanged(entity) => {
//self.set_check_button(text_box, ctx); //println!("entry changed: {}", text_box(ctx.get_widget(entity)).text());
//self.set_check_button(policy_check_label_policy_number, ctx);
self.set_visibility(entity, ctx);
} }
Action::OpenMenu(text_block) => { Action::OpenMenu(text_block) => {
self.open_menu(text_block, ctx); self.open_menu(text_block, ctx);
} }
Action::ParseEntry(text_box) => { Action::ParseEntry(text_box) => {
self.parse_entry(text_box, ctx); self.parse_entry(text_box, ctx);
ctx.get_widget(text_box).get::<String16>("text").as_string();
//self.parse_entry(text_box, &mut policy_numbers, //self.parse_entry(text_box, &mut policy_numbers,
// &lang, ctx); // &lang, ctx);
} }
Action::RemoveFocus(text_box) => { Action::RemoveFocus(policy_check_policy_number) => {
ctx.get_widget(text_box).set("enabled", false); ctx.get_widget(policy_check_policy_number).set("enabled", false);
ctx.push_event_by_window(FocusEvent::RemoveFocus(text_box)); ctx.push_event_by_window(FocusEvent::RemoveFocus(policy_check_policy_number));
} }
Action::SetEntry(text_box) => { Action::SetEntry(policy_check_policy_number) => {
self.last_focused = Some(text_box); //self.last_focused = Some();
self.set_entry(text_box, ctx); self.set_entry(policy_check_policy_number, ctx);
}
Action::SetVisibility(entity) => {
//text_block(ctx.child(entity).set_visibility(Visibility::Visible));
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_visibility(Visibility::Collapsed);
} }
Action::TextChanged(entity, _index) => { Action::TextChanged(entity, _index) => {
self.set_entry(entity, ctx); self.set_entry(entity, ctx);
@@ -293,4 +336,16 @@ impl State for PolicyCheckState {
} }
self.action = None; self.action = None;
} }
fn update_post_layout(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
let string_result = "Prüfungsergebnis:".to_string();
//string_result = format!("{} {:?}", string_result, self.??;
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_text(string_result);
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_visibility(Visibility::Collapsed);
let mut string_data_count = "Prüflisten-Elemente:".to_string();
string_data_count = format!("{} {:?}", string_data_count, self.policy_numbers.len());
text_block(ctx.child(ID_POLICY_DATA_COUNT_BLOCK)).set_text(string_data_count);
}
} }

View File

@@ -14,43 +14,21 @@ use crate::{
//policycheck_state::{Action, PolicyCheckState}, //policycheck_state::{Action, PolicyCheckState},
}; };
// Macro that initializes the widget structures/variables for our view (essential!)
widget!( widget!(
/// Dialog to enter a policy identifier/number. /// Dialog to enter a policy identifier/number.
/// This identifier is checked agains a map of valid policy codes. /// This identifier is checked agains a map of valid policy codes.
PolicyCheckView<PolicyCheckState> { PolicyCheckView<PolicyCheckState> {
policy_check: PolicyCheck, policy_check: PolicyCheck,
//policy_check_list: PolicyCheckList,
policy_check_title: String16, policy_check_title: String16,
policy_check_number: String16, policy_data_count: u32
policy_check_number_valid: bool,
policy_check_result: String16,
policy_data_count: u32,
//policylist_view: u32,
title: String
} }
); );
// The template implementation for our View
impl Template for PolicyCheckView { impl Template for PolicyCheckView {
fn template(self, id: Entity, ctx: &mut BuildContext)-> Self { fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
// collect the DCES elements of our 'policy check' view
// let items_widget = ItemsWidget::new()
// .id(ID_POLICY_CHECK_ITEMS_WIDGET)
// .v_align("start")
// .items_builder(move |ctx, index| {
// let mut title = "".to_string();
// if let Some(policy_check) = ctx
// .get_widget(id)
// .get::<PolicyCheckList>(PROP_POLICY_CHECK_LIST)
// .get(index)
// {
// title = policy_check.title.clone();
// }
// })
// .count((PROP_POLICY_DATA_COUNT, id))
// .build(ctx);
let policy_check_menu_text_block = TextBlock::new() let policy_check_menu_text_block = TextBlock::new()
.foreground("#3b434a") .foreground("#3b434a")
.text("Help Menu") .text("Help Menu")
@@ -81,24 +59,21 @@ impl Template for PolicyCheckView {
}) })
.build(ctx); .build(ctx);
// let policy_check_text_box = TextBox::new()
// .id(ID_POLICY_CHECK_TEXT_BOX) let policy_data_count_block = TextBlock::new()
// .attach(Grid::row(4)) .id(ID_POLICY_DATA_COUNT_BLOCK)
// .attach(Grid::row(0)) //.class(CLASS_TEXT_BLOCK)
// .attach(Grid::column(0)) .attach(Grid::row(2))
// .v_align("top") .attach(Grid::column(0))
// .margin((4.0, 0.0, 0.0, 0.0)) .attach(Grid::column_span(3))
// .lost_focus_on_activation(false) .margin((0., 0., 0., 16.))
// //.text(("policy_number", id)) .h_align("end")
// // .on_activate(move |ctx, entity| { .v_align("end")
// // ctx.get_mut::<PolicyCheckState>(id) .enabled(true)
// // .action(Action::ParseEntry(entity)); .min_width(250.0)
// // }) .min_height(45.0)
// // .on_changed(move |ctx, entity| { .text("Anzahl Prüfsätze:")
// // ctx.get_mut::<PolicyCheckState>(id) .build(ctx);
// // .action(Action::InputTextChanged(entity));
// // })
// .build(ctx);
// let policy_check_menu_container = Container::new() // let policy_check_menu_container = Container::new()
// .id(ID_POLICY_CHECK_MENU_CONTAINER) // .id(ID_POLICY_CHECK_MENU_CONTAINER)
@@ -128,252 +103,266 @@ impl Template for PolicyCheckView {
// Starter page: check for valid policy number // Starter page: check for valid policy number
self.name("PolicyCheckView") self.name("PolicyCheckView")
//.policy_check(PolicyCheck::default()) // initialize struct consuming the derived default macro
.policy_check(PolicyCheck::default())
.child( .child(
Grid::new() Grid::new()
.id(ID_POLICY_CHECK_WIDGET) .id(ID_POLICY_CHECK_WIDGET)
.background("#fafafa") .background("#fafafa")
.columns( .columns(
Columns::new() Columns::new()
.add(84.0) .add(84.0)
.add("*") .add("*")
.add(50.0) .add(50.0)
.build(), .build(),
) )
.rows( .rows(
Rows::new() Rows::new()
// Top Bar // Top Bar
.add("auto") .add("auto")
.add(1.0) .add(1.0)
// Content // Content
.add("*") .add("*")
.add(1.0) .add(1.0)
// Bottom Bar // Bottom Bar
.add(52.0) .add(52.0)
/* .add("auto") */ /* .add("auto") */
.build(), .build(),
) )
// Header Bar // Header Bar
.child( .child(
//.border_color("transparent") //.border_color("transparent")
Container::new() Container::new()
//.class(CLASS_TOP_BAR) //.class(CLASS_TOP_BAR)
.attach(Grid::row(0)) .attach(Grid::row(0))
.attach(Grid::column(0)) .attach(Grid::column(0))
.attach(Grid::column_span(3)) .attach(Grid::column_span(3))
.child( .child(
Grid::new() Grid::new()
.child( .child(
TextBlock::new() TextBlock::new()
//.class(CLASS_HEADER) //.class(CLASS_HEADER)
.class("h1") .class("h1")
//.class(".myheader") //.class(".myheader")
.id(ID_POLICY_CHECK_HEADER) .id(ID_POLICY_CHECK_HEADER)
//.font_size(24) //.font_size(24)
//.font("Roboto Medium") //.font("Roboto Medium")
.v_align("center") .v_align("center")
.h_align("center") .h_align("center")
.margin((32.0, 32.0, 32.0, 32.0)) .margin((32.0, 32.0, 32.0, 32.0))
.text("Validierung Versicherungsnummer") .text("Validierung Versicherungsnummer")
.build(ctx), .build(ctx),
) )
.build(ctx), .build(ctx),
) )
.child(policy_check_menu_button) .child(policy_check_menu_button)
.build(ctx), .build(ctx),
) )
.child( .child(
Container::new() Container::new()
.class("separator") .class("separator")
.attach(Grid::row(1)) .attach(Grid::row(1))
.attach(Grid::column_span(3)) .attach(Grid::column_span(3))
.build(ctx), .build(ctx),
) )
// Policy Check Form // Policy Check Form
.child( .child(
Container::new() Container::new()
//.class(CLASS_POLICY_CHECK_FORM) //.class(CLASS_POLICY_CHECK_FORM)
.attach(Grid::row(2)) .attach(Grid::row(2))
.attach(Grid::column(0)) .attach(Grid::column(0))
.attach(Grid::column_span(3)) .attach(Grid::column_span(3))
.margin((16.0, 26.0, 26.0, 16.0)) .margin((16.0, 26.0, 26.0, 16.0))
.child( .child(
Grid::new() Grid::new()
.id(ID_POLICY_CHECK_FORM) .id(ID_POLICY_CHECK_FORM)
.columns( .columns(
Columns::new() Columns::new()
// Labels // Labels
.add("220.0") .add("220.0")
// Seperator // Seperator
.add("16.0") .add("16.0")
// Values // Values
.add("100.0") .add("100.0")
.build(), .build(),
) )
.rows( .rows(
Rows::new() Rows::new()
.add("64.0") .add("64.0")
.add("64.0") .add("64.0")
.build(), .build(),
) )
.child( .child(
// Labels // Labels
Stack::new() Stack::new()
.attach(Grid::column(0)) .attach(Grid::column(0))
.attach(Grid::row(0)) .attach(Grid::row(0))
.orientation("vertical") .orientation("vertical")
//.v_align("center") //.v_align("center")
.child( .child(
TextBlock::new() TextBlock::new()
.id(ID_POLICY_CHECK_LABEL_POLICY_NUMBER) .id(ID_POLICY_CHECK_LABEL_POLICY_NUMBER)
//.class(CLASS_TEXT_BLOCK) //.class(CLASS_TEXT_BLOCK)
.margin((0.0, 0.0, 16.0, 16.0)) .margin((0.0, 0.0, 16.0, 16.0))
.h_align("end") .h_align("end")
.v_align("center") .v_align("center")
.min_width(250.0) .min_width(250.0)
.min_height(45.0) .min_height(45.0)
//.size(250.0, 45.0) //.size(250.0, 45.0)
.text("Versicherungsnummer:") .text("Versicherungsnummer:")
.build(ctx), .build(ctx),
) )
.child( .child(
TextBlock::new() TextBlock::new()
.id(ID_POLICY_CHECK_LABEL_RESULT) .id(ID_POLICY_CHECK_LABEL_RESULT)
//.class(CLASS_TEXT_BLOCK) .class(CLASS_TEXT_BLOCK)
.attach(Grid::column(0)) .attach(Grid::column(0))
.attach(Grid::row(1)) .attach(Grid::row(1))
.margin((0.0, 0.0, 16.0, 0.0)) .margin((0.0, 0.0, 16.0, 0.0))
.h_align("end") .h_align("end")
.v_align("center") .v_align("center")
.min_width(250.0) .min_width(250.0)
//.min_size(120.0, 180.0) .text("Result:")
//.text("Ergebnis:") .build(ctx),
//.text("Result:") )
.build(ctx), .build(ctx)
) )
.build(ctx) .child(
) // Values
.child( Stack::new()
// Values .attach(Grid::column(1))
Stack::new() .attach(Grid::row(0))
.attach(Grid::column(1)) //.attach(Grid::column_span(3))
.attach(Grid::row(0)) .orientation("vertical")
//.attach(Grid::column_span(3)) //.margin((16.0, 16.0, 16.0, 16.0))
.orientation("vertical") //.child(policy_check_text_box)
//.margin((16.0, 16.0, 16.0, 16.0)) .child(
//.child(policy_check_text_box) TextBox::new()
.child( .id(ID_POLICY_CHECK_POLICY_NUMBER)
TextBox::new() .h_align("start")
.id(ID_POLICY_CHECK_POLICY_NUMBER) .width(280.0)
.h_align("start") .min_width(200.0)
.width(280.0) .margin((0.0, 0.0, 0.0, 16.0))
.min_width(200.0) .lost_focus_on_activation(false)
.margin((0.0, 0.0, 0.0, 16.0)) .water_mark("Nummer 10-stellig")
.lost_focus_on_activation(false) .text("")
.water_mark("10-stellige Nummer (ohne 'AS')") .on_activate(move |ctx, entity| {
.text("") // Entity is entered/activated via Mouse/Keyboard
.on_activate(move |ctx, entity| { println!("activation finished!");
// Entity is entered/activated via Mouse/Keyboard ctx.get_mut::<PolicyCheckState>(id)
ctx.get_mut::<PolicyCheckState>(id) .action(Action::ParseEntry(entity));
.action(Action::ParseEntry(entity)); })
}) .on_changed(move |ctx, entity| {
.on_changed(move |ctx, entity| { // Element value has changed
// Element value has changed ctx.get_mut::<PolicyCheckState>(id)
ctx.get_mut::<PolicyCheckState>(id) .action(Action::InputTextChanged(entity));
.action(Action::InputTextChanged(entity)); ctx.get_mut::<PolicyCheckState>(id)
}) .action(Action::SetVisibility(entity));
.build(ctx), //ctx.get_widget(policy_check_label_policy_number).set("visible");
) // ctx.get_mut::<PolicyCheckState>(id)
// .action(Action::SetVisility(entity));
})
// .on_mouse_down | .on_mouse_move | .on_mouse_up (move |ctx, entity| {
// state(id, states).action(Action::AddItem);
// })
// .on_click(move |states, _| {
// state(id, states).action(Action::AddItem);
// true
// })
.build(ctx),
)
//.icon(material_icons_font_ttf::MD_ADD_CIRCLE) //.icon(material_icons_font_ttf::MD_ADD_CIRCLE)
// .child() // .child()
// NumericBox::new() // NumericBox::new()
// .id(ID_POLICY_CHECK_POLICY_NUMBER) // .id(ID_POLICY_CHECK_POLICY_NUMBER)
// .h_align("start") // .h_align("start")
// .width(250.0) // .width(250.0)
// .min(1000000000) // .min(1000000000)
// .max(9999999999) // .max(9999999999)
// .val(0) // .val(0)
// .min_width(200.0) // .min_width(200.0)
// .margin((0.0, 0.0, 0.0, 16.0)) // .margin((0.0, 0.0, 0.0, 16.0))
// //.lost_focus_on_activation(false) // //.lost_focus_on_activation(false)
// //.water_mark("10-stellige Nummer (ohne 'AS')") // //.water_mark("10-stellige Nummer (ohne 'AS')")
// //.text("") // //.text("")
// //.on_activate(move |ctx, entity| { // //.on_activate(move |ctx, entity| {
// // ctx.get_mut::<PolicyCheckState>(id) // // ctx.get_mut::<PolicyCheckState>(id)
// // .action(Action::ParseEntry(entity)); // // .action(Action::ParseEntry(entity));
// //}) // //})
// // .on_changed(move |ctx, entity| { // // .on_changed(move |ctx, entity| {
// // ctx.get_mut::<PolicyCheckState>(id) // // ctx.get_mut::<PolicyCheckState>(id)
// // .action(Action::InputTextChanged(entity)); // // .action(Action::InputTextChanged(entity));
// // }) // // })
// // .on_update(move |ctx, entity| { // // .on_update(move |ctx, entity| {
// // ctx.get_mut::<PolicyCheckState>(id) // // ctx.get_mut::<PolicyCheckState>(id)
// // .action(Action::InputTextChanged(entity)); // // .action(Action::InputTextChanged(entity));
// // }) // // })
// .build(ctx), // .build(ctx),
//) //)
.child( .child(
TextBlock::new() TextBlock::new()
//.id(ID_POLICY_CHECK_RESULT) .id(ID_POLICY_CHECK_RESULT)
.id("policy_check_result") //.id("policy_check_result")
.h_align("start") .h_align("start")
.attach(Grid::column(1)) .attach(Grid::column(1))
.attach(Grid::row(1)) .attach(Grid::row(1))
.text(("")) .text("")
.width(250.)
//.margin((4.0, 0.0, 0.0, 0.0)) //.margin((4.0, 0.0, 0.0, 0.0))
//.lost_focus_on_activation(false) //.lost_focus_on_activation(false)
// .on_activate(move |ctx, entity| { // .on_activate(move |ctx, entity| {
// ctx.get_mut::<PolicyCheckState>(id) // ctx.get_mut::<PolicyCheckState>(id)
// .action(Action::ParseEntry(entity)); // .action(Action::ParseEntry(entity));
// }) // })
// .on_changed(move |ctx, entity| { // .on_changed(move |ctx, entity| {
// ctx.get_mut::<PolicyCheckState>(id) // ctx.get_mut::<PolicyCheckState>(id)
// .action(Action::InputTextChanged(entity)); // .action(Action::InputTextChanged(entity));
// }) // })
.build(ctx), .build(ctx),
) )
.build(ctx) .build(ctx)
) )
.build(ctx) .build(ctx)
) )
.build(ctx) .build(ctx)
) )
.child( .child(
Container::new() Container::new()
.class("separator") .class("")
.attach(Grid::row(3)) .attach(Grid::row(3))
.attach(Grid::column_span(3)) .attach(Grid::column_span(3))
.build(ctx), .build(ctx),
) )
.child(policy_data_count_block)
// Bottom bar // Bottom bar
.child( .child(
Container::new() Container::new()
.class(CLASS_BOTTOM_BAR) .class(CLASS_BOTTOM_BAR)
.attach(Grid::row(4)) .attach(Grid::row(4))
.attach(Grid::column(0)) .attach(Grid::column(0))
.attach(Grid::column_span(3)) .attach(Grid::column_span(3))
.v_align("end") .v_align("end")
.child( .child(
Grid::new() Grid::new()
.element("logo_customer") .element("logo_customer")
.margin((9.0, 16.0, 16.0, 9.0)) .margin((9.0, 16.0, 16.0, 9.0))
.attach(Grid::column(0))
.attach(Grid::row(1))
.h_align("start")
.v_align("center")
.child(
ImageWidget::new()
.image("resources/images/hiedemann_logo.png")
.build(ctx),
)
.build(ctx),
)
.child(
Grid::new()
.element("logo_vendor")
.margin((9.0, 16.0, 16.0, 9.0))
.attach(Grid::column(0)) .attach(Grid::column(0))
.attach(Grid::row(1)) .attach(Grid::row(5))
.h_align("start")
.v_align("center")
.child(
ImageWidget::new()
.image("resources/images/hiedemann_logo.png")
.build(ctx),
)
.build(ctx),
)
.child(
Grid::new()
.element("logo_vendor")
.margin((9.0, 16.0, 16.0, 9.0))
.attach(Grid::column(0))
.attach(Grid::row(4))
.h_align("end") .h_align("end")
.v_align("center") .v_align("center")
.child( .child(