Merge branch 'orbtk-localization' into master
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
Submodule advotracker-db updated: 5534da7f29...d29c747d7b
@@ -1,7 +1,16 @@
|
||||
###
|
||||
# .env
|
||||
# will overwrite standard environment viariables
|
||||
###
|
||||
# set the language variable used in test-runs
|
||||
#test lang=it
|
||||
TEST_LANG=de
|
||||
#test LANG=es-ES
|
||||
#test LANG=it-IT
|
||||
#test LANG=C
|
||||
# set the language variable (overwriting standard Enviroment)
|
||||
#TEST_LANG=de_DE
|
||||
#TEST_LANG=C
|
||||
#RUST_LOG=advotracker=trace
|
||||
RUST_LOG=trace
|
||||
#RUST_LOG=none
|
||||
USERNAME=hiedemann
|
||||
DB_DRIVER=sqlite
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "advotracker"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
authors = ["Ralf Zerres <ralf.zerres@networkx.de>"]
|
||||
description = "Frontend component that supports lawyers to capture relevant data encountered during an online legal advice."
|
||||
readme = "README.md"
|
||||
@@ -32,7 +32,7 @@ orbtk = { git = "https://github.com/redox-os/orbtk.git", branch = "develop" }
|
||||
serde = { version = "~1.0", features = ["derive"] }
|
||||
#tokio = { version = "~0.2", features = ["macros", "rt-threaded", "stream", "time"] }
|
||||
tracing = { version = "~0.1" }
|
||||
tracing-subscriber = { version = "0.2.0-alpha", features = ["tracing-log"] }
|
||||
tracing-subscriber = { version = "~0.2.0", features = ["tracing-log"] }
|
||||
viperus = { git = "https://github.com/maurocordioli/viperus", features = ["cache", "fmt-clap", "fmt-env", "global", "watch"] }
|
||||
|
||||
[features]
|
||||
|
||||
@@ -2,13 +2,7 @@
|
||||
name = "advotracker"
|
||||
width = 580
|
||||
height = 280
|
||||
|
||||
assets = "resources/advotracker"
|
||||
[[apps.fonts]]
|
||||
font_family = "Material Icons"
|
||||
font_family = "MaterialIcons-Regular"
|
||||
src = "resources/fonts/MaterialIcons.ttf"
|
||||
[[apps.fonts]]
|
||||
font_family = "Roboto Regular"
|
||||
src = "resources/fonts/Roboto-Regular.ttf"
|
||||
[[apps.fonts]]
|
||||
font_family = "Roboto Medium"
|
||||
src = "resources/fonts/Roboto-Medium.ttf"
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
35
advotracker/resources/advotracker/advotracker_de_DE.ron
Normal file
35
advotracker/resources/advotracker/advotracker_de_DE.ron
Normal file
@@ -0,0 +1,35 @@
|
||||
// *
|
||||
// * advotracker - Hotline tackingtool for Advocats
|
||||
// *
|
||||
// * Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
// * SPDX-License-Identifier: (0BSD or MIT)
|
||||
// */
|
||||
|
||||
// the language class
|
||||
Dictionary (
|
||||
// the map of active identifiers
|
||||
// like a struct, but keys are also values instead of just beenig identifiers
|
||||
words: {
|
||||
// policycheck_view
|
||||
"Validation policy number": "Prüfung Versicherungsnummer",
|
||||
"Policy number": "Versicherungsnummer",
|
||||
"Policy code": "ID der Vers.-Nummer",
|
||||
"Checklist elements: ": "Prüflistenelemente: ",
|
||||
"Check result": "Prüfungsergebnis",
|
||||
"Importing data": "Importiere Datensätze",
|
||||
"Processing time": "Bearbeitungszeit",
|
||||
"Error:": "Fehler:",
|
||||
"Reason": "Grund",
|
||||
"Policy number is to long": "Die Nummer ist zu lang",
|
||||
"Policy number is to short": "Die Nummer ist zu kurz",
|
||||
"The given policy number is invalid": "Die Versicherungsnummer ist ungültig",
|
||||
"The given policy number is valid": "Die Versicherungsnummer ist gültig",
|
||||
"Only numbers are valid": "Nur Nummern sind zulässig",
|
||||
// localization
|
||||
"Hello": "Hallo",
|
||||
"User": "Anwender",
|
||||
"Localization dialog": "Lokalisierungs-Dialog",
|
||||
"German": "Deutsch",
|
||||
"English": "Englisch"
|
||||
}
|
||||
)
|
||||
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -1,32 +0,0 @@
|
||||
.header {
|
||||
background: #444e55;
|
||||
}
|
||||
|
||||
.content {
|
||||
background: #3b434a;
|
||||
}
|
||||
|
||||
text_box {
|
||||
background: transparent;
|
||||
border-width: 0;
|
||||
color: #9dafbf;
|
||||
font-size: 16;
|
||||
}
|
||||
|
||||
#input {
|
||||
font-size: 16;
|
||||
}
|
||||
|
||||
text-block {
|
||||
font-size: 42;
|
||||
color: #dfebf5;
|
||||
}
|
||||
|
||||
#input {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 1;
|
||||
font-size: 20;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
.header {
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.content {
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
text_box {
|
||||
color: #4d4c4c;
|
||||
}
|
||||
|
||||
text-block {
|
||||
color: #4d4c4c;
|
||||
}
|
||||
BIN
advotracker/resources/fonts/MaterialIcons.ttf
Normal file
BIN
advotracker/resources/fonts/MaterialIcons.ttf
Normal file
Binary file not shown.
@@ -1,25 +0,0 @@
|
||||
* {
|
||||
font-size: 24;
|
||||
}
|
||||
|
||||
lynch {
|
||||
background: #647b91;
|
||||
}
|
||||
|
||||
bluebayoux {
|
||||
background: #516475;
|
||||
}
|
||||
|
||||
linkwater {
|
||||
background: #dfebf5;
|
||||
color: #3b434a;
|
||||
}
|
||||
|
||||
light-text {
|
||||
color: #dfebf5;
|
||||
}
|
||||
|
||||
goldendream {
|
||||
background: #efd035;
|
||||
color: #3b434a;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 237 KiB |
@@ -1,25 +0,0 @@
|
||||
* {
|
||||
font-size: 24;
|
||||
}
|
||||
|
||||
lynch {
|
||||
background: #647b91;
|
||||
}
|
||||
|
||||
bluebayoux {
|
||||
background: #516475;
|
||||
}
|
||||
|
||||
linkwater {
|
||||
background: #dfebf5;
|
||||
color: #3b434a;
|
||||
}
|
||||
|
||||
light-text {
|
||||
color: #dfebf5;
|
||||
}
|
||||
|
||||
goldendream {
|
||||
background: #efd035;
|
||||
color: #3b434a;
|
||||
}
|
||||
@@ -1,113 +1,122 @@
|
||||
Theme (
|
||||
styles: {
|
||||
"button_menu": (
|
||||
base: "menu",
|
||||
properties: {
|
||||
"background": "transparent",
|
||||
//"background": "$GOLDEN_DREAM",
|
||||
//"background": "$LINK_WATER",
|
||||
//"border_brush": "$LINK_WATER",
|
||||
//"border_brush": "$GOLDEN_DREAM",
|
||||
"border_radius": 0,
|
||||
"border_width": 0,
|
||||
//"foreground": "$BRIGHT_GRAY",
|
||||
//"icon_brush": "$BRIGHT_GRAY",
|
||||
"font_size": "$ICON_SIZE_16",
|
||||
"h_align": "left",
|
||||
//"height": 14,
|
||||
"margin": (0, 4, 0, 0),
|
||||
//"padding": (8, 0, 8, 0),
|
||||
},
|
||||
),
|
||||
"container_menu": (
|
||||
properties: {
|
||||
"border_radius": 0,
|
||||
"border_width": 1,
|
||||
"background": "$BRIGHT_GRAY",
|
||||
"border_brush": "$LINK_WATER",
|
||||
//"border_brush": "$GOLDEN_DREAM",
|
||||
"padding": 4,
|
||||
},
|
||||
),
|
||||
"container_progress": (
|
||||
properties: {
|
||||
"border_radius": 3,
|
||||
"border_width": 1,
|
||||
"background": "$BRIGHT_GRAY",
|
||||
"border_brush": "$LINK_WATER",
|
||||
//"border_brush": "$GOLDEN_DREAM",
|
||||
"padding": 14,
|
||||
"h_align": "end"
|
||||
},
|
||||
),
|
||||
"container_form": (
|
||||
base: "container",
|
||||
properties: {
|
||||
"background": "$BRIGHT_GRAY",
|
||||
"border_brush": "$LINK_WATER",
|
||||
"border_radius": 3,
|
||||
"border_width": 1,
|
||||
"padding": 14,
|
||||
"v_align": "top",
|
||||
},
|
||||
),
|
||||
"header_bar": (
|
||||
base: "header",
|
||||
properties: {
|
||||
"foreground": "$LINK_WATER",
|
||||
},
|
||||
),
|
||||
"menu": (
|
||||
//base: "base",
|
||||
properties: {
|
||||
"font_size": 16,
|
||||
"font_family": "$MEDIUM_FONT",
|
||||
"background": "$BLACK",
|
||||
"opacity": 1,
|
||||
},
|
||||
states: {
|
||||
"pressed": {
|
||||
"background": "$WHITE",
|
||||
},
|
||||
},
|
||||
),
|
||||
"popup_progress": (
|
||||
base: "popup",
|
||||
properties: {
|
||||
//"h_align": "center",
|
||||
"width": 300,
|
||||
"heigth": 120,
|
||||
},
|
||||
),
|
||||
"stack_menu": (
|
||||
properties: {
|
||||
//"background": "transparent",
|
||||
"spacing": 2,
|
||||
"orientation": "vertical",
|
||||
"h_align": "left",
|
||||
},
|
||||
),
|
||||
"stack_progress": (
|
||||
properties: {
|
||||
//"background": "transparent",
|
||||
"spacing": 8,
|
||||
"margin": (16, 16, 16, 16),
|
||||
},
|
||||
),
|
||||
"textblock": (
|
||||
//base: "base",
|
||||
properties: {
|
||||
"font_size": "$ICON_SIZE_12",
|
||||
},
|
||||
),
|
||||
"textblock_progress": (
|
||||
base: "textblock",
|
||||
properties: {
|
||||
//"background": "transparent",
|
||||
//"font_size": 12,
|
||||
"h_align": "center",
|
||||
"v_align": "center",
|
||||
},
|
||||
),
|
||||
"button_menu": (
|
||||
base: "menu",
|
||||
properties: {
|
||||
"background": "transparent",
|
||||
//"background": "$GOLDEN_DREAM",
|
||||
//"background": "$LINK_WATER",
|
||||
//"border_brush": "$LINK_WATER",
|
||||
//"border_brush": "$GOLDEN_DREAM",
|
||||
"border_radius": 0,
|
||||
"border_width": 0,
|
||||
//"foreground": "$BRIGHT_GRAY",
|
||||
//"icon_brush": "$BRIGHT_GRAY",
|
||||
"font_size": "$ICON_SIZE_16",
|
||||
"h_align": "left",
|
||||
//"height": 14,
|
||||
"margin": (0, 4, 0, 0),
|
||||
//"padding": (8, 0, 8, 0),
|
||||
},
|
||||
),
|
||||
"container_menu": (
|
||||
properties: {
|
||||
"border_radius": 0,
|
||||
"border_width": 1,
|
||||
"background": "$BRIGHT_GRAY",
|
||||
"border_brush": "$LINK_WATER",
|
||||
//"border_brush": "$GOLDEN_DREAM",
|
||||
"padding": 4,
|
||||
},
|
||||
),
|
||||
"container_progress": (
|
||||
properties: {
|
||||
"border_radius": 3,
|
||||
"border_width": 1,
|
||||
"background": "$BRIGHT_GRAY",
|
||||
"border_brush": "$LINK_WATER",
|
||||
//"border_brush": "$GOLDEN_DREAM",
|
||||
"padding": 14,
|
||||
"h_align": "end"
|
||||
},
|
||||
),
|
||||
"container_form": (
|
||||
base: "container",
|
||||
properties: {
|
||||
"background": "$BRIGHT_GRAY",
|
||||
"border_brush": "$LINK_WATER",
|
||||
"border_radius": 3,
|
||||
"border_width": 1,
|
||||
"padding": 14,
|
||||
"v_align": "top",
|
||||
},
|
||||
),
|
||||
"header_bar": (
|
||||
base: "header",
|
||||
properties: {
|
||||
"foreground": "$LINK_WATER",
|
||||
},
|
||||
),
|
||||
"hint": (
|
||||
base: "body",
|
||||
properties: {
|
||||
"font_size": 11,
|
||||
"font_family": "$MEDIUM_FONT",
|
||||
"width": "250",
|
||||
"min_width": "250"
|
||||
},
|
||||
),
|
||||
"menu": (
|
||||
//base: "base",
|
||||
properties: {
|
||||
"font_size": 16,
|
||||
"font_family": "$MEDIUM_FONT",
|
||||
"background": "$BLACK",
|
||||
"opacity": 1,
|
||||
},
|
||||
states: {
|
||||
"pressed": {
|
||||
"background": "$WHITE",
|
||||
},
|
||||
},
|
||||
),
|
||||
"popup_progress": (
|
||||
base: "popup",
|
||||
properties: {
|
||||
//"h_align": "center",
|
||||
"width": 300,
|
||||
"heigth": 120,
|
||||
},
|
||||
),
|
||||
"stack_menu": (
|
||||
properties: {
|
||||
//"background": "transparent",
|
||||
"spacing": 2,
|
||||
"orientation": "vertical",
|
||||
"h_align": "left",
|
||||
},
|
||||
),
|
||||
"stack_progress": (
|
||||
properties: {
|
||||
//"background": "transparent",
|
||||
"spacing": 8,
|
||||
"margin": (16, 16, 16, 16),
|
||||
},
|
||||
),
|
||||
"textblock": (
|
||||
//base: "base",
|
||||
properties: {
|
||||
"font_size": "$ICON_SIZE_12",
|
||||
},
|
||||
),
|
||||
"textblock_progress": (
|
||||
base: "textblock",
|
||||
properties: {
|
||||
//"background": "transparent",
|
||||
//"font_size": 12,
|
||||
"h_align": "center",
|
||||
"v_align": "center",
|
||||
},
|
||||
),
|
||||
}
|
||||
)
|
||||
@@ -5,7 +5,10 @@
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use dotenv::dotenv;
|
||||
use serde::Deserialize;
|
||||
use std::env;
|
||||
use tracing::{info, trace};
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
@@ -23,33 +26,36 @@ struct Environment {
|
||||
rust_log: String,
|
||||
}
|
||||
|
||||
/// Provides generic methods to handle states of datatypes (e.g. used in `PolicyList`).
|
||||
/// Provides generic methods to handle states of datatypes.
|
||||
pub trait GlobalState {
|
||||
/// Navigates to the given entity.
|
||||
fn navigate(&self, to: Entity, ctx: &mut Context<'_>) {
|
||||
if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget {
|
||||
let mut old_focused_element = ctx.get_widget(old_focused_element);
|
||||
old_focused_element.set("focused", false);
|
||||
//old_focused_element.update_theme_by_state(false);
|
||||
/// Get the active language environment.
|
||||
fn get_lang() -> String {
|
||||
// get system environment
|
||||
let mut lang = env::var("LANG").unwrap_or("C".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) => { info!(target: "advotracker", "{}", e) }
|
||||
}
|
||||
ctx.window().get_mut::<Global>("global").focused_widget = None;
|
||||
ctx.widget().set("visibility", Visibility::Collapsed);
|
||||
ctx.get_widget(to).set("visibility", Visibility::Visible);
|
||||
trace!(target: "advotracker", lang = ?lang);
|
||||
lang
|
||||
}
|
||||
|
||||
/// Get the text of a widget.
|
||||
fn get_text(&self, ctx: &mut Context<'_>, entity: Entity) -> Option<String> {
|
||||
let mut widget = ctx.get_widget(entity);
|
||||
|
||||
let entry = widget.get_mut::<String>("text");
|
||||
if entry.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let copy = entry.to_string();
|
||||
entry.clear();
|
||||
Some(copy)
|
||||
}
|
||||
// /// Navigates to the given entity.
|
||||
// fn navigate(&self, to: Entity, ctx: &mut Context<'_>) {
|
||||
// if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget {
|
||||
// let mut old_focused_element = ctx.get_widget(old_focused_element);
|
||||
// old_focused_element.set("focused", false);
|
||||
// //old_focused_element.update_theme_by_state(false);
|
||||
// }
|
||||
// ctx.window().get_mut::<Global>("global").focused_widget = None;
|
||||
// ctx.widget().set("visibility", Visibility::Collapsed);
|
||||
// ctx.get_widget(to).set("visibility", Visibility::Visible);
|
||||
// }
|
||||
|
||||
/// Save the our data structure and convert it to `ron` file format.
|
||||
/// The cargo package identifier (here: 'nwx.advotracker') is taken to create the app directory.
|
||||
@@ -67,3 +73,9 @@ pub trait GlobalState {
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod tests {
|
||||
// #[test]
|
||||
// assert_eq!(2 + 2, 4);
|
||||
// }
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//use chrono::{Local, DateTime, Duration};
|
||||
use dotenv::dotenv;
|
||||
use locales::t;
|
||||
use orbtk::{
|
||||
prelude::*,
|
||||
@@ -15,10 +13,10 @@ use orbtk::theme::DARK_THEME_RON;
|
||||
use orbtk::theme::LIGHT_THEME_RON;
|
||||
|
||||
use serde::Deserialize;
|
||||
use std::{env, process};
|
||||
use std::process;
|
||||
use std::collections::HashMap;
|
||||
use std::time::{Duration, SystemTime};
|
||||
use tracing::{debug, error, info, trace};
|
||||
use tracing::{error, info, trace};
|
||||
|
||||
use crate::{
|
||||
callbacks::global_state::GlobalState,
|
||||
@@ -64,7 +62,7 @@ pub struct PolicyCheckState {
|
||||
duration: Duration,
|
||||
label_result: Entity,
|
||||
lang: String,
|
||||
last_focused: Option<Entity>,
|
||||
//last_focused: Option<Entity>,
|
||||
button_menu: Entity,
|
||||
menu: Entity,
|
||||
policy_data_count: u64,
|
||||
@@ -94,8 +92,7 @@ impl PolicyCheckState {
|
||||
pub fn create_hashmap(&mut self, _ctx: &mut Context<'_>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
trace!(target: "advotracker", create_hashmap = "started");
|
||||
|
||||
let res = t!("policy.string.label_policy_list", self.lang);
|
||||
let policy_list = PolicyList::new(res);
|
||||
let policy_list = PolicyList::new("policy list");
|
||||
trace!(target: "advotracker", policy_list = ?policy_list);
|
||||
|
||||
// create vector to hold imported data
|
||||
@@ -136,28 +133,12 @@ impl PolicyCheckState {
|
||||
TextBox::text_set(&mut ctx.widget(), String::from(""));
|
||||
}
|
||||
|
||||
/// Get the active language environment.
|
||||
pub fn get_lang() -> String {
|
||||
// get system environment
|
||||
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) => { info!(target: "advotracker", "{}", e) }
|
||||
}
|
||||
lang
|
||||
}
|
||||
|
||||
/// Import policy numbers into hashmap
|
||||
fn import_data(&mut self, ctx: &mut Context<'_>)
|
||||
-> Result<(), Box<dyn std::error::Error>> {
|
||||
// WIP: for now, only import once per session
|
||||
if self.policy_data_count == 0 {
|
||||
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true);
|
||||
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), true);
|
||||
|
||||
if self.policy_numbers.len() == 0 {
|
||||
// initialize popup widget
|
||||
@@ -216,25 +197,21 @@ impl PolicyCheckState {
|
||||
ctx: &mut Context<'_>) {
|
||||
trace!(target: "advotracker", parse_entry = "started");
|
||||
|
||||
//let policy_number_string = ctx.get_widget(policy_check_policy_number).get::<String16>("text").as_string();
|
||||
let policy_number_string = TextBox::text_clone(&mut ctx.get_widget(policy_check_policy_number));
|
||||
let policy_number_length = policy_number_string.len();
|
||||
|
||||
// // 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); }
|
||||
// }
|
||||
if self.policy_data_count == 0 {
|
||||
// Load data into hashmap
|
||||
match self.import_data(ctx) {
|
||||
Ok(()) => {
|
||||
trace!(target: "advotracker", policycheck_state = "init", import_data = "success");
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_DATA_STACK), Visibility::Visible);
|
||||
let policy_data_count_string = format!("{:?}", &self.policy_data_count);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_DATA_COUNT), String::from(&policy_data_count_string));
|
||||
},
|
||||
|
||||
// Load data into hashmap
|
||||
match self.import_data(ctx) {
|
||||
Ok(()) => trace!(target: "advotracker", policycheck_state = "init", import_data = "success"),
|
||||
Err(e) => trace!(target: "advotracker", policycheck_state = "init", import_data = ?e),
|
||||
Err(e) => trace!(target: "advotracker", policycheck_state = "init", import_data = ?e),
|
||||
}
|
||||
}
|
||||
|
||||
trace!(target: "advotracker", state = "parsing", policy_number = ?policy_number_string);
|
||||
@@ -242,15 +219,20 @@ impl PolicyCheckState {
|
||||
// Parse policy code: "AS-123456789"
|
||||
// DION VERS POLLFNR
|
||||
// 1 AS 1515735810
|
||||
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Collapsed);
|
||||
Button::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible);
|
||||
Button::background_set(&mut ctx.child("policy_check_button_result"), String::from("transparent"));
|
||||
//Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
//Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), Visibility::Collapsed);
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
||||
Button::background_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("transparent"));
|
||||
//Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Collapsed);
|
||||
|
||||
if policy_number_length == 10 {
|
||||
// cast policy_number_sting to <u64>
|
||||
match policy_number_string.parse::<u64>() {
|
||||
Ok(p) => {
|
||||
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(""));
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from(""));
|
||||
|
||||
// match hashmap's key
|
||||
match self.policy_numbers.get(&p) {
|
||||
@@ -258,62 +240,92 @@ impl PolicyCheckState {
|
||||
// matching key, get associated value
|
||||
trace!(target: "advotracker", state = "success",
|
||||
policy_number = ?p, policy_code = ?policy_code);
|
||||
|
||||
let string_result = format!("1-{:?}-{}",
|
||||
policy_code, p);
|
||||
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true);
|
||||
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(string_result));
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from(string_result));
|
||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#008000"));
|
||||
|
||||
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible);
|
||||
let res = t!("policy.validation.button_success", self.lang);
|
||||
Button::text_set(&mut ctx.child("policy_check_button_result"), String::from(res));
|
||||
Button::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible);
|
||||
Button::icon_set(&mut ctx.child("policy_check_button_result"), material_icons_font::MD_CHECK);
|
||||
Button::icon_brush_set(&mut ctx.child("policy_check_button_result"), String::from("#008000"));
|
||||
Button::foreground_set(&mut ctx.child("policy_check_button_result"), String::from("#008000"));
|
||||
Button::background_set(&mut ctx.child("policy_check_button_result"), String::from("transparent"));
|
||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
|
||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CHECK);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Visible);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
|
||||
}
|
||||
_ => {
|
||||
// no matching key
|
||||
let res = t!("policy.validation.failed", self.lang);
|
||||
trace!(target: "advotracker", state = ?res, policy_number = ?p);
|
||||
|
||||
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible);
|
||||
let res = t!("policy.validation.button_failed", self.lang);
|
||||
Button::text_set(&mut ctx.child("policy_check_button_result"), String::from(res));
|
||||
Button::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible);
|
||||
Button::icon_set(&mut ctx.child("policy_check_button_result"), material_icons_font::MD_CLEAR);
|
||||
Button::icon_brush_set(&mut ctx.child("policy_check_button_result"), String::from("#FF0000"));
|
||||
Button::foreground_set(&mut ctx.child("policy_check_button_result"), String::from("#FF0000"));
|
||||
let res = t!("policy.validation.not_found", self.lang);
|
||||
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(res));
|
||||
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible);
|
||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("The given policy number is invalid"));
|
||||
|
||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
trace!(target: "advotracker", state = "error", error_type = "invalid type", error = ?e);
|
||||
|
||||
Button::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible);
|
||||
Button::icon_set(&mut ctx.child("policy_check_button_result"), material_icons_font::MD_CLEAR);
|
||||
Button::icon_brush_set(&mut ctx.child("policy_check_button_result"), String::from("#FF0000"));
|
||||
Button::foreground_set(&mut ctx.child("policy_check_button_result"), String::from("#FF0000"));
|
||||
let res = t!("policy.validation.invalid_input", self.lang);
|
||||
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(res));
|
||||
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true);
|
||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
||||
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("Only numbers are valid"));
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||
|
||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
if policy_number_length < 10 {
|
||||
let res = t!("policy.validation.to_short", self.lang);
|
||||
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(res));
|
||||
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true);
|
||||
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible);
|
||||
let res = t!("policy.validation.failed", self.lang);
|
||||
trace!(target: "advotracker", state = ?res, reason = "number to short");
|
||||
|
||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
||||
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("Policy number is to short"));
|
||||
|
||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
|
||||
}
|
||||
if policy_number_length > 10 {
|
||||
let res = t!("policy.validation.to_long", self.lang);
|
||||
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(res));
|
||||
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true);
|
||||
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible);
|
||||
let res = t!("policy.validation.failed", self.lang);
|
||||
trace!(target: "advotracker", state = ?res, reason = "number to long");
|
||||
|
||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
||||
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("Policy number is to long"));
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||
|
||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
|
||||
}
|
||||
|
||||
trace!(target: "advotracker", parse_entry = "finished");
|
||||
@@ -342,11 +354,11 @@ impl PolicyCheckState {
|
||||
/// Change status of given text box to edit mode.
|
||||
fn set_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) {
|
||||
if ctx.get_widget(text_box).get::<String16>("text").is_empty() {
|
||||
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Collapsed);
|
||||
} else {
|
||||
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,13 +371,6 @@ impl PolicyCheckState {
|
||||
self.menu = create_menu(current_entity, build_context);
|
||||
let _menu = build_context.append_child_to_overlay(self.menu)
|
||||
.expect("PolicyCheckState: Can't create overlay as child of entity");
|
||||
|
||||
let label_account = t!("policy.menu.label_account", self.lang);
|
||||
Button::text_set(&mut ctx.child(ID_POLICY_CHECK_MENU_LABEL_ACCOUNT), String::from(label_account));
|
||||
let label_quit = t!("policy.menu.label_quit", self.lang);
|
||||
Button::text_set(&mut ctx.child(ID_POLICY_CHECK_MENU_LABEL_QUIT), String::from(label_quit));
|
||||
let label_toggle_theme = t!("policy.menu.label_toggle_theme", self.lang);
|
||||
Button::text_set(&mut ctx.child(ID_POLICY_CHECK_MENU_LABEL_TOGGLE_THEME), String::from(label_toggle_theme));
|
||||
}
|
||||
|
||||
/// Set a progress popup that updates the import status in a progress bar
|
||||
@@ -377,8 +382,7 @@ impl PolicyCheckState {
|
||||
let current_entity = ctx.entity;
|
||||
let build_context = &mut ctx.build_context();
|
||||
|
||||
let res = t!("policy.string.progress_text", self.lang);
|
||||
self.progress_popup = create_popup_progress(current_entity, &res, build_context);
|
||||
self.progress_popup = create_popup_progress(current_entity, build_context);
|
||||
|
||||
// create a progress_popup widget as a child of entity "ID_POLICY_CHECK_POLICY_NUMBER"
|
||||
build_context.append_child(stack, self.progress_popup);
|
||||
@@ -460,30 +464,15 @@ impl State for PolicyCheckState {
|
||||
.entity_of_child(ID_POLICY_CHECK_LABEL_RESULT)
|
||||
.expect("PolicyCheckState.init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'.");
|
||||
|
||||
// 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); }
|
||||
}
|
||||
self.lang = lang;
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
//Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_0), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
|
||||
|
||||
// Constants
|
||||
let res = t!("policy.string.header", self.lang);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HEADER), String::from(res));
|
||||
|
||||
let res = t!("policy.string.label_policy_number", self.lang);
|
||||
let string_label_policy_number = format!("{}:", res);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_POLICY_NUMBER), String::from(string_label_policy_number));
|
||||
|
||||
let res = t!("policy.string.label_result", self.lang);
|
||||
let string_label_result = format!("{}:", res);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), String::from(string_label_result));
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
// Preset localization with given environment lang
|
||||
self.lang = PolicyCheckState::get_lang();
|
||||
ctx.set_language(&self.lang);
|
||||
|
||||
// // 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
|
||||
@@ -505,15 +494,15 @@ impl State for PolicyCheckState {
|
||||
|
||||
/// Update the widget state.
|
||||
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);
|
||||
}
|
||||
}
|
||||
// // 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);
|
||||
// }
|
||||
//}
|
||||
|
||||
if let Some(action) = self.action {
|
||||
match action {
|
||||
@@ -605,23 +594,10 @@ impl State for PolicyCheckState {
|
||||
self.action = None;
|
||||
}
|
||||
|
||||
/// Update the view after the layout is rendered.
|
||||
fn update_post_layout(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
// 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); }
|
||||
}
|
||||
// /// Update the view after the layout is rendered.
|
||||
// fn update_post_layout(&mut self, _: &mut Registry, _ctx: &mut Context<'_>) {
|
||||
// }
|
||||
|
||||
let res = t!("policy.string.data_count", lang);
|
||||
let string_data_count = format!("{}: {:?}", res, self.policy_numbers.len());
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_DATA_COUNT_BLOCK), String::from(string_data_count));
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a menu popup
|
||||
@@ -708,7 +684,7 @@ fn create_menu(menu: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
}
|
||||
|
||||
/// Create a progress popup with update status of an onging data import
|
||||
fn create_popup_progress(target: Entity, text: &str, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
fn create_popup_progress(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
Popup::new()
|
||||
.id(ID_POLICY_CHECK_POPUP_PROGRESS)
|
||||
.target(target)
|
||||
@@ -725,14 +701,15 @@ fn create_popup_progress(target: Entity, text: &str, ctx: &mut BuildContext<'_>)
|
||||
.child(
|
||||
Container::new()
|
||||
.style("container_progress")
|
||||
.child( Stack::new()
|
||||
.child(
|
||||
Stack::new()
|
||||
.style("stack_progress")
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_PROGRESS_TEXT)
|
||||
//.style("textblock_progress")
|
||||
.font_size(12)
|
||||
.text(text)
|
||||
.text("Importing data")
|
||||
.build(ctx)
|
||||
)
|
||||
.child(
|
||||
@@ -748,6 +725,7 @@ fn create_popup_progress(target: Entity, text: &str, ctx: &mut BuildContext<'_>)
|
||||
//.style("textblock_progress")
|
||||
.h_align("end")
|
||||
.font_size(12)
|
||||
.text("Processing time")
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx)
|
||||
|
||||
@@ -16,11 +16,16 @@ pub static STYLE_STACK_MENU: &'static str = "stack_menu";
|
||||
|
||||
// Widget IDs (DCES: Entity[id] => [Component1, .. , Component<n>] -> data or state)
|
||||
pub static ID_POLICY_CHECK_FORM: &'static str = "policy_check_form";
|
||||
pub static ID_POLICY_CHECK_FORM_ROW_0: &'static str = "policy_check_form_row_0";
|
||||
pub static ID_POLICY_CHECK_FORM_ROW_1: &'static str = "policy_check_form_row_1";
|
||||
pub static ID_POLICY_CHECK_FORM_ROW_2: &'static str = "policy_check_form_row_2";
|
||||
pub static ID_POLICY_CHECK_HEADER: &'static str = "policy_check_header";
|
||||
pub static ID_POLICY_CHECK_ITEMS_WIDGET: &'static str = "policy_check_items_widget";
|
||||
pub static ID_POLICY_CHECK_BUTTON_RESULT: &'static str = "policy_check_button_result";
|
||||
pub static ID_POLICY_CHECK_BUTTON_MENU: &'static str = "policy_check_button_menu";
|
||||
pub static ID_POLICY_CHECK_DATA_COUNT_BLOCK: &'static str = "policy_check_data_count_block";
|
||||
pub static ID_POLICY_CHECK_HINT: &'static str = "policy_check_hint";
|
||||
pub static ID_POLICY_CHECK_LABEL_HINT: &'static str = "policy_check_label_hint";
|
||||
pub static ID_POLICY_CHECK_LABEL_MENU: &'static str = "policy_check_label_menu";
|
||||
pub static ID_POLICY_CHECK_LABEL_POLICY_NUMBER: &'static str = "policy_check_label_policy_number";
|
||||
pub static ID_POLICY_CHECK_LABEL_RESULT: &'static str = "policy_check_label_result";
|
||||
@@ -39,12 +44,14 @@ pub static ID_POLICY_CHECK_RESULT: &'static str = "policy_check_result";
|
||||
pub static ID_POLICY_CHECK_WIDGET: &'static str = "policy_check_widget";
|
||||
|
||||
pub static ID_POLICY_DATA_ADD_BUTTON: &'static str = "policy_data_add_button";
|
||||
pub static ID_POLICY_DATA_COUNT_BLOCK: &'static str = "policy_data_count_block";
|
||||
pub static ID_POLICY_DATA_COUNT: &'static str = "policy_data_count";
|
||||
pub static ID_POLICY_DATA_LABEL: &'static str = "policy_data_label";
|
||||
pub static ID_POLICY_DATA_ITEMS_WIDGET: &'static str = "policy_data_items_widget";
|
||||
pub static ID_POLICY_DATA_DATE_INSERTED: &'static str = "policy_data_date_inserted";
|
||||
pub static ID_POLICY_DATA_DION: &'static str = "policy_data_dion";
|
||||
pub static ID_POLICY_DATA_POLICY_CODE: &'static str = "policy_data_policy_code";
|
||||
pub static ID_POLICY_DATA_POLICY_NUMBER: &'static str = "policy_data_policy_number";
|
||||
pub static ID_POLICY_DATA_STACK: &'static str = "policy_data_stack";
|
||||
pub static ID_POLICY_DATA_STATUS: &'static str = "policy_data_status";
|
||||
pub static ID_POLICY_DATA_LIST_NAME: &'static str = "policy_data_list_name";
|
||||
|
||||
|
||||
@@ -1,238 +1,238 @@
|
||||
{
|
||||
"err.lang.not_found": {
|
||||
"de_DE.UTF-8": "Konnte Sprachkode nicht auslesen",
|
||||
"de": "Konnte Sprachkode nicht auslesen",
|
||||
"en": "Couldn't read LANG"
|
||||
"de_DE": "Konnte Sprachkode nicht auslesen",
|
||||
"C": "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"
|
||||
"de_DE.UTF-8": "Anwender nicht gefunden: $email, $id",
|
||||
"de_DE": "Anwender nicht gefunden: $email, $id",
|
||||
"C": "User not found: $email, $id"
|
||||
},
|
||||
"main.started": {
|
||||
"de_DE.UTF-8": "Programmlogik starten",
|
||||
"de": "Programmlogik starten",
|
||||
"en": "Program logic started"
|
||||
"de_DE": "Programmlogik starten",
|
||||
"C": "Program logic started"
|
||||
},
|
||||
"main.finished": {
|
||||
"de_DE.UTF-8": "Programmlogik beendet",
|
||||
"de": "Programmlogik beendet",
|
||||
"en": "Program logic finished"
|
||||
"de_DE": "Programmlogik beendet",
|
||||
"C": "Program logic finished"
|
||||
},
|
||||
"parse.arguments": {
|
||||
"de_DE.UTF-8": "Programmargumente prüfen",
|
||||
"de": "Programmargumente prüfen",
|
||||
"en": "Parsing arguments"
|
||||
"de_DE": "Programmargumente prüfen",
|
||||
"C": "Parsing arguments"
|
||||
},
|
||||
"parse.environment": {
|
||||
"de_DE.UTF-8": "Umgebungsvariablen prüfen",
|
||||
"de": "Umgebungsvariablen prüfen",
|
||||
"en": "Parsing environment"
|
||||
"de_DE": "Umgebungsvariablen prüfen",
|
||||
"C": "Parsing environment"
|
||||
},
|
||||
"parse.results": {
|
||||
"de_DE.UTF-8": "Ergebnisse der Konfigurations-Parameterprüfung",
|
||||
"de": "Ergebnisse der Konfigurationsparameterprüfung",
|
||||
"en": "Config parsing results"
|
||||
"de_DE": "Ergebnisse der Konfigurationsparameterprüfung",
|
||||
"C": "Config parsing results"
|
||||
},
|
||||
"config.name": {
|
||||
"de_DE.UTF-8": "Konfigurationswert für",
|
||||
"de": "Konfigurationswert für",
|
||||
"en": "Config Value for"
|
||||
"de_DE": "Konfigurationswert für",
|
||||
"C": "Config Value for"
|
||||
},
|
||||
"config.name.lang": {
|
||||
"de_DE.UTF-8": "Sprach-Code",
|
||||
"de": "Sprach-Code",
|
||||
"en": "Language code"
|
||||
"de_DE.UTF-8": "Sprach-Code_DE",
|
||||
"de_DE": "Sprach-Code_DE",
|
||||
"C": "Language code_DE"
|
||||
},
|
||||
"config.name.verbositylevel": {
|
||||
"de_DE.UTF-8": "Ausgabe-Ebene",
|
||||
"de": "Ausgabe-Ebene",
|
||||
"en": "verbosity level"
|
||||
"de_DE": "Ausgabe-Ebene",
|
||||
"C": "verbosity level"
|
||||
},
|
||||
"config.name.environment": {
|
||||
"de_DE.UTF-8": "Umgebungsvariablen",
|
||||
"de": "Umgebungsvariablen",
|
||||
"en": "environment"
|
||||
"de_DE": "Umgebungsvariablen",
|
||||
"C": "environment"
|
||||
},
|
||||
"config.name.configfile": {
|
||||
"de_DE.UTF-8": "Konfigurations-Datei",
|
||||
"de": "Konfigurations-Datei",
|
||||
"en": "config file"
|
||||
"de_DE": "Konfigurations-Datei",
|
||||
"C": "config file"
|
||||
},
|
||||
"config.name.dbdriver": {
|
||||
"de_DE.UTF-8": "Datenbank-Treiber",
|
||||
"de": "Datenbank-Treiber",
|
||||
"en": "database driver"
|
||||
"de_DE": "Datenbank-Treiber",
|
||||
"C": "database driver"
|
||||
},
|
||||
"config.name.redis": {
|
||||
"de_DE.UTF-8": "Redis Datenbank",
|
||||
"de": "Redis Datenbank",
|
||||
"en": "Redis database"
|
||||
"de_DE": "Redis Datenbank",
|
||||
"C": "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"
|
||||
"de_DE": "Export in eine CSV Datei starten",
|
||||
"C": "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"
|
||||
"de_DE": "Export in eine CSV Datei beendet",
|
||||
"C": "Export to csv file finished"
|
||||
},
|
||||
"csv.import.started": {
|
||||
"de_DE.UTF-8": "Import aus einer CSV Datei",
|
||||
"de": "Import aus einer CSV Datei",
|
||||
"en": "Import from a csv file"
|
||||
"de_DE": "Import aus einer CSV Datei",
|
||||
"C": "Import from a csv file"
|
||||
},
|
||||
"csv.import.finished": {
|
||||
"de_DE.UTF-8": "Import aus einer CSV Datei beendet",
|
||||
"de": "Import aus einer CSV Datei beendet",
|
||||
"en": "Import from a csv file finished"
|
||||
"de_DE": "Import aus einer CSV Datei beendet",
|
||||
"C": "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"
|
||||
"de_DE": "Es konnte keine Redis Verbindung aufgebaut werden",
|
||||
"C": "Could not establish a redis connection"
|
||||
},
|
||||
"policy.hashmap.success": {
|
||||
"de_DE.UTF-8": "Hashmap wurde erfolgreich erstellt",
|
||||
"de": "Hashmap wurde erfolgreich erstellt",
|
||||
"en": "Hashmap creation was successfull"
|
||||
"de_DE": "Hashmap wurde erfolgreich erstellt",
|
||||
"C": "Hashmap creation was successfull"
|
||||
},
|
||||
"policy.hashmap.failed": {
|
||||
"de_DE.UTF-8": "Hashmap konnte nicht erstellt werden",
|
||||
"de": "Hashmap konnte nicht erstellt werden",
|
||||
"en": "Hashmap creation failed"
|
||||
"de_DE": "Hashmap konnte nicht erstellt werden",
|
||||
"C": "Hashmap creation failed"
|
||||
},
|
||||
"policy.menu.label": {
|
||||
"de_DE.UTF-8": "Menü",
|
||||
"de": "Menü",
|
||||
"en": "Menu"
|
||||
"de_DE": "Menü",
|
||||
"C": "Menu"
|
||||
},
|
||||
"policy.menu.label_account": {
|
||||
"de_DE.UTF-8": "Aktueller Benutzer",
|
||||
"de": "Aktueller Benutzer",
|
||||
"en": "Active user"
|
||||
"de_DE": "Aktueller Benutzer",
|
||||
"C": "Active user"
|
||||
},
|
||||
"policy.menu.label_quit": {
|
||||
"de_DE.UTF-8": "Beenden",
|
||||
"de": "Beenden",
|
||||
"en": "Quit"
|
||||
"de_DE": "Beenden",
|
||||
"C": "Quit"
|
||||
},
|
||||
"policy.menu.label_toggle_theme": {
|
||||
"de_DE.UTF-8": "Thema wechseln",
|
||||
"de": "Thema wechseln",
|
||||
"en": "Toggle theme"
|
||||
"de_DE": "Thema wechseln",
|
||||
"C": "Toggle theme"
|
||||
},
|
||||
"policy.string.header": {
|
||||
"de_DE.UTF-8": "Validierung Versicherungsnummer",
|
||||
"de": "Validierung Versicherungsnummer",
|
||||
"en": "Policy number validation"
|
||||
"de_DE": "Validierung Versicherungsnummer",
|
||||
"C": "Policy number validation"
|
||||
},
|
||||
"policy.string.label_policy_data": {
|
||||
"de_DE.UTF-8": "Importierte Daten",
|
||||
"de": "Importierte Daten",
|
||||
"en": "imported data"
|
||||
"de_DE": "Importierte Daten",
|
||||
"C": "imported data"
|
||||
},
|
||||
"policy.string.label_policy_list": {
|
||||
"de_DE.UTF-8": "Versicherungsnummern-Liste",
|
||||
"de": "Versicherungsnummern-Liste",
|
||||
"en": "policy list"
|
||||
"de_DE": "Versicherungsnummern-Liste",
|
||||
"C": "policy list"
|
||||
},
|
||||
"policy.string.label_policy_number": {
|
||||
"de_DE.UTF-8": "Versicherungsnummer",
|
||||
"de": "Versicherungsnummer",
|
||||
"en": "policy number"
|
||||
"de_DE": "Versicherungsnummer",
|
||||
"C": "policy number"
|
||||
},
|
||||
"policy.string.label_result": {
|
||||
"de_DE.UTF-8": "Prüfungsergebnis",
|
||||
"de": "Prüfungsergebnis",
|
||||
"en": "check result"
|
||||
"de_DE": "Prüfungsergebnis",
|
||||
"C": "check result"
|
||||
},
|
||||
"policy.string.data_count": {
|
||||
"de_DE.UTF-8": "Anzahl Prüflistenelemente",
|
||||
"de": "Anzahl Prüflistenelemente",
|
||||
"en": "Number of checklist elements"
|
||||
"de_DE": "Anzahl Prüflistenelemente",
|
||||
"C": "Number of checklist elements"
|
||||
},
|
||||
"policy.string.import_data": {
|
||||
"de_DE.UTF-8": "Importieren der Prüflisten-Elemente",
|
||||
"de": "Importieren der Prüflisten-Elemente",
|
||||
"en": "Import checklist elements"
|
||||
"de_DE": "Importieren der Prüflisten-Elemente",
|
||||
"C": "Import checklist elements"
|
||||
},
|
||||
"policy.string.progress_time": {
|
||||
"de_DE.UTF-8": "Bearbeitungszeit",
|
||||
"de": "Bearbeitungszeit",
|
||||
"en": "processing time"
|
||||
"de_DE": "Bearbeitungszeit",
|
||||
"C": "processing time"
|
||||
},
|
||||
"policy.string.progress_text": {
|
||||
"de_DE.UTF-8": "Importiere Daten",
|
||||
"de": "Importiere Daten",
|
||||
"en": "Importing data"
|
||||
"de_DE": "Importiere Daten",
|
||||
"C": "Importing data"
|
||||
},
|
||||
"policy.validation.button_failed": {
|
||||
"de_DE.UTF-8": "ungültig",
|
||||
"de": "ungültig",
|
||||
"en": "invalid"
|
||||
"de_DE": "ungültig",
|
||||
"C": "invalid"
|
||||
},
|
||||
"policy.validation.button_success": {
|
||||
"de_DE.UTF-8": "gültig",
|
||||
"de": "gültig",
|
||||
"en": "valid"
|
||||
"de_DE": "gültig",
|
||||
"C": "valid"
|
||||
},
|
||||
"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"
|
||||
"de_DE": "Die Versicherungsscheinnummber ist ungültig",
|
||||
"C": "The given policy number is invalid"
|
||||
},
|
||||
"policy.validation.new": {
|
||||
"de_DE.UTF-8": "Neue Prüfung",
|
||||
"de": "Neue Prüfung",
|
||||
"en": "New validation"
|
||||
"de_DE": "Neue Prüfung",
|
||||
"C": "New validation"
|
||||
},
|
||||
"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"
|
||||
"de_DE": "Die Versicherungsscheinnummber ist gültig",
|
||||
"C": "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"
|
||||
"de_DE": "Die Prüfung der Versicherungsscheinnummber wurde gestartet",
|
||||
"C": "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"
|
||||
"de_DE": "Die Prüfung der Versicherungsscheinnummber wurde beendet",
|
||||
"C": "Validation of the policy number finished"
|
||||
},
|
||||
"policy.validation.invalid_input": {
|
||||
"de_DE.UTF-8": "Nur Nummer sind zulässig",
|
||||
"de": "Nur Nummer sind zulässig",
|
||||
"en": "only numbers are valid"
|
||||
"de_DE": "Nur Nummer sind zulässig",
|
||||
"C": "Only numbers are valid"
|
||||
},
|
||||
"policy.validation.not_found": {
|
||||
"de_DE.UTF-8": "Nummer ist nicht aktiviert",
|
||||
"de": "Nummer ist nicht aktiviert",
|
||||
"en": "number isn't marked active"
|
||||
"de_DE": "Nummer ist nicht aktiviert",
|
||||
"C": "number isn't marked active"
|
||||
},
|
||||
"policy.validation.to_long": {
|
||||
"de_DE.UTF-8": "Die Nummer ist zu lang",
|
||||
"de": "Die Nummer ist zu lang",
|
||||
"en": "Policy number is to long"
|
||||
"de_DE": "Die Nummer ist zu lang",
|
||||
"C": "Policy number is to long"
|
||||
},
|
||||
"policy.validation.to_short": {
|
||||
"de_DE.UTF-8": "Die Nummer ist zu kurz",
|
||||
"de": "Die Nummer ist zu kurz",
|
||||
"en": "Policy number is to short"
|
||||
"de_DE": "Die Nummer ist zu kurz",
|
||||
"C": "Policy number is to short"
|
||||
},
|
||||
"state.started": {
|
||||
"de_DE.UTF-8": "gestartet",
|
||||
"de": "gestartet",
|
||||
"en": "started"
|
||||
"de_DE": "gestartet",
|
||||
"C": "started"
|
||||
},
|
||||
"state.finished": {
|
||||
"de_DE.UTF-8": "beendet",
|
||||
"de": "beended",
|
||||
"en": "finished"
|
||||
"de_DE": "beended",
|
||||
"C": "finished"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,208 +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 aus einer CSV Datei",
|
||||
"de": "Import aus einer CSV Datei",
|
||||
"en": "Import from a csv file"
|
||||
},
|
||||
"csv.import.finished": {
|
||||
"de_DE.UTF-8": "Import aus einer CSV Datei beendet",
|
||||
"de": "Import aus 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.hashmap.success": {
|
||||
"de_DE.UTF-8": "Hashmap wurde erfolgreich erstellt",
|
||||
"de": "Hashmap wurde erfolgreich erstellt",
|
||||
"en": "Hashmap creation was successfull"
|
||||
},
|
||||
"policy.hashmap.failed": {
|
||||
"de_DE.UTF-8": "Hashmap konnte nicht erstellt werden",
|
||||
"de": "Hashmap konnte nicht erstellt werden",
|
||||
"en": "Hashmap creation failed"
|
||||
},
|
||||
"policy.string.header": {
|
||||
"de_DE.UTF-8": "Validierung Versicherungsnummer",
|
||||
"de": "Validierung Versicherungsnummer",
|
||||
"en": "Policy number validation"
|
||||
},
|
||||
"policy.string.label_policy_number": {
|
||||
"de_DE.UTF-8": "Versicherungsnummer",
|
||||
"de": "Versicherungsnummer",
|
||||
"en": "policy number"
|
||||
},
|
||||
"policy.string.label_result": {
|
||||
"de_DE.UTF-8": "Prüfungsergebnis",
|
||||
"de": "Prüfungsergebnis",
|
||||
"en": "check result"
|
||||
},
|
||||
"policy.string.data_count": {
|
||||
"de_DE.UTF-8": "Anzahl Prüflistenelemente",
|
||||
"de": "Anzahl Prüflistenelemente",
|
||||
"en": "Number of checklist elements"
|
||||
},
|
||||
"policy.string.import_data": {
|
||||
"de_DE.UTF-8": "Importieren der Prüflisten-Elemente",
|
||||
"de": "Importieren der Prüflisten-Elemente",
|
||||
"en": "Import checklist elements"
|
||||
},
|
||||
"policy.string.progress_time": {
|
||||
"de_DE.UTF-8": "Bearbeitungszeit",
|
||||
"de": "Bearbeitungszeit",
|
||||
"en": "processing time"
|
||||
},
|
||||
"policy.string.progress_text": {
|
||||
"de_DE.UTF-8": "Importiere Daten",
|
||||
"de": "Importiere Daten",
|
||||
"en": "Importing data"
|
||||
},
|
||||
"policy.validation.button_failed": {
|
||||
"de_DE.UTF-8": "ungültig",
|
||||
"de": "ungültig",
|
||||
"en": "invalid"
|
||||
},
|
||||
"policy.validation.button_success": {
|
||||
"de_DE.UTF-8": "gültig",
|
||||
"de": "gültig",
|
||||
"en": "valid"
|
||||
},
|
||||
"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.new": {
|
||||
"de_DE.UTF-8": "Neue Prüfung",
|
||||
"de": "Neue Prüfung",
|
||||
"en": "New validation"
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"policy.validation.invalid_input": {
|
||||
"de_DE.UTF-8": "Nur Nummer sind zulässig",
|
||||
"de": "Nur Nummer sind zulässig",
|
||||
"en": "only numbers are valid"
|
||||
},
|
||||
"policy.validation.not_found": {
|
||||
"de_DE.UTF-8": "Nummer ist nicht aktiviert",
|
||||
"de": "Nummer ist nicht aktiviert",
|
||||
"en": "number isn't marked active"
|
||||
},
|
||||
"policy.validation.to_long": {
|
||||
"de_DE.UTF-8": "Die Nummer ist zu lang",
|
||||
"de": "Die Nummer ist zu lang",
|
||||
"en": "Policy number is to long"
|
||||
},
|
||||
"policy.validation.to_short": {
|
||||
"de_DE.UTF-8": "Die Nummer ist zu kurz",
|
||||
"de": "Die Nummer ist zu kurz",
|
||||
"en": "Policy number is to short"
|
||||
},
|
||||
"state.started": {
|
||||
"de_DE.UTF-8": "gestartet",
|
||||
"de": "gestartet",
|
||||
"en": "started"
|
||||
},
|
||||
"state.finished": {
|
||||
"de_DE.UTF-8": "beendet",
|
||||
"de": "beended",
|
||||
"en": "finished"
|
||||
}
|
||||
}
|
||||
@@ -12,18 +12,19 @@
|
||||
//extern crate lazy_static;
|
||||
|
||||
//use chrono::{Local, DateTime};
|
||||
use dotenv::dotenv;
|
||||
use locales::t;
|
||||
use serde::Deserialize;
|
||||
//use std::env;
|
||||
use std::env;
|
||||
//use std::process;
|
||||
use tracing::{trace, Level};
|
||||
use tracing::{info, trace, Level};
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
// The Main view
|
||||
use advotracker::{
|
||||
widgets::main_view,
|
||||
callbacks::policycheck_state::PolicyCheckState,
|
||||
widgets::main_view,
|
||||
};
|
||||
|
||||
mod parse_args;
|
||||
@@ -33,10 +34,31 @@ mod parse_args;
|
||||
/// this is primarily used in testing scenarios (eg. debugging)
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Environment {
|
||||
lang: String,
|
||||
test_lang: String,
|
||||
rust_log: String,
|
||||
}
|
||||
|
||||
// German localization file.
|
||||
static ADVOTRACKER_DE_DE: &str = include_str!("../resources/advotracker/advotracker_de_DE.ron");
|
||||
|
||||
/// Get the active language environment.
|
||||
fn get_lang() -> String {
|
||||
// get system environment
|
||||
let mut lang = env::var("LANG").unwrap_or("C".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) => { info!(target: "advotracker", "{}", e) }
|
||||
}
|
||||
trace!(target: "advotracker", lang = ?lang);
|
||||
lang
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
use parse_args::parse_args;
|
||||
use tracing_subscriber::fmt;
|
||||
@@ -66,7 +88,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
tracing::subscriber::with_default(subscriber, || {
|
||||
// get system environment
|
||||
let lang = PolicyCheckState::get_lang();
|
||||
let lang = get_lang();
|
||||
|
||||
let mut state = t!("state.started", lang);
|
||||
let mut res = t!("parse.environment", lang);
|
||||
@@ -74,7 +96,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
trace!(target: "advotracker", environment = "system", lang = ?lang);
|
||||
trace!(target: "advotracker", machine = ?&machine_kind);
|
||||
|
||||
// how to handle unumplemented lang resources??
|
||||
// how to handle unimplemented lang resources??
|
||||
res = t!("parse.environment", lang);
|
||||
trace!(target: "advotracker", environment = "envy", lang = ?lang);
|
||||
state = t!("state.finished", lang);
|
||||
@@ -100,8 +122,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// use this only if you want to run it as web application.
|
||||
orbtk::initialize();
|
||||
|
||||
// if no dictionary is set for the default language e.g. english the content of the text property will drawn.
|
||||
let localization = RonLocalization::create()
|
||||
.language("en_US")
|
||||
.dictionary("de_DE", ADVOTRACKER_DE_DE)
|
||||
.build();
|
||||
|
||||
Application::from_name("nwx.advotracker")
|
||||
.theme(PolicyCheckState::theme())
|
||||
.localization(localization)
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
.title("AdvoTracker - DirectCall")
|
||||
|
||||
@@ -24,7 +24,7 @@ pub fn export(p: &mut String, lang: &String) -> Result<(), Box<dyn Error>> {
|
||||
|
||||
let mut res = t!("csv.export.started", lang);
|
||||
let mut state = t!("state.started", lang);
|
||||
trace!(target: "advotrackerd", process = ?res, state = ?state);
|
||||
trace!(target: "csv-export", process = ?res, state = ?state);
|
||||
|
||||
// Note: slash syntax also works on Windows!
|
||||
let path = Path::new(p);
|
||||
|
||||
@@ -34,13 +34,13 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
||||
let time_start = SystemTime::now();
|
||||
let datetime: DateTime<Local> = time_start.into();
|
||||
|
||||
trace!(target: "advotrackerd", process = ?res, state = ?state, date_start = ?datetime.to_string());
|
||||
trace!(target: "csv-import", process = ?res, state = ?state, date_start = ?datetime.to_string());
|
||||
|
||||
// Note: slash syntax also works on Windows!
|
||||
let path = Path::new(p);
|
||||
|
||||
// must be a readable file
|
||||
trace!(target: "advotrackerd", path = ?path);
|
||||
trace!(target: "csv-import", path = ?path);
|
||||
assert_eq!(path.is_file(), true);
|
||||
|
||||
// only accept files with '.txt' extensions
|
||||
@@ -49,7 +49,7 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
||||
|
||||
// open the file
|
||||
let file = File::open(path)?;
|
||||
trace!(target: "advotrackerd", extension = ?extension, file = ?file);
|
||||
trace!(target: "csv-import", extension = ?extension, file = ?file);
|
||||
|
||||
// Build the CSV reader
|
||||
let mut csv_reader = csv::ReaderBuilder::new()
|
||||
@@ -61,7 +61,7 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
||||
{
|
||||
// We nest this call in its own scope because of lifetimes.
|
||||
let headers = csv_reader.headers()?;
|
||||
trace!(target: "advotrackerd", header = ?headers);
|
||||
trace!(target: "csv-import", header = ?headers);
|
||||
}
|
||||
|
||||
// Iterate over each record, deserialize und write to our structures
|
||||
@@ -88,12 +88,12 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
||||
let time_end = SystemTime::now();
|
||||
let duration = time_end.duration_since(time_start)
|
||||
.expect("Clock may have gone backwards");
|
||||
trace!(target: "advotrackerd", record_count = ?count, duration = ?duration);
|
||||
trace!(target: "csv-import", record_count = ?count, duration = ?duration);
|
||||
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("csv.import.finished", lang);
|
||||
let datetime: DateTime<Local> = time_end.into();
|
||||
trace!(target: "advotrackerd", process = ?res, state = ?state, date_stop = ?datetime.to_string());
|
||||
trace!(target: "csv-import", process = ?res, state = ?state, date_stop = ?datetime.to_string());
|
||||
|
||||
Ok((count, duration))
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
/// advotracker import modules
|
||||
pub mod imports;
|
||||
|
||||
/// advotracker import modules
|
||||
/// advotracker export modules
|
||||
pub mod exports;
|
||||
|
||||
@@ -12,20 +12,23 @@ use crate::{
|
||||
widgets::policycheck_view::PolicyCheckView,
|
||||
};
|
||||
|
||||
type List = Vec<String>;
|
||||
|
||||
// [START] views
|
||||
|
||||
widget!(MainView {
|
||||
// policy_list: PolicyList,
|
||||
// policy_data_list: PolicyDataList,
|
||||
// policylist_view: u32,
|
||||
// policydata_view: u32,
|
||||
//policycheck_view: u32
|
||||
policycheck_view: PolicyCheck
|
||||
});
|
||||
|
||||
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)
|
||||
//.policy_number_count(0)
|
||||
//.policylist_view(id)
|
||||
.build(ctx);
|
||||
|
||||
// let policylist_view = PolicyListView::new()
|
||||
@@ -49,6 +52,83 @@ impl Template for MainView {
|
||||
// .policylist_view(policylist_view.0)
|
||||
// .child(policydata_view)
|
||||
// .child(policylist_view)
|
||||
.child(policycheck_view)
|
||||
.child(
|
||||
TabWidget::new()
|
||||
.tab("Policynumber check", policycheck_view)
|
||||
.tab("Localization", LocalizationView::new().build(ctx))
|
||||
.build(ctx),
|
||||
)
|
||||
//.child(policycheck_view)
|
||||
}
|
||||
}
|
||||
|
||||
widget!(LocalizationView<LocalizationState> { languages: List, selected_index: i32 });
|
||||
|
||||
impl Template for LocalizationView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
let languages = vec!["English".to_string(), "German".to_string()];
|
||||
let count = languages.len();
|
||||
|
||||
self.languages(languages).selected_index(1).child(
|
||||
Stack::new()
|
||||
.width(120)
|
||||
.margin(16)
|
||||
.spacing(8)
|
||||
.child(TextBlock::new().text("Hello").build(ctx))
|
||||
.child(TextBlock::new().text("User").build(ctx))
|
||||
.child(TextBlock::new().text("Localization dialog").build(ctx))
|
||||
.child(
|
||||
ComboBox::new()
|
||||
.count(count)
|
||||
.items_builder(move |bc, index| {
|
||||
let text = bc.get_widget(id)
|
||||
.get::<Vec<String>>("languages")[index]
|
||||
.clone();
|
||||
TextBlock::new().v_align("center").text(text).build(bc)
|
||||
})
|
||||
.on_changed("selected_index", move |states, _| {
|
||||
states.get_mut::<LocalizationState>(id).change_language();
|
||||
})
|
||||
.selected_index(id)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// [END] views
|
||||
|
||||
// [START] states
|
||||
|
||||
#[derive(AsAny, Debug, Default)]
|
||||
struct LocalizationState {
|
||||
change_language: bool,
|
||||
}
|
||||
|
||||
impl LocalizationState {
|
||||
fn change_language(&mut self) {
|
||||
self.change_language = true;
|
||||
}
|
||||
}
|
||||
|
||||
impl State for LocalizationState {
|
||||
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
|
||||
if !self.change_language {
|
||||
return;
|
||||
}
|
||||
|
||||
let index = *LocalizationView::selected_index_ref(&ctx.widget()) as usize;
|
||||
let selected_language = LocalizationView::languages_ref(&ctx.widget())[index].clone();
|
||||
|
||||
match selected_language.as_str() {
|
||||
"English" => ctx.set_language("en_US"),
|
||||
"German" => ctx.set_language("de_DE"),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
self.change_language = false;
|
||||
}
|
||||
}
|
||||
|
||||
// [END] states
|
||||
|
||||
@@ -43,7 +43,7 @@ impl Template for PolicyCheckView {
|
||||
.v_align("center")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
.image("resources/images/hiedemann_logo.png")
|
||||
.image("resources/advotracker/hiedemann_logo.png")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
@@ -58,7 +58,7 @@ impl Template for PolicyCheckView {
|
||||
.v_align("end")
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.margin((0, 9, 16, 0))
|
||||
.margin((0, 9, 48, 0))
|
||||
.text("©Networkx GmbH")
|
||||
.build(ctx)
|
||||
)
|
||||
@@ -111,7 +111,7 @@ impl Template for PolicyCheckView {
|
||||
.id(ID_POLICY_CHECK_HEADER)
|
||||
.v_align("center")
|
||||
.h_align("left")
|
||||
.text("Validierung Versicherungsnummer")
|
||||
.text("Validation policy number")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
@@ -120,11 +120,14 @@ impl Template for PolicyCheckView {
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_form_row_0 = Stack::new()
|
||||
// 1st row
|
||||
.id(ID_POLICY_CHECK_FORM_ROW_0)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(5))
|
||||
.orientation("horizontal")
|
||||
.v_align("center")
|
||||
//.h_align("center")
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_LABEL_POLICY_NUMBER)
|
||||
@@ -134,7 +137,9 @@ impl Template for PolicyCheckView {
|
||||
.margin((0, 0, 16, 0))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.text("Versicherungsnummer:")
|
||||
.width(300)
|
||||
.min_width(300)
|
||||
.text("Policy number")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
@@ -144,6 +149,7 @@ impl Template for PolicyCheckView {
|
||||
.id(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
.h_align("start")
|
||||
.lost_focus_on_activation(false)
|
||||
//WIP: localization for water_mark
|
||||
.water_mark("10-stellig")
|
||||
.on_activate(move |ctx, entity| {
|
||||
// Entity is entered/activated via Mouse/Keyboard
|
||||
@@ -181,11 +187,13 @@ impl Template for PolicyCheckView {
|
||||
|
||||
let policy_check_form_row_1 = Stack::new()
|
||||
// 2nd row
|
||||
.id(ID_POLICY_CHECK_FORM_ROW_1)
|
||||
.attach(Grid::row(1))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(5))
|
||||
.orientation("horizontal")
|
||||
.v_align("center")
|
||||
//.h_align("center")
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_LABEL_RESULT)
|
||||
@@ -195,9 +203,9 @@ impl Template for PolicyCheckView {
|
||||
.margin((0, 0, 16, 0))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.width(250)
|
||||
.min_width(250)
|
||||
.visibility(Visibility::Visible)
|
||||
.width(300)
|
||||
.min_width(300)
|
||||
.text("Policy code")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
@@ -212,35 +220,78 @@ impl Template for PolicyCheckView {
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_form_row_2 = Stack::new()
|
||||
// 3nd row
|
||||
.id(ID_POLICY_CHECK_FORM_ROW_2)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(5))
|
||||
.orientation("horizontal")
|
||||
.v_align("center")
|
||||
.h_align("center")
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_LABEL_HINT)
|
||||
//.style("hint")
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.margin((0, 0, 16, 0))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.width(300)
|
||||
.min_width(300)
|
||||
.font_size(11.)
|
||||
.text("Error:")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_HINT)
|
||||
//.style("hint")
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(2))
|
||||
.h_align("start")
|
||||
.v_align("center")
|
||||
.font_size(11)
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_form = Container::new()
|
||||
.id(ID_POLICY_CHECK_FORM)
|
||||
.min_width(420)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(1))
|
||||
.style("container_form")
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_POLICY_CHECK_FORM)
|
||||
.width(450)
|
||||
.min_width(400)
|
||||
.columns(
|
||||
Columns::create()
|
||||
// Labels
|
||||
.push("250")
|
||||
// Label
|
||||
.push("300")
|
||||
// Seperator
|
||||
.push("16")
|
||||
// Values
|
||||
.push("100")
|
||||
.push("auto")
|
||||
// Seperator
|
||||
.push("16")
|
||||
// Result-Button
|
||||
.push("32")
|
||||
.build(),
|
||||
//.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
.build(),
|
||||
.push("*")
|
||||
//.build(),
|
||||
)
|
||||
.child(policy_check_form_row_0)
|
||||
.child(policy_check_form_row_1)
|
||||
.child(policy_check_form_row_2)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
@@ -267,14 +318,31 @@ impl Template for PolicyCheckView {
|
||||
//})
|
||||
.build(ctx);
|
||||
|
||||
let policy_data_count_block = TextBlock::new()
|
||||
.id(ID_POLICY_DATA_COUNT_BLOCK)
|
||||
let policy_data_stack = Stack::new()
|
||||
.id(ID_POLICY_DATA_STACK)
|
||||
.attach(Grid::row(3))
|
||||
.attach(Grid::column(1))
|
||||
.margin((0, 4, 0, 0))
|
||||
.h_align("end")
|
||||
.v_align("top")
|
||||
.enabled(true)
|
||||
.orientation("horizontal")
|
||||
.visibility(Visibility::Collapsed)
|
||||
//.spacing("4")
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_DATA_LABEL)
|
||||
.margin((0, 4, 0, 0))
|
||||
.enabled(true)
|
||||
.text("Checklist elements: ")
|
||||
.build(ctx)
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_DATA_COUNT)
|
||||
.margin((0, 4, 0, 0))
|
||||
.enabled(true)
|
||||
.text("0")
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
// Starter page: check policy numbers
|
||||
@@ -289,7 +357,7 @@ impl Template for PolicyCheckView {
|
||||
.push(50)
|
||||
.push("*")
|
||||
.push(50)
|
||||
.build(),
|
||||
//.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
@@ -298,7 +366,7 @@ impl Template for PolicyCheckView {
|
||||
.push("*")
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
.build(),
|
||||
//.build(),
|
||||
)
|
||||
|
||||
// row 0: Policy Check Header
|
||||
@@ -310,7 +378,7 @@ impl Template for PolicyCheckView {
|
||||
.child(policy_check_form)
|
||||
|
||||
// row 3: Sum HashMap elements
|
||||
.child(policy_data_count_block)
|
||||
.child(policy_data_stack)
|
||||
|
||||
// row 4: Policy Check Bottom
|
||||
.child(policy_check_bottom_bar)
|
||||
|
||||
Submodule advotrackerd updated: 3331aa284d...409d8d1f1a
Reference in New Issue
Block a user