advotracker: policy_state update
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
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 crate::services::imports::allianzdirectcall::import;
|
||||
use crate::callbacks::policy_check::is_valid;
|
||||
|
||||
use crate::{
|
||||
callbacks::global_state::GlobalState,
|
||||
//data::structures::{PolicyData, PolicyDataList},
|
||||
data::structures::{PolicyCode, PolicyDataList, PolicyData, PolicyList},
|
||||
data::keys::*,
|
||||
};
|
||||
|
||||
@@ -18,14 +27,22 @@ pub enum Action {
|
||||
TextChanged(Entity, usize),
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Environment {
|
||||
test_lang: String,
|
||||
log: String,
|
||||
}
|
||||
|
||||
/// Handles the requests of the `PolicyCheckView`.
|
||||
#[derive(Default, AsAny)]
|
||||
pub struct PolicyCheckState {
|
||||
action:Option<Action>,
|
||||
action: Option<Action>,
|
||||
last_focused: Option<Entity>,
|
||||
pub text_box: Entity,
|
||||
menu_button: Entity,
|
||||
policy_number_valid: bool,
|
||||
policy_number_count: usize,
|
||||
policy_numbers: HashMap<usize, PolicyCode>,
|
||||
}
|
||||
|
||||
impl GlobalState for PolicyCheckState {}
|
||||
@@ -36,6 +53,46 @@ impl PolicyCheckState {
|
||||
self.action = action.into();
|
||||
}
|
||||
|
||||
pub fn create_hashmap(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
||||
// WIP: redundant lang selection (already in main!)
|
||||
let mut lang = env::var("LANG").unwrap_or("en".to_string());
|
||||
// testing environment: read from .env file
|
||||
dotenv().ok();
|
||||
match envy::from_env::<Environment>() {
|
||||
Ok(environment) => {
|
||||
if environment.test_lang != lang { lang = environment.test_lang; }
|
||||
},
|
||||
Err(e) => { debug!(target: "advotracker", "{}", e); }
|
||||
}
|
||||
|
||||
// importing policy code elements from csv-file
|
||||
let policy_list = PolicyList::new("Allianz Versicherungsnummen-List");
|
||||
println!("Policy List {:?} ", policy_list.name);
|
||||
|
||||
let mut policy_data = PolicyDataList::new("Allianz-Import latest");
|
||||
println!("Policy Data List {:?} ", policy_data.name);
|
||||
|
||||
let mut policy_numbers : HashMap<usize, PolicyCode> = HashMap::new();
|
||||
|
||||
//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);
|
||||
}
|
||||
Err(err) => {
|
||||
println!("error running CSV-Import: {}", err);
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
self.policy_numbers = policy_numbers;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Clear text in text box.
|
||||
pub fn clear_entry(&mut self, text_box: Entity, ctx: &mut Context) {
|
||||
let mut text_box = TextBox::get(ctx.get_widget(text_box));
|
||||
@@ -50,27 +107,86 @@ impl PolicyCheckState {
|
||||
println!("Menu text: {}", text);
|
||||
}
|
||||
|
||||
fn parse_entry(&self, policy_check_policy_number: Entity, ctx: &mut Context) {
|
||||
let mut policy_check_policy_number = TextBox::get(ctx.get_widget(policy_check_policy_number));
|
||||
let policy_number = policy_check_policy_number.text_mut();
|
||||
|
||||
println!("parsing policy Number: {}", policy_number);
|
||||
fn parse_entry(&mut self, policy_check_policy_number: Entity,
|
||||
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();
|
||||
|
||||
// Parse policy code: "AS-123456789"
|
||||
// DION VERS POLLFNR
|
||||
// 1 AS 1515735810
|
||||
let policy_number_length = policy_number.len();
|
||||
if policy_number_length == 10 {
|
||||
println!("Verify {} ...", policy_number);
|
||||
// check against hash-table
|
||||
// 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);
|
||||
match self.policy_numbers.get(&p) {
|
||||
// check hashmaps value field
|
||||
Some(policy_code) => {
|
||||
//let res = t!("policy.validation.success", lang);
|
||||
//println!("{:?}", res);
|
||||
println!("policy_number: {} ({:?})",
|
||||
p, policy_code);
|
||||
}
|
||||
_ => {
|
||||
//let res = t!("policy.validation.failed", lang);
|
||||
//println!("{:?}", res);
|
||||
println!("Nuup! Number isn't valid!");
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
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!");
|
||||
//TextBox::get(ctx.child("text_box")).set_foreground("#ffffff");
|
||||
//TextBox::get(ctx.child("text_box")).set_background("#5b0f22");
|
||||
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);
|
||||
}
|
||||
if policy_number_length > 10 {
|
||||
println!("Policy number is to big!");
|
||||
@@ -78,26 +194,26 @@ impl PolicyCheckState {
|
||||
//TextBox::get(ctx.child("text_box")).set_background("#5b0f22");
|
||||
}
|
||||
|
||||
// if let policy_number = text_box.text() {
|
||||
// match policy_number {
|
||||
// _ => {
|
||||
// println!("policynumber: {} is valid!", policy_number);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//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 "check"
|
||||
/// 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) {
|
||||
// if ctx.get_widget(text_box).get::<String>("policy_check_policy_number").is_empty() {
|
||||
// ctx.get_widget(self.policy_check_result).set("enabled", false);
|
||||
// } else {
|
||||
// ctx.get_widget(self.policy_check_result).set("enabled", true);
|
||||
// }
|
||||
// fn set_check_button(&self, text_box: 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.text_box).update_theme_by_state(true);
|
||||
// }
|
||||
|
||||
/// Change status of given text box to edit mode.
|
||||
fn set_entry(&self, text_box: Entity, ctx: &mut Context) {
|
||||
@@ -122,16 +238,18 @@ impl PolicyCheckState {
|
||||
.length = ctx.get_widget(text_box).get::<String>("policy_number").len();
|
||||
ctx.push_event_by_window(FocusEvent::RequestFocus(text_box));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
// .expect("PolicyCheckState.init: Can't find child 'Menu button'.");
|
||||
// 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'.");
|
||||
.entity_of_child(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
.expect("PolicyCheckState.init: Can't find child 'Text Box'.");
|
||||
|
||||
}
|
||||
|
||||
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context) {
|
||||
@@ -150,13 +268,15 @@ impl State for PolicyCheckState {
|
||||
self.clear_entry(text_box, ctx);
|
||||
}
|
||||
Action::InputTextChanged(text_box) => {
|
||||
self.set_check_button(text_box, ctx);
|
||||
//self.set_check_button(text_box, ctx);
|
||||
}
|
||||
Action::OpenMenu(text_block) => {
|
||||
self.open_menu(text_block, ctx);
|
||||
}
|
||||
Action::ParseEntry(text_box) => {
|
||||
self.parse_entry(text_box, ctx);
|
||||
//self.parse_entry(text_box, &mut policy_numbers,
|
||||
// &lang, ctx);
|
||||
}
|
||||
Action::RemoveFocus(text_box) => {
|
||||
ctx.get_widget(text_box).set("enabled", false);
|
||||
|
||||
@@ -18,6 +18,7 @@ pub static CLASS_SEPERATOR: &str = "seperator";
|
||||
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_LABEL_POLICY_NUMBER: &str = "policy_check_label_policy_number";
|
||||
pub static ID_POLICY_CHECK_LABEL_RESULT: &str = "policy_check_label_result";
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
//use chrono::{Local, DateTime};
|
||||
use locales::t;
|
||||
//use serde::{Deserialize, Serialize};
|
||||
use serde::Deserialize;
|
||||
use std::{env, process};
|
||||
//use std::{error::Error, process};
|
||||
use std::collections::HashMap;
|
||||
//use std::collections::HashMap;
|
||||
use tracing::{debug, trace, Level};
|
||||
|
||||
use orbtk::prelude::*;
|
||||
@@ -33,7 +36,8 @@ struct Environment {
|
||||
}
|
||||
|
||||
//#[cfg(feature = "light-theme")]
|
||||
static STYLESHEET: &'static str = include_str!("../resources/stylesheets/advotracker.css");
|
||||
//static STYLESHEET: &'static str = include_str!("../resources/stylesheets/advotracker.css");
|
||||
static STYLESHEET: &'static str = include_str!("../resources/stylesheets/policyholder-check.css");
|
||||
|
||||
fn get_theme() -> ThemeValue {
|
||||
//ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
||||
@@ -81,7 +85,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Ok(environment) => {
|
||||
if environment.test_lang != lang { lang = environment.test_lang; }
|
||||
},
|
||||
Err(e) => { debug!(target: "csv-test", "{}", e); }
|
||||
Err(e) => { debug!(target: "advotracker", "{}", e); }
|
||||
}
|
||||
// how to handle unumplemented lang resources??
|
||||
res = t!("parse.environment", lang);
|
||||
@@ -90,46 +94,60 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
trace!(target: "csv-test", message = ?res, state = ?state);
|
||||
|
||||
// initialize viperus structure
|
||||
let mut v = Viperus::new();
|
||||
let mut viperus = Viperus::new();
|
||||
|
||||
// lazy_static! {
|
||||
// static ref VIPERUS: Viperus + 'static = { let mut viperus = Viperus::new(); };
|
||||
// static ref VIPERUS_COUNT: usize = VIPERUS.len();
|
||||
// }
|
||||
// lazy_static! {
|
||||
// static ref HASHMAP: HashMap<usize, PolicyCode> = {
|
||||
// let mut policy_numbers = HashMap::new();
|
||||
// policy_numbers
|
||||
// }
|
||||
// static ref COUNT: usize = HASHMAP.len();
|
||||
// println!("The map has {} entries.", *COUNT);
|
||||
// }
|
||||
|
||||
// parse commandline arguments
|
||||
res = t!("parse.arguments", lang);
|
||||
state = t!("state.started", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
|
||||
let _ = parse_args(&mut v);
|
||||
let _ = parse_args(&mut viperus);
|
||||
state = t!("state.finished", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
//trace!(target: "Viperus", "Config results: {:?}", v);
|
||||
//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);
|
||||
|
||||
// importing policy code elements from csv-file
|
||||
let policy_list = PolicyList::new("Allianz Versicherungsnummen-List");
|
||||
println!("Policy List {:?} ", policy_list.name);
|
||||
// moved to callback: checkview_state.rs
|
||||
// // importing policy code elements from csv-file
|
||||
// let policy_list = PolicyList::new("Allianz Versicherungsnummen-List");
|
||||
// println!("Policy List {:?} ", policy_list.name);
|
||||
|
||||
let mut policy_data = PolicyDataList::new("Allianz-Import 20200628");
|
||||
println!("Policy Data List {:?} ", policy_data.name);
|
||||
// let mut policy_data = PolicyDataList::new("Allianz-Import 20200628");
|
||||
// println!("Policy Data List {:?} ", policy_data.name);
|
||||
|
||||
let mut policy_numbers : HashMap<usize, PolicyCode> = HashMap::new();
|
||||
// let mut policy_numbers : HashMap<usize, PolicyCode> = HashMap::new();
|
||||
|
||||
let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
||||
match import(&mut csv_import_path, &mut policy_data,
|
||||
&mut policy_numbers, &lang) {
|
||||
Ok(count) => {
|
||||
println!("Imported {:?} records", count);
|
||||
}
|
||||
Err(err) => {
|
||||
println!("error running Csv-Test: {}", err);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
// let mut csv_import_path = viperus.get::<String>("import_file").unwrap();
|
||||
// match import(&mut csv_import_path, &mut policy_data,
|
||||
// &mut policy_numbers, &lang) {
|
||||
// Ok(count) => {
|
||||
// println!("Imported {:?} records", count);
|
||||
// }
|
||||
// Err(err) => {
|
||||
// println!("error running Csv-Test: {}", err);
|
||||
// process::exit(1);
|
||||
// }
|
||||
//}
|
||||
|
||||
// // test if policy_number is_valid
|
||||
// let test_policy_number = v.get::<i32>("test_policy_number").unwrap() as usize;
|
||||
// let test_policy_number = VIPERUS.get::<i32>("test_policy_number").unwrap() as usize;
|
||||
// trace!(target: "csv-test", test_policy_number = ?test_policy_number);
|
||||
// match policy_numbers.get(&test_policy_number) {
|
||||
// Some(&policy_code) => {
|
||||
@@ -146,28 +164,30 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
//}
|
||||
|
||||
|
||||
|
||||
Application::from_name("rzerres.advotracker")
|
||||
.window(move |ctx| {
|
||||
Window::new()
|
||||
//.title("OrbTk - Policyholder checker")
|
||||
.title("AdvoTracker - Versicherungsnummern")
|
||||
.position((500.0, 100.0))
|
||||
.size(580.0, 320.0)
|
||||
.min_width(460.0)
|
||||
.min_height(180.0)
|
||||
.resizeable(true)
|
||||
.theme(get_theme())
|
||||
.child(main_view::MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("main.finished", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
});
|
||||
|
||||
Application::from_name("rzerres.advotracker")
|
||||
.window(move |ctx| {
|
||||
Window::new()
|
||||
//.title("OrbTk - Policyholder checker example")
|
||||
.title("AdvoTracker - Versicherungsnummern")
|
||||
.position((500.0, 100.0))
|
||||
.size(640.0, 480.0)
|
||||
.min_width(460.0)
|
||||
.min_height(180.0)
|
||||
.resizeable(true)
|
||||
.theme(get_theme())
|
||||
.child(main_view::MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
|
||||
Ok(())
|
||||
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -66,7 +66,7 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
||||
// error here.
|
||||
let record: PolicyData = result?;
|
||||
//let record: data::AllianzPolicyNumber = result?;
|
||||
//println!("{:?}", record);
|
||||
println!("{:?}", record);
|
||||
|
||||
// WIP: write to redis backend
|
||||
// append the policy_number to the HashMap
|
||||
@@ -83,6 +83,25 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
||||
|
||||
trace!(target: "advotrackerd", record_count = ?count, duration = ?duration);
|
||||
|
||||
// Tests
|
||||
// Takes a reference and returns Option<&V>
|
||||
let test_policy_number : usize = 1511111111;
|
||||
match data_list.get(test_policy_number) {
|
||||
Some(policy_code) => {
|
||||
println!("Policy-Number {:?} {:?}",
|
||||
test_policy_number, policy_code);
|
||||
},
|
||||
_ => println!("1. No number found!"),
|
||||
}
|
||||
|
||||
let test_policy_number_2 : usize = 9999999991;
|
||||
match data_list.get(test_policy_number_2) {
|
||||
Some(policy_code) => { println!("Policy-Number: {:?} {:?}",
|
||||
test_policy_number, policy_code);
|
||||
},
|
||||
_ => println!("2. No number found!"),
|
||||
}
|
||||
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("csv.import.finished", lang);
|
||||
trace!(target: "advotrackerd", process = ?res, state = ?state, date_stop = ?dt_end.to_string());
|
||||
|
||||
@@ -11,17 +11,19 @@ use crate::data::structures::PolicyCheck;
|
||||
use crate::widgets::policycheck_view::PolicyCheckView;
|
||||
|
||||
widget!(MainView {
|
||||
// policy_list_count: usize,
|
||||
// policy_list: PolicyList,
|
||||
// policy_data_list: PolicyDataList,
|
||||
// policylist_view: u32,
|
||||
// policydata_view: u32,
|
||||
// policydata_view: u32,
|
||||
policy_number_count: usize,
|
||||
policycheck_view: u32
|
||||
});
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
let policycheck_view = PolicyCheckView::new()
|
||||
//.policy_number_count(0)
|
||||
//.policylist_view(id)
|
||||
.build(ctx);
|
||||
|
||||
@@ -39,7 +41,7 @@ impl Template for MainView {
|
||||
// .build(ctx);
|
||||
|
||||
self.name("MainView")
|
||||
//.policy_list_count(0)
|
||||
.policy_number_count(0)
|
||||
//.policycheck_view(PolicyCheck::default())
|
||||
// //.policycheck_view(0)
|
||||
// .policydata_view(policydata_view.0)
|
||||
|
||||
@@ -20,10 +20,10 @@ widget!(
|
||||
PolicyCheckView<PolicyCheckState> {
|
||||
policy_check: PolicyCheck,
|
||||
//policy_check_list: PolicyCheckList,
|
||||
policy_check_title: String,
|
||||
policy_check_number: String,
|
||||
policy_check_title: String16,
|
||||
policy_check_number: String16,
|
||||
policy_check_number_valid: bool,
|
||||
policy_check_text_box: String,
|
||||
policy_check_result: String16,
|
||||
policy_data_count: u32,
|
||||
//policylist_view: u32,
|
||||
title: String
|
||||
@@ -132,22 +132,23 @@ impl Template for PolicyCheckView {
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_POLICY_CHECK_WIDGET)
|
||||
//.v_align("start")
|
||||
//.h_align("center")
|
||||
.background("#fafafa")
|
||||
.columns(
|
||||
Columns::new()
|
||||
.add(64.0)
|
||||
.add(84.0)
|
||||
.add("*")
|
||||
.add(50.0)
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::new()
|
||||
// Top Bar
|
||||
.add("auto")
|
||||
.add(1.0)
|
||||
// Content
|
||||
.add("*")
|
||||
.add(1.0)
|
||||
// Bottom Bar
|
||||
.add(52.0)
|
||||
/* .add("auto") */
|
||||
.build(),
|
||||
@@ -195,35 +196,40 @@ impl Template for PolicyCheckView {
|
||||
.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()
|
||||
.add("5.0")
|
||||
// Labels
|
||||
.add("220.0")
|
||||
.add("5.0")
|
||||
// Seperator
|
||||
.add("16.0")
|
||||
// Values
|
||||
.add("100.0")
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::new()
|
||||
.add("45.0")
|
||||
.add("45.0")
|
||||
.add("64.0")
|
||||
.add("64.0")
|
||||
.build(),
|
||||
)
|
||||
.child(
|
||||
// Labels
|
||||
Stack::new()
|
||||
.attach(Grid::column(1))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(0))
|
||||
.margin((16.0, 16.0, 16.0, 16.0))
|
||||
.orientation("vertical")
|
||||
//.v_align("center")
|
||||
.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)
|
||||
//.size(250.0, 45.0)
|
||||
@@ -234,24 +240,27 @@ impl Template for PolicyCheckView {
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_LABEL_RESULT)
|
||||
//.class(CLASS_TEXT_BLOCK)
|
||||
.attach(Grid::column(1))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(1))
|
||||
.margin((0.0, 0.0, 16.0, 0.0))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.min_width(250.0)
|
||||
//.min_size(120.0, 180.0)
|
||||
.text("Ergebnis:")
|
||||
.text("Result:")
|
||||
//.min_size(120.0, 180.0)
|
||||
//.text("Ergebnis:")
|
||||
//.text("Result:")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
)
|
||||
.child(
|
||||
// Values
|
||||
Stack::new()
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::column(1))
|
||||
.attach(Grid::row(0))
|
||||
//.attach(Grid::column_span(3))
|
||||
.orientation("vertical")
|
||||
.margin((16.0, 16.0, 16.0, 16.0))
|
||||
//.margin((16.0, 16.0, 16.0, 16.0))
|
||||
//.child(policy_check_text_box)
|
||||
.child(
|
||||
TextBox::new()
|
||||
@@ -259,26 +268,57 @@ impl Template for PolicyCheckView {
|
||||
.h_align("start")
|
||||
.width(250.0)
|
||||
.min_width(200.0)
|
||||
.margin((4.0, 0.0, 0.0, 0.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| {
|
||||
// Entity is entered/activated via Mouse/Keyboard
|
||||
ctx.get_mut::<PolicyCheckState>(id)
|
||||
.action(Action::ParseEntry(entity));
|
||||
})
|
||||
.on_changed(move |ctx, entity| {
|
||||
// Element value has changed
|
||||
ctx.get_mut::<PolicyCheckState>(id)
|
||||
.action(Action::InputTextChanged(entity));
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
//.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),
|
||||
//)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_RESULT)
|
||||
.h_align("start")
|
||||
.attach(Grid::column(3))
|
||||
.attach(Grid::column(1))
|
||||
.attach(Grid::row(1))
|
||||
.text((""))
|
||||
//.margin((4.0, 0.0, 0.0, 0.0))
|
||||
//.lost_focus_on_activation(false)
|
||||
// .on_activate(move |ctx, entity| {
|
||||
@@ -341,16 +381,11 @@ impl Template for PolicyCheckView {
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
|
||||
//ctx.append_child_to_overlay(policycheck_menu_text_block).unwrap()
|
||||
|
||||
)
|
||||
.build(ctx),
|
||||
|
||||
)
|
||||
.build(ctx),
|
||||
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user