@@ -1,128 +0,0 @@
|
|||||||
{
|
|
||||||
"err.lang.not_found": {
|
|
||||||
"de_DE.UTF-8": "Konnte Sprachkode nicht auslesen",
|
|
||||||
"de": "Konnte Sprachkode nicht auslesen",
|
|
||||||
"en": "Couldn't read LANG"
|
|
||||||
},
|
|
||||||
"err.user.not_found": {
|
|
||||||
"fr": "Utilisateur introuvable: $email, $id",
|
|
||||||
"de-DE.UTF-8": "Anwender nicht gefunden: $email, $id",
|
|
||||||
"de": "Anwender nicht gefunden: $email, $id",
|
|
||||||
"en": "User not found: $email, $id"
|
|
||||||
},
|
|
||||||
"main.started": {
|
|
||||||
"de_DE.UTF-8": "Programmlogik starten",
|
|
||||||
"de": "Programmlogik starten",
|
|
||||||
"en": "Program logic started"
|
|
||||||
},
|
|
||||||
"main.finished": {
|
|
||||||
"de_DE.UTF-8": "Programmlogik beendet",
|
|
||||||
"de": "Programmlogik beendet",
|
|
||||||
"en": "Program logic finished"
|
|
||||||
},
|
|
||||||
"parse.arguments": {
|
|
||||||
"de_DE.UTF-8": "Programmargumente prüfen",
|
|
||||||
"de": "Programmargumente prüfen",
|
|
||||||
"en": "Parsing arguments"
|
|
||||||
},
|
|
||||||
"parse.environment": {
|
|
||||||
"de_DE.UTF-8": "Umgebungsvariablen prüfen",
|
|
||||||
"de": "Umgebungsvariablen prüfen",
|
|
||||||
"en": "Parsing environment"
|
|
||||||
},
|
|
||||||
"parse.results": {
|
|
||||||
"de_DE.UTF-8": "Ergebnisse der Konfigurations-Parameterprüfung",
|
|
||||||
"de": "Ergebnisse der Konfigurationsparameterprüfung",
|
|
||||||
"en": "Config parsing results"
|
|
||||||
},
|
|
||||||
"config.name": {
|
|
||||||
"de_DE.UTF-8": "Konfigurationswert für",
|
|
||||||
"de": "Konfigurationswert für",
|
|
||||||
"en": "Config Value for"
|
|
||||||
},
|
|
||||||
"config.name.lang": {
|
|
||||||
"de_DE.UTF-8": "Sprach-Code",
|
|
||||||
"de": "Sprach-Code",
|
|
||||||
"en": "Language code"
|
|
||||||
},
|
|
||||||
"config.name.verbositylevel": {
|
|
||||||
"de_DE.UTF-8": "Ausgabe-Ebene",
|
|
||||||
"de": "Ausgabe-Ebene",
|
|
||||||
"en": "verbosity level"
|
|
||||||
},
|
|
||||||
"config.name.environment": {
|
|
||||||
"de_DE.UTF-8": "Umgebungsvariablen",
|
|
||||||
"de": "Umgebungsvariablen",
|
|
||||||
"en": "environment"
|
|
||||||
},
|
|
||||||
"config.name.configfile": {
|
|
||||||
"de_DE.UTF-8": "Konfigurations-Datei",
|
|
||||||
"de": "Konfigurations-Datei",
|
|
||||||
"en": "config file"
|
|
||||||
},
|
|
||||||
"config.name.dbdriver": {
|
|
||||||
"de_DE.UTF-8": "Datenbank-Treiber",
|
|
||||||
"de": "Datenbank-Treiber",
|
|
||||||
"en": "database driver"
|
|
||||||
},
|
|
||||||
"config.name.redis": {
|
|
||||||
"de_DE.UTF-8": "Redis Datenbank",
|
|
||||||
"de": "Redis Datenbank",
|
|
||||||
"en": "Redis database"
|
|
||||||
},
|
|
||||||
"csv.export.started": {
|
|
||||||
"de_DE.UTF-8": "Export in eine CSV Datei starten",
|
|
||||||
"de": "Export in eine CSV Datei starten",
|
|
||||||
"en": "Export to csv file started"
|
|
||||||
},
|
|
||||||
"csv.export.finished": {
|
|
||||||
"de_DE.UTF-8": "Export in eine CSV Datei beendet",
|
|
||||||
"de": "Export in eine CSV Datei beendet",
|
|
||||||
"en": "Export to csv file finished"
|
|
||||||
},
|
|
||||||
"csv.import.started": {
|
|
||||||
"de_DE.UTF-8": "Import von einer CSV Datei starten",
|
|
||||||
"de": "Import von einer CSV Datei starten",
|
|
||||||
"en": "Import from a csv file started"
|
|
||||||
},
|
|
||||||
"csv.import.finished": {
|
|
||||||
"de_DE.UTF-8": "Import von einer CSV Datei beendet",
|
|
||||||
"de": "Import von einer CSV Datei beendet",
|
|
||||||
"en": "Import from a csv file finished"
|
|
||||||
},
|
|
||||||
"redis.connection.error": {
|
|
||||||
"de_DE.UTF-8": "Es konnte keine Redis Verbindung aufgebaut werden",
|
|
||||||
"de": "Es konnte keine Redis Verbindung aufgebaut werden",
|
|
||||||
"en": "Could not establish a redis connection"
|
|
||||||
},
|
|
||||||
"policy.validation.failed": {
|
|
||||||
"de_DE.UTF-8": "Die Versicherungsscheinnummber ist ungültig",
|
|
||||||
"de": "Die Versicherungsscheinnummber ist ungültig",
|
|
||||||
"en": "The given policy number is invalid"
|
|
||||||
},
|
|
||||||
"policy.validation.success": {
|
|
||||||
"de_DE.UTF-8": "Die Versicherungsscheinnummber ist gültig",
|
|
||||||
"de": "Die Versicherungsscheinnummber ist gültig",
|
|
||||||
"en": "The given policy number is valid"
|
|
||||||
},
|
|
||||||
"policy.validation.started": {
|
|
||||||
"de_DE.UTF-8": "Die Prüfung der Versicherungsscheinnummber wurde gestartet",
|
|
||||||
"de": "Die Prüfung der Versicherungsscheinnummber wurde gestartet",
|
|
||||||
"en": "Validation of the policy number started"
|
|
||||||
},
|
|
||||||
"policy.validation.finished": {
|
|
||||||
"de_DE.UTF-8": "Die Prüfung der Versicherungsscheinnummber wurde beendet",
|
|
||||||
"de": "Die Prüfung der Versicherungsscheinnummber wurde beendet",
|
|
||||||
"en": "Validation of the policy number finished"
|
|
||||||
},
|
|
||||||
"state.started": {
|
|
||||||
"de_DE.UTF-8": "gestartet",
|
|
||||||
"de": "gestartet",
|
|
||||||
"en": "started"
|
|
||||||
},
|
|
||||||
"state.finished": {
|
|
||||||
"de_DE.UTF-8": "beendet",
|
|
||||||
"de": "beended",
|
|
||||||
"en": "finished"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +1 @@
|
|||||||
../../../advotrackerd/data/POLLFNR_WOECHENTLICH.txt
|
../../../data/POLLFNR_WOECHENTLICH.txt
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
{
|
|
||||||
"err.lang.not_found": {
|
|
||||||
"de_DE.UTF-8": "Konnte die Umgebungsvarialbe LANG nicht auslesen",
|
|
||||||
"de": "Konnte die Umgebungsvarialbe LANG nicht auslesen",
|
|
||||||
"en": "Couldn't read LANG"
|
|
||||||
},
|
|
||||||
"err.user.not_found": {
|
|
||||||
"fr": "Utilisateur introuvable: $email, $id",
|
|
||||||
"de-DE.UTF-8": "Anwender nicht gefunden: $email, $id",
|
|
||||||
"de": "Anwender nicht gefunden: $email, $id",
|
|
||||||
"en": "User not found: $email, $id"
|
|
||||||
},
|
|
||||||
"main.started": {
|
|
||||||
"de_DE.UTF-8": "Programmlogik starten",
|
|
||||||
"de": "Programmlogik starten",
|
|
||||||
"en": "Program logic started"
|
|
||||||
},
|
|
||||||
"main.finished": {
|
|
||||||
"de_DE.UTF-8": "Programmlogik beendet",
|
|
||||||
"de": "Programmlogik beendet",
|
|
||||||
"en": "Program logic finished"
|
|
||||||
},
|
|
||||||
"parse.arguments": {
|
|
||||||
"de_DE.UTF-8": "Programmargumente prüfen",
|
|
||||||
"de": "Programmargumente prüfen",
|
|
||||||
"en": "Parsing arguments"
|
|
||||||
},
|
|
||||||
"parse.environment": {
|
|
||||||
"de_DE.UTF-8": "Umgebungsvariablen prüfen",
|
|
||||||
"de": "Umgebungsvariablen prüfen",
|
|
||||||
"en": "Parsing environment"
|
|
||||||
},
|
|
||||||
"parse.results": {
|
|
||||||
"de_DE.UTF-8": "Ergebnisse der Konfigurations-Parameterprüfung",
|
|
||||||
"de": "Ergebnisse der Konfigurationsparameterprüfung",
|
|
||||||
"en": "Config parsing results"
|
|
||||||
},
|
|
||||||
"config.name": {
|
|
||||||
"de_DE.UTF-8": "Konfigurationswert für",
|
|
||||||
"de": "Konfigurationswert für",
|
|
||||||
"en": "Config Value for"
|
|
||||||
},
|
|
||||||
"config.name.lang": {
|
|
||||||
"de_DE.UTF-8": "Sprach-Code",
|
|
||||||
"de": "Sprach-Code",
|
|
||||||
"en": "Language code"
|
|
||||||
},
|
|
||||||
"config.name.verbositylevel": {
|
|
||||||
"de_DE.UTF-8": "Ausgabe-Ebene",
|
|
||||||
"de": "Ausgabe-Ebene",
|
|
||||||
"en": "verbosity level"
|
|
||||||
},
|
|
||||||
"config.name.environment": {
|
|
||||||
"de_DE.UTF-8": "Umgebungsvariablen",
|
|
||||||
"de": "Umgebungsvariablen",
|
|
||||||
"en": "environment"
|
|
||||||
},
|
|
||||||
"config.name.configfile": {
|
|
||||||
"de_DE.UTF-8": "Konfigurations-Datei",
|
|
||||||
"de": "Konfigurations-Datei",
|
|
||||||
"en": "config file"
|
|
||||||
},
|
|
||||||
"config.name.dbdriver": {
|
|
||||||
"de_DE.UTF-8": "Datenbank-Treiber",
|
|
||||||
"de": "Datenbank-Treiber",
|
|
||||||
"en": "database driver"
|
|
||||||
},
|
|
||||||
"csv_import.started": {
|
|
||||||
"de_DE.UTF-8": "importieren von einer csv-datei gestartet",
|
|
||||||
"de": "importieren von einer csv-datei gestartet",
|
|
||||||
"en": "import from a csv-file started"
|
|
||||||
},
|
|
||||||
"csv_import.finished": {
|
|
||||||
"de_DE.UTF-8": "importieren von einer csv-datei beendet",
|
|
||||||
"de": "importieren von einer csv-datei beendet",
|
|
||||||
"en": "import from a csv-file finished"
|
|
||||||
},
|
|
||||||
"csv_export.started": {
|
|
||||||
"de_DE.UTF-8": "exportieren in eine csv-datei gestartet",
|
|
||||||
"de": "exportieren in eine csv-datei gestartet",
|
|
||||||
"en": "export to csv-file started"
|
|
||||||
},
|
|
||||||
"csv_export.finished": {
|
|
||||||
"de_DE.UTF-8": "exportieren in eine csv-datei beendet",
|
|
||||||
"de": "exportieren in eine csv-datei beendet",
|
|
||||||
"en": "export to csv-file finished"
|
|
||||||
},
|
|
||||||
"state.started": {
|
|
||||||
"de_DE.UTF-8": "gestartet",
|
|
||||||
"de": "gestartet",
|
|
||||||
"en": "started"
|
|
||||||
},
|
|
||||||
"state.finished": {
|
|
||||||
"de_DE.UTF-8": "beendet",
|
|
||||||
"de": "beended",
|
|
||||||
"en": "finished"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -154,6 +154,25 @@ fn import(p: &mut String, data_list: &mut PolicyDataList,
|
|||||||
count +=1;
|
count +=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests
|
||||||
|
// Takes a reference and returns Option<&V>
|
||||||
|
let test_policy_number : usize = 1511111111;
|
||||||
|
match policy_numbers.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 policy_numbers.get(&test_policy_number_2) {
|
||||||
|
Some(policy_code) => { println!("Policy-Number: {:?} {:?}",
|
||||||
|
test_policy_number, policy_code);
|
||||||
|
},
|
||||||
|
_ => println!("2. No number found!"),
|
||||||
|
}
|
||||||
|
|
||||||
let dt_end: DateTime<Local> = Local::now();
|
let dt_end: DateTime<Local> = Local::now();
|
||||||
let duration = dt_end.signed_duration_since(dt_start);
|
let duration = dt_end.signed_duration_since(dt_start);
|
||||||
|
|
||||||
@@ -361,7 +380,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
//match is_valid(&policy_number, &policy_data, &mut policy_numbers, &lang) {
|
//match is_valid(&policy_number, &policy_data, &mut policy_numbers, &lang) {
|
||||||
// Ok(true) => {
|
// Ok(true) => {
|
||||||
// use Hashmap method 'get' to check if we have the given key
|
// use Hashmap method 'get' to check if we have the given key
|
||||||
match policy_numbers.get(&test_policy_number) {
|
match &policy_numbers.get(&test_policy_number) {
|
||||||
Some(&policy_code) => {
|
Some(&policy_code) => {
|
||||||
let res = t!("policy.validation.success", lang);
|
let res = t!("policy.validation.success", lang);
|
||||||
println!("{:?}", res);
|
println!("{:?}", res);
|
||||||
|
|||||||
@@ -1,8 +1,17 @@
|
|||||||
|
use locales::t;
|
||||||
|
use dotenv::dotenv;
|
||||||
use orbtk::prelude::*;
|
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::{
|
use crate::{
|
||||||
callbacks::global_state::GlobalState,
|
callbacks::global_state::GlobalState,
|
||||||
//data::structures::{PolicyData, PolicyDataList},
|
data::structures::{PolicyCode, PolicyDataList, PolicyData, PolicyList},
|
||||||
data::keys::*,
|
data::keys::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -18,14 +27,22 @@ pub enum Action {
|
|||||||
TextChanged(Entity, usize),
|
TextChanged(Entity, usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
struct Environment {
|
||||||
|
test_lang: String,
|
||||||
|
log: String,
|
||||||
|
}
|
||||||
|
|
||||||
/// Handles the requests of the `PolicyCheckView`.
|
/// Handles the requests of the `PolicyCheckView`.
|
||||||
#[derive(Default, AsAny)]
|
#[derive(Default, AsAny)]
|
||||||
pub struct PolicyCheckState {
|
pub struct PolicyCheckState {
|
||||||
action:Option<Action>,
|
action: Option<Action>,
|
||||||
last_focused: Option<Entity>,
|
last_focused: Option<Entity>,
|
||||||
pub text_box: Entity,
|
pub text_box: Entity,
|
||||||
menu_button: Entity,
|
menu_button: Entity,
|
||||||
policy_number_valid: bool,
|
policy_number_valid: bool,
|
||||||
|
policy_number_count: usize,
|
||||||
|
policy_numbers: HashMap<usize, PolicyCode>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalState for PolicyCheckState {}
|
impl GlobalState for PolicyCheckState {}
|
||||||
@@ -36,6 +53,48 @@ impl PolicyCheckState {
|
|||||||
self.action = action.into();
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// move results to the golbal accessible instance
|
||||||
|
self.policy_numbers = policy_numbers;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// 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));
|
||||||
@@ -50,27 +109,87 @@ impl PolicyCheckState {
|
|||||||
println!("Menu text: {}", text);
|
println!("Menu text: {}", text);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_entry(&self, policy_check_policy_number: Entity, ctx: &mut Context) {
|
fn parse_entry(&mut self, policy_check_policy_number: Entity,
|
||||||
let mut policy_check_policy_number = TextBox::get(ctx.get_widget(policy_check_policy_number));
|
ctx: &mut Context) {
|
||||||
let policy_number = policy_check_policy_number.text_mut();
|
let policy_string = ctx.get_widget(policy_check_policy_number).get::<String16>("text").as_string();
|
||||||
|
let policy_number_length = policy_string.len();
|
||||||
println!("parsing policy Number: {}", policy_number);
|
|
||||||
|
|
||||||
// Parse policy code: "AS-123456789"
|
// Parse policy code: "AS-123456789"
|
||||||
// DION VERS POLLFNR
|
// DION VERS POLLFNR
|
||||||
// 1 AS 1515735810
|
// 1 AS 1515735810
|
||||||
let policy_number_length = policy_number.len();
|
|
||||||
if policy_number_length == 10 {
|
if policy_number_length == 10 {
|
||||||
println!("Verify {} ...", policy_number);
|
// needs to be an integer
|
||||||
// check against hash-table
|
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(text_box).set("policy_number_valid", true);
|
||||||
//ctx.get_widget(policy_check_policy_number).set("policy_check_result", 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);
|
//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!");
|
||||||
//TextBox::get(ctx.child("text_box")).set_foreground("#ffffff");
|
//ctx.child(ID_POLICY_CHECK_POLICY_NUMBER).set("text", String::from(""));
|
||||||
//TextBox::get(ctx.child("text_box")).set_background("#5b0f22");
|
|
||||||
|
//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 {
|
if policy_number_length > 10 {
|
||||||
println!("Policy number is to big!");
|
println!("Policy number is to big!");
|
||||||
@@ -78,26 +197,26 @@ impl PolicyCheckState {
|
|||||||
//TextBox::get(ctx.child("text_box")).set_background("#5b0f22");
|
//TextBox::get(ctx.child("text_box")).set_background("#5b0f22");
|
||||||
}
|
}
|
||||||
|
|
||||||
// if let policy_number = text_box.text() {
|
//if let policy_number = policy_check_policy_number.text() {
|
||||||
// match policy_number {
|
// match policy_number {
|
||||||
// _ => {
|
// _ => {
|
||||||
// println!("policynumber: {} is valid!", 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.
|
/// otherwise enabled it.
|
||||||
fn set_check_button(&self, text_box: Entity, ctx: &mut Context) {
|
// 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() {
|
// if ctx.get_widget(clear_button).get::<String>("policy_check_policy_number").is_empty() {
|
||||||
// ctx.get_widget(self.policy_check_result).set("enabled", false);
|
// ctx.get_widget(self.policy_check_clear_button).set("enabled", false);
|
||||||
// } else {
|
// } else {
|
||||||
// ctx.get_widget(self.policy_check_result).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.text_box).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, text_box: Entity, ctx: &mut Context) {
|
||||||
@@ -122,16 +241,21 @@ impl PolicyCheckState {
|
|||||||
.length = ctx.get_widget(text_box).get::<String>("policy_number").len();
|
.length = ctx.get_widget(text_box).get::<String>("policy_number").len();
|
||||||
ctx.push_event_by_window(FocusEvent::RequestFocus(text_box));
|
ctx.push_event_by_window(FocusEvent::RequestFocus(text_box));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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.menu_button = ctx
|
// self.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 child 'Menu button'.");
|
||||||
self.text_box = ctx
|
self.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 child 'Text Box'.");
|
||||||
|
// self.text_block = ctx
|
||||||
|
// .entity_of_child(ID_POLICY_CHECK_RESULT)
|
||||||
|
// .expect("PolicyCheckState.init: Can't find child 'Text Block'.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context) {
|
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context) {
|
||||||
@@ -150,13 +274,15 @@ impl State for PolicyCheckState {
|
|||||||
self.clear_entry(text_box, ctx);
|
self.clear_entry(text_box, ctx);
|
||||||
}
|
}
|
||||||
Action::InputTextChanged(text_box) => {
|
Action::InputTextChanged(text_box) => {
|
||||||
self.set_check_button(text_box, ctx);
|
//self.set_check_button(text_box, 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);
|
||||||
|
//self.parse_entry(text_box, &mut policy_numbers,
|
||||||
|
// &lang, ctx);
|
||||||
}
|
}
|
||||||
Action::RemoveFocus(text_box) => {
|
Action::RemoveFocus(text_box) => {
|
||||||
ctx.get_widget(text_box).set("enabled", false);
|
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_FORM: &str = "policy_check_form";
|
||||||
pub static ID_POLICY_CHECK_HEADER: &str = "policy_check_header";
|
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_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_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_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_LABEL_RESULT: &str = "policy_check_label_result";
|
||||||
@@ -38,7 +39,8 @@ pub static ID_POLICY_DATA_LIST_NAME: &str = "policy_data_list_name";
|
|||||||
|
|
||||||
pub static ID_POLICY_LIST_ADD_BUTTON: &str = "policy_list_add_button";
|
pub static ID_POLICY_LIST_ADD_BUTTON: &str = "policy_list_add_button";
|
||||||
pub static ID_POLICY_LIST_ITEMS_WIDGET: &str = "policy_list_items_widget";
|
pub static ID_POLICY_LIST_ITEMS_WIDGET: &str = "policy_list_items_widget";
|
||||||
pub static ID_POLICY_LIST_TEXT_BOX: &str = "policy_list_text_box";
|
//pub static ID_POLICY_LIST_TEXT_BOX: &str = "policy_list_text_box";
|
||||||
|
//pub static ID_POLICY_LIST_TEXT_BLOCK: &str = "policy_list_text_block";
|
||||||
|
|
||||||
// Component Values (Properties)
|
// Component Values (Properties)
|
||||||
pub static PROP_POLICY_CHECK: &str = "policy_check";
|
pub static PROP_POLICY_CHECK: &str = "policy_check";
|
||||||
|
|||||||
@@ -5,13 +5,16 @@
|
|||||||
* SPDX-License-Identifier: (0BSD or MIT)
|
* SPDX-License-Identifier: (0BSD or MIT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate lazy_static;
|
||||||
|
|
||||||
//use chrono::{Local, DateTime};
|
//use chrono::{Local, DateTime};
|
||||||
use locales::t;
|
use locales::t;
|
||||||
//use serde::{Deserialize, Serialize};
|
//use serde::{Deserialize, Serialize};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{env, process};
|
use std::{env, process};
|
||||||
//use std::{error::Error, process};
|
//use std::{error::Error, process};
|
||||||
use std::collections::HashMap;
|
//use std::collections::HashMap;
|
||||||
use tracing::{debug, trace, Level};
|
use tracing::{debug, trace, Level};
|
||||||
|
|
||||||
use orbtk::prelude::*;
|
use orbtk::prelude::*;
|
||||||
@@ -33,7 +36,8 @@ struct Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//#[cfg(feature = "light-theme")]
|
//#[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 {
|
fn get_theme() -> ThemeValue {
|
||||||
//ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
//ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
||||||
@@ -81,7 +85,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
Ok(environment) => {
|
Ok(environment) => {
|
||||||
if environment.test_lang != lang { lang = environment.test_lang; }
|
if environment.test_lang != lang { lang = environment.test_lang; }
|
||||||
},
|
},
|
||||||
Err(e) => { debug!(target: "csv-test", "{}", e); }
|
Err(e) => { debug!(target: "advotracker", "{}", e); }
|
||||||
}
|
}
|
||||||
// how to handle unumplemented lang resources??
|
// how to handle unumplemented lang resources??
|
||||||
res = t!("parse.environment", lang);
|
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);
|
trace!(target: "csv-test", message = ?res, state = ?state);
|
||||||
|
|
||||||
// initialize viperus structure
|
// 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
|
// parse commandline arguments
|
||||||
res = t!("parse.arguments", lang);
|
res = t!("parse.arguments", lang);
|
||||||
state = t!("state.started", lang);
|
state = t!("state.started", lang);
|
||||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||||
|
|
||||||
let _ = parse_args(&mut v);
|
let _ = parse_args(&mut viperus);
|
||||||
state = t!("state.finished", lang);
|
state = t!("state.finished", lang);
|
||||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
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
|
// main tasks
|
||||||
res = t!("main.started", lang);
|
res = t!("main.started", lang);
|
||||||
state = t!("state.started", lang);
|
state = t!("state.started", lang);
|
||||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||||
|
|
||||||
// importing policy code elements from csv-file
|
// moved to callback: checkview_state.rs
|
||||||
let policy_list = PolicyList::new("Allianz Versicherungsnummen-List");
|
// // importing policy code elements from csv-file
|
||||||
println!("Policy List {:?} ", policy_list.name);
|
// let policy_list = PolicyList::new("Allianz Versicherungsnummen-List");
|
||||||
|
// println!("Policy List {:?} ", policy_list.name);
|
||||||
|
|
||||||
let mut policy_data = PolicyDataList::new("Allianz-Import 20200628");
|
// let mut policy_data = PolicyDataList::new("Allianz-Import 20200628");
|
||||||
println!("Policy Data List {:?} ", policy_data.name);
|
// println!("Policy Data List {:?} ", policy_data.name);
|
||||||
|
|
||||||
let mut policy_numbers : HashMap<usize, PolicyCode> = HashMap::new();
|
// 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 = viperus.get::<String>("import_file").unwrap();
|
||||||
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) => {
|
||||||
println!("Imported {:?} records", count);
|
// println!("Imported {:?} records", count);
|
||||||
}
|
// }
|
||||||
Err(err) => {
|
// Err(err) => {
|
||||||
println!("error running Csv-Test: {}", err);
|
// println!("error running Csv-Test: {}", err);
|
||||||
process::exit(1);
|
// process::exit(1);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
// // test if policy_number is_valid
|
// // 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);
|
// trace!(target: "csv-test", test_policy_number = ?test_policy_number);
|
||||||
// match policy_numbers.get(&test_policy_number) {
|
// match policy_numbers.get(&test_policy_number) {
|
||||||
// Some(&policy_code) => {
|
// 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);
|
state = t!("state.finished", lang);
|
||||||
res = t!("main.finished", lang);
|
res = t!("main.finished", lang);
|
||||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
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(())
|
Ok(())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
|||||||
// error here.
|
// error here.
|
||||||
let record: PolicyData = result?;
|
let record: PolicyData = result?;
|
||||||
//let record: data::AllianzPolicyNumber = result?;
|
//let record: data::AllianzPolicyNumber = result?;
|
||||||
//println!("{:?}", record);
|
// if debug ...
|
||||||
|
// println!("{:?}", record);
|
||||||
|
|
||||||
// WIP: write to redis backend
|
// WIP: write to redis backend
|
||||||
// append the policy_number to the HashMap
|
// append the policy_number to the HashMap
|
||||||
@@ -84,6 +85,25 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
|||||||
|
|
||||||
trace!(target: "advotrackerd", record_count = ?count, duration = ?duration);
|
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);
|
state = t!("state.finished", lang);
|
||||||
res = t!("csv.import.finished", lang);
|
res = t!("csv.import.finished", lang);
|
||||||
trace!(target: "advotrackerd", process = ?res, state = ?state, date_stop = ?dt_end.to_string());
|
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;
|
use crate::widgets::policycheck_view::PolicyCheckView;
|
||||||
|
|
||||||
widget!(MainView {
|
widget!(MainView {
|
||||||
// policy_list_count: usize,
|
|
||||||
// policy_list: PolicyList,
|
// policy_list: PolicyList,
|
||||||
// policy_data_list: PolicyDataList,
|
// policy_data_list: PolicyDataList,
|
||||||
// policylist_view: u32,
|
// policylist_view: u32,
|
||||||
// policydata_view: u32,
|
// policydata_view: u32,
|
||||||
|
// policydata_view: u32,
|
||||||
|
policy_number_count: usize,
|
||||||
policycheck_view: u32
|
policycheck_view: u32
|
||||||
});
|
});
|
||||||
|
|
||||||
impl Template for MainView {
|
impl Template for MainView {
|
||||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||||
let policycheck_view = PolicyCheckView::new()
|
let policycheck_view = PolicyCheckView::new()
|
||||||
|
//.policy_number_count(0)
|
||||||
//.policylist_view(id)
|
//.policylist_view(id)
|
||||||
.build(ctx);
|
.build(ctx);
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ impl Template for MainView {
|
|||||||
// .build(ctx);
|
// .build(ctx);
|
||||||
|
|
||||||
self.name("MainView")
|
self.name("MainView")
|
||||||
//.policy_list_count(0)
|
.policy_number_count(0)
|
||||||
//.policycheck_view(PolicyCheck::default())
|
//.policycheck_view(PolicyCheck::default())
|
||||||
// //.policycheck_view(0)
|
// //.policycheck_view(0)
|
||||||
// .policydata_view(policydata_view.0)
|
// .policydata_view(policydata_view.0)
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ widget!(
|
|||||||
PolicyCheckView<PolicyCheckState> {
|
PolicyCheckView<PolicyCheckState> {
|
||||||
policy_check: PolicyCheck,
|
policy_check: PolicyCheck,
|
||||||
//policy_check_list: PolicyCheckList,
|
//policy_check_list: PolicyCheckList,
|
||||||
policy_check_title: String,
|
policy_check_title: String16,
|
||||||
policy_check_number: String,
|
policy_check_number: String16,
|
||||||
policy_check_number_valid: bool,
|
policy_check_number_valid: bool,
|
||||||
policy_check_text_box: String,
|
policy_check_result: String16,
|
||||||
policy_data_count: u32,
|
policy_data_count: u32,
|
||||||
//policylist_view: u32,
|
//policylist_view: u32,
|
||||||
title: String
|
title: String
|
||||||
@@ -62,6 +62,7 @@ impl Template for PolicyCheckView {
|
|||||||
.id(ID_POLICY_CHECK_MENU_BUTTON)
|
.id(ID_POLICY_CHECK_MENU_BUTTON)
|
||||||
.margin((0.0, 0.0, 12.0, 12.0))
|
.margin((0.0, 0.0, 12.0, 12.0))
|
||||||
.icon(material_icons_font_ttf::MD_MENU)
|
.icon(material_icons_font_ttf::MD_MENU)
|
||||||
|
//.icon(material_icons_font_ttf::MD_ADD_CIRCLE)
|
||||||
.class(CLASS_ICON_ONLY)
|
.class(CLASS_ICON_ONLY)
|
||||||
//.attach(Grid::row(0))
|
//.attach(Grid::row(0))
|
||||||
.attach(Grid::column(2))
|
.attach(Grid::column(2))
|
||||||
@@ -128,26 +129,27 @@ 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())
|
//.policy_check_view(PolicyCheck::default())
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.id(ID_POLICY_CHECK_WIDGET)
|
.id(ID_POLICY_CHECK_WIDGET)
|
||||||
//.v_align("start")
|
|
||||||
//.h_align("center")
|
|
||||||
.background("#fafafa")
|
.background("#fafafa")
|
||||||
.columns(
|
.columns(
|
||||||
Columns::new()
|
Columns::new()
|
||||||
.add(64.0)
|
.add(84.0)
|
||||||
.add("*")
|
.add("*")
|
||||||
.add(50.0)
|
.add(50.0)
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::new()
|
Rows::new()
|
||||||
|
// Top Bar
|
||||||
.add("auto")
|
.add("auto")
|
||||||
.add(1.0)
|
.add(1.0)
|
||||||
|
// Content
|
||||||
.add("*")
|
.add("*")
|
||||||
.add(1.0)
|
.add(1.0)
|
||||||
|
// Bottom Bar
|
||||||
.add(52.0)
|
.add(52.0)
|
||||||
/* .add("auto") */
|
/* .add("auto") */
|
||||||
.build(),
|
.build(),
|
||||||
@@ -195,35 +197,40 @@ impl Template for PolicyCheckView {
|
|||||||
.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))
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.id(ID_POLICY_CHECK_FORM)
|
.id(ID_POLICY_CHECK_FORM)
|
||||||
.columns(
|
.columns(
|
||||||
Columns::new()
|
Columns::new()
|
||||||
.add("5.0")
|
// Labels
|
||||||
.add("220.0")
|
.add("220.0")
|
||||||
.add("5.0")
|
// Seperator
|
||||||
|
.add("16.0")
|
||||||
|
// Values
|
||||||
.add("100.0")
|
.add("100.0")
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::new()
|
Rows::new()
|
||||||
.add("45.0")
|
.add("64.0")
|
||||||
.add("45.0")
|
.add("64.0")
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
// Labels
|
||||||
Stack::new()
|
Stack::new()
|
||||||
.attach(Grid::column(1))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(0))
|
.attach(Grid::row(0))
|
||||||
.margin((16.0, 16.0, 16.0, 16.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))
|
||||||
.h_align("end")
|
.h_align("end")
|
||||||
|
.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)
|
||||||
@@ -234,24 +241,27 @@ impl Template for PolicyCheckView {
|
|||||||
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(1))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(2))
|
||||||
|
.margin((0.0, 0.0, 16.0, 0.0))
|
||||||
.h_align("end")
|
.h_align("end")
|
||||||
|
.v_align("center")
|
||||||
.min_width(250.0)
|
.min_width(250.0)
|
||||||
//.min_size(120.0, 180.0)
|
//.min_size(120.0, 180.0)
|
||||||
.text("Ergebnis:")
|
//.text("Ergebnis:")
|
||||||
.text("Result:")
|
//.text("Result:")
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
// Values
|
||||||
Stack::new()
|
Stack::new()
|
||||||
.attach(Grid::column(2))
|
.attach(Grid::column(1))
|
||||||
.attach(Grid::row(0))
|
.attach(Grid::row(0))
|
||||||
//.attach(Grid::column_span(3))
|
//.attach(Grid::column_span(3))
|
||||||
.orientation("vertical")
|
.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(policy_check_text_box)
|
||||||
.child(
|
.child(
|
||||||
TextBox::new()
|
TextBox::new()
|
||||||
@@ -259,26 +269,59 @@ impl Template for PolicyCheckView {
|
|||||||
.h_align("start")
|
.h_align("start")
|
||||||
.width(250.0)
|
.width(250.0)
|
||||||
.min_width(200.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)
|
.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| {
|
||||||
|
// 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
|
||||||
ctx.get_mut::<PolicyCheckState>(id)
|
ctx.get_mut::<PolicyCheckState>(id)
|
||||||
.action(Action::InputTextChanged(entity));
|
.action(Action::InputTextChanged(entity));
|
||||||
})
|
})
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
|
// .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(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.id(ID_POLICY_CHECK_RESULT)
|
.id(ID_POLICY_CHECK_RESULT)
|
||||||
.h_align("start")
|
.attach(Grid::column(1))
|
||||||
.attach(Grid::column(3))
|
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(1))
|
||||||
|
.h_align("start")
|
||||||
|
.width(250.0)
|
||||||
|
.min_width(200.0)
|
||||||
|
.margin((0.0, 0.0, 0.0, 16.0))
|
||||||
|
.text("")
|
||||||
//.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| {
|
||||||
@@ -341,16 +384,11 @@ impl Template for PolicyCheckView {
|
|||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
|
|
||||||
//ctx.append_child_to_overlay(policycheck_menu_text_block).unwrap()
|
//ctx.append_child_to_overlay(policycheck_menu_text_block).unwrap()
|
||||||
|
|
||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
|
|
||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user