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:
@@ -1,17 +1,17 @@
|
||||
use locales::t;
|
||||
//use locales::t;
|
||||
use dotenv::dotenv;
|
||||
use orbtk::prelude::*;
|
||||
use serde::Deserialize;
|
||||
use std::{env, process};
|
||||
use std::collections::HashMap;
|
||||
use tracing::{debug, trace};
|
||||
use tracing::{debug, error, info, trace};
|
||||
|
||||
use crate::services::imports::allianzdirectcall::import;
|
||||
use crate::callbacks::policy_check::is_valid;
|
||||
//use crate::callbacks::policy_check::is_valid;
|
||||
|
||||
use crate::{
|
||||
callbacks::global_state::GlobalState,
|
||||
data::structures::{PolicyCode, PolicyDataList, PolicyData, PolicyList},
|
||||
data::structures::{PolicyCheck, PolicyCode, PolicyDataList, PolicyList},
|
||||
data::keys::*,
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@ pub enum Action {
|
||||
ParseEntry(Entity),
|
||||
RemoveFocus(Entity),
|
||||
SetEntry(Entity),
|
||||
SetVisibility(Entity),
|
||||
TextChanged(Entity, usize),
|
||||
}
|
||||
|
||||
@@ -37,16 +38,19 @@ struct Environment {
|
||||
#[derive(Default, AsAny)]
|
||||
pub struct PolicyCheckState {
|
||||
action: Option<Action>,
|
||||
label_result_text_block: Entity,
|
||||
last_focused: Option<Entity>,
|
||||
pub text_box: Entity,
|
||||
menu_button: Entity,
|
||||
policy_number_valid: bool,
|
||||
policy_number_count: usize,
|
||||
policy_numbers: HashMap<usize, PolicyCode>,
|
||||
//policy_check_clean_button: Entity,
|
||||
policy_check: PolicyCheck,
|
||||
policy_data_count: usize,
|
||||
//policy_number_text_box: Entity,
|
||||
policy_numbers: HashMap<usize, PolicyCode>
|
||||
}
|
||||
|
||||
impl GlobalState for PolicyCheckState {}
|
||||
|
||||
/// method definitions, that react on any given state change inside the view
|
||||
impl PolicyCheckState {
|
||||
/// Sets a new action.
|
||||
pub fn action(&mut self, action: Action) {
|
||||
@@ -74,14 +78,15 @@ impl PolicyCheckState {
|
||||
|
||||
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 = String::from("POLLFNR_WOECHENTLICH.txt");
|
||||
println!("Importing from: {:?}", csv_import_path);
|
||||
match import(&mut csv_import_path, &mut policy_data,
|
||||
&mut policy_numbers, &lang) {
|
||||
Ok(count) => {
|
||||
self.policy_number_count = count;
|
||||
println!("Imported {:?} records", self.policy_number_count);
|
||||
self.policy_data_count = count;
|
||||
println!("Imported {:?} records", self.policy_data_count);
|
||||
}
|
||||
Err(err) => {
|
||||
println!("error running CSV-Import: {}", err);
|
||||
@@ -94,24 +99,26 @@ impl PolicyCheckState {
|
||||
}
|
||||
|
||||
/// 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 text = text_box.text_mut();
|
||||
println!("reset {}", text);
|
||||
}
|
||||
|
||||
/// 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 text = text_block.text_mut();
|
||||
println!("Menu text: {}", text);
|
||||
}
|
||||
|
||||
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_number_length = policy_string.len();
|
||||
|
||||
trace!(target: "advotracker", state = "parsing", policy_number = ?policy_string);
|
||||
|
||||
// Parse policy code: "AS-123456789"
|
||||
// DION VERS POLLFNR
|
||||
// 1 AS 1515735810
|
||||
@@ -119,107 +126,84 @@ impl PolicyCheckState {
|
||||
// needs to be an integer
|
||||
match policy_string.parse::<usize>() {
|
||||
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);
|
||||
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) {
|
||||
// check hashmaps value field
|
||||
// check hashmap value field
|
||||
Some(policy_code) => {
|
||||
//let res = t!("policy.validation.success", lang);
|
||||
//println!("{:?}", res);
|
||||
println!("policy_number: {} ({:?})",
|
||||
p, 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-{:?}-{}",
|
||||
policy_code, p);
|
||||
result_wrapper.set_text(string_result);
|
||||
}
|
||||
_ => {
|
||||
//let res = t!("policy.validation.failed", lang);
|
||||
//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) => {
|
||||
trace!(target: "advotracker", state = "error", error_type = "invalid type");
|
||||
println!("invalid: {}", e);
|
||||
// Feedback
|
||||
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 {
|
||||
println!("Policy number is to short!");
|
||||
ctx.child(ID_POLICY_CHECK_POLICY_NUMBER).set("text", String::from(""));
|
||||
//ctx.child(ID_POLICY_CHECK_RESULT).set("text", String::from("Policy number is to short!"));
|
||||
// ctx.get_widget(policy_check_policy_number).set("policy_number_valid", true);
|
||||
//policy_check_view(ctx.widget())
|
||||
// .set_policy_check_result(String16::from(format!("Given Number is to small: {}", policy_number_length)));
|
||||
//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);
|
||||
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!");
|
||||
//TextBox::get(ctx.child("text_box")).set_foreground("#ffffff");
|
||||
//TextBox::get(ctx.child("text_box")).set_background("#5b0f22");
|
||||
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!");
|
||||
}
|
||||
|
||||
//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"
|
||||
/// 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() {
|
||||
// ctx.get_widget(self.policy_check_clear_button).set("enabled", false);
|
||||
// } else {
|
||||
// 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.
|
||||
fn set_entry(&self, text_box: Entity, ctx: &mut Context) {
|
||||
if *ctx.get_widget(text_box).get::<bool>("focused") {
|
||||
ctx.get_widget(text_box).set("enabled", false);
|
||||
ctx.push_event_by_window(FocusEvent::RemoveFocus(text_box));
|
||||
fn set_entry(&self, policy_check_policy_number: Entity, ctx: &mut Context<'_>) {
|
||||
if *ctx.get_widget(policy_check_policy_number).get::<bool>("focused") {
|
||||
//let mut my_ctx: WidgetContainer<'_> = ctx.widget();
|
||||
//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;
|
||||
}
|
||||
|
||||
@@ -227,36 +211,88 @@ impl PolicyCheckState {
|
||||
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 {
|
||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
// self.button = ctx
|
||||
// .entity_of_child(ID_POLICY_CHECK_MENU_BUTTON)
|
||||
// .expect("PolicyCheckState.init: Can't find child 'Menu button'.");
|
||||
self.text_box = ctx
|
||||
.entity_of_child(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
.expect("PolicyCheckState.init: Can't find child 'Text Box'.");
|
||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
self.menu_button = ctx
|
||||
.entity_of_child(ID_POLICY_CHECK_MENU_BUTTON)
|
||||
.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
|
||||
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
|
||||
if self.last_focused != ctx.window().get::<Global>("global").focused_widget {
|
||||
if let Some(last_focused) = self.last_focused {
|
||||
ctx.get_widget(last_focused).set("focused", false);
|
||||
// widget is unvisible, but takes space to be considered
|
||||
ctx.get_widget(last_focused)
|
||||
.set("visibility", Visibility::Collapsed);
|
||||
}
|
||||
@@ -264,27 +300,34 @@ impl State for PolicyCheckState {
|
||||
|
||||
if let Some(action) = self.action {
|
||||
match action {
|
||||
Action::ClearEntry(text_box) => {
|
||||
self.clear_entry(text_box, ctx);
|
||||
Action::ClearEntry(policy_check_policy_number) => {
|
||||
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
||||
}
|
||||
Action::InputTextChanged(text_box) => {
|
||||
//self.set_check_button(text_box, ctx);
|
||||
Action::InputTextChanged(entity) => {
|
||||
//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) => {
|
||||
self.open_menu(text_block, ctx);
|
||||
}
|
||||
Action::ParseEntry(text_box) => {
|
||||
self.parse_entry(text_box, ctx);
|
||||
ctx.get_widget(text_box).get::<String16>("text").as_string();
|
||||
//self.parse_entry(text_box, &mut policy_numbers,
|
||||
// &lang, ctx);
|
||||
}
|
||||
Action::RemoveFocus(text_box) => {
|
||||
ctx.get_widget(text_box).set("enabled", false);
|
||||
ctx.push_event_by_window(FocusEvent::RemoveFocus(text_box));
|
||||
Action::RemoveFocus(policy_check_policy_number) => {
|
||||
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
||||
ctx.push_event_by_window(FocusEvent::RemoveFocus(policy_check_policy_number));
|
||||
}
|
||||
Action::SetEntry(text_box) => {
|
||||
self.last_focused = Some(text_box);
|
||||
self.set_entry(text_box, ctx);
|
||||
Action::SetEntry(policy_check_policy_number) => {
|
||||
//self.last_focused = Some();
|
||||
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) => {
|
||||
self.set_entry(entity, ctx);
|
||||
@@ -293,4 +336,16 @@ impl State for PolicyCheckState {
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,43 +14,21 @@ use crate::{
|
||||
//policycheck_state::{Action, PolicyCheckState},
|
||||
};
|
||||
|
||||
|
||||
// Macro that initializes the widget structures/variables for our view (essential!)
|
||||
widget!(
|
||||
/// Dialog to enter a policy identifier/number.
|
||||
/// This identifier is checked agains a map of valid policy codes.
|
||||
PolicyCheckView<PolicyCheckState> {
|
||||
policy_check: PolicyCheck,
|
||||
//policy_check_list: PolicyCheckList,
|
||||
policy_check_title: String16,
|
||||
policy_check_number: String16,
|
||||
policy_check_number_valid: bool,
|
||||
policy_check_result: String16,
|
||||
policy_data_count: u32,
|
||||
//policylist_view: u32,
|
||||
title: String
|
||||
policy_data_count: u32
|
||||
}
|
||||
);
|
||||
|
||||
// The template implementation for our View
|
||||
impl Template for PolicyCheckView {
|
||||
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);
|
||||
|
||||
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
let policy_check_menu_text_block = TextBlock::new()
|
||||
.foreground("#3b434a")
|
||||
.text("Help Menu")
|
||||
@@ -81,24 +59,21 @@ impl Template for PolicyCheckView {
|
||||
})
|
||||
.build(ctx);
|
||||
|
||||
// let policy_check_text_box = TextBox::new()
|
||||
// .id(ID_POLICY_CHECK_TEXT_BOX)
|
||||
// .attach(Grid::row(4))
|
||||
// .attach(Grid::row(0))
|
||||
// .attach(Grid::column(0))
|
||||
// .v_align("top")
|
||||
// .margin((4.0, 0.0, 0.0, 0.0))
|
||||
// .lost_focus_on_activation(false)
|
||||
// //.text(("policy_number", id))
|
||||
// // .on_activate(move |ctx, entity| {
|
||||
// // ctx.get_mut::<PolicyCheckState>(id)
|
||||
// // .action(Action::ParseEntry(entity));
|
||||
// // })
|
||||
// // .on_changed(move |ctx, entity| {
|
||||
// // ctx.get_mut::<PolicyCheckState>(id)
|
||||
// // .action(Action::InputTextChanged(entity));
|
||||
// // })
|
||||
// .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.))
|
||||
.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()
|
||||
// .id(ID_POLICY_CHECK_MENU_CONTAINER)
|
||||
@@ -128,110 +103,111 @@ impl Template for PolicyCheckView {
|
||||
|
||||
// Starter page: check for valid policy number
|
||||
self.name("PolicyCheckView")
|
||||
//.policy_check(PolicyCheck::default())
|
||||
// initialize struct consuming the derived default macro
|
||||
.policy_check(PolicyCheck::default())
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_POLICY_CHECK_WIDGET)
|
||||
.background("#fafafa")
|
||||
.columns(
|
||||
Columns::new()
|
||||
.add(84.0)
|
||||
.add("*")
|
||||
.add(50.0)
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::new()
|
||||
Grid::new()
|
||||
.id(ID_POLICY_CHECK_WIDGET)
|
||||
.background("#fafafa")
|
||||
.columns(
|
||||
Columns::new()
|
||||
.add(84.0)
|
||||
.add("*")
|
||||
.add(50.0)
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::new()
|
||||
// Top Bar
|
||||
.add("auto")
|
||||
.add(1.0)
|
||||
.add("auto")
|
||||
.add(1.0)
|
||||
// Content
|
||||
.add("*")
|
||||
.add(1.0)
|
||||
.add("*")
|
||||
.add(1.0)
|
||||
// Bottom Bar
|
||||
.add(52.0)
|
||||
.add(52.0)
|
||||
/* .add("auto") */
|
||||
.build(),
|
||||
)
|
||||
// Header Bar
|
||||
.child(
|
||||
//.border_color("transparent")
|
||||
Container::new()
|
||||
.build(),
|
||||
)
|
||||
// Header Bar
|
||||
.child(
|
||||
//.border_color("transparent")
|
||||
Container::new()
|
||||
//.class(CLASS_TOP_BAR)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.child(
|
||||
Grid::new()
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.child(
|
||||
Grid::new()
|
||||
.child(
|
||||
TextBlock::new()
|
||||
//.class(CLASS_HEADER)
|
||||
.class("h1")
|
||||
.class("h1")
|
||||
//.class(".myheader")
|
||||
.id(ID_POLICY_CHECK_HEADER)
|
||||
.id(ID_POLICY_CHECK_HEADER)
|
||||
//.font_size(24)
|
||||
//.font("Roboto Medium")
|
||||
.v_align("center")
|
||||
.h_align("center")
|
||||
.margin((32.0, 32.0, 32.0, 32.0))
|
||||
.text("Validierung Versicherungsnummer")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(policy_check_menu_button)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Container::new()
|
||||
.class("separator")
|
||||
.attach(Grid::row(1))
|
||||
.attach(Grid::column_span(3))
|
||||
.build(ctx),
|
||||
)
|
||||
// Policy Check Form
|
||||
.child(
|
||||
Container::new()
|
||||
.v_align("center")
|
||||
.h_align("center")
|
||||
.margin((32.0, 32.0, 32.0, 32.0))
|
||||
.text("Validierung Versicherungsnummer")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(policy_check_menu_button)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Container::new()
|
||||
.class("separator")
|
||||
.attach(Grid::row(1))
|
||||
.attach(Grid::column_span(3))
|
||||
.build(ctx),
|
||||
)
|
||||
// Policy Check Form
|
||||
.child(
|
||||
Container::new()
|
||||
//.class(CLASS_POLICY_CHECK_FORM)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.margin((16.0, 26.0, 26.0, 16.0))
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_POLICY_CHECK_FORM)
|
||||
.columns(
|
||||
Columns::new()
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.margin((16.0, 26.0, 26.0, 16.0))
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_POLICY_CHECK_FORM)
|
||||
.columns(
|
||||
Columns::new()
|
||||
// Labels
|
||||
.add("220.0")
|
||||
.add("220.0")
|
||||
// Seperator
|
||||
.add("16.0")
|
||||
.add("16.0")
|
||||
// Values
|
||||
.add("100.0")
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::new()
|
||||
.add("64.0")
|
||||
.add("64.0")
|
||||
.build(),
|
||||
)
|
||||
.child(
|
||||
// Labels
|
||||
Stack::new()
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(0))
|
||||
.orientation("vertical")
|
||||
.add("100.0")
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::new()
|
||||
.add("64.0")
|
||||
.add("64.0")
|
||||
.build(),
|
||||
)
|
||||
.child(
|
||||
// Labels
|
||||
Stack::new()
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(0))
|
||||
.orientation("vertical")
|
||||
//.v_align("center")
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_LABEL_POLICY_NUMBER)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_LABEL_POLICY_NUMBER)
|
||||
//.class(CLASS_TEXT_BLOCK)
|
||||
.margin((0.0, 0.0, 16.0, 16.0))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.min_width(250.0)
|
||||
.min_height(45.0)
|
||||
.margin((0.0, 0.0, 16.0, 16.0))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.min_width(250.0)
|
||||
.min_height(45.0)
|
||||
//.size(250.0, 45.0)
|
||||
.text("Versicherungsnummer:")
|
||||
.build(ctx),
|
||||
@@ -286,31 +262,31 @@ impl Template for PolicyCheckView {
|
||||
)
|
||||
//.icon(material_icons_font_ttf::MD_ADD_CIRCLE)
|
||||
// .child()
|
||||
// NumericBox::new()
|
||||
// .id(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
// .h_align("start")
|
||||
// .width(250.0)
|
||||
// .min(1000000000)
|
||||
// .max(9999999999)
|
||||
// .val(0)
|
||||
// .min_width(200.0)
|
||||
// .margin((0.0, 0.0, 0.0, 16.0))
|
||||
// //.lost_focus_on_activation(false)
|
||||
// //.water_mark("10-stellige Nummer (ohne 'AS')")
|
||||
// //.text("")
|
||||
// //.on_activate(move |ctx, entity| {
|
||||
// // ctx.get_mut::<PolicyCheckState>(id)
|
||||
// // .action(Action::ParseEntry(entity));
|
||||
// //})
|
||||
// // .on_changed(move |ctx, entity| {
|
||||
// // ctx.get_mut::<PolicyCheckState>(id)
|
||||
// // .action(Action::InputTextChanged(entity));
|
||||
// // })
|
||||
// // .on_update(move |ctx, entity| {
|
||||
// // ctx.get_mut::<PolicyCheckState>(id)
|
||||
// // .action(Action::InputTextChanged(entity));
|
||||
// // })
|
||||
// .build(ctx),
|
||||
// NumericBox::new()
|
||||
// .id(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
// .h_align("start")
|
||||
// .width(250.0)
|
||||
// .min(1000000000)
|
||||
// .max(9999999999)
|
||||
// .val(0)
|
||||
// .min_width(200.0)
|
||||
// .margin((0.0, 0.0, 0.0, 16.0))
|
||||
// //.lost_focus_on_activation(false)
|
||||
// //.water_mark("10-stellige Nummer (ohne 'AS')")
|
||||
// //.text("")
|
||||
// //.on_activate(move |ctx, entity| {
|
||||
// // ctx.get_mut::<PolicyCheckState>(id)
|
||||
// // .action(Action::ParseEntry(entity));
|
||||
// //})
|
||||
// // .on_changed(move |ctx, entity| {
|
||||
// // ctx.get_mut::<PolicyCheckState>(id)
|
||||
// // .action(Action::InputTextChanged(entity));
|
||||
// // })
|
||||
// // .on_update(move |ctx, entity| {
|
||||
// // ctx.get_mut::<PolicyCheckState>(id)
|
||||
// // .action(Action::InputTextChanged(entity));
|
||||
// // })
|
||||
// .build(ctx),
|
||||
//)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
@@ -321,58 +297,59 @@ impl Template for PolicyCheckView {
|
||||
.text((""))
|
||||
//.margin((4.0, 0.0, 0.0, 0.0))
|
||||
//.lost_focus_on_activation(false)
|
||||
// .on_activate(move |ctx, entity| {
|
||||
// ctx.get_mut::<PolicyCheckState>(id)
|
||||
// .action(Action::ParseEntry(entity));
|
||||
// })
|
||||
// .on_changed(move |ctx, entity| {
|
||||
// ctx.get_mut::<PolicyCheckState>(id)
|
||||
// .action(Action::InputTextChanged(entity));
|
||||
// })
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx)
|
||||
)
|
||||
.child(
|
||||
Container::new()
|
||||
.class("separator")
|
||||
.attach(Grid::row(3))
|
||||
.attach(Grid::column_span(3))
|
||||
.build(ctx),
|
||||
)
|
||||
// .on_activate(move |ctx, entity| {
|
||||
// ctx.get_mut::<PolicyCheckState>(id)
|
||||
// .action(Action::ParseEntry(entity));
|
||||
// })
|
||||
// .on_changed(move |ctx, entity| {
|
||||
// ctx.get_mut::<PolicyCheckState>(id)
|
||||
// .action(Action::InputTextChanged(entity));
|
||||
// })
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx)
|
||||
)
|
||||
.child(
|
||||
Container::new()
|
||||
.class("")
|
||||
.attach(Grid::row(3))
|
||||
.attach(Grid::column_span(3))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(policy_data_count_block)
|
||||
// Bottom bar
|
||||
.child(
|
||||
Container::new()
|
||||
.class(CLASS_BOTTOM_BAR)
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.v_align("end")
|
||||
.child(
|
||||
Grid::new()
|
||||
.element("logo_customer")
|
||||
.margin((9.0, 16.0, 16.0, 9.0))
|
||||
.child(
|
||||
Container::new()
|
||||
.class(CLASS_BOTTOM_BAR)
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.v_align("end")
|
||||
.child(
|
||||
Grid::new()
|
||||
.element("logo_customer")
|
||||
.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::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::row(4))
|
||||
.attach(Grid::row(5))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.child(
|
||||
|
||||
Reference in New Issue
Block a user