13 Commits

Author SHA1 Message Date
fafd38f210 widgets/configuration: reference styling to theme handling
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-08 18:52:41 +01:00
667a2e39bf widget/policycheck: update logic
* remove handling of the menu logic (isolated in dedicated widget)
* reference styling via theme
* update documentation strings

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-08 18:47:43 +01:00
c90099e1cf widgets/menu: introduce dedicated module menu
* new menu_view
* new menu_state
* update constants
* update main_view referencing a tab_view

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-08 18:45:33 +01:00
9624567dbd assets: update theme definitions for default_dark.ron
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-08 18:43:29 +01:00
014b98bd85 widgets/menu: introduce dedicated menu module
* new menu_view
* new menu_state
* adapt constant values for the menu structure

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-07 13:14:14 +01:00
8fd512b83f theme update dark
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 20:23:32 +01:00
85f9fdf7db widget/configuration: correcting label constant
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 20:10:16 +01:00
c4d6506dee language: update
* update constants
* adopt width of languages combo box

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 20:10:07 +01:00
646955c0fb widget/policycheck: intoduce os dependent theme handling
* theme_fluent: only makes sense in windows environment

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 20:02:17 +01:00
df6bae482c widgets/localization: update label constant
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 20:00:19 +01:00
00ad56ce71 assets: adapt default_dark theme definitions
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 17:51:45 +01:00
6350d14ce7 assets: adapt fluent_dark theme definitions
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 17:49:57 +01:00
e8a86e8afd policycheck:
* insert copyright hint
* more descriptive import of allianzdirectcall function
* documentation update
* introduce KeyHandler in menu popup
* rename action function to `set_action`

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 17:46:18 +01:00
205 changed files with 1242 additions and 8627 deletions

11
.gitmodules vendored
View File

@@ -1,6 +1,9 @@
[submodule "advotrackerdb"] [submodule "backend"]
path = crates/advotrackerdb path = backend
url = https://gitea.networkx.de:50443/rzerres/advotrackerdb url = ./backend/
[submodule "advotracker-db"]
path = advotracker-db
url = https://gitea.networkx.de:50443/rzerres/advotracker-db
[submodule "advotrackerd"] [submodule "advotrackerd"]
path = crates/advotrackerd path = advotrackerd
url = https://gitea.networkx.de:50443/rzerres/advotrackerd url = https://gitea.networkx.de:50443/rzerres/advotrackerd

View File

@@ -1,5 +1,5 @@
[package] [package]
name = "advotracker" name = "advotracker-framework"
version = "0.1.0" version = "0.1.0"
authors = ["Ralf Zerres <ralf.zerres@networkx.de>"] authors = ["Ralf Zerres <ralf.zerres@networkx.de>"]
description = "Supports lawyers to capture relevant data encountered during an online legal advice\n" description = "Supports lawyers to capture relevant data encountered during an online legal advice\n"
@@ -8,39 +8,10 @@ homepage = "https://gitea.networkx.de:50443/rzerres/advotracker"
documentation = "https://docs.rs/advotracker" documentation = "https://docs.rs/advotracker"
readme = "README.md" readme = "README.md"
license = "0BSD OR MIT" license = "0BSD OR MIT"
keywords = [
"advotracker",
"lawyer",
]
edition = "2018" edition = "2018"
publish = false publish = false
#default-run = "crates/advotracker_client"
[dependencies]
advotrackerdb = { version = "0.1.0-alpha1", path = "crates/advotrackerdb" }
advotrackerd = { version = "0.1.0-alpha1", path = "crates/advotrackerd", default-features = false }
advotracker_client = { version = "0.1.5-alpha2", path = "crates/advotracker_client", default-features = false }
[features]
default = ["sqlite"]
# enable optional db backends
sqlite = []
#sqlite = ["advotrackerdb_sqlite"]
#postgresql = ["advotrackerdb_pstgresql"]
[profile.dev]
#opt-level = 0
opt-level = 1
incremental = true
debug = true
lto = false
codegen-units = 5
panic = 'unwind'
overflow-checks = true
[profile.release] [profile.release]
incremental = true
panic = "abort" panic = "abort"
lto = true lto = true
codegen-units=1 codegen-units=1
@@ -50,6 +21,15 @@ opt-level="s"
# optimize to smallest size # optimize to smallest size
#opt-level = "z" #opt-level = "z"
[profile.dev]
opt-level = 0
debug = true
lto = false
codegen-units = 5
panic = 'unwind'
incremental = true
overflow-checks = true
[profile.test] [profile.test]
opt-level = 0 opt-level = 0
debug = 2 debug = 2
@@ -63,7 +43,8 @@ overflow-checks = true
[workspace] [workspace]
members = [ members = [
"crates/advotrackerd", "advotrackerd",
"crates/advotrackerdb", "advotracker-db",
"crates/advotracker_client", "advotracker",
"advotracker_qml",
] ]

View File

@@ -6,14 +6,14 @@
## About ## About
`advotracker` supports lawyers to capture relevant data encountered during an online `AdvoTracker` supports lawyers to capture relevant data encountered during an online
legal advice. legal advice.
The application components are implemented using the programming language *Rust*. The application components are implemented using the programming language *Rust*.
The graphical user interface (GUI) uses the class-lib *OrbTk*, which is natively The graphical user interface (GUI) uses the class-lib *OrbTk*, which is natively
encoded in *Rust* as well. encoded in *Rust* as well.
`advotracker` can be deployed on every target operating system that is officialy `AdvoTracker` can be deployed on every target operating system that is officialy
supported by the `OrbTK` toolkit. Currently included are: supported by the `OrbTK` toolkit. Currently included are:
* macOS * macOS
@@ -36,24 +36,24 @@ as documentation sources.
Dialogs and messages generated inside the application will respect the system language Dialogs and messages generated inside the application will respect the system language
of the active user. This is adaptable via the environment variable of the active user. This is adaptable via the environment variable
(default: LANG = en_US.UTF8 or LANG = C). (default: LANG = en_US.UTF8 ).
Within the source code you can find translated constants in the subdirectory 'locales' Within the source code you can find translated constants in the subdirectory 'locales'
(<crate-root>/src/locales/advotracker.json). (<src-root>/advotracker/src/locales/advotracker.json).
For every supported language-string, you will find a block starting with the For every supported language-string, you will find a block starting with the
generic message code, followed by the target language translation. Translation lines generic message code, followed by the target language translation. Translation lines
are identified by its ISO Code (e.g. de_DE.UTF8, es_ES.UTF8). are identified by its ISO Code (e.g. de_DE.UTF8, es_ES.UTF8).
## Installation from source code ## Installation from source code
You can either download the `advotracker` source code as a Zip-File or using `git` You can either download the `Advotracker` source code as a Zip-File or using `git`
from projects repositoy URL. from projects repositoy URL.
The source code is subdiveded in three crates: The source code is subdiveded in three submodules:
* advotracker * advotracker
* advotrackerd * advotrackerd
* advotrackerdb * advotracker-db
Currently the given WEB-URL certificate is signed by a Microsoft CA. Currently the given WEB-URL certificate is signed by a Microsoft CA.
Since this CA can't be verified from offical CA-lists you have to proceed as follows: Since this CA can't be verified from offical CA-lists you have to proceed as follows:
@@ -149,7 +149,7 @@ This work is licensed under a [Creative Common License 4.0][License-CC_BY]
![Creative Common Logo][Logo-CC_BY] ![Creative Common Logo][Logo-CC_BY]
<EFBFBD> 2020-2021 Ralf Zerres, Networkx GmbH <EFBFBD> 2020 Ralf Zerres, Networkx GmbH
--- ---

1
advotracker-db Submodule

Submodule advotracker-db added at d29c747d7b

View File

@@ -1,54 +1,42 @@
[package] [package]
name = "advotracker_client" name = "advotracker"
version = "0.1.5-alpha2" version = "0.1.4"
authors = ["Ralf Zerres <ralf.zerres@networkx.de>"] authors = ["Ralf Zerres <ralf.zerres@networkx.de>"]
description = "Frontend component that supports lawyers to capture relevant data encountered during an online legal advice." description = "Frontend component that supports lawyers to capture relevant data encountered during an online legal advice."
readme = "README.md" readme = "README.md"
license = "(0BSD OR MIT)" license = "(0BSD OR MIT)"
edition = "2018" edition = "2018"
default-run = "advotracker" default-run = "advotracker"
build = "build.rs"
[target.x86_64-pc-windows-gnu]
linker = "/usr/bin/x86_64-w64-mingw32-gcc"
ar = "/usr/x86_64-w64-mingw32i/bin/ar"
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = [ "winuser" ] } winapi = { version = "0.3", features = ["winuser"] }
#diesel = { version = "1.4", features = [ "postgres", "sqlite" ] } #diesel = { version = "1.4", features = [ "postgres", "sqlite" ] }
[target.'cfg(target_os = "windows")'.build-dependencies]
winres = { version = "0.1" }
# for language constants
winapi = { version = "0.3", features = [ "winnt" ] }
[dependencies] [dependencies]
async-stream = "~0.2" async-stream = "~0.2"
chrono = { version = "~0.4.0", features = ["serde"] } chrono = { version = "~0.4.0", features = ["serde"] }
cfg-if = { version = "~1.0" }
clap = { version = "~2.33", features = ["suggestions", "color"] } clap = { version = "~2.33", features = ["suggestions", "color"] }
csv = { version = "~1.1" } csv = { version = "~1.1" }
dotenv = { version = "~0.15.0" } dotenv = { version = "~0.15.0" }
envy = { version = "~0.4" } envy = { version = "~0.4" }
#lettre ={ version = "0.10.0-beta.1", features = ["smtp-transport", "native-tls", "hostname", "r2d2", "builder"] }
lettre ={ version = "0.10.0-beta.1" }
lazy_static = { version = "~1.4.0" } lazy_static = { version = "~1.4.0" }
log = { version = "~0.4.8" } log = { version = "~0.4.8" }
locales = { version = "~0.1" } locales = { version = "~0.1" }
maud = { version = "~0.22.1" }
#orbtk = { version = "~0.3.1-alpha4" } #orbtk = { version = "~0.3.1-alpha4" }
#orbtk = { git = "https://github.com/redox-os/orbtk.git", branch = "develop" } orbtk = { git = "https://github.com/redox-os/orbtk.git", branch = "develop" }
orbtk = { path = "../../../orbtk" } #orbtk = { path = "../../orbtk" }
serde = { version = "~1.0", features = ["derive"] } serde = { version = "~1.0", features = ["derive"] }
sdl2 = { version = "~0.34" }
substring = { version = "~1" }
#tokio = { version = "~0.2", features = ["macros", "rt-threaded", "stream", "time"] } #tokio = { version = "~0.2", features = ["macros", "rt-threaded", "stream", "time"] }
tracing = { version = "~0.1" } tracing = { version = "~0.1" }
tracing-subscriber = { version = "~0.2.0", 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"] } viperus = { git = "https://github.com/maurocordioli/viperus", features = ["cache", "fmt-clap", "fmt-env", "global", "watch"] }
[build-dependencies]
winres = { version = "0.1" }
#[dev-dependencies]
[features] [features]
# no features by default
default = [] default = []
debug = ["orbtk/debug"] debug = ["orbtk/debug"]
light = [] light = []
@@ -58,14 +46,3 @@ name = "advotracker"
identifier = "nwx.advotracker" identifier = "nwx.advotracker"
short_description = "Online legal advice helper." short_description = "Online legal advice helper."
description = "Supports lawyers to capture relevant data encountered during an online legal advice.\n" description = "Supports lawyers to capture relevant data encountered during an online legal advice.\n"
[package.metadata.winres]
LegalCopyright = "Copyright © 2020-2021"
#[[bin]]
#//name = "policycheck"
#path = "src/bin/policycheck.rs"
[[bin]]
name = "advotracker"
path = "src/main.rs"

View File

@@ -11,22 +11,36 @@ Dictionary (
// like a struct, but keys are also values instead of just beenig identifiers // like a struct, but keys are also values instead of just beenig identifiers
words: { words: {
// policycheck_view // policycheck_view
"Policy number validation": "Versicherungsnummern Prüfung", "Validation policy number": "Prüfung Versicherungsnummer",
"Policy number": "Versicherungsnummer", "Policy number": "Versicherungsnummer",
"Policy code": "ID der Vers.-Nummer",
"Checklist elements: ": "Prüflistenelemente: ", "Checklist elements: ": "Prüflistenelemente: ",
"Check result": "Prüfungsergebnis", "Check result": "Prüfungsergebnis",
"Importing data": "Importiere Datensätze", "Importing data": "Importiere Datensätze",
"Processing time": "Bearbeitungszeit", "Processing time": "Bearbeitungszeit",
"Error:": "Fehler:",
"Reason": "Grund",
"Policy number is to long": "Die Nummer ist zu lang", "Policy number is to long": "Die Nummer ist zu lang",
"Policy number is to short": "Die Nummer ist zu kurz", "Policy number is to short": "Die Nummer ist zu kurz",
"The given policy number is invalid": "Die Versicherungsnumber ist ungültig", "The given policy number is invalid": "Die Versicherungsnummer ist ungültig",
"The given policy number is valid": "Die Versicherungsnumber ist gültig", "The given policy number is valid": "Die Versicherungsnummer ist gültig",
"Only numbers are valid": "Nur Nummern sind zulässig", "Only numbers are valid": "Nur Nummern sind zulässig",
// localization "Account": "Benutzer",
"Hello": "Hallo", "Toggle theme": "Thema wechseln",
"User": "Anwender", "Quit": "Beenden",
// localization view
"Language ID": "Sprache ID",
"Localization dialog": "Lokalisierungs-Dialog", "Localization dialog": "Lokalisierungs-Dialog",
"German": "Deutsch", "German": "Deutsch",
"English": "Englisch" "English": "Englisch",
// configuration view
"Configuration settings": "Konfigurationseinstellungen",
"Configuration file": "Konfigurationsdatei",
"Language Id": "Sprach-Id",
"Default theme": "Standard-Thema",
"load": "laden",
"save": "speichern"
} }
) )

View File

@@ -0,0 +1,54 @@
Theme (
styles: {
"button_menu": (
base: "button",
properties: {
"padding": 4,
"border_radius": 0,
},
),
"container_form": (
base: "container",
properties: {
"padding": 14,
"border_width": 1,
"border_radius": 0,
"border_brush": "$CONTAINER_BORDER",
},
),
"configuration_form": (
base: "container",
properties: {
"margin": 4,
},
),
"container_progress": (
base: "container",
properties: {
"padding": 14,
//"border_width": 1,
//"border_radius": 0,
"border_brush": "$CONTAINER_BORDER",
},
),
"popup_progress": (
base: "popup",
properties: {
//"background": "$BACKGROUND",
"padding": 4,
},
),
"text_block_progress": (
base: "small_text",
properties: {
"background": "$PROGRESS_BAR_BACKGROUND",
},
),
"stack_progress": (
base: "container",
properties: {
"spacing": 10,
},
),
}
)

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 220 B

After

Width:  |  Height:  |  Size: 220 B

View File

Before

Width:  |  Height:  |  Size: 123 B

After

Width:  |  Height:  |  Size: 123 B

View File

Before

Width:  |  Height:  |  Size: 123 B

After

Width:  |  Height:  |  Size: 123 B

View File

Before

Width:  |  Height:  |  Size: 289 B

After

Width:  |  Height:  |  Size: 289 B

View File

Before

Width:  |  Height:  |  Size: 126 B

After

Width:  |  Height:  |  Size: 126 B

View File

Before

Width:  |  Height:  |  Size: 158 B

After

Width:  |  Height:  |  Size: 158 B

View File

Before

Width:  |  Height:  |  Size: 351 B

After

Width:  |  Height:  |  Size: 351 B

View File

Before

Width:  |  Height:  |  Size: 130 B

After

Width:  |  Height:  |  Size: 130 B

View File

Before

Width:  |  Height:  |  Size: 193 B

After

Width:  |  Height:  |  Size: 193 B

View File

Before

Width:  |  Height:  |  Size: 452 B

After

Width:  |  Height:  |  Size: 452 B

View File

Before

Width:  |  Height:  |  Size: 131 B

After

Width:  |  Height:  |  Size: 131 B

View File

Before

Width:  |  Height:  |  Size: 223 B

After

Width:  |  Height:  |  Size: 223 B

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 768 B

After

Width:  |  Height:  |  Size: 768 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 455 KiB

After

Width:  |  Height:  |  Size: 455 KiB

View File

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 71 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 237 KiB

After

Width:  |  Height:  |  Size: 237 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -0,0 +1 @@
../../../advotrackerd/data/POLLFNR_WOECHENTLICH.txt

View File

@@ -1,8 +1,8 @@
{ {
"err.lang.not_found": { "err.lang.not_found": {
"de_DE.UTF-8": "Konnte Sprachkode nicht auslesen", "de_DE.UTF-8": "Konnte die Umgebungsvarialbe LANG nicht auslesen",
"de": "Konnte Sprachkode nicht auslesen", "de": "Konnte die Umgebungsvarialbe LANG nicht auslesen",
"en": "Couldn't read LANG" "en": "Couldn't read LANG"
}, },
"err.user.not_found": { "err.user.not_found": {
"fr": "Utilisateur introuvable: $email, $id", "fr": "Utilisateur introuvable: $email, $id",
@@ -65,6 +65,26 @@
"de": "Datenbank-Treiber", "de": "Datenbank-Treiber",
"en": "database driver" "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": { "state.started": {
"de_DE.UTF-8": "gestartet", "de_DE.UTF-8": "gestartet",
"de": "gestartet", "de": "gestartet",

View File

@@ -9,12 +9,9 @@ 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::{ use std::env;
collections::HashMap, use std::{error::Error, process};
env, use std::collections::HashMap;
{error::Error, process},
//path::{Path, PathBuf},
};
use tracing::{debug, trace, Level}; use tracing::{debug, trace, Level};
use advotracker::data::structures::{PolicyCode, PolicyList, PolicyDataList, PolicyData}; use advotracker::data::structures::{PolicyCode, PolicyList, PolicyDataList, PolicyData};
@@ -52,6 +49,14 @@ fn export(p: &mut String, lang: &String) -> Result<u64, Box<dyn Error>> {
// Note: slash syntax also works on Windows! // Note: slash syntax also works on Windows!
let path = Path::new(p); let path = Path::new(p);
// only create files with a '.txt' extensions
//let extension = path.extension();
// match extension {
// //Some(String) => println!("file extension ok!"),
// //_ => extension = OsStr::new("txt")
// _ => println!("got file extension {:?}", extension)
// };
// open the file descriptor // open the file descriptor
let mut file = File::create(path)?; let mut file = File::create(path)?;
trace!(target: "csv-export", extension = ?path.extension(), file = ?file); trace!(target: "csv-export", extension = ?path.extension(), file = ?file);
@@ -98,6 +103,10 @@ fn import(p: &mut String, data_list: &mut PolicyDataList,
// must be a readable file // must be a readable file
trace!(target: "csv-test", path = ?path); trace!(target: "csv-test", path = ?path);
let valid = path.is_file();
println!("is_file: {}", valid);
//if let Some(res) = valid
assert_eq!(path.is_file(), true); assert_eq!(path.is_file(), true);
// only accept files with '.txt' extensions // only accept files with '.txt' extensions
@@ -324,8 +333,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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);
// create policy structures // importing policy code elements from csv-file
let policy_list = PolicyList::new("Allianz Versicherungsnummen-Liste"); let policy_list = PolicyList::new("Allianz Versicherungsnummen-List");
println!("Policy List {:?} ", policy_list.name); println!("Policy List {:?} ", policy_list.name);
let mut policy_data = PolicyDataList::new("Allianz-Import 20200628"); let mut policy_data = PolicyDataList::new("Allianz-Import 20200628");
@@ -346,9 +355,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} }
// test if policy_number is_valid // test if policy_number is_valid
// type conversion (viperus String -> u64) let test_policy_number = v.get::<i32>("test_policy_number").unwrap() as u64;
let test_policy_number = v.get::<String>("test_policy_number").unwrap().parse::<u64>().unwrap();
trace!(target: "csv-test", test_policy_number = ?test_policy_number); trace!(target: "csv-test", test_policy_number = ?test_policy_number);
//let policy_number : u64 = 1999999999;
//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
@@ -385,25 +394,3 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(()) Ok(())
} }
#[test]
fn test_policy_number() {
// Takes a reference and returns Option<&V>
let my_policy_numbers : [u64; 2] = [1511111111, 9999999993];
assert_eq!(my_policy_numbers, [1511111111, 9999999993]);
//let mut csv_import_path = v.get::<String>("import_file").unwrap();
let mut csv_import_path = String::from("data/POLLFNR_TEST.txt");
let mut policy_data = PolicyDataList::new("PolicyDataList");
let mut policy_numbers : HashMap<u64, PolicyCode> = HashMap::new();
let lang = "en".to_string();
println!("import with Path: {:?} PolicyData: {:?} PolicyNumbers: {:?}, Lang: {:?}",
csv_import_path, policy_data, policy_numbers, lang);
let count = import(&mut csv_import_path, &mut policy_data,
&mut policy_numbers, &lang);
assert_eq!(count.unwrap(), 15498);
}

View File

@@ -25,7 +25,7 @@ pub fn parse_args(v: &mut Viperus) -> Result<(), Box<dyn std::error::Error>> {
v.add_default("config_file", String::from("csv_import.ron")); v.add_default("config_file", String::from("csv_import.ron"));
v.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt")); v.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
v.add_default("export_file", String::from("")); v.add_default("export_file", String::from(""));
v.add_default("test_policy_number", String::from("9999999992")); v.add_default("test_policy_number", 123456789);
v.add_default("to_email_address_file", String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>")); v.add_default("to_email_address_file", String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"));
v.add_default("from_email_address_file", String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>")); v.add_default("from_email_address_file", String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>"));
//v.add_default("username", String::from("nctalkbot")); //v.add_default("username", String::from("nctalkbot"));
@@ -188,7 +188,7 @@ SMR Unerledigt: 089 92529 60222")
); );
println!( println!(
"test_policy_number: {:?}", "test_policy_number: {:?}",
v.get::<String>("test_policy_number").unwrap_or_default() v.get::<i32>("test_policy_number").unwrap_or_default()
); );
// println!( // println!(
// "username: {:?}", // "username: {:?}",

View File

@@ -1,5 +1,11 @@
use orbtk::prelude::*; use orbtk::prelude::*;
// use orbtk::theme::DEFAULT_THEME_CSS;
// use orbtk::theme::LIGHT_THEME_EXTENSION_CSS;
// //#[cfg(feature = "light-theme")]
// static WIDGET_EXT: &'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)
// ThemeValue::create_from_css(DEFAULT_THEME_CSS) // ThemeValue::create_from_css(DEFAULT_THEME_CSS)
@@ -9,8 +15,12 @@ use orbtk::prelude::*;
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
enum Action { enum Action {
//ClearText,
EntryActivated(Entity), EntryActivated(Entity),
EntryChanged(Entity) EntryChanged(Entity),
//ValueChanged(Entity),
//ValueOk,
//ValueNone,
} }
#[derive(AsAny)] #[derive(AsAny)]
@@ -48,16 +58,23 @@ impl State for MainViewState {
// //ctx.widget().set("policynumber", background("#5b0f22")); // //ctx.widget().set("policynumber", background("#5b0f22"));
//} //}
Action::EntryActivated(entity) => { Action::EntryActivated(entity) => {
//let text = ctx.get_widget(entity).clone::<String>("text"); let mut text_box = TextBox::get(ctx.get_widget(entity));
let widget = ctx.get_widget(entity); let text = text_box.text_mut();
let text = widget.get::<String>("text"); //let mut widget = ctx.get_widget(entity);
//let text = widget.get_mut::<String16>("text");
println!("got value policynumber: {}", text); println!("got value policynumber: {}", text);
//text.clear();
} }
Action::EntryChanged(entity) => { Action::EntryChanged(entity) => {
let widget = ctx.get_widget(entity); let widget = ctx.get_widget(entity);
let text = widget.get::<String>("text"); let text = widget.get::<String16>("text");
println!("entry changed: {}", text); println!("entry changed: {}", text);
} }
// Action::ValueChanged(entity) => {
// let val =
// ((*ctx.get_widget(entity).get::<f64>("val")).floor() as i32).to_string();
// ctx.child("value_text").set("text", String16::from(val));
//}
} }
self.action = None; self.action = None;
@@ -68,6 +85,7 @@ impl State for MainViewState {
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity { fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
TextBlock::new() TextBlock::new()
.text(text) .text(text)
//.element("text-block")
.style("header") .style("header")
.build(ctx) .build(ctx)
} }
@@ -83,19 +101,26 @@ widget!(
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 {
self.name("MainView").child( self.name("MainView").child(
//.result("Anzahl Versicherungsnummern: 0")
//.result("Policyholders count: 0").sum_policynumbers(0)
//.sum_policynumbers(0)
Grid::new() Grid::new()
.background("#fafafa") .background("#fafafa")
//.width(200.0)
//.height(360.0)
.columns( .columns(
Columns::create() Columns::new()
.push(150.0) .add(150.0)
.push("*") .add("*")
.push(150.0) //.add(120.0)
//.add("auto")
.add(150.0)
.build(), .build(),
) )
.rows( .rows(
Rows::create() Rows::new()
.push("*") .add("*")
.push("*") .add("*")
.build(), .build(),
) )
.child( .child(
@@ -115,22 +140,27 @@ impl Template for MainView {
.child(create_header(ctx, "Validierung Versicherungsnummer")) .child(create_header(ctx, "Validierung Versicherungsnummer"))
.child( .child(
TextBox::new() TextBox::new()
//.class("text_box")
// overwriting the class defaults
/* .background("transparent")
.foreground("#9dafbf") .foreground("#9dafbf")
.background("#fafafa") .background("#fafafa")
/* .foreground(colors::LINK_WATER_COLOR) */
.border_brush("#5b0f22") .border_brush("#5b0f22")
.border_width(5) .border_width(5)
.border_radius(15) .border_radius(15) */
//.name("policynumber") //.name("policynumber")
.focused(true) .focused(true)
.water_mark("Versicherungs-Nr...") .water_mark("Versicherungs-Nr...")
//.text("Number policyholder", id)
.text(("policynumber", id)) .text(("policynumber", id))
.font_size(24.0) .font_size(24.0)
.h_align("stretch") .h_align("stretch")
.on_activate(move |ctx, entity| { .on_activate(move |states, entity| {
state(id, ctx).action(Action::EntryActivated(entity)); state(id, states).action(Action::EntryActivated(entity));
}) })
.on_changed("text", move |ctx, entity| { .on_changed(move |states, entity| {
state(id, ctx).action(Action::EntryChanged(entity)); state(id, states).action(Action::EntryChanged(entity));
}) })
.build(ctx), .build(ctx),
) )
@@ -150,28 +180,28 @@ impl Template for MainView {
) )
.child( .child(
Grid::new() Grid::new()
//.class("logo_customer") //.element("logo_customer")
.margin((9.0, 16.0, 16.0, 9.0)) .margin((9.0, 16.0, 16.0, 9.0))
.attach(Grid::column(0)) .attach(Grid::column(0))
.attach(Grid::row(1)) .attach(Grid::row(1))
.v_align("end") .v_align("end")
.child( .child(
ImageWidget::new() ImageWidget::new()
.image("assets/images/customer_logo.png") .image("./resources/images/hiedemann_logo.png")
.build(ctx), .build(ctx),
) )
.build(ctx), .build(ctx),
) )
.child( .child(
Grid::new() Grid::new()
//.class("logo_vendor") //.element("logo_vendor")
.margin((9.0, 16.0, 16.0, 9.0)) .margin((9.0, 16.0, 16.0, 9.0))
.attach(Grid::column(2)) .attach(Grid::column(2))
.attach(Grid::row(1)) .attach(Grid::row(1))
.v_align("end") .v_align("end")
.child( .child(
ImageWidget::new() ImageWidget::new()
.image("assets/images/networkx_logo.png") .image("./resources/images/networkx_logo.png")
.build(ctx), .build(ctx),
) )
.build(ctx), .build(ctx),

View File

@@ -0,0 +1,88 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
// Styles (RON based theme system)
pub static STYLE_BOTTOM_BAR: &str = "bottom_bar";
pub static STYLE_HEADER_BAR: &str = "header_bar";
pub static STYLE_SEPERATOR: &str = "seperator";
//pub static STYLE_ITEM_BUTTON: &str = "item_button";
pub static STYLE_MENU: &str = "menu";
pub static STYLE_BUTTON_MENU: &str = "button_menu";
pub static STYLE_STACK_MENU: &str = "stack_menu";
// Widget IDs (DCES: Entity[id] => [Component1, .. , Component<n>] -> data or state)
pub static ID_CONFIGURATION_FORM: &str = "configuration_form";
pub static ID_CONFIGURATION_HEADER: &str = "configuration_header";
pub static ID_CONFIGURATION_LABEL_CONFIG_FILE: &str = "configuration_label_config_file";
pub static ID_CONFIGURATION_CONFIG_FILE: &str = "configuration_config_file";
pub static ID_CONFIGURATION_LABEL_LANGUAGE_ID: &str = "configuration_label_language_id";
pub static ID_CONFIGURATION_LANGUAGE_ID: &str = "configuration_language_id";
pub static ID_LOCALIZATION_FORM: &str = "localization_form";
pub static ID_LOCALIZATION_HEADER: &str = "localization_header";
pub static ID_LOCALIZATION_LANGUAGES: &str = "localization_languages";
pub static ID_LOCALIZATION_LABEL_LANGUAGE_NAME: &str = "localization_label_language_name";
pub static ID_LOCALIZATION_LANGUAGE_NAME: &str = "localization_language_name";
pub static ID_MENU_POPUP: &str = "menu_popup";
pub static ID_MENU_STACK: &str = "menu_stack";
pub static ID_MENU_BUTTON: &str = "menu_button";
pub static ID_MENU_GRID: &str = "menu_grid";
pub static ID_MENU_LABEL_ACCOUNT: &str = "menu_label_account";
pub static ID_MENU_LABEL_QUIT: &str = "menu_label_quit";
pub static ID_MENU_LABEL_TOGGLE_THEME: &str = "menu_label_toggle_theme";
pub static ID_MENU_SHORTCUT_QUIT: &str = "menu_shortcut_quit";
pub static ID_MENU_TOGGLE_THEME: &str = "menu_toggle_theme";
pub static ID_POLICY_CHECK_FORM: &str = "policy_check_form";
pub static ID_POLICY_CHECK_FORM_ROW_0: &str = "policy_check_form_row_0";
pub static ID_POLICY_CHECK_FORM_ROW_1: &str = "policy_check_form_row_1";
pub static ID_POLICY_CHECK_FORM_ROW_2: &str = "policy_check_form_row_2";
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_BUTTON_RESULT: &str = "policy_check_button_result";
pub static ID_POLICY_CHECK_BUTTON_MENU: &str = "policy_check_button_menu";
pub static ID_POLICY_CHECK_DATA_COUNT_BLOCK: &str = "policy_check_data_count_block";
pub static ID_POLICY_CHECK_HINT: &str = "policy_check_hint";
pub static ID_POLICY_CHECK_LABEL_HINT: &str = "policy_check_label_hint";
pub static ID_POLICY_CHECK_LABEL_MENU: &str = "policy_check_label_menu";
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_POLICY_NUMBER: &str = "policy_check_policy_number";
pub static ID_POLICY_CHECK_POPUP_PROGRESS: &str = "policy_check_popup_progress";
pub static ID_POLICY_CHECK_PROGRESS_BAR: &str = "policy_check_progress_bar";
pub static ID_POLICY_CHECK_PROGRESS_TIME: &str = "policy_check_progress_time";
pub static ID_POLICY_CHECK_PROGRESS_TEXT: &str = "policy_check_progress_text";
pub static ID_POLICY_CHECK_RESULT: &str = "policy_check_result";
pub static ID_POLICY_CHECK_WIDGET: &str = "policy_check_widget";
pub static ID_POLICY_DATA_ADD_BUTTON: &str = "policy_data_add_button";
pub static ID_POLICY_DATA_COUNT: &str = "policy_data_count";
pub static ID_POLICY_DATA_LABEL: &str = "policy_data_label";
pub static ID_POLICY_DATA_ITEMS_WIDGET: &str = "policy_data_items_widget";
pub static ID_POLICY_DATA_DATE_INSERTED: &str = "policy_data_date_inserted";
pub static ID_POLICY_DATA_DION: &str = "policy_data_dion";
pub static ID_POLICY_DATA_POLICY_CODE: &str = "policy_data_policy_code";
pub static ID_POLICY_DATA_POLICY_NUMBER: &str = "policy_data_policy_number";
pub static ID_POLICY_DATA_STACK: &str = "policy_data_stack";
pub static ID_POLICY_DATA_STATUS: &str = "policy_data_status";
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_ITEMS_WIDGET: &str = "policy_list_items_widget";
pub static ID_POLICY_LIST_TEXT_BOX: &str = "policy_list_text_box";
// Component Values (Properties)
pub static PROP_ADVOTRACKER: &str = "advotracker";
pub static PROP_POLICY_CHECK: &str = "policy_check";
pub static PROP_POLICY_PROGRESS_COUNT: &str = "policy_progress_count";
pub static PROP_POLICY_DATA_LIST: &str = "policy_data_list";
pub static PROP_POLICY_DATA_COUNT: &str = "policy_data_count";
pub static PROP_POLICY_LIST: &str = "policy_list";
pub static PROP_POLICY_LIST_COUNT: &str = "policy_list_count";

View File

@@ -110,39 +110,6 @@ pub struct CsvExportRecord {
pub ivr_comment: String, pub ivr_comment: String,
} }
/// Handel fields of an Email (header, body)
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct Email {
/// Recipient address
pub mail_to: String,
/// Carbon Copy recipient address
pub mail_cc: String,
/// Blind Carbon Copy recipient address
pub mail_bcc: String,
/// Sender address
pub mail_from: String,
/// Replay to given address
pub mail_reply: String,
/// Mail subject
pub subject: String,
/// Body policy code
pub policy_code: String,
/// Body type policy holder
pub policy_holder: String,
/// Body type deductible
pub deductible: String,
/// Body callback number
pub callback_number: String,
/// Body type callback date
pub callback_date: String,
/// Body type harm type
pub harm_type: String,
/// Body type ivr comment
pub ivr_comment: String
}
impl Email {}
/// Harm data are list/collections of harm types. You may toggle them to an unselected state. /// Harm data are list/collections of harm types. You may toggle them to an unselected state.
#[derive(Default, Debug, Clone, Deserialize, Serialize)] #[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct HarmData { pub struct HarmData {
@@ -190,6 +157,20 @@ pub struct PolicyCheck {
impl PolicyCheck {} impl PolicyCheck {}
// #[derive(Default, Clone, Debug, Serialize, Deserialize)]
// pub struct PolicyCheckList {
// pub title: String,
// pub list: Vec<PolicyCheck>
// }
// impl PolicyCheckList {
// pub fn new(title: impl Into<String>) -> Self {
// PolicyCheckList {
// title: title.into(),
// ..Default::default()
// }
// }
/// Structure collecting policy data elements /// Structure collecting policy data elements
#[derive(Default, Clone, Debug, Serialize, Deserialize)] #[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PolicyList { pub struct PolicyList {
@@ -260,7 +241,7 @@ pub struct PolicyDataList {
/// implements the helper methods, to manage policy data collections. /// implements the helper methods, to manage policy data collections.
impl PolicyDataList { impl PolicyDataList {
/// Prüfung auf Versicherungselemente /// Prüfung ob Versicherungselemente .
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.policy_data.is_empty() self.policy_data.is_empty()
} }

View File

@@ -5,9 +5,6 @@
* SPDX-License-Identifier: 0BSD, MIT * SPDX-License-Identifier: 0BSD, MIT
*/ */
#![crate_name = "advotracker_client"]
#![crate_type = "lib"]
//#![warn(missing_docs, rust_2018_idioms, rust_2018_compatibility)] //#![warn(missing_docs, rust_2018_idioms, rust_2018_compatibility)]
#![warn(rust_2018_idioms, rust_2018_compatibility)] #![warn(rust_2018_idioms, rust_2018_compatibility)]

View File

@@ -225,16 +225,6 @@
"de_DE": "Die Nummer ist zu kurz", "de_DE": "Die Nummer ist zu kurz",
"C": "Policy number is to short" "C": "Policy number is to short"
}, },
"sendticketdata.export.started":{
"de_DE.UTF-8": "Versenden von ticket daten via eMail gestartet",
"de_DE": "Versenden von ticket daten via eMail gestartet",
"C": "Send ticket data via eMail started"
},
"sendticketdata.export.finished":{
"de_DE.UTF-8": "Versenden von ticket daten via eMail beendet",
"de_DE": "Versenden von ticket daten via eMail beendet",
"C": "Send ticket data via eMail finished"
},
"state.started": { "state.started": {
"de_DE.UTF-8": "gestartet", "de_DE.UTF-8": "gestartet",
"de_DE": "gestartet", "de_DE": "gestartet",

View File

@@ -18,7 +18,6 @@ use cfg_if::cfg_if;
use serde::Deserialize; use serde::Deserialize;
use std::env; use std::env;
//use std::process; //use std::process;
use substring::Substring;
use tracing::{info, trace, Level}; use tracing::{info, trace, Level};
use orbtk::{ use orbtk::{
@@ -31,7 +30,7 @@ use orbtk::{
use orbtk::theme_fluent::{THEME_FLUENT, THEME_FLUENT_COLORS_DARK, THEME_FLUENT_FONTS}; use orbtk::theme_fluent::{THEME_FLUENT, THEME_FLUENT_COLORS_DARK, THEME_FLUENT_FONTS};
// The Main view // The Main view
use advotracker_client::widgets::main_view; use advotracker::widgets::main_view;
mod parse_args; mod parse_args;
@@ -60,9 +59,7 @@ static ADVOTRACKER_DE_DE: &str = include_str!("../assets/advotracker/advotracker
/// Get the active language environment. /// Get the active language environment.
fn get_lang() -> String { fn get_lang() -> String {
// get system environment // get system environment
let mut lang = env::var("LANG").unwrap_or_else(|_| "C".to_string()); let mut lang = env::var("LANG").unwrap_or("C".to_string());
lang = lang.substring(0,5).to_string(); // "de_DE.UTF-8" -> "de_DE"
info!("GUI-Language: preset to {:?}", lang);
// testing environment: read from .env file // testing environment: read from .env file
dotenv().ok(); dotenv().ok();
@@ -73,8 +70,6 @@ fn get_lang() -> String {
Err(e) => { info!(target: "advotracker", "{}", e) } Err(e) => { info!(target: "advotracker", "{}", e) }
} }
trace!(target: "advotracker", lang = ?lang); trace!(target: "advotracker", lang = ?lang);
// return the active language
lang lang
} }
@@ -148,7 +143,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut state = t!("state.started", lang); let mut state = t!("state.started", lang);
let mut res = t!("parse.environment", lang); let mut res = t!("parse.environment", lang);
trace!(target: "advotracker", process = ?res, state = ?state); trace!(target: "advotracker", message = ?res, state = ?state);
trace!(target: "advotracker", environment = "system", lang = ?lang); trace!(target: "advotracker", environment = "system", lang = ?lang);
trace!(target: "advotracker", machine = ?&machine_kind); trace!(target: "advotracker", machine = ?&machine_kind);
@@ -156,7 +151,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
res = t!("parse.environment", lang); res = t!("parse.environment", lang);
trace!(target: "advotracker", environment = "envy", lang = ?lang); trace!(target: "advotracker", environment = "envy", lang = ?lang);
state = t!("state.finished", lang); state = t!("state.finished", lang);
trace!(target: "advotracker", process = ?res, state = ?state); trace!(target: "advotracker", message = ?res, state = ?state);
// initialize viperus structure // initialize viperus structure
let mut viperus = Viperus::new(); let mut viperus = Viperus::new();
@@ -170,10 +165,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
state = t!("state.finished", lang); state = t!("state.finished", lang);
trace!(target: "advotracker", process = ?res, state = ?state); trace!(target: "advotracker", process = ?res, state = ?state);
// type conversion (viperus String -> u64)
let test_policy_number = viperus.get::<String>("test_policy_number").unwrap().parse::<u64>().unwrap();
trace!(target: "advotracker", test_policy_number = ?test_policy_number);
// main tasks // main tasks
res = t!("main.started", lang); res = t!("main.started", lang);
state = t!("state.started", lang); state = t!("state.started", lang);
@@ -182,13 +173,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// use this only if you want to run it as web application. // use this only if you want to run it as web application.
orbtk::initialize(); orbtk::initialize();
// Preset localization and language from given environment. // if no dictionary is set for the default language e.g. english the content of the text property will drawn.
// if no dictionary is set for the chosen default language
// the content of the text property will be drawn.
//let language = lang.substring(0,5); // "de_DE.UTF-8" -> "de_DE"
//info!("GUI-Language: preset to {:?}", language);
let localization = RonLocalization::create() let localization = RonLocalization::create()
.language(&lang) .language("en_US")
.dictionary("de_DE", ADVOTRACKER_DE_DE) .dictionary("de_DE", ADVOTRACKER_DE_DE)
.build(); .build();
@@ -199,9 +186,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Window::new() Window::new()
.title("AdvoTracker - DirectCall") .title("AdvoTracker - DirectCall")
.position((500.0, 100.0)) .position((500.0, 100.0))
.size(800.0, 620.0) .size(580.0, 320.0)
//.min_width(460.0) //.min_width(460.0)
//.min_height(380.0) //.min_height(180.0)
.resizeable(true) .resizeable(true)
.child(main_view::MainView::new().build(ctx)) .child(main_view::MainView::new().build(ctx))
.build(ctx) .build(ctx)

View File

@@ -30,7 +30,7 @@ pub fn parse_args(viperus: &mut Viperus) -> Result<(), Box<dyn std::error::Error
viperus.add_default("config_file", String::from("csv_import.ron")); viperus.add_default("config_file", String::from("csv_import.ron"));
viperus.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt")); viperus.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
viperus.add_default("export_file", String::from("")); viperus.add_default("export_file", String::from(""));
viperus.add_default("test_policy_number", String::from("9999999992")); viperus.add_default("test_policy_number", 123456789);
viperus.add_default("to_email_address_file", String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>")); viperus.add_default("to_email_address_file", String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"));
viperus.add_default("from_email_address_file", String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>")); viperus.add_default("from_email_address_file", String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>"));
//viperus.add_default("username", String::from("nctalkbot")); //viperus.add_default("username", String::from("nctalkbot"));
@@ -139,7 +139,7 @@ SMR Unerledigt: 089 92529 60222")
// preset the prefix for relevant environment variables ("ADVOTRACKER_") // preset the prefix for relevant environment variables ("ADVOTRACKER_")
let mut env_prefix: String = crate_name!().to_uppercase(); let mut env_prefix: String = crate_name!().to_uppercase();
env_prefix.push('_'); env_prefix.push_str("_");
viperus.set_env_prefix(&env_prefix); viperus.set_env_prefix(&env_prefix);
// enable caching and automatic update of environment values // enable caching and automatic update of environment values

View File

@@ -8,12 +8,16 @@
//use chrono::{Local, DateTime}; //use chrono::{Local, DateTime};
use locales::t; use locales::t;
use std::error::Error; use std::error::Error;
//use std::collections::HashMap;
use tracing::trace; use tracing::trace;
//use crate::db::redis;
//use crate::data::structures::{PolicyCode, PolicyDataList, PolicyData};
/// export as csv format /// export as csv format
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html /// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
/// https://blog.burntsushi.net/csv/ /// https://blog.burntsushi.net/csv/
pub fn export(p: &mut String, lang: &str) -> Result<(), Box<dyn Error>> { pub fn export(p: &mut String, lang: &String) -> Result<(), Box<dyn Error>> {
use std::fs::File; use std::fs::File;
use std::path::Path; use std::path::Path;
//use std::ffi::OsStr; //use std::ffi::OsStr;

View File

@@ -5,8 +5,5 @@
* SPDX-License-Identifier: (0BSD or MIT) * SPDX-License-Identifier: (0BSD or MIT)
*/ */
/// Send ticketdata via email
pub mod send_ticketdata;
/// Exporting Allianz DirecCall data /// Exporting Allianz DirecCall data
pub mod allianzdirectcall; pub mod allianzdirectcall;

View File

@@ -23,7 +23,7 @@ use crate::data::structures::{PolicyCode, PolicyDataList, PolicyData};
pub fn import(p: &mut String, data_list: &mut PolicyDataList, pub fn import(p: &mut String, data_list: &mut PolicyDataList,
policy_numbers: &mut HashMap<u64, PolicyCode>, policy_numbers: &mut HashMap<u64, PolicyCode>,
policy_data_count: &mut u64, policy_data_count: &mut u64,
lang: &str) lang: &String)
-> Result<(u64, Duration), Box<dyn Error>> { -> Result<(u64, Duration), Box<dyn Error>> {
use std::fs::File; use std::fs::File;
use std::path::Path; use std::path::Path;

View File

@@ -24,7 +24,7 @@ fn import() -> Result<(), Box<dyn Error>> {
fn main() { fn main() {
if let Err(err) = import() { if let Err(err) = import() {
println!("import error: {}", err); println!("error running example: {}", err);
process::exit(1); process::exit(1);
} }
} }

View File

@@ -39,31 +39,25 @@ impl State for ConfigurationState {
) { ) {
for message in messages.read::<ConfigurationAction>() { for message in messages.read::<ConfigurationAction>() {
match message { match message {
ConfigurationAction::LoadConfiguration => { ConfigurationAction::LoadConfiguration => registry
registry .get::<Settings>("settings")
.get::<Settings>("settings") .load_async::<ConfigurationData>("configuration_data".to_string(), ctx.entity()),
.load_async::<ConfigurationData>(
"configuration_data".to_string(), ctx.entity()
);
}
ConfigurationAction::SaveConfiguration => { ConfigurationAction::SaveConfiguration => {
let configuration_file: String = ConfigurationView::configuration_file_clone(&ctx.widget()); let configuration_file: String = ConfigurationView::configuration_file_clone(&ctx.widget());
let language_id: String = ConfigurationView::language_id_clone(&ctx.widget()); let language_id: String = ConfigurationView::language_id_clone(&ctx.widget());
registry registry.get::<Settings>("settings").save_async(
.get::<Settings>("settings") "configuration_data".to_string(),
.save_async( ConfigurationData(
"configuration_data".to_string(), configuration_file,
ConfigurationData( language_id
configuration_file, ),
language_id ctx.entity(),
), );
ctx.entity(),
);
} }
} }
} }
// save the result // save result
for message in messages.read::<SettingsResult<()>>() { for message in messages.read::<SettingsResult<()>>() {
println!("Result {:?}", message); println!("Result {:?}", message);
} }

View File

@@ -27,7 +27,7 @@ impl Template for ConfigurationView {
self.child( self.child(
Grid::new() Grid::new()
.id(ID_CONFIGURATION_FORM) .id(ID_CONFIGURATION_FORM)
.style("configuration_form") .style(configuration_form)
.columns( .columns(
Columns::create() Columns::create()
.push(120) .push(120)
@@ -35,13 +35,13 @@ impl Template for ConfigurationView {
.push("auto") .push("auto")
) )
.rows(Rows::create() .rows(Rows::create()
.push("auto") // Header_Bar .push("auto")
.push(4) // Seperator .push(4)
.push("auto") // Configuartion_File .push("auto")
.push(4) // Seperator .push(4)
.push("auto") // Language_ID .push("auto")
.push(12) // Seperator .push(12)
.push("auto"), // Action .push("auto"),
) )
.child( .child(
TextBlock::new() TextBlock::new()
@@ -112,7 +112,7 @@ impl Template for ConfigurationView {
.style("button_single_content") .style("button_single_content")
.attach(Grid::column(0)) .attach(Grid::column(0))
.attach(Grid::row(0)) .attach(Grid::row(0))
.text("Load") .text("load")
.on_click(move |ctx, _| { .on_click(move |ctx, _| {
ctx.send_message(ConfigurationAction::LoadConfiguration, id); ctx.send_message(ConfigurationAction::LoadConfiguration, id);
true true
@@ -121,7 +121,7 @@ impl Template for ConfigurationView {
) )
.child( .child(
Button::new() Button::new()
.text("Save") .text("save")
.style("button_single_content") .style("button_single_content")
.attach(Grid::column(2)) .attach(Grid::column(2))
.attach(Grid::row(0)) .attach(Grid::row(0))

View File

@@ -8,7 +8,6 @@
use dotenv::dotenv; use dotenv::dotenv;
use serde::Deserialize; use serde::Deserialize;
use std::env; use std::env;
use substring::Substring;
use tracing::{info, trace}; use tracing::{info, trace};
use orbtk::prelude::*; use orbtk::prelude::*;
@@ -29,11 +28,10 @@ struct Environment {
/// Provides generic methods to handle states of datatypes. /// Provides generic methods to handle states of datatypes.
pub trait GlobalState { pub trait GlobalState {
/// Get the active language environment.
fn get_lang() -> String { fn get_lang() -> String {
// get system environment // get system environment
let mut lang = env::var("LANG").unwrap_or_else(|_| "C".to_string()); let mut lang = env::var("LANG").unwrap_or("C".to_string());
lang = lang.substring(0,5).to_string(); // "de_DE.UTF-8" -> "de_DE"
info!("GUI-Language: preset to {:?}", lang);
// testing environment: read from .env file // testing environment: read from .env file
dotenv().ok(); dotenv().ok();
@@ -44,28 +42,17 @@ pub trait GlobalState {
Err(e) => { info!(target: "advotracker", "{}", e) } Err(e) => { info!(target: "advotracker", "{}", e) }
} }
trace!(target: "advotracker", lang = ?lang); trace!(target: "advotracker", lang = ?lang);
// return the active language
lang lang
} }
/// Get the text of a widget.
fn get_text(&self, ctx: &mut Context<'_>, entity: Entity) -> Option<String> {
let text = TextBox::text_clone(&ctx.get_widget(entity));
if text.is_empty() {
return None;
}
TextBox::text_set(&mut ctx.get_widget(entity), String::default());
Some(text)
}
// /// Navigates to the given entity. // /// Navigates to the given entity.
// fn navigate(&self, to: Entity, ctx: &mut Context<'_>) { // fn navigate(&self, to: Entity, ctx: &mut Context<'_>) {
// if let Some(old_focused_element) = *Window::focus_state_ref(&ctx.window()).focused_entity() { // if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget {
// ctx.push_event_by_window(FocusEvent::RemoveFocus(old_focused_element)); // 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.widget().set("visibility", Visibility::Collapsed);
// ctx.get_widget(to).set("visibility", Visibility::Visible); // ctx.get_widget(to).set("visibility", Visibility::Visible);
// } // }
@@ -75,6 +62,7 @@ pub trait GlobalState {
/// in users 'settings directory'. The directory location is OS dependant /// in users 'settings directory'. The directory location is OS dependant
/// (Windows: AppData, Unix: XDG_CONFIG_HOME, MacOS: $HOME/Library/Preferences). /// (Windows: AppData, Unix: XDG_CONFIG_HOME, MacOS: $HOME/Library/Preferences).
/// The data is stored in filename PROP_ADVOTRACKER (here: `advotracker.ron`) /// The data is stored in filename PROP_ADVOTRACKER (here: `advotracker.ron`)
fn save(&self, registry: &mut Registry, ctx: &mut Context<'_>) { fn save(&self, registry: &mut Registry, ctx: &mut Context<'_>) {
registry registry
.get::<Settings>("settings") .get::<Settings>("settings")

View File

@@ -6,7 +6,6 @@
*/ */
use orbtk::prelude::*; use orbtk::prelude::*;
use tracing::info;
use crate::widgets::localization::localization_view::LocalizationView; use crate::widgets::localization::localization_view::LocalizationView;
@@ -27,10 +26,8 @@ impl State for LocalizationState {
return; return;
} }
// get value of activ selected combo_box item
let index = *LocalizationView::selected_index_ref(&ctx.widget()) as usize; let index = *LocalizationView::selected_index_ref(&ctx.widget()) as usize;
let selected_language = LocalizationView::languages_ref(&ctx.widget())[index].clone(); let selected_language = LocalizationView::languages_ref(&ctx.widget())[index].clone();
info!("New selected language item: {:?}", selected_language);
match selected_language.as_str() { match selected_language.as_str() {
"English" => ctx.set_language("en_US"), "English" => ctx.set_language("en_US"),

View File

@@ -8,15 +8,11 @@
use orbtk::prelude::*; use orbtk::prelude::*;
use crate::{ use crate::{
data::{ data::structures::PolicyCheck,
constants::*,
structures::PolicyCheck,
},
widgets::configuration::configuration_view::ConfigurationView,
widgets::policycheck::policycheck_view::PolicycheckView, widgets::policycheck::policycheck_view::PolicycheckView,
widgets::localization::localization_view::LocalizationView, widgets::localization::localization_view::LocalizationView,
//widgets::menu::menu_view::MenuView, widgets::configuration::configuration_view::ConfigurationView,
widgets::ticketdata::ticketdata_view::TicketdataView, widgets::menu::menu_view::MenuView,
}; };
// [START] views // [START] views
@@ -27,18 +23,13 @@ widget!(MainView {
// policylist_view: u32, // policylist_view: u32,
// policydata_view: u32, // policydata_view: u32,
policycheck_view: PolicyCheck policycheck_view: PolicyCheck
//ticketdata_view: TicketData
}); });
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 ticketdata_view = TicketdataView::new()
.build(ctx);
let policycheck_view = PolicycheckView::new() let policycheck_view = PolicycheckView::new()
.target(ticketdata_view.0) //.policy_number_count(0)
//.policy_number_count(0) //.policylist_view(id)
//.policylist_view(id)
.build(ctx); .build(ctx);
// let policylist_view = PolicyListView::new() // let policylist_view = PolicyListView::new()
@@ -55,7 +46,7 @@ impl Template for MainView {
// .build(ctx); // .build(ctx);
self.name("MainView") self.name("MainView")
//.policycheck_view(PolicyCheck::default()) .policycheck_view(PolicyCheck::default())
// //.policycheck_view(0) // //.policycheck_view(0)
// .policydata_view(policydata_view.0) // .policydata_view(policydata_view.0)
// //.policylist_view(PolicyList::default()) // //.policylist_view(PolicyList::default())
@@ -64,11 +55,10 @@ impl Template for MainView {
// .child(policylist_view) // .child(policylist_view)
.child( .child(
TabWidget::new() TabWidget::new()
.tab(ID_POLICY_CHECK_VIEW, policycheck_view) .tab("Policynumber check", policycheck_view)
.tab(ID_TICKET_DATA_VIEW, ticketdata_view) .tab("Localization", LocalizationView::new().build(ctx))
.tab(ID_LOCALIZATION_VIEW, LocalizationView::new().build(ctx)) .tab("Configuration", ConfigurationView::new().build(ctx))
.tab(ID_CONFIGURATION_VIEW, ConfigurationView::new().build(ctx)) .tab("Menu", MenuView::new().build(ctx))
//.tab(ID_MENU_VIEW, MenuView::new().build(ctx))
.build(ctx), .build(ctx),
) )
//.child(policycheck_view) //.child(policycheck_view)

View File

@@ -0,0 +1,300 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
use cfg_if::cfg_if;
use orbtk::prelude::*;
use orbtk::shell::event::Key;
use std::process;
use crate::{
data::constants::*,
widgets::menu::menu_view::MenuView,
//widgets::policycheck::policycheck_view::PolicycheckView,
};
/// Valid `actions` that are handled as state changes in the `Menu` widget.
#[derive(Debug, Clone, Copy)]
pub enum MenuAction {
CreateMenu,
CreateMenuToggleTheme(Entity),
RemoveMenu,
RemoveMenuToggleTheme(Entity),
SetTheme
}
/// Valid `structures` that are handled inside the state of the `Menu` widget.
#[derive(AsAny, Default)]
pub struct MenuState {
action: Option<MenuAction>,
menu: Entity,
menu_toggle_theme: Entity
}
/// Method definitions, that react on any given state change inside the `Menu` widget.
impl MenuState {
/// Set a menu holding all valid menu elements
/// The elements are ordered compontents inside a stack
pub fn create_menu(&mut self, ctx: &mut Context<'_>) {
// create a stack as a child of the given component
let stack = ctx
.entity_of_child(ID_MENU_BUTTON)
.expect("PolicycheckState: Can't find entity of resource 'ID_MENU_BUTTON'.");
//.entity_of_child(<PolicycheckView>ID_MENU_BUTTON)
//.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_POPUP_MENU'.");
let current_entity = ctx.entity();
let build_context = &mut ctx.build_context();
// create a new popup menu overlay
self.menu = create_menu_popup(current_entity, build_context);
// create a menu_popup widget as a child of entity "ID_POLICY_CHECK_BUTTON_MENU"
build_context.append_child(stack, self.menu);
println!("Popup Menu created: {:?}", self.menu);
}
/// Set a toggle_theme menu
/// Select the active theme from a `ComboBox` offering a list of valid `themes``
fn create_menu_toggle_theme(&mut self, ctx: &mut Context<'_>) {
let stack = ctx
.entity_of_child(ID_MENU_LABEL_TOGGLE_THEME)
.expect("MenuState: Can't find entity of resource 'ID_MENU_LABEL_TOGGLE_THEME'.");
let current_entity = ctx.entity();
let build_context = &mut ctx.build_context();
// create a new menu overlay
self.menu_toggle_theme = create_menu_toggle_theme_popup(current_entity, build_context);
// create a menu_popup widget as a child of entity "ID_POPUP_MENU"
build_context.append_child(stack, self.menu_toggle_theme);
println!("Popup Menu Toggle Theme created: {:?}", self.menu_toggle_theme);
}
/// Remove the menu popup box
fn remove_menu(&mut self, ctx: &mut Context<'_>) {
ctx.remove_child(ctx.entity());
println!("Popup {:?} removed !", ctx.entity());
}
/// Remove the menu popup box
fn remove_menu_toggle_theme(&mut self, id: Entity, ctx: &mut Context<'_>) {
ctx.remove_child(self.menu_toggle_theme);
println!("Popup {:?} removed !", id);
}
/// Sets a new action.
pub fn set_action(&mut self, action: MenuAction) {
self.action = action.into();
}
}
/// Supported methods handled inside the `MenuState`
impl State for MenuState {
/// Initialize the state of widgets inside `MenuState`
fn init(&mut self, _: &mut Registry, _ctx: &mut Context<'_>) {
// Initialize required entities
// let menu_button = ctx
// .entity_of_child(ID_MENU_STACK)
// .expect("MenuState.init: Can't find resource entity 'PolicycheckView::ID_POLICY_CHECK_BUTTON_MENU'.");
}
/// Handle messages for the `MenuState`
fn messages(
&mut self,
mut messages: MessageReader,
_registry: &mut Registry,
ctx: &mut Context<'_>,
) {
for message in messages.read::<MenuAction>() {
match message {
MenuAction::SetTheme => {
let theme_index = *MenuView::selected_index_ref(&ctx.widget());
cfg_if! {
if #[cfg(windows)] {
match theme_index {
0 => ctx.switch_theme(theme_default_dark()),
1 => ctx.switch_theme(theme_default_light()),
2 => ctx.switch_theme(theme_redox()),
3 => ctx.switch_theme(theme_fluent_dark()),
4 => ctx.switch_theme(theme_fluent_light()),
_ => {}
}
} else {
match theme_index {
0 => ctx.switch_theme(theme_default_dark()),
1 => ctx.switch_theme(theme_default_light()),
2 => ctx.switch_theme(theme_redox()),
_ => {}
}
}
}
},
_ => (),
}
}
}
/// Update the state of widgets inside the `Menu` view.
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
if let Some(action) = self.action {
match action {
MenuAction::CreateMenu => {
println!("MenuAction::CreateMenu(_entity)");
self.create_menu(ctx);
}
MenuAction::CreateMenuToggleTheme(_entity) => {
self.create_menu_toggle_theme(ctx);
}
MenuAction::RemoveMenu => {
self.remove_menu(ctx);
}
MenuAction::RemoveMenuToggleTheme(entity) => {
self.remove_menu_toggle_theme(entity, ctx);
}
_ => (),
}
}
}
}
/// Create a new popup presenting the menu components
pub fn create_menu_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
Popup::new()
.id(ID_MENU_POPUP)
.style("container_menu")
.target(id)
.open(true)
.width(280)
.height(140)
.on_key_down(move | ctx, key_event | {
match key_event.key {
Key::Q(..) => {
//if is_ctrl_home_down(ctx)
println!("KeyHandler: got Ctrl+Q");
process::exit(0);
//}
},
Key::Escape => {
println!("KeyHandler: got Escape");
ctx.get_mut::<MenuState>(id)
.set_action(MenuAction::RemoveMenu);
},
_ => {
println!("KeyHandler: got {:?}", key_event.key);
},
};
true
})
.child(
Grid::new()
.id(ID_MENU_GRID)
.columns(
Columns::create()
.push("80") // Menu Button
.push("1") // Seperator
.push("*") // Keyboard Shortcut
.build(),
)
.rows(
Rows::create()
.push("auto")
.push("auto")
.push("auto")
.build(),
)
.child(
Button::new()
.id(ID_MENU_LABEL_ACCOUNT)
.style("button_menu")
.attach(Grid::row(0))
.attach(Grid::column(0))
.attach(Grid::column_span(2))
.icon(material_icons_font::MD_PERSON)
.text("Account")
.build(ctx),
)
.child(
Button::new()
.id(ID_MENU_LABEL_TOGGLE_THEME)
.style("button_menu")
.attach(Grid::row(1))
.attach(Grid::column(0))
.attach(Grid::column_span(2))
.icon(material_icons_font::MD_EDIT)
.text("Toggle theme")
// .on_click(move |ctx, _| {
// ctx.get_mut::<MenuState>(id)
// .set_action(MenuAction::SetTheme(id));
// true
// })
.build(ctx),
)
.child(
Button::new()
.id(ID_MENU_LABEL_QUIT)
.style("button_menu")
.attach(Grid::row(2))
.attach(Grid::column(0))
.attach(Grid::column_span(2))
.icon(material_icons_font::MD_SETTINGS_POWER)
.text("Quit")
.on_mouse_down(move |_states, _| {
process::exit(0);
})
.build(ctx),
)
.child(
TextBlock::new()
.id(ID_MENU_SHORTCUT_QUIT)
.style("button_menu")
.attach(Grid::row(2))
.attach(Grid::column(2))
.margin((0, 0, 16, 0))
.h_align("end")
.v_align("center")
.text("CTRL+Q")
.build(ctx),
)
.build(ctx),
)
.build(ctx)
}
/// Create a new popup submenu to toogle the active theme
pub fn create_menu_toggle_theme_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
//let themes_count = themes.len();
//ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), new_width);
Popup::new()
.id(ID_MENU_TOGGLE_THEME)
.style("container_menu")
.target(id)
.open(true)
.width(280)
.height(140)
.child(
ComboBox::new()
.attach(Grid::column(2))
.attach(Grid::row(6))
//.count(themes_count)
.items_builder(move |build_ctx, index| {
let theme_name =
MenuView::themes_ref(&build_ctx.get_widget(id))[index].clone();
TextBlock::new().v_align("center").text(theme_name).build(build_ctx)
})
.on_changed("selected_index", move |ctx, _| {
ctx.send_message(MenuAction::SetTheme, id);
println!("changed theme.");
})
.selected_index(id)
.build(ctx),
)
.build(ctx)
}

View File

@@ -0,0 +1,82 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
use cfg_if::cfg_if;
use orbtk::prelude::*;
use crate::data::constants::*;
use crate::widgets::menu::menu_state::{MenuAction, MenuState};
type List = Vec<String>;
// Macro that initializes the widget structures/variables for the menu view
widget!(
MenuView<MenuState> {
//menu_stack: Entity,
//button_menu: Entity,
selected_index: i32,
themes: List
}
);
/// The template implementation of the menu view
/// All GUI elements are styled using the "style" attribute referencing to a ron based css
impl Template for MenuView {
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
cfg_if! {
if #[cfg(windows)] {
// define the list of supported themes
let themes = vec![
"default_dark".to_string(),
"default_light".to_string(),
"redox".to_string(),
"fluent_dark".to_string(),
"fluent_light".to_string()
];
} else {
// define the list of supported themes
let themes = vec![
"default_dark".to_string(),
"default_light".to_string(),
"redox".to_string(),
];
}
}
//self.themes(themes).child(MenuState::create_menu(ID_MENU_POPUP, ctx))
self.themes(themes).child(
Stack::new()
.id(ID_MENU_STACK)
.child(
TextBlock::new()
.style("header")
.attach(Grid::row(0))
.attach(Grid::column(0))
.style("small_text")
.text("Select theme")
.build(ctx),
)
.child(
Button::new()
//.id("button_menu")
.id(ID_MENU_BUTTON)
.style("button_single_content")
.icon(material_icons_font::MD_MENU)
.attach(Grid::column(2))
.h_align("end")
.on_click(move |ctx, _| {
println!("WIP: open menu popup from MenuView");
ctx.get_mut::<MenuState>(id)
.set_action(MenuAction::CreateMenu);
true
})
.build(ctx),
)
.build(ctx),
)
}
}

View File

@@ -28,6 +28,3 @@ pub mod policycheck;
// /// Policylists widget. // /// Policylists widget.
// pub mod policylist; // pub mod policylist;
/// Ticketdata wigdet.
pub mod ticketdata;

View File

@@ -19,37 +19,30 @@ use crate::{
structures::{PolicyCode, PolicyDataList, PolicyList}, structures::{PolicyCode, PolicyDataList, PolicyList},
constants::*, constants::*,
}, },
//services::imports::allianzdirectcall::import,
services::imports::allianzdirectcall,
widgets::global_state::GlobalState, widgets::global_state::GlobalState,
//widgets::menu::menu_view::MenuView, //widgets::menu::menu_view::MenuView,
//widgets::policycheck::policycheck_view::PolicycheckView, //services::imports::allianzdirectcall::import,
//widgets::ticketdata::ticketdata_state::TicketdataAction, services::imports::allianzdirectcall,
}; };
/// Enumeration of valid `action variants` that need to be handled as /// Valid `actions` that are handled as state changes in the `Policycheck` widget.
/// state changes for the `PolicycheckView` widget. #[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone)]
pub enum PolicycheckAction { pub enum PolicycheckAction {
ClearPolicyNumber, AddProgress(f64),
ClearEntry(Entity),
ChangeTheme(), ChangeTheme(),
SendPolicynumber(),
InputTextChanged(Entity), InputTextChanged(Entity),
ImportData, ImportData,
NewTicket, ParseEntry(Entity),
ParsePolicyNumber(Entity),
RemoveFocus(Entity), RemoveFocus(Entity),
RemovePopup(Entity), RemovePopup(Entity),
ResetProgress, ResetProgress,
GetProgress,
SetProgress(f64), SetProgress(f64),
SetProgressPopup(Entity), SetProgressPopup(Entity),
SetToggleTheme(Entity), SetToggleTheme(Entity),
SetEntry(Entity), SetEntry(Entity),
SetVisibility(Entity), SetVisibility(Entity),
TextChanged(Entity, usize), TextChanged(Entity, usize)
UpdatePolicyCode,
UpdateProgress(f64)
} }
/// Define valid environment variables provided via .env files /// Define valid environment variables provided via .env files
@@ -64,20 +57,16 @@ struct Environment {
/// Valid `structures` that are handled inside the state of the `Policycheck` widget. /// Valid `structures` that are handled inside the state of the `Policycheck` widget.
#[derive(AsAny, Default)] #[derive(AsAny, Default)]
pub struct PolicycheckState { pub struct PolicycheckState {
actions: Vec<PolicycheckAction>, action: Option<PolicycheckAction>,
button_menu: Entity,
duration: Duration, duration: Duration,
label_result: Entity, label_result: Entity,
lang: String, lang: String,
button_menu: Entity,
policy_data_count: u64, policy_data_count: u64,
//policy_number: Entity,
policy_numbers: HashMap<u64, PolicyCode>, policy_numbers: HashMap<u64, PolicyCode>,
progress_bar: Entity, progress_bar: Entity,
progress_count: f64, progress_count: f64,
progress_popup: Entity, progress_popup: Entity
// target that recieves messages
target: Entity,
ticketdata_view: Entity
} }
impl GlobalState for PolicycheckState {} impl GlobalState for PolicycheckState {}
@@ -85,8 +74,7 @@ impl GlobalState for PolicycheckState {}
/// Method definitions, that react on any given state change inside the `Policycheck` widget. /// Method definitions, that react on any given state change inside the `Policycheck` widget.
impl PolicycheckState { impl PolicycheckState {
/// Create a hashmap (key: policy number, value: policy type). /// Create a hashmap (key: policy number, value: policy type).
pub fn create_hashmap(&mut self, _ctx: &mut Context<'_>) pub fn create_hashmap(&mut self, _ctx: &mut Context<'_>) -> Result<(), Box<dyn std::error::Error>> {
-> Result<(), Box<dyn std::error::Error>> {
trace!(target: "advotracker", create_hashmap = "started"); trace!(target: "advotracker", create_hashmap = "started");
let policy_list = PolicyList::new("policy list"); let policy_list = PolicyList::new("policy list");
@@ -126,31 +114,29 @@ impl PolicycheckState {
} }
/// Clear text in text box. /// Clear text in text box.
pub fn clear_policy_number(&mut self, ctx: &mut Context<'_>) { pub fn clear_entry(&mut self, _text_box: Entity, ctx: &mut Context<'_>) {
TextBox::text_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("")); TextBox::text_set(&mut ctx.widget(), String::from(""));
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed); }
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Collapsed);
}
/// Import policy numbers into hashmap /// Import policy numbers into hashmap
fn import_data(&mut self, ctx: &mut Context<'_>) fn import_data(&mut self, ctx: &mut Context<'_>)
-> Result<(), Box<dyn std::error::Error>> { -> Result<(), Box<dyn std::error::Error>> {
// WIP: for now, only import once per session // WIP: for now, only import once per session
if self.policy_data_count == 0 { if self.policy_data_count == 0 {
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), true); TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), true);
if self.policy_numbers.is_empty() { if self.policy_numbers.len() == 0 {
// initialize popup widget // initialize popup widget
self.set_popup_progress(ctx); self.set_popup_progress(ctx);
self.progress_count += 0.33; self.progress_count += 0.33;
self.update_progress_bar(ctx); self.update_progress_bar(ctx);
//sender.send(WindowRequest::Redraw).unwrap();
for _ in 1..4 { // for _ in 1..4 {
self.progress_count += 0.33; // self.progress_count += 0.33;
self.update_progress_bar(ctx); // self.update_progress_bar(ctx);
ctx.send_message(PolicycheckAction::UpdateProgress(self.progress_count), self.progress_popup); // sender.send(WindowRequest::Redraw).unwrap();
} //}
// importing policy code elements from csv-file // importing policy code elements from csv-file
match self.create_hashmap(ctx) { match self.create_hashmap(ctx) {
@@ -164,6 +150,7 @@ impl PolicycheckState {
self.progress_count = 1.; self.progress_count = 1.;
self.update_progress_bar(ctx); self.update_progress_bar(ctx);
//sender.send(WindowRequest::Redraw).unwrap();
} }
_ => { _ => {
let res = t!("policy.hashmap.failed", self.lang); let res = t!("policy.hashmap.failed", self.lang);
@@ -181,20 +168,12 @@ impl PolicycheckState {
Ok(()) Ok(())
} }
/// Create new ticket
pub fn new_ticket(&mut self, _ctx: &mut Context<'_>) {
println!("WIP: new ticket.");
self.ticketdata_view.0;
//ctx.widget().get_mut::<TicketdataView>(0).
//ctx.get_widget(self.ticketdata_view);
}
/// Parse validity of the given policy number. /// Parse validity of the given policy number.
pub fn parse_entry(&mut self, policy_check_policy_number: Entity, fn parse_entry(&mut self, policy_check_policy_number: Entity,
ctx: &mut Context<'_>) { ctx: &mut Context<'_>) {
trace!(target: "advotracker", parse_entry = "started"); trace!(target: "advotracker", parse_entry = "started");
let policy_number_string = TextBox::text_clone(&ctx.get_widget(policy_check_policy_number)); let policy_number_string = TextBox::text_clone(&mut ctx.get_widget(policy_check_policy_number));
let policy_number_length = policy_number_string.len(); let policy_number_length = policy_number_string.len();
if self.policy_data_count == 0 { if self.policy_data_count == 0 {
@@ -216,14 +195,20 @@ impl PolicycheckState {
// Parse policy code: "AS-123456789" // Parse policy code: "AS-123456789"
// DION VERS POLLFNR // DION VERS POLLFNR
// 1 AS 1515735810 // 1 AS 1515735810
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), 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);
//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::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 { if policy_number_length == 10 {
// cast policy_number_sting to <u64> // cast policy_number_sting to <u64>
match policy_number_string.parse::<u64>() { match policy_number_string.parse::<u64>() {
Ok(p) => { Ok(p) => {
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), String::from("")); TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from(""));
// match hashmap's key // match hashmap's key
match self.policy_numbers.get(&p) { match self.policy_numbers.get(&p) {
@@ -234,9 +219,7 @@ impl PolicycheckState {
let string_result = format!("1-{:?}-{}", let string_result = format!("1-{:?}-{}",
policy_code, p); policy_code, p);
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from(string_result));
// adapt the view properties
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), string_result);
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#008000")); TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#008000"));
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000")); Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
@@ -244,13 +227,8 @@ impl PolicycheckState {
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CHECK); 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); Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Visible); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Visible);
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_BUTTON_CLEAR), Visibility::Visible);
} }
_ => { _ => {
// no matching key // no matching key
@@ -265,10 +243,8 @@ impl PolicycheckState {
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR); 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); Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
} }
} }
}, },
@@ -277,17 +253,17 @@ impl PolicycheckState {
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000")); 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::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::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::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::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); Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
} }
} }
} }
@@ -306,10 +282,8 @@ impl PolicycheckState {
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR); 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); Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
} }
if policy_number_length > 10 { if policy_number_length > 10 {
let res = t!("policy.validation.failed", self.lang); let res = t!("policy.validation.failed", self.lang);
@@ -326,20 +300,13 @@ impl PolicycheckState {
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR); 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); Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed); Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
} }
trace!(target: "advotracker", parse_entry = "finished"); trace!(target: "advotracker", parse_entry = "finished");
} }
/// parse message 'ParseEntry'
pub fn parse_policy_number(&mut self, entity: Entity) {
self.actions.push(PolicycheckAction::ParsePolicyNumber(entity));
}
/// Remove the popup box /// Remove the popup box
fn remove_popup(&mut self, id: Entity, ctx: &mut Context<'_>) { fn remove_popup(&mut self, id: Entity, ctx: &mut Context<'_>) {
ctx.remove_child(self.progress_popup); ctx.remove_child(self.progress_popup);
@@ -359,23 +326,19 @@ impl PolicycheckState {
// ctx.get_widget(self.policy_check_policy_number).update_theme_by_state(true); // ctx.get_widget(self.policy_check_policy_number).update_theme_by_state(true);
// } // }
/// Sending message 'UpdatePolicyCode' /// Sets a new action.
pub fn send_message_update_policy_code(&mut self, entity: Entity) { pub fn set_action(&mut self, action: PolicycheckAction) {
println!("WIP: send_message_update_policy_code = {:?}", entity); self.action = action.into();
//self.actions.push(PolicycheckAction::UpdatePolicyNumber("4711".to_string()));
//let policy_number = (ctx.get_child(entity).get::<String>("text"));
//println!("WIP: poliy_number = {:?}", policy_number);
//self.actions.push(PolicycheckAction::UpdatePolicyNumber(self.policy_number));
} }
/// Change status of given text box to edit mode. /// Change status of given text box to edit mode.
fn set_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) { fn set_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) {
if ctx.get_widget(text_box).get::<String16>("text").is_empty() { if ctx.get_widget(text_box).get::<String16>("text").is_empty() {
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);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed); TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Collapsed);
} else { } else {
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_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_POLICY_CODE), Visibility::Visible); TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
} }
} }
@@ -390,16 +353,18 @@ impl PolicycheckState {
// create the progress_popup widget // create the progress_popup widget
self.progress_popup = create_popup_progress(current_entity, build_context); self.progress_popup = create_popup_progress(current_entity, build_context);
info!("set_popup_progress: New entity 'popup_progress' {:?} created", self.progress_popup); println!("New entity `progress_popup` created: {:?}", self.progress_popup);
// append the stack inside the progress_popup // append the stack inside the progress_popup
build_context.append_child(stack, self.progress_popup); build_context.append_child(stack, self.progress_popup);
// make sure we have a progress bar // make sure we have a
self.progress_bar = ctx self.progress_bar = ctx
.entity_of_child(ID_POLICY_CHECK_PROGRESS_BAR) .entity_of_child(ID_POLICY_CHECK_PROGRESS_BAR)
.expect("PolicycheckState.init: Can't find entity of resource 'ID_POLICY_CHECK_PROGRESS_BAR'."); .expect("PolicycheckState.init: Can't find entity of resource 'ID_POLICY_CHECK_PROGRESS_BAR'.");
info!("set_popup_progress: New entity 'progress_bar' created: {:?}", self.progress_bar); println!("New entity `progress_bar` created: {:?}", self.progress_bar);
println!("function `set_popup_progress()` finished!");
} }
/// Change visibility of the result label. /// Change visibility of the result label.
@@ -411,6 +376,8 @@ impl PolicycheckState {
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_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); TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
} }
//ctx.get_widget(self.label_result).update_theme_by_state(true);
} }
/// Update count of elements in the policy data list. /// Update count of elements in the policy data list.
@@ -423,19 +390,11 @@ impl PolicycheckState {
let res = t!("policy.string.progress_time", self.lang); let res = t!("policy.string.progress_time", self.lang);
let string_duration = format!("{}: {:?}", res, self.duration); let string_duration = format!("{}: {:?}", res, self.duration);
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_TIME), string_duration); TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_TIME), String::from(string_duration));
let mut progress_bar = ctx.child(ID_POLICY_CHECK_PROGRESS_BAR); let mut progress_bar = ctx.child(ID_POLICY_CHECK_PROGRESS_BAR);
progress_bar.set::<f64>("val", self.progress_count); progress_bar.set::<f64>("val", self.progress_count);
} }
/// Update the policy code policy data list.
fn update_policy_code(&self, _ctx: &mut Context<'_>) {
println!("update internal: policy_code");
//let policy_code = ctx.widget().get::<PolicycheckState>(ID_POLICY_CHECK_POLICY_CODE);
//ctx.widget().set(PROP_POLICY_DATA_COUNT, policy_code);
}
} }
/// Supported methods handled inside the `PolicycheckState` /// Supported methods handled inside the `PolicycheckState`
@@ -446,35 +405,24 @@ impl State for PolicycheckState {
trace!(target: "advotracker", policycheck_state = "init", status = "started"); trace!(target: "advotracker", policycheck_state = "init", status = "started");
// Get language from environment
self.lang = PolicycheckState::get_lang();
// Initialize required entities // Initialize required entities
self.button_menu = ctx self.button_menu = ctx
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU) .entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
.expect("PolicycheckState::init: Can't find resource entity 'ID_POLICY_CHECK_BUTTON_MENU'."); .expect("PolicycheckState.init: Can't find resource entity 'ID_POLICY_CHECK_BUTTON_MENU'.");
self.label_result = ctx self.label_result = ctx
.entity_of_child(ID_POLICY_CHECK_LABEL_RESULT) .entity_of_child(ID_POLICY_CHECK_LABEL_RESULT)
.expect("PolicycheckState::init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'."); .expect("PolicycheckState.init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'.");
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);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed); //TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed); //Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_0), Visibility::Collapsed);
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), 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);
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Collapsed); // Preset localization with given environment lang
self.lang = PolicycheckState::get_lang();
ctx.set_language(&self.lang);
//self.policy_number = Entity::from(ctx.widget().try_clone::<u32>(ID_POLICY_CHECK_POLICY_NUMBER)
// .expect("PolicycheckState::init(): Can't find resource entity 'ID_POLICY_CHECK_POLICY_NUMBER'."));
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
.expect("PolicycheckState::init(): Can't find resource entity 'target'."));
//self.ticketdata_view = (*ctx.widget().get::<u32>("ticketdata_view")).into();
//self.ticketdata = Entity::from(ctx.widget().try_clone::<u32>(ID_TICKET_DATA_VIEW)
// .expect("PolicycheckState::init(): Can't find resource entity 'ticketdata'."));
// // Load the saved data from a file in 'ron' format into our data structure. // // 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 // // The cargo package identifier (default: 'nwx.advotracker') is used as the
@@ -503,17 +451,8 @@ impl State for PolicycheckState {
) { ) {
for message in messages.read::<PolicycheckAction>() { for message in messages.read::<PolicycheckAction>() {
match message { match message {
PolicycheckAction::ClearPolicyNumber => { PolicycheckAction::AddProgress(increment) => {
self.clear_policy_number(ctx); let old_width = ProgressBar::val_clone(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
}
PolicycheckAction::NewTicket => {
self.new_ticket(ctx);
}
PolicycheckAction::UpdatePolicyCode => {
self.update_policy_code(ctx);
}
PolicycheckAction::UpdateProgress(increment) => {
let old_width = ProgressBar::val_clone(&ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
let new_width = old_width + increment; let new_width = old_width + increment;
// Set the ProgressBar's val property to the calculated percentage // Set the ProgressBar's val property to the calculated percentage
@@ -524,7 +463,7 @@ impl State for PolicycheckState {
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 1.); ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 1.);
} }
} }
_ => { println!("PolicycheckAction: action not implemented!"); } _ => (),
} }
} }
} }
@@ -541,14 +480,10 @@ impl State for PolicycheckState {
// } // }
//} //}
// Create `actions`, a drained iterator (".." => full range that clears the vector) if let Some(action) = self.action {
let actions: Vec<PolicycheckAction> = self.actions.drain(..).collect();
for action in actions {
match action { match action {
PolicycheckAction::ClearPolicyNumber => { PolicycheckAction::ClearEntry(policy_check_policy_number) => {
println!("clear entry"); ctx.get_widget(policy_check_policy_number).set("enabled", false);
self.clear_policy_number(ctx);
} }
PolicycheckAction::InputTextChanged(entity) => { PolicycheckAction::InputTextChanged(entity) => {
println!("entry changed: {}", TextBox::text_clone(&ctx.get_widget(entity))); println!("entry changed: {}", TextBox::text_clone(&ctx.get_widget(entity)));
@@ -564,10 +499,7 @@ impl State for PolicycheckState {
} }
} }
} }
PolicycheckAction::NewTicket => { PolicycheckAction::ParseEntry(text_box) => {
self.new_ticket(ctx);
}
PolicycheckAction::ParsePolicyNumber(text_box) => {
self.parse_entry(text_box, ctx); self.parse_entry(text_box, ctx);
} }
PolicycheckAction::RemoveFocus(policy_check_policy_number) => { PolicycheckAction::RemoveFocus(policy_check_policy_number) => {
@@ -575,6 +507,7 @@ impl State for PolicycheckState {
//ctx.EventAdapter(FocusEvent::RemoveFocus(policy_check_policy_number)); //ctx.EventAdapter(FocusEvent::RemoveFocus(policy_check_policy_number));
} }
PolicycheckAction::RemovePopup(entity) => { PolicycheckAction::RemovePopup(entity) => {
//println!("WIP: remove popup");
self.remove_popup(entity, ctx); self.remove_popup(entity, ctx);
} }
PolicycheckAction::ResetProgress => { PolicycheckAction::ResetProgress => {
@@ -599,31 +532,11 @@ impl State for PolicycheckState {
PolicycheckAction::TextChanged(entity, _index) => { PolicycheckAction::TextChanged(entity, _index) => {
self.set_entry(entity, ctx); self.set_entry(entity, ctx);
} }
PolicycheckAction::UpdatePolicyCode => {
self.update_policy_code(ctx);
//info!("Message send: 'PolicycheckAction::UpdatePolicyNumber({:?}) -> {:?}'", policy_number, self.target);
//let policy_number = (&mut ctx.get_widget(entity).get::<String>("text"));
//let policy_number = ctx.get_widget(ID_POLICY_CHECK_POLICY_NUMBER).get::<text>("text");
//ctx.send_message(PolicycheckAction::UpdatePolicyCode("AS-1-4711".to_string()), self.target);
//ctx.send_message(PolicycheckAction::UpdatePolicyCode, self.target);
//let mut widget_container : WidgetContainer = ctx.widget();
//widget_container.get::<String16>("text");
//let polnum: TextBox = TextBox::get(ctx.child(ID_POLICY_CHECK_POLICY_NUMBER));
//println!("Policy number: {:?}", polnum);
//let policy_number = ctx.get_widget(self.policy_check_policy_number);
//let policy_number2 = TextBox::text_clone(&ctx.get_widget(ID_POLICY_CHECK_POLICY_NUMBER));
//let policy_number_string = ctx.get_widget(entity).get::<String16>("text").is_empty();
//let policy_number = TextBox::text_clone(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER));
//ctx.send_message(PolicycheckAction::UpdatePolicyNumber(policy_check_policy_number), self.target);
//info!("Message send: 'PolicycheckAction::UpdatePolicyNumber({:?}) -> {:?}'", policy_check_policy_number, self.target);
}
_ => (), _ => (),
} }
} }
// Reset action
self.action = None;
} }
// /// Update the view after the layout is rendered. // /// Update the view after the layout is rendered.
@@ -635,16 +548,15 @@ impl State for PolicycheckState {
fn create_popup_progress(id: Entity, ctx: &mut BuildContext<'_>) -> Entity { fn create_popup_progress(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
Popup::new() Popup::new()
.id(ID_POLICY_CHECK_POPUP_PROGRESS) .id(ID_POLICY_CHECK_POPUP_PROGRESS)
.target(id.0) .target(id)
.open(true) .open(true)
.style("popup_progress") .style("popup_progress")
.width(280) .width(280)
.height(100) .height(100)
.visibility(Visibility::Visible) .on_click(move |ctx, _| {
.on_click(move |_ctx, _| {
println!("create_popup_progress: on_click -> remove_popup(popup_progress)"); println!("create_popup_progress: on_click -> remove_popup(popup_progress)");
//ctx.get_mut::<PolicycheckState>(id) ctx.get_mut::<PolicycheckState>(id)
// .set_action(PolicycheckAction::RemovePopup(id)); .set_action(PolicycheckAction::RemovePopup(id));
true true
}) })
.child( .child(

View File

@@ -0,0 +1,396 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
use orbtk::prelude::*;
use orbtk::shell::event::Key;
use crate::{
data::{
constants::*,
structures::PolicyCheck,
},
//widgets::menu::menu_state::{MenuAction, MenuState},
widgets::policycheck::policycheck_state::{PolicycheckAction, PolicycheckState},
};
// Macro that initializes the widget structures/variables for the policy check view
widget!(
/// Dialog to enter a policy identifier/number.
/// This identifier is checked agains a map of valid policy codes.
// PolicycheckView<PolicycheckState>: KeyDownHandler {
PolicycheckView<PolicycheckState> {
lang: String,
policy_check: PolicyCheck,
policy_check_title: String,
policy_data_count: u32
}
);
/// The template implementation of the policy check view
/// All GUI elements are styled using the "style" attribute referencing to a ron based css
impl Template for PolicycheckView {
//fn template(self, policycheck_view: Entity, ctx: &mut BuildContext<'_>) -> Self {
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
let policy_check_bottom_bar = Container::new()
//.style(STYLE_BOTTOM_BAR)
.attach(Grid::row(4))
.attach(Grid::column(1))
.attach(Grid::column_span(2))
.v_align("end")
.child(
Container::new()
.child( Container::new()
.margin((0, 16, 16, 0))
.v_align("center")
.child(
ImageWidget::new()
.image("assets/advotracker/hiedemann_logo.png")
.v_align("center")
.build(ctx),
)
.build(ctx),
)
.build(ctx),
)
.child(
Container::new()
.attach(Grid::column(1))
.h_align("end")
.v_align("end")
.child(
TextBlock::new()
.margin((0, 9, 48, 0))
.text("©Networkx GmbH")
.build(ctx)
)
.build(ctx),
)
.build(ctx);
let policy_check_button_menu = Button::new()
.id(ID_POLICY_CHECK_BUTTON_MENU)
.style("button_single_content")
.icon(material_icons_font::MD_MENU)
.attach(Grid::column(2))
//.min_size(16, 16)
.h_align("end")
.on_click(move |_ctx, _| {
println!("WIP: open menu popup from MenuView");
// ctx.get_mut::<MenuState>(id)
// .set_action(MenuAction::CreateMenu(ID_MENU_STACK));
true
})
.build(ctx);
let policy_check_button_result = Button::new()
.id(ID_POLICY_CHECK_BUTTON_RESULT)
.style("button_single_content")
.h_align("start")
.v_align("center")
.visibility(Visibility::Collapsed)
.enabled(false)
.build(ctx);
let policy_check_header_bar = Container::new()
.style(STYLE_HEADER_BAR)
.attach(Grid::row(0))
.attach(Grid::column(1))
.attach(Grid::column_span(2))
.child(
Grid::new()
.child(
TextBlock::new()
.style("header")
.id(ID_POLICY_CHECK_HEADER)
.v_align("center")
.h_align("left")
.text("Validation policy number")
.build(ctx),
)
.build(ctx),
)
.child(policy_check_button_menu)
.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)
.style("body")
.attach(Grid::row(0))
.attach(Grid::column(0))
.margin((0, 0, 16, 0))
.h_align("end")
.v_align("center")
.width(300)
.min_width(300)
.text("Policy number")
.build(ctx),
)
.child(
TextBox::new()
.attach(Grid::row(0))
.attach(Grid::column(2))
.id(ID_POLICY_CHECK_POLICY_NUMBER)
.h_align("start")
.lose_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
//ctx.get_mut::<PolicycheckState>(policy_check_view)
ctx.get_mut::<PolicycheckState>(id)
.set_action(PolicycheckAction::ParseEntry(entity));
})
//.on_changed(|_, entity, _, _| println!("Selection changed: {:?}", entity))
// .on_changed(move |ctx, entity, _| {
// ctx.get_mut::<PolicycheckState>(id)
// .set_action(Action::SetProgressBox(entity));
// ctx.get_mut::<PolicycheckState>(id)
// .set_action(Action::AddProgress(0.5));
// ctx.get_mut::<PolicycheckState>(id)
// .set_action(Action::InputTextChanged(entity));
// ctx.get_mut::<PolicycheckState>(id)
// .set_action(Action::SetVisibility(entity));
// ctx.get_widget(policy_check_label_policy_number).set("visible");
// ctx.get_mut::<PolicycheckState>(id)
// .set_action(Action::SetVisility(entity));
// })
// .on_mouse_down | .on_mouse_move | .on_mouse_up (move |ctx, entity| {
// state(id, states).set_action(Action::AddItem);
// })
.on_key_down(move |_, key_event| {
if key_event.key == Key::A(true) {
println!("A key down");
}
// ctx.get_mut::<PolicycheckState>(id)
// .set_action(Action::ImportData);
true
})
.build(ctx),
)
.child(policy_check_button_result)
.build(ctx);
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)
.style("body")
.attach(Grid::row(1))
.attach(Grid::column(0))
.margin((0, 0, 16, 0))
.h_align("end")
.v_align("center")
.width(300)
.min_width(300)
.text("Policy code")
.build(ctx),
)
.child(
TextBlock::new()
.id(ID_POLICY_CHECK_RESULT)
.style("body")
.attach(Grid::row(1))
.attach(Grid::column(2))
.h_align("start")
.v_align("center")
.text("empty")
.build(ctx)
)
.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()
// Label
.push("300")
// Seperator
.push("16")
// Values
.push("auto")
// Seperator
.push("16")
// Result-Button
.push("32")
//.build(),
)
.rows(
Rows::create()
.push("auto")
.push("auto")
.push("*")
//.build(),
)
.child(policy_check_form_row_0)
.child(policy_check_form_row_1)
.child(policy_check_form_row_2)
.build(ctx),
)
.build(ctx);
// WIP: this widget type should handle our target natively
// but it isn't able to get textinput, nor handle usize values
// ... yet
let _policy_check_numeric_box = NumericBox::new()
.id(ID_POLICY_CHECK_POLICY_NUMBER)
.h_align("start")
.width(100)
//.min(<usize>1000000000)
//.max(<usize>9999999999)
.val(0)
.min_width(95)
.margin((0, 0, 0, 16))
// WIP code @kivimango
// .on_activate(move |ctx, entity| {
// ctx.get_mut::<PolicycheckState>(id)
// .set_action(Action::ParseEntry(entity));
// })
// .on_changed(move |ctx, entity| {
// ctx.get_mut::<PolicycheckState>(id)
// .set_action(Action::InputTextChanged(entity));
//})
.build(ctx);
// row3: only shown, if we read in `policy numbers` in
// a hashmap as values
let policy_data_stack = Stack::new()
.id(ID_POLICY_DATA_STACK)
.attach(Grid::row(3))
.attach(Grid::column(1))
.h_align("end")
.v_align("top")
.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
self.name("PolicycheckView")
// initialize struct (derived default macro)
.policy_check(PolicyCheck::default())
.child(
Grid::new()
.id(ID_POLICY_CHECK_WIDGET)
.columns(
Columns::create()
.push(50)
.push("*")
.push(50)
//.build(),
)
.rows(
Rows::create()
.push("auto")
.push(28)
.push("*")
.push("auto")
.push("auto")
//.build(),
)
// row 0: Policy Check Header
.child(policy_check_header_bar)
// row 1: Seperator
// row 2: Policy Check Form
.child(policy_check_form)
// row 3: Sum HashMap elements
.child(policy_data_stack)
// row 4: Policy Check Bottom
.child(policy_check_bottom_bar)
.build(ctx),
)
}
}
// helper to request PolicycheckState
//fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut PolicycheckState {
// states.get_mut(id)
//}

1
advotrackerd Submodule

Submodule advotrackerd added at 409d8d1f1a

View File

@@ -1 +0,0 @@
data/POLLFNR_WOECHENTLICH.txt

View File

@@ -1,17 +0,0 @@
###
# .env
# will overwrite standard environment viariables
###
# set the language variable used in test-runs
#test LANG=de-DE
#test LANG=es-ES
#test LANG=C
# set the language variable (overwriting standard Enviroment)
#TEST_LANG=de_DE
#TEST_LANG=C
#RUST_LOG=advotracker=trace
#LANG=de_DE
RUST_LOG=trace
#RUST_LOG=none
USERNAME=hiedemann
DB_DRIVER=sqlite

View File

@@ -1,16 +0,0 @@
###
# .env
# will overwrite standard environment viariables
###
# set the language variable used in test-runs
#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

Some files were not shown because too many files have changed in this diff Show More