Compare commits
59 Commits
next
...
wip_messag
| Author | SHA1 | Date | |
|---|---|---|---|
| 9fc4c6c01d | |||
| 9ef2e3816e | |||
| 3162233c85 | |||
| 30131ecdb1 | |||
| 6d9d82bb8e | |||
| 5e390a8cfa | |||
| 8630ee1c12 | |||
| 791b451d39 | |||
| aeaafd8c57 | |||
| 1af299dc01 | |||
| bd6971d4d0 | |||
| 85fb4ceb16 | |||
| a451b58ab4 | |||
| b96c3c510f | |||
| 2c903c67dd | |||
| a40f6e94dd | |||
| 8af49deb34 | |||
| 202ba81b4f | |||
| 43db004179 | |||
| 3b65dafbec | |||
| 23732350ca | |||
| 3c40055e2e | |||
| 6a61d2f878 | |||
| 044ad84598 | |||
| b2a9d9aa52 | |||
| 157da4228a | |||
| 26cf43bfae | |||
| a2314d4909 | |||
| 0dab2dddb3 | |||
| bb40033554 | |||
| a4a09bc37c | |||
| 9fba66d8a6 | |||
| 7d6476205f | |||
| 41ebf4168a | |||
| c4caf12706 | |||
| 075505eec9 | |||
| 59e7e71143 | |||
| 7440f7a6dd | |||
| a401379f9e | |||
| be9b8b1a1c | |||
| 70bd6b8b8d | |||
| 1f3c6a7fff | |||
| ef26a3bf65 | |||
| fa4914839e | |||
| 571243731d | |||
| b38a677b7b | |||
| 26cea8e844 | |||
| 48545d2879 | |||
| b352f2a581 | |||
| 89a6842106 | |||
| 76e6e7503f | |||
| a1541ae307 | |||
| c66335951f | |||
| d0e661d5d0 | |||
| 2253c2892b | |||
| 8cc9ba5782 | |||
| ef8b884efa | |||
| 6b7ae9d17d | |||
| f0e9014fb7 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,6 +1,3 @@
|
||||
[submodule "backend"]
|
||||
path = backend
|
||||
url = ./backend/
|
||||
[submodule "advotracker-db"]
|
||||
path = advotracker-db
|
||||
url = https://gitea.networkx.de:50443/rzerres/advotracker-db
|
||||
|
||||
Submodule advotracker-db updated: d29c747d7b...51e747ef6d
@@ -3,13 +3,14 @@
|
||||
# will overwrite standard environment viariables
|
||||
###
|
||||
# set the language variable used in test-runs
|
||||
#test LANG=de-DE
|
||||
#test LANG=es-ES
|
||||
#test LANG=it-IT
|
||||
#test LANG=C
|
||||
# set the language variable (overwriting standard Enviroment)
|
||||
#TEST_LANG=de_DE
|
||||
#TEST_LANG=C
|
||||
#RUST_LOG=advotracker=trace
|
||||
#LANG=de_DE
|
||||
RUST_LOG=trace
|
||||
#RUST_LOG=none
|
||||
USERNAME=hiedemann
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "advotracker"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
authors = ["Ralf Zerres <ralf.zerres@networkx.de>"]
|
||||
description = "Frontend component that supports lawyers to capture relevant data encountered during an online legal advice."
|
||||
readme = "README.md"
|
||||
@@ -19,24 +19,29 @@ winapi = { version = "0.3", features = ["winuser"] }
|
||||
[dependencies]
|
||||
async-stream = "~0.2"
|
||||
chrono = { version = "~0.4.0", features = ["serde"] }
|
||||
cfg-if = { version = "~1.0" }
|
||||
clap = { version = "~2.33", features = ["suggestions", "color"] }
|
||||
csv = { version = "~1.1" }
|
||||
dotenv = { version = "~0.15.0" }
|
||||
envy = { version = "~0.4" }
|
||||
lettre = "0.10.0-beta.1"
|
||||
lazy_static = { version = "~1.4.0" }
|
||||
log = { version = "~0.4.8" }
|
||||
locales = { version = "~0.1" }
|
||||
maud = { version = "~0.22.1" }
|
||||
#orbtk = { version = "~0.3.1-alpha4" }
|
||||
orbtk = { git = "https://github.com/redox-os/orbtk.git", branch = "develop" }
|
||||
#orbtk = { path = "../../orbtk" }
|
||||
#orbtk = { git = "https://github.com/redox-os/orbtk.git", branch = "develop" }
|
||||
orbtk = { path = "../../orbtk" }
|
||||
serde = { version = "~1.0", features = ["derive"] }
|
||||
substring = { version = "~1" }
|
||||
#tokio = { version = "~0.2", features = ["macros", "rt-threaded", "stream", "time"] }
|
||||
tracing = { version = "~0.1" }
|
||||
tracing-subscriber = { version = "~0.2.0", features = ["tracing-log"] }
|
||||
viperus = { git = "https://github.com/maurocordioli/viperus", features = ["cache", "fmt-clap", "fmt-env", "global", "watch"] }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
[features]
|
||||
# no features by default
|
||||
default = []
|
||||
debug = ["orbtk/debug"]
|
||||
light = []
|
||||
@@ -46,3 +51,18 @@ name = "advotracker"
|
||||
identifier = "nwx.advotracker"
|
||||
short_description = "Online legal advice helper."
|
||||
description = "Supports lawyers to capture relevant data encountered during an online legal advice.\n"
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 1
|
||||
incremental = true
|
||||
|
||||
[profile.release]
|
||||
incremental = true
|
||||
|
||||
#[[bin]]
|
||||
#//name = "policycheck"
|
||||
#path = "src/bin/policycheck.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "advotracker"
|
||||
path = "src/main.rs"
|
||||
|
||||
@@ -10,38 +10,50 @@ Dictionary (
|
||||
// the map of active identifiers
|
||||
// like a struct, but keys are also values instead of just beenig identifiers
|
||||
words: {
|
||||
// policycheck_view
|
||||
"Validation policy number": "Prüfung Versicherungsnummer",
|
||||
"Policy number": "Versicherungsnummer",
|
||||
"Policy code": "ID der Vers.-Nummer",
|
||||
"Checklist elements: ": "Prüflistenelemente: ",
|
||||
"Check result": "Prüfungsergebnis",
|
||||
"Importing data": "Importiere Datensätze",
|
||||
"Processing time": "Bearbeitungszeit",
|
||||
"Error:": "Fehler:",
|
||||
"Reason": "Grund",
|
||||
"Policy number is to long": "Die Nummer ist zu lang",
|
||||
"Policy number is to short": "Die Nummer ist zu kurz",
|
||||
"The given policy number is invalid": "Die Versicherungsnummer ist ungültig",
|
||||
"The given policy number is valid": "Die Versicherungsnummer ist gültig",
|
||||
"Only numbers are valid": "Nur Nummern sind zulässig",
|
||||
"Account": "Benutzer",
|
||||
"Toggle theme": "Thema wechseln",
|
||||
"Quit": "Beenden",
|
||||
// policycheck_view
|
||||
"Validation policy number": "Prüfung Versicherungsnummer",
|
||||
"Policy number": "Versicherungsnummer",
|
||||
"Policy code": "Vers.-Schein/Schadennummer",
|
||||
"Policy holder": "Versicherungsnehmer",
|
||||
"Checklist elements: ": "Prüflistenelemente: ",
|
||||
"Check result": "Prüfungsergebnis",
|
||||
"Importing data": "Importiere Datensätze",
|
||||
"Processing time": "Bearbeitungszeit",
|
||||
"Error:": "Fehler:",
|
||||
"Reason": "Grund",
|
||||
"Policy number is to long": "Die Nummer ist zu lang",
|
||||
"Policy number is to short": "Die Nummer ist zu kurz",
|
||||
"The given policy number is invalid": "Die Versicherungsnummer ist ungültig",
|
||||
"The given policy number is valid": "Die Versicherungsnummer ist gültig",
|
||||
"Only numbers are valid": "Nur Nummern sind zulässig",
|
||||
"Account": "Benutzer",
|
||||
"Toggle theme": "Thema wechseln",
|
||||
"Quit": "Beenden",
|
||||
|
||||
// localization view
|
||||
"Hello": "Hallo",
|
||||
"User": "Anwender",
|
||||
"Localization dialog": "Lokalisierungs-Dialog",
|
||||
"German": "Deutsch",
|
||||
"English": "Englisch",
|
||||
// ticketdata_view
|
||||
"Callback number": "Rückrufnummer",
|
||||
"Callback date": "Erreichbarkeit",
|
||||
"Clear": "Zurücksetzen",
|
||||
"Deductible": "Selbstbehalt",
|
||||
"Harm type": "Rechtsproblem",
|
||||
"IVR comment": "Rechtsrat",
|
||||
"Policy holder": "Versicherungsnehmer",
|
||||
"Recipient (To)": "Empfänger (To)",
|
||||
"Copie (CC)": "Kopie (CC)",
|
||||
"Send": "Senden",
|
||||
|
||||
// configuration view
|
||||
"Configuration settings": "Konfigurationseinstellungen",
|
||||
"Configuration file": "Konfigurationsdatei",
|
||||
"Language Id": "Sprach-Id",
|
||||
"Default theme": "Standard-Thema",
|
||||
"load": "laden",
|
||||
"save": "speichern"
|
||||
// localization view
|
||||
"Language ID": "Sprache ID",
|
||||
"Localization dialog": "Lokalisierungs-Dialog",
|
||||
"German": "Deutsch",
|
||||
"English": "Englisch",
|
||||
|
||||
// configuration view
|
||||
"Configuration settings": "Konfigurationseinstellungen",
|
||||
"Configuration file": "Konfigurationsdatei",
|
||||
"Language Id": "Sprach-Id",
|
||||
"Default theme": "Standard-Thema",
|
||||
"Load": "Laden",
|
||||
"Save": "Speichern",
|
||||
}
|
||||
)
|
||||
|
||||
187
advotracker/assets/advotracker/default_dark.ron
Normal file
187
advotracker/assets/advotracker/default_dark.ron
Normal file
@@ -0,0 +1,187 @@
|
||||
Theme (
|
||||
styles: {
|
||||
"button_action": (
|
||||
base: "button",
|
||||
properties: {
|
||||
//"background": "transparent",
|
||||
"border_radius": 3,
|
||||
"h_align": "center",
|
||||
"v_align": "center",
|
||||
},
|
||||
),
|
||||
"button_menu": (
|
||||
base: "button_single_content",
|
||||
properties: {
|
||||
"h_align": "end",
|
||||
//"icon": "material_icons_font::MD_MENU",
|
||||
},
|
||||
),
|
||||
"combo_box_form": (
|
||||
base: "combo_box",
|
||||
properties: {
|
||||
"width": 200,
|
||||
"height": 28,
|
||||
},
|
||||
),
|
||||
"mail_label": (
|
||||
base: "base",
|
||||
properties: {
|
||||
"h_align": "end",
|
||||
"v_align": "center",
|
||||
},
|
||||
),
|
||||
"mail_to": (
|
||||
base: "combo_box_form",
|
||||
properties: {
|
||||
"h_align": "end",
|
||||
},
|
||||
),
|
||||
"mail_cc": (
|
||||
base: "combo_box_form",
|
||||
properties: {
|
||||
"h_align": "end",
|
||||
},
|
||||
),
|
||||
"combo_box_popup": (
|
||||
//base: "popup",
|
||||
properties: {
|
||||
//"height": 120,
|
||||
"width": 240,
|
||||
},
|
||||
),
|
||||
"configuration_form": (
|
||||
base: "container",
|
||||
properties: {
|
||||
"margin": 4,
|
||||
},
|
||||
),
|
||||
"container_action": (
|
||||
base: "container_form",
|
||||
properties: {
|
||||
"border_width": 1,
|
||||
"padding": {
|
||||
"left": 14,
|
||||
"top": 0,
|
||||
"right": 14,
|
||||
"bottom": 0,
|
||||
},
|
||||
"h_align": "center",
|
||||
},
|
||||
),
|
||||
"container_form": (
|
||||
base: "container",
|
||||
properties: {
|
||||
"padding": 14,
|
||||
"border_brush": "$CONTAINER_BORDER",
|
||||
"border_radius": 0,
|
||||
"border_width": 1,
|
||||
"min_height": 330,
|
||||
},
|
||||
),
|
||||
"container_mail": (
|
||||
base: "container_form",
|
||||
properties: {
|
||||
"border_width": 0,
|
||||
"padding": {
|
||||
"left": 14,
|
||||
"top": 0,
|
||||
"right": 14,
|
||||
"bottom": 14,
|
||||
}
|
||||
},
|
||||
),
|
||||
"container_progress": (
|
||||
base: "container",
|
||||
properties: {
|
||||
"border_brush": "$CONTAINER_BORDER",
|
||||
"h_align": "center",
|
||||
"padding": 14,
|
||||
"v_align": "center",
|
||||
},
|
||||
),
|
||||
"header_bar": (
|
||||
base: "header",
|
||||
properties: {
|
||||
//"h_align": "center",
|
||||
//"v_align": "center",
|
||||
"min_height": 32,
|
||||
//"padding": 14,
|
||||
}
|
||||
),
|
||||
"header_text": (
|
||||
base: "header",
|
||||
properties: {
|
||||
"h_align": "center",
|
||||
"v_align": "center",
|
||||
}
|
||||
),
|
||||
"popup_form": (
|
||||
//base: "popup",
|
||||
properties: {
|
||||
"background": "#FFFFFF",
|
||||
"border_brush": "#0000FF",
|
||||
"border_radius": 3,
|
||||
"border_width": 2,
|
||||
"padding": 4,
|
||||
},
|
||||
),
|
||||
"popup_menu": (
|
||||
//base: "popup",
|
||||
properties: {
|
||||
"width": 300,
|
||||
"hight": 200,
|
||||
"border_radius": 0,
|
||||
"border_width": 1,
|
||||
"h_align": "center",
|
||||
},
|
||||
),
|
||||
"popup_progress": (
|
||||
base: "popup",
|
||||
properties: {
|
||||
"padding": 4,
|
||||
},
|
||||
),
|
||||
"stack_action": (
|
||||
//base: "stack",
|
||||
properties: {
|
||||
//"min_height": 50,
|
||||
"orientation": "Horizontal",
|
||||
"spacing": 50,
|
||||
},
|
||||
),
|
||||
"stack_progress": (
|
||||
base: "container",
|
||||
properties: {
|
||||
"spacing": 10,
|
||||
},
|
||||
),
|
||||
"ticket_data_form_label": (
|
||||
base: "container_form",
|
||||
properties: {
|
||||
"padding": 1,
|
||||
"h_align": "end",
|
||||
"v_align": "center",
|
||||
"margin": {
|
||||
"left": 0,
|
||||
"top": 0,
|
||||
"right": 0,
|
||||
"bottom": 0,
|
||||
},
|
||||
"min_size": 300,
|
||||
"max_size": 400,
|
||||
},
|
||||
),
|
||||
"ticket_data_form_input": (
|
||||
base: "ticket_data_form_label",
|
||||
properties: {
|
||||
"h_align": "start",
|
||||
},
|
||||
),
|
||||
"text_block_progress": (
|
||||
base: "small_text",
|
||||
properties: {
|
||||
"background": "$PROGRESS_BAR_BACKGROUND",
|
||||
},
|
||||
),
|
||||
}
|
||||
)
|
||||
@@ -1,15 +1,9 @@
|
||||
Theme (
|
||||
styles: {
|
||||
"button_single_content_segmdl2": (
|
||||
base: "button_single_content",
|
||||
properties: {
|
||||
"icon font": "$SEGEO_ICON_FONT",
|
||||
},
|
||||
),
|
||||
"container_master_detail": (
|
||||
"container_form": (
|
||||
base: "container",
|
||||
properties: {
|
||||
"padding": 14,
|
||||
"border": 1,
|
||||
},
|
||||
),
|
||||
}
|
||||
|
||||
1
advotracker/examples/csv-test/data/POLLFNR_WOECHENTLICH.txt
Symbolic link
1
advotracker/examples/csv-test/data/POLLFNR_WOECHENTLICH.txt
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../data/POLLFNR_WOECHENTLICH.txt
|
||||
@@ -9,9 +9,12 @@ use chrono::{Local, DateTime};
|
||||
use locales::t;
|
||||
//use serde::{Deserialize, Serialize};
|
||||
use serde::Deserialize;
|
||||
use std::env;
|
||||
use std::{error::Error, process};
|
||||
use std::collections::HashMap;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
env,
|
||||
{error::Error, process},
|
||||
//path::{Path, PathBuf},
|
||||
};
|
||||
use tracing::{debug, trace, Level};
|
||||
|
||||
use advotracker::data::structures::{PolicyCode, PolicyList, PolicyDataList, PolicyData};
|
||||
@@ -49,14 +52,6 @@ fn export(p: &mut String, lang: &String) -> Result<u64, Box<dyn Error>> {
|
||||
// Note: slash syntax also works on Windows!
|
||||
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
|
||||
let mut file = File::create(path)?;
|
||||
trace!(target: "csv-export", extension = ?path.extension(), file = ?file);
|
||||
@@ -103,10 +98,6 @@ fn import(p: &mut String, data_list: &mut PolicyDataList,
|
||||
|
||||
// must be a readable file
|
||||
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);
|
||||
|
||||
// only accept files with '.txt' extensions
|
||||
@@ -333,8 +324,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
state = t!("state.started", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
|
||||
// importing policy code elements from csv-file
|
||||
let policy_list = PolicyList::new("Allianz Versicherungsnummen-List");
|
||||
// create policy structures
|
||||
let policy_list = PolicyList::new("Allianz Versicherungsnummen-Liste");
|
||||
println!("Policy List {:?} ", policy_list.name);
|
||||
|
||||
let mut policy_data = PolicyDataList::new("Allianz-Import 20200628");
|
||||
@@ -355,9 +346,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
|
||||
// test if policy_number is_valid
|
||||
let test_policy_number = v.get::<i32>("test_policy_number").unwrap() as u64;
|
||||
// type conversion (viperus String -> 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);
|
||||
//let policy_number : u64 = 1999999999;
|
||||
//match is_valid(&policy_number, &policy_data, &mut policy_numbers, &lang) {
|
||||
// Ok(true) => {
|
||||
// use Hashmap method 'get' to check if we have the given key
|
||||
@@ -394,3 +385,25 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
@@ -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("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
|
||||
v.add_default("export_file", String::from(""));
|
||||
v.add_default("test_policy_number", 123456789);
|
||||
v.add_default("test_policy_number", String::from("9999999992"));
|
||||
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("username", String::from("nctalkbot"));
|
||||
@@ -188,7 +188,7 @@ SMR Unerledigt: 089 92529 60222")
|
||||
);
|
||||
println!(
|
||||
"test_policy_number: {:?}",
|
||||
v.get::<i32>("test_policy_number").unwrap_or_default()
|
||||
v.get::<String>("test_policy_number").unwrap_or_default()
|
||||
);
|
||||
// println!(
|
||||
// "username: {:?}",
|
||||
33
advotracker/examples/messages_test/main.rs
Normal file
33
advotracker/examples/messages_test/main.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
mod data;
|
||||
mod main_view;
|
||||
mod receiver;
|
||||
mod sender;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// use this only if you want to run it as web application.
|
||||
orbtk::initialize();
|
||||
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
.name("Main")
|
||||
.title("OrbTK: example send/receive messages")
|
||||
.position((100.0, 100.0))
|
||||
.resizeable(true)
|
||||
.size(450.0, 500.0)
|
||||
.child(main_view::MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
38
advotracker/examples/messages_test/main_view.rs
Normal file
38
advotracker/examples/messages_test/main_view.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::{
|
||||
receiver::receiver_view::ReceiverView,
|
||||
sender::sender_view::SenderView,
|
||||
};
|
||||
|
||||
widget!(MainView {
|
||||
//sender_view: ,
|
||||
//receiver_view:
|
||||
});
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
let receiver_view = ReceiverView::new()
|
||||
.build(ctx);
|
||||
|
||||
let sender_view = SenderView::new()
|
||||
.target(receiver_view.0) // entity of the target
|
||||
.build(ctx);
|
||||
|
||||
self.name("MainView")
|
||||
.child(
|
||||
Stack::new()
|
||||
.orientation("vertical")
|
||||
.child(sender_view)
|
||||
.child(receiver_view)
|
||||
.build(ctx)
|
||||
)
|
||||
}
|
||||
}
|
||||
8
advotracker/examples/messages_test/mod.rs
Normal file
8
advotracker/examples/messages_test/mod.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
// The starting point (Main View).
|
||||
pub mod main_view;
|
||||
|
||||
/// Receiver widget
|
||||
pub mod receiver;
|
||||
|
||||
/// Sender widget.
|
||||
pub mod sender;
|
||||
5
advotracker/examples/messages_test/receiver/mod.rs
Normal file
5
advotracker/examples/messages_test/receiver/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
/// The reciever state
|
||||
pub mod receiver_state;
|
||||
|
||||
/// The receiver view
|
||||
pub mod receiver_view;
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::{
|
||||
data::constants::*,
|
||||
sender::sender_state::SenderAction,
|
||||
};
|
||||
|
||||
// /// Enumeration of valid `action variants` that need to be handled as
|
||||
/// state changes for the `SenderView` widget.
|
||||
pub enum TestMessageAction {
|
||||
// Toggle visibility of a message TextBlock.
|
||||
ToggleMessageBlock
|
||||
}
|
||||
|
||||
/// Valid `structure members` of the `ReceiverState` used to react on
|
||||
/// state changes inside the `ReceiverView` widget.
|
||||
#[derive(Default, AsAny)]
|
||||
pub struct ReceiverState {
|
||||
message_block: Option<Entity>,
|
||||
progress_bar: Entity
|
||||
}
|
||||
|
||||
/// Method definitions, we provide inside the `ReceiverState`.
|
||||
impl ReceiverState {
|
||||
fn toggle_message_block(&self, ctx: &mut Context) {
|
||||
if let Some(message_block) = self.message_block {
|
||||
ctx.get_widget(message_block)
|
||||
.set("visibility", Visibility::Visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait methods provided for the `ReceiverState`
|
||||
impl State for ReceiverState {
|
||||
// initialize the view entities
|
||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
self.progress_bar = ctx
|
||||
.entity_of_child(ID_RECEIVER_PROGRESS_BAR)
|
||||
.expect("Cannot find ProgressBar!");
|
||||
//self.message_box = ctx
|
||||
// .entity_of_child(ID_RECEIVER_MESSAGE)
|
||||
// .expect("Cannot find 'ID_RECEIVER_MESSAGE'!");
|
||||
}
|
||||
|
||||
// handle messages targeting the view
|
||||
fn messages(
|
||||
&mut self,
|
||||
mut messages: MessageReader,
|
||||
_registry: &mut Registry,
|
||||
ctx: &mut Context
|
||||
) {
|
||||
for message in messages.read::<SenderAction>() {
|
||||
match message {
|
||||
SenderAction::UpdateProgress(amount) => {
|
||||
println!("UpdateProgress message received");
|
||||
let mut progress_bar = ctx.get_widget(self.progress_bar);
|
||||
let current_progress = progress_bar.clone::<f64>("val");
|
||||
progress_bar.set::<f64>("val", current_progress + amount);
|
||||
}
|
||||
SenderAction::UpdateMessage(message) => {
|
||||
println!("UpdateMessage message received");
|
||||
//Reciever::text_set(&mut ctx.widget(), self.message.to_string());
|
||||
//Reciever::text_set(&mut ctx.widget(), self.message.to_string());
|
||||
TextBlock::text_set(&mut ctx.child(ID_RECEIVER_MESSAGE_BLOCK), String::from(message));
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
for action in messages.read::<TestMessageAction>() {
|
||||
match action {
|
||||
TestMessageAction::ToggleMessageBlock => {
|
||||
self.toggle_message_block(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
advotracker/examples/messages_test/receiver/receiver_view.rs
Normal file
56
advotracker/examples/messages_test/receiver/receiver_view.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::{
|
||||
data::constants::*,
|
||||
//receiver::receiver_state::{TestMessageAction, ReceiverState},
|
||||
receiver::receiver_state::ReceiverState,
|
||||
};
|
||||
|
||||
widget!(ReceiverView<ReceiverState>);
|
||||
|
||||
impl Template for ReceiverView {
|
||||
fn template(self, _id: Entity, build_context: &mut BuildContext) -> Self {
|
||||
self.id(ID_RECEIVER)
|
||||
.name(ID_RECEIVER)
|
||||
.child(
|
||||
Container::new()
|
||||
.id(ID_RECEIVER_CONTAINER)
|
||||
.border_brush(COLOR_BOMBAY)
|
||||
.border_width(2)
|
||||
.name(ID_RECEIVER_CONTAINER)
|
||||
.padding(16)
|
||||
.child(
|
||||
Stack::new()
|
||||
.orientation("vertical")
|
||||
.spacing(8)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_RECEIVER_TEXT_BLOCK)
|
||||
.text(ID_RECEIVER)
|
||||
.build(build_context)
|
||||
)
|
||||
.child(
|
||||
ProgressBar::new()
|
||||
.id(ID_RECEIVER_PROGRESS_BAR)
|
||||
.build(build_context)
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_RECEIVER_MESSAGE_BLOCK)
|
||||
.text("")
|
||||
.water_mark("here we expect the message updates.")
|
||||
.build(build_context)
|
||||
)
|
||||
.build(build_context)
|
||||
)
|
||||
.build(build_context)
|
||||
)
|
||||
}
|
||||
}
|
||||
5
advotracker/examples/messages_test/sender/mod.rs
Normal file
5
advotracker/examples/messages_test/sender/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
/// The sender state
|
||||
pub mod sender_state;
|
||||
|
||||
/// The sender view
|
||||
pub mod sender_view;
|
||||
78
advotracker/examples/messages_test/sender/sender_state.rs
Normal file
78
advotracker/examples/messages_test/sender/sender_state.rs
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
//use crate::data::constants::*;
|
||||
|
||||
/// Enumeration of valid `action variants` that need to be handled as
|
||||
/// state changes for the `SenderView` widget.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum SenderAction {
|
||||
UpdateProgress(f64),
|
||||
UpdateMessage(String),
|
||||
}
|
||||
|
||||
/// Valid `structure members` of the `SenderState` used to react on
|
||||
/// state changes inside the `SenderView` widget.
|
||||
#[derive(AsAny, Default)]
|
||||
pub struct SenderState {
|
||||
// actions
|
||||
actions: Vec<SenderAction>,
|
||||
// entity that will receive the message
|
||||
target: Entity
|
||||
}
|
||||
|
||||
/// Method definitions, we provide inside the `SenderState`.
|
||||
impl SenderState {
|
||||
/// Sending message with type 'UpdateProgress'
|
||||
pub fn send_update_progress(&mut self) {
|
||||
println!("Sender: push 'UpdateProgress' action");
|
||||
self.actions.push(SenderAction::UpdateProgress(0.1));
|
||||
}
|
||||
/// Sending message with type 'UpdateMessage'
|
||||
pub fn send_update_message(&mut self) {
|
||||
println!("Sender: push 'UpdateMessage' action");
|
||||
self.actions.push(SenderAction::UpdateMessage(String::from("Hey sender. I got your message. All fine.")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Trait methods provided for the `SenderState`
|
||||
impl State for SenderState {
|
||||
// initialize the view entities
|
||||
fn init(&mut self, _registry: &mut Registry, ctx: &mut Context) {
|
||||
// create the target entity, that receives the Sender messages
|
||||
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
||||
.expect("ERROR: SenderState::init(): target entity not found!"));
|
||||
}
|
||||
|
||||
// update entities, before we render the view
|
||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
let actions: Vec<SenderAction> = self.actions.drain(..).collect();
|
||||
|
||||
//let message = ctx.child(ID_SENDER_TEXT_BOX).get::<String>("text").to_string();
|
||||
//println!("Child text: {:?}", message);
|
||||
|
||||
// create an explicit message_adapter context
|
||||
let message_adapter = ctx.message_adapter();
|
||||
|
||||
for action in actions {
|
||||
match action {
|
||||
SenderAction::UpdateProgress(amount) => {
|
||||
message_adapter.send_message(SenderAction::UpdateProgress(amount), self.target);
|
||||
println!("Sender: send message 'SenderAction::UpdateProgress'");
|
||||
}
|
||||
SenderAction::UpdateMessage(message) => {
|
||||
//let message = ctx.child(ID_SENDER_TEXT_BOX).get::<String>("text").to_string();
|
||||
message_adapter.send_message(SenderAction::UpdateMessage(message), self.target);
|
||||
println!("Sender: send message 'SenderAction::UpdateMessage'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
100
advotracker/examples/messages_test/sender/sender_view.rs
Normal file
100
advotracker/examples/messages_test/sender/sender_view.rs
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* OrbTK - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::{
|
||||
prelude::*,
|
||||
shell::event::Key,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
data::constants::*,
|
||||
sender::sender_state::SenderState,
|
||||
//sender::sender_state::{SenderAction, SenderState},
|
||||
};
|
||||
|
||||
widget!(SenderView<SenderState> {
|
||||
// the Entity of the widget that will receive the messages
|
||||
target: u32
|
||||
});
|
||||
|
||||
impl Template for SenderView {
|
||||
fn template(self, id: Entity, build_context: &mut BuildContext) -> Self {
|
||||
let sender_header = TextBlock::new()
|
||||
.attach(Grid::row(0))
|
||||
.text(ID_SENDER)
|
||||
.build(build_context);
|
||||
|
||||
let sender_message = TextBox::new()
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.name(ID_SENDER_TEXT_BOX)
|
||||
.text("")
|
||||
.water_mark("Message text to be send via MessageHandler.")
|
||||
.on_key_down(move | states, key_event | {
|
||||
match key_event.key {
|
||||
Key::Tab | Key::S(..) => {
|
||||
println!("KeyHandler: got Tab");
|
||||
states.get_mut::<SenderState>(id).send_update_progress();
|
||||
states.get_mut::<SenderState>(id).send_update_message();
|
||||
},
|
||||
_ => {
|
||||
println!("KeyHandler: got {:?}", key_event.key);
|
||||
},
|
||||
};
|
||||
true
|
||||
})
|
||||
.build(build_context);
|
||||
|
||||
let sender_button = Button::new()
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(2))
|
||||
.name(ID_SENDER_BUTTON)
|
||||
.text("send")
|
||||
.icon(material_icons_font::MD_SEND)
|
||||
.on_click(move |states, _entity| {
|
||||
states.get_mut::<SenderState>(id).send_update_progress();
|
||||
false
|
||||
})
|
||||
.build(build_context);
|
||||
|
||||
//let sender_content =
|
||||
|
||||
self.id(ID_SENDER)
|
||||
.name(ID_SENDER)
|
||||
.child(
|
||||
Container::new()
|
||||
.id(ID_SENDER_CONTAINER)
|
||||
.border_brush(COLOR_BOMBAY)
|
||||
.border_width(2)
|
||||
.padding(16)
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_SENDER_GRID)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push("stretch") // Message
|
||||
.push(16) // Delimiter
|
||||
.push("auto") // Button
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Header
|
||||
.push(6) // Delimiter
|
||||
.push("auto") // Message
|
||||
.push(6) // Delimiter
|
||||
)
|
||||
|
||||
.child(sender_header) // row 0
|
||||
.child(sender_message) // row 2
|
||||
.child(sender_button) // row 3
|
||||
.build(build_context)
|
||||
)
|
||||
.build(build_context)
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
../../../advotrackerd/data/POLLFNR_WOECHENTLICH.txt
|
||||
@@ -1,98 +0,0 @@
|
||||
{
|
||||
"err.lang.not_found": {
|
||||
"de_DE.UTF-8": "Konnte die Umgebungsvarialbe LANG nicht auslesen",
|
||||
"de": "Konnte die Umgebungsvarialbe LANG nicht auslesen",
|
||||
"en": "Couldn't read LANG"
|
||||
},
|
||||
"err.user.not_found": {
|
||||
"fr": "Utilisateur introuvable: $email, $id",
|
||||
"de-DE.UTF-8": "Anwender nicht gefunden: $email, $id",
|
||||
"de": "Anwender nicht gefunden: $email, $id",
|
||||
"en": "User not found: $email, $id"
|
||||
},
|
||||
"main.started": {
|
||||
"de_DE.UTF-8": "Programmlogik starten",
|
||||
"de": "Programmlogik starten",
|
||||
"en": "Program logic started"
|
||||
},
|
||||
"main.finished": {
|
||||
"de_DE.UTF-8": "Programmlogik beendet",
|
||||
"de": "Programmlogik beendet",
|
||||
"en": "Program logic finished"
|
||||
},
|
||||
"parse.arguments": {
|
||||
"de_DE.UTF-8": "Programmargumente prüfen",
|
||||
"de": "Programmargumente prüfen",
|
||||
"en": "Parsing arguments"
|
||||
},
|
||||
"parse.environment": {
|
||||
"de_DE.UTF-8": "Umgebungsvariablen prüfen",
|
||||
"de": "Umgebungsvariablen prüfen",
|
||||
"en": "Parsing environment"
|
||||
},
|
||||
"parse.results": {
|
||||
"de_DE.UTF-8": "Ergebnisse der Konfigurations-Parameterprüfung",
|
||||
"de": "Ergebnisse der Konfigurationsparameterprüfung",
|
||||
"en": "Config parsing results"
|
||||
},
|
||||
"config.name": {
|
||||
"de_DE.UTF-8": "Konfigurationswert für",
|
||||
"de": "Konfigurationswert für",
|
||||
"en": "Config Value for"
|
||||
},
|
||||
"config.name.lang": {
|
||||
"de_DE.UTF-8": "Sprach-Code",
|
||||
"de": "Sprach-Code",
|
||||
"en": "Language code"
|
||||
},
|
||||
"config.name.verbositylevel": {
|
||||
"de_DE.UTF-8": "Ausgabe-Ebene",
|
||||
"de": "Ausgabe-Ebene",
|
||||
"en": "verbosity level"
|
||||
},
|
||||
"config.name.environment": {
|
||||
"de_DE.UTF-8": "Umgebungsvariablen",
|
||||
"de": "Umgebungsvariablen",
|
||||
"en": "environment"
|
||||
},
|
||||
"config.name.configfile": {
|
||||
"de_DE.UTF-8": "Konfigurations-Datei",
|
||||
"de": "Konfigurations-Datei",
|
||||
"en": "config file"
|
||||
},
|
||||
"config.name.dbdriver": {
|
||||
"de_DE.UTF-8": "Datenbank-Treiber",
|
||||
"de": "Datenbank-Treiber",
|
||||
"en": "database driver"
|
||||
},
|
||||
"csv_import.started": {
|
||||
"de_DE.UTF-8": "importieren von einer csv-datei gestartet",
|
||||
"de": "importieren von einer csv-datei gestartet",
|
||||
"en": "import from a csv-file started"
|
||||
},
|
||||
"csv_import.finished": {
|
||||
"de_DE.UTF-8": "importieren von einer csv-datei beendet",
|
||||
"de": "importieren von einer csv-datei beendet",
|
||||
"en": "import from a csv-file finished"
|
||||
},
|
||||
"csv_export.started": {
|
||||
"de_DE.UTF-8": "exportieren in eine csv-datei gestartet",
|
||||
"de": "exportieren in eine csv-datei gestartet",
|
||||
"en": "export to csv-file started"
|
||||
},
|
||||
"csv_export.finished": {
|
||||
"de_DE.UTF-8": "exportieren in eine csv-datei beendet",
|
||||
"de": "exportieren in eine csv-datei beendet",
|
||||
"en": "export to csv-file finished"
|
||||
},
|
||||
"state.started": {
|
||||
"de_DE.UTF-8": "gestartet",
|
||||
"de": "gestartet",
|
||||
"en": "started"
|
||||
},
|
||||
"state.finished": {
|
||||
"de_DE.UTF-8": "beendet",
|
||||
"de": "beended",
|
||||
"en": "finished"
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,5 @@
|
||||
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 {
|
||||
// //ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
||||
// ThemeValue::create_from_css(DEFAULT_THEME_CSS)
|
||||
@@ -15,12 +9,8 @@ use orbtk::prelude::*;
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
enum Action {
|
||||
//ClearText,
|
||||
EntryActivated(Entity),
|
||||
EntryChanged(Entity),
|
||||
//ValueChanged(Entity),
|
||||
//ValueOk,
|
||||
//ValueNone,
|
||||
EntryChanged(Entity)
|
||||
}
|
||||
|
||||
#[derive(AsAny)]
|
||||
@@ -58,23 +48,16 @@ impl State for MainViewState {
|
||||
// //ctx.widget().set("policynumber", background("#5b0f22"));
|
||||
//}
|
||||
Action::EntryActivated(entity) => {
|
||||
let mut text_box = TextBox::get(ctx.get_widget(entity));
|
||||
let text = text_box.text_mut();
|
||||
//let mut widget = ctx.get_widget(entity);
|
||||
//let text = widget.get_mut::<String16>("text");
|
||||
//let text = ctx.get_widget(entity).clone::<String>("text");
|
||||
let widget = ctx.get_widget(entity);
|
||||
let text = widget.get::<String>("text");
|
||||
println!("got value policynumber: {}", text);
|
||||
//text.clear();
|
||||
}
|
||||
Action::EntryChanged(entity) => {
|
||||
let widget = ctx.get_widget(entity);
|
||||
let text = widget.get::<String16>("text");
|
||||
let text = widget.get::<String>("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;
|
||||
@@ -85,7 +68,6 @@ impl State for MainViewState {
|
||||
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
|
||||
TextBlock::new()
|
||||
.text(text)
|
||||
//.element("text-block")
|
||||
.style("header")
|
||||
.build(ctx)
|
||||
}
|
||||
@@ -101,26 +83,19 @@ widget!(
|
||||
impl Template for MainView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
self.name("MainView").child(
|
||||
//.result("Anzahl Versicherungsnummern: 0")
|
||||
//.result("Policyholders count: 0").sum_policynumbers(0)
|
||||
//.sum_policynumbers(0)
|
||||
Grid::new()
|
||||
.background("#fafafa")
|
||||
//.width(200.0)
|
||||
//.height(360.0)
|
||||
.columns(
|
||||
Columns::new()
|
||||
.add(150.0)
|
||||
.add("*")
|
||||
//.add(120.0)
|
||||
//.add("auto")
|
||||
.add(150.0)
|
||||
Columns::create()
|
||||
.push(150.0)
|
||||
.push("*")
|
||||
.push(150.0)
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::new()
|
||||
.add("*")
|
||||
.add("*")
|
||||
Rows::create()
|
||||
.push("*")
|
||||
.push("*")
|
||||
.build(),
|
||||
)
|
||||
.child(
|
||||
@@ -140,27 +115,22 @@ impl Template for MainView {
|
||||
.child(create_header(ctx, "Validierung Versicherungsnummer"))
|
||||
.child(
|
||||
TextBox::new()
|
||||
//.class("text_box")
|
||||
// overwriting the class defaults
|
||||
/* .background("transparent")
|
||||
.foreground("#9dafbf")
|
||||
.background("#fafafa")
|
||||
/* .foreground(colors::LINK_WATER_COLOR) */
|
||||
.border_brush("#5b0f22")
|
||||
.border_width(5)
|
||||
.border_radius(15) */
|
||||
.border_radius(15)
|
||||
//.name("policynumber")
|
||||
.focused(true)
|
||||
.water_mark("Versicherungs-Nr...")
|
||||
//.text("Number policyholder", id)
|
||||
.text(("policynumber", id))
|
||||
.font_size(24.0)
|
||||
.h_align("stretch")
|
||||
.on_activate(move |states, entity| {
|
||||
state(id, states).action(Action::EntryActivated(entity));
|
||||
.on_activate(move |ctx, entity| {
|
||||
state(id, ctx).action(Action::EntryActivated(entity));
|
||||
})
|
||||
.on_changed(move |states, entity| {
|
||||
state(id, states).action(Action::EntryChanged(entity));
|
||||
.on_changed("text", move |ctx, entity| {
|
||||
state(id, ctx).action(Action::EntryChanged(entity));
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
@@ -180,28 +150,28 @@ impl Template for MainView {
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
//.element("logo_customer")
|
||||
//.class("logo_customer")
|
||||
.margin((9.0, 16.0, 16.0, 9.0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(1))
|
||||
.v_align("end")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
.image("./resources/images/hiedemann_logo.png")
|
||||
.image("assets/images/customer_logo.png")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
//.element("logo_vendor")
|
||||
//.class("logo_vendor")
|
||||
.margin((9.0, 16.0, 16.0, 9.0))
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(1))
|
||||
.v_align("end")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
.image("./resources/images/networkx_logo.png")
|
||||
.image("assets/images/networkx_logo.png")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
|
||||
@@ -1,71 +1,164 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
// Component Values (Properties)
|
||||
pub static PROP_ADVOTRACKER: &str = "advotracker";
|
||||
|
||||
pub static PROP_MAIL_CC_1: &str = "info@hiedemann.de";
|
||||
pub static PROP_MAIL_CC_2: &str = "service@hiedemann.de";
|
||||
pub static PROP_MAIL_BCC_1: &str = "Networkx Support <support@networkx.de>";
|
||||
pub static PROP_MAIL_BCC_2: &str = "knoche@hiedemann.de";
|
||||
pub static PROP_MAIL_FROM: &str = "Kanzlei Hiedemann <info@heidemann.de>";
|
||||
pub static PROP_MAIL_REPLY: &str = "Kanzlei Hiedemann <info@heidemann.de>";
|
||||
pub static PROP_MAIL_SUBJECT: &str = "ZMB Allianz - neues Mandat";
|
||||
pub static PROP_MAIL_TO_1: &str = "allianz@ponschab-partner.com";
|
||||
pub static PROP_MAIL_TO_2: &str = "kontakt@chevalier.law";
|
||||
pub static PROP_MAIL_TO_3: &str = "kontakt@metamedlaw.de";
|
||||
pub static PROP_MAIL_TO_4: &str = "sekretariat@m2-mediation.de";
|
||||
|
||||
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";
|
||||
|
||||
// Styles (RON based theme system)
|
||||
pub static STYLE_BOTTOM_BAR: &'static str = "bottom_bar";
|
||||
pub static STYLE_HEADER_BAR: &'static str = "header_bar";
|
||||
pub static STYLE_SEPERATOR: &'static str = "seperator";
|
||||
//pub static STYLE_ITEM_BUTTON: &'static str = "item_button";
|
||||
pub static STYLE_MENU: &'static str = "menu";
|
||||
pub static STYLE_BUTTON_MENU: &'static str = "button_menu";
|
||||
pub static STYLE_STACK_MENU: &'static str = "stack_menu";
|
||||
pub static STYLE_BOTTOM_BAR: &str = "bottom_bar";
|
||||
pub static STYLE_BUTTON_MENU: &str = "button_menu";
|
||||
pub static STYLE_BUTTON_ACTION: &str = "button_action";
|
||||
pub static STYLE_CONTAINER_ACTION: &str = "container_action";
|
||||
pub static STYLE_CONTAINER_MAIL: &str = "container_mail";
|
||||
pub static STYLE_HEADER_BAR: &str = "header_bar";
|
||||
pub static STYLE_HEADER_TEXT: &str = "header_text";
|
||||
pub static STYLE_SEPARATOR: &str = "separator";
|
||||
pub static STYLE_MAIL_LABEL: &str = "mail_label";
|
||||
pub static STYLE_MAIL_TO: &str = "mail_to";
|
||||
pub static STYLE_MAIL_CC: &str = "mail_cc";
|
||||
pub static STYLE_MENU: &str = "menu";
|
||||
pub static STYLE_STACK_ACTION: &str = "stack_action";
|
||||
pub static STYLE_STACK_MENU: &str = "stack_menu";
|
||||
|
||||
// Widget IDs (DCES: Entity[id] => [Component1, .. , Component<n>] -> data or state)
|
||||
pub static ID_POLICY_CHECK_FORM: &'static str = "policy_check_form";
|
||||
pub static ID_POLICY_CHECK_FORM_ROW_0: &'static str = "policy_check_form_row_0";
|
||||
pub static ID_POLICY_CHECK_FORM_ROW_1: &'static str = "policy_check_form_row_1";
|
||||
pub static ID_POLICY_CHECK_FORM_ROW_2: &'static str = "policy_check_form_row_2";
|
||||
pub static ID_POLICY_CHECK_HEADER: &'static str = "policy_check_header";
|
||||
pub static ID_POLICY_CHECK_ITEMS_WIDGET: &'static str = "policy_check_items_widget";
|
||||
pub static ID_POLICY_CHECK_BUTTON_RESULT: &'static str = "policy_check_button_result";
|
||||
pub static ID_POLICY_CHECK_BUTTON_MENU: &'static str = "policy_check_button_menu";
|
||||
pub static ID_POLICY_CHECK_DATA_COUNT_BLOCK: &'static str = "policy_check_data_count_block";
|
||||
pub static ID_POLICY_CHECK_HINT: &'static str = "policy_check_hint";
|
||||
pub static ID_POLICY_CHECK_LABEL_HINT: &'static str = "policy_check_label_hint";
|
||||
pub static ID_POLICY_CHECK_LABEL_MENU: &'static str = "policy_check_label_menu";
|
||||
pub static ID_POLICY_CHECK_LABEL_POLICY_NUMBER: &'static str = "policy_check_label_policy_number";
|
||||
pub static ID_POLICY_CHECK_LABEL_RESULT: &'static str = "policy_check_label_result";
|
||||
pub static ID_POLICY_CHECK_MENU: &'static str = "policy_check_menu";
|
||||
pub static ID_POLICY_CHECK_MENU_LABEL_ACCOUNT: &'static str = "policy_check_menu_label_account";
|
||||
pub static ID_POLICY_CHECK_MENU_LABEL_QUIT: &'static str = "policy_check_menu_label_quit";
|
||||
pub static ID_POLICY_CHECK_MENU_SHORTCUT_QUIT: &'static str = "policy_check_menu_shortcut_quit";
|
||||
pub static ID_POLICY_CHECK_MENU_LABEL_TOGGLE_THEME: &'static str = "policy_check_menu_label_toggle_theme";
|
||||
pub static ID_POLICY_CHECK_POLICY_NUMBER: &'static str = "policy_check_policy_number";
|
||||
pub static ID_POLICY_CHECK_POPUP_MENU: &'static str = "policy_check_popup_menu";
|
||||
pub static ID_POLICY_CHECK_POPUP_PROGRESS: &'static str = "policy_check_popup_progress";
|
||||
pub static ID_POLICY_CHECK_PROGRESS_BAR: &'static str = "policy_check_progress_bar";
|
||||
pub static ID_POLICY_CHECK_PROGRESS_TIME: &'static str = "policy_check_progress_time";
|
||||
pub static ID_POLICY_CHECK_PROGRESS_TEXT: &'static str = "policy_check_progress_text";
|
||||
pub static ID_POLICY_CHECK_RESULT: &'static str = "policy_check_result";
|
||||
pub static ID_POLICY_CHECK_WIDGET: &'static str = "policy_check_widget";
|
||||
pub static ID_CONFIGURATION_VIEW: &str = "Configuration";
|
||||
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_POLICY_DATA_ADD_BUTTON: &'static str = "policy_data_add_button";
|
||||
pub static ID_POLICY_DATA_COUNT: &'static str = "policy_data_count";
|
||||
pub static ID_POLICY_DATA_LABEL: &'static str = "policy_data_label";
|
||||
pub static ID_POLICY_DATA_ITEMS_WIDGET: &'static str = "policy_data_items_widget";
|
||||
pub static ID_POLICY_DATA_DATE_INSERTED: &'static str = "policy_data_date_inserted";
|
||||
pub static ID_POLICY_DATA_DION: &'static str = "policy_data_dion";
|
||||
pub static ID_POLICY_DATA_POLICY_CODE: &'static str = "policy_data_policy_code";
|
||||
pub static ID_POLICY_DATA_POLICY_NUMBER: &'static str = "policy_data_policy_number";
|
||||
pub static ID_POLICY_DATA_STACK: &'static str = "policy_data_stack";
|
||||
pub static ID_POLICY_DATA_STATUS: &'static str = "policy_data_status";
|
||||
pub static ID_POLICY_DATA_LIST_NAME: &'static str = "policy_data_list_name";
|
||||
pub static ID_LOCALIZATION_VIEW: &str = "Localization";
|
||||
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_POLICY_LIST_ADD_BUTTON: &'static str = "policy_list_add_button";
|
||||
pub static ID_POLICY_LIST_ITEMS_WIDGET: &'static str = "policy_list_items_widget";
|
||||
pub static ID_POLICY_LIST_TEXT_BOX: &'static str = "policy_list_text_box";
|
||||
pub static ID_MAIN_GRID: &str = "main_grid";
|
||||
pub static ID_MAIN_TABWIDGET: &str = "main_tabwidget";
|
||||
pub static ID_MAIN_BUTTON_MENU: &str = "main_button_menu";
|
||||
|
||||
// Component Values (Properties)
|
||||
pub static PROP_ADVOTRACKER: &'static str = "advotracker";
|
||||
pub static PROP_POLICY_CHECK: &'static str = "policy_check";
|
||||
pub static PROP_POLICY_PROGRESS_COUNT: &'static str = "policy_progress_count";
|
||||
pub static ID_MENU_VIEW: &str = "menu_view";
|
||||
pub static ID_MENU_POPUP: &str = "menu_popup";
|
||||
pub static ID_MENU_STACK: &str = "menu_stack";
|
||||
pub static ID_MENU_BOTTOM_BAR: &str = "menu_bottom_bar";
|
||||
pub static ID_MENU_BUTTON: &str = "menu_button";
|
||||
pub static ID_MENU_BUTTON_MENU: &str = "menu_button_menu";
|
||||
pub static ID_MENU_GRID: &str = "menu_grid";
|
||||
pub static ID_MENU_HEADER: &str = "menu_header";
|
||||
pub static ID_MENU_HEADER_BAR: &str = "menu_header_bar";
|
||||
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 PROP_POLICY_DATA_LIST: &'static str = "policy_data_list";
|
||||
pub static PROP_POLICY_DATA_COUNT: &'static str = "policy_data_count";
|
||||
pub static ID_POLICY_CHECK_VIEW: &str = "policy_check_view";
|
||||
pub static ID_POLICY_CHECK_ACTION_BUTTON_CREATE: &str = "policy_check_action_button_create";
|
||||
pub static ID_POLICY_CHECK_ACTION_GRID: &str = "policy_check_action_grid";
|
||||
pub static ID_POLICY_CHECK_BOTTOM_BAR: &str = "policy_check_bottom_bar";
|
||||
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_FORM: &str = "policy_check_form";
|
||||
pub static ID_POLICY_CHECK_HEADER: &str = "policy_check_header";
|
||||
pub static ID_POLICY_CHECK_HEADER_BAR: &str = "policy_check_header_bar";
|
||||
pub static ID_POLICY_CHECK_HINT: &str = "policy_check_hint";
|
||||
pub static ID_POLICY_CHECK_ITEMS_WIDGET: &str = "policy_check_items_widget";
|
||||
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_CODE: &str = "policy_check_policy_code";
|
||||
pub static ID_POLICY_CHECK_POLICY_NUMBER: &str = "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 PROP_POLICY_LIST: &'static str = "policy_list";
|
||||
pub static PROP_POLICY_LIST_COUNT: &'static str = "policy_list_count";
|
||||
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";
|
||||
|
||||
pub static ID_TICKET_DATA_ACTION_BUTTON_CLEAR: &str = "ticket_data_action_button_clear";
|
||||
pub static ID_TICKET_DATA_ACTION_BUTTON_SEND: &str = "ticket_data_action_button_send";
|
||||
pub static ID_TICKET_DATA_ACTION_GRID: &str = "ticket_data_action_grid";
|
||||
pub static ID_TICKET_DATA_BOTTOM_BAR: &str = "ticket_data_bottom_bar";
|
||||
pub static ID_TICKET_DATA_BUTTON_MENU: &str = "ticket_data_button_menu";
|
||||
pub static ID_TICKET_DATA_BUTTON_RESULT: &str = "ticket_data_button_result";
|
||||
pub static ID_TICKET_DATA_CALLBACK_DATE: &str = "ticket_data_label_callback_date";
|
||||
pub static ID_TICKET_DATA_CALLBACK_NUMBER: &str = "ticket_data_label_callback_number";
|
||||
pub static ID_TICKET_DATA_COMBO_BOX_MAIL_CC: &str = "ticket_data_combo_box_mail_cc";
|
||||
pub static ID_TICKET_DATA_COMBO_BOX_MAIL_TO: &str = "ticket_data_combo_box_mail_to";
|
||||
pub static ID_TICKET_DATA_CONTAINER_MAIL: &str = "ticket_data_container_mail";
|
||||
pub static ID_TICKET_DATA_COUNT_BLOCK: &str = "ticket_data_count_block";
|
||||
pub static ID_TICKET_DATA_DEDUCTIBLE: &str = "ticket_data_deductible";
|
||||
pub static ID_TICKET_DATA_FORM: &str = "ticket_data_form";
|
||||
pub static ID_TICKET_DATA_GRID: &str = "ticket_data_grid";
|
||||
pub static ID_TICKET_DATA_GRID_MAIL: &str = "ticket_data_grid_mail";
|
||||
pub static ID_TICKET_DATA_HARM_TYPE: &str = "ticket_data_harm_type";
|
||||
pub static ID_TICKET_DATA_HEADER_BAR: &str = "ticket_data_header_bar";
|
||||
pub static ID_TICKET_DATA_HEADER: &str = "ticket_data_header";
|
||||
pub static ID_TICKET_DATA_HINT: &str = "ticket_data_hint";
|
||||
pub static ID_TICKET_DATA_ITEMS_WIDGET: &str = "ticket_data_items_widget";
|
||||
pub static ID_TICKET_DATA_IVR_COMMENT: &str = "ticket_data_ivr_comment";
|
||||
pub static ID_TICKET_DATA_LABEL_CALLBACK_DATE: &str = "ticket_data_label_callback_data";
|
||||
pub static ID_TICKET_DATA_LABEL_CALLBACK_NUMBER: &str = "ticket_data_label_callback_number";
|
||||
pub static ID_TICKET_DATA_LABEL_DEDUCTIBLE: &str = "ticket_data_label_deductible";
|
||||
pub static ID_TICKET_DATA_LABEL_HARM_TYPE: &str = "ticket_data_label_harm_type";
|
||||
pub static ID_TICKET_DATA_LABEL_HINT: &str = "ticket_data_label_hint";
|
||||
pub static ID_TICKET_DATA_LABEL_IVR_COMMENT: &str = "ticket_data_label_ivr_comment";
|
||||
pub static ID_TICKET_DATA_LABEL_MAIL_CC: &str = "ticket_data_label_mail_cc";
|
||||
pub static ID_TICKET_DATA_LABEL_MAIL_TO: &str = "ticket_data_label_mail_to";
|
||||
pub static ID_TICKET_DATA_LABEL_MENU: &str = "ticket_data_label_menu";
|
||||
pub static ID_TICKET_DATA_LABEL_POLICY_CODE: &str = "ticket_data_label_policy_code";
|
||||
pub static ID_TICKET_DATA_LABEL_POLICY_HOLDER: &str = "ticket_data_label_policy_holder";
|
||||
pub static ID_TICKET_DATA_LOGO_BAR: &str = "ticket_data_logo_bar";
|
||||
pub static ID_TICKET_DATA_MAIL_CC: &str = "ticket_data_mail_cc";
|
||||
pub static ID_TICKET_DATA_MAIL_TO: &str = "ticket_data_mail_to";
|
||||
pub static ID_TICKET_DATA_POLICY_CODE: &str = "ticket_data_policy_code";
|
||||
pub static ID_TICKET_DATA_POLICY_HOLDER: &str = "ticket_data_policy_holder";
|
||||
pub static ID_TICKET_DATA_RESULT: &str = "ticket_data_result";
|
||||
pub static ID_TICKET_DATA_VIEW: &str = "ticket_data_view";
|
||||
pub static ID_TICKET_DATA_WIDGET: &str = "ticket_data_widget";
|
||||
|
||||
@@ -110,6 +110,39 @@ pub struct CsvExportRecord {
|
||||
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.
|
||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct HarmData {
|
||||
@@ -157,20 +190,6 @@ pub struct 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
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct PolicyList {
|
||||
@@ -241,7 +260,7 @@ pub struct PolicyDataList {
|
||||
|
||||
/// implements the helper methods, to manage policy data collections.
|
||||
impl PolicyDataList {
|
||||
/// Prüfung ob Versicherungselemente .
|
||||
/// Prüfung auf Versicherungselemente
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.policy_data.is_empty()
|
||||
}
|
||||
|
||||
@@ -225,6 +225,16 @@
|
||||
"de_DE": "Die Nummer ist zu kurz",
|
||||
"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": {
|
||||
"de_DE.UTF-8": "gestartet",
|
||||
"de_DE": "gestartet",
|
||||
|
||||
@@ -14,22 +14,24 @@
|
||||
//use chrono::{Local, DateTime};
|
||||
use dotenv::dotenv;
|
||||
use locales::t;
|
||||
use cfg_if::cfg_if;
|
||||
use serde::Deserialize;
|
||||
use std::env;
|
||||
//use std::process;
|
||||
use substring::Substring;
|
||||
use tracing::{info, trace, Level};
|
||||
|
||||
use orbtk::{
|
||||
prelude::*,
|
||||
theme_default::{THEME_DEFAULT, THEME_DEFAULT_COLORS_DARK, THEME_DEFAULT_FONTS},
|
||||
theming::config::ThemeConfig,
|
||||
};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use orbtk::theme_fluent::{THEME_FLUENT, THEME_FLUENT_COLORS_DARK, THEME_FLUENT_FONTS};
|
||||
|
||||
// The Main view
|
||||
use advotracker::{
|
||||
widgets::{
|
||||
main_view,
|
||||
//policycheck::policycheck_state::PolicyCheckState,
|
||||
}
|
||||
};
|
||||
use advotracker::widgets::main_view;
|
||||
|
||||
mod parse_args;
|
||||
|
||||
@@ -44,8 +46,13 @@ struct Environment {
|
||||
}
|
||||
|
||||
// Style extension
|
||||
//static FLUENT_DARK_EXT: &str = include_str!("../assets/advotracker/fluent_dark.ron");
|
||||
//static FLUENT_LIGHT_EXT: &str = include_str!("../assets/advotracker/fluent_light.ron");
|
||||
static DEFAULT_DARK_EXT: &str = include_str!("../assets/advotracker/default_dark.ron");
|
||||
cfg_if! {
|
||||
if #[cfg(windows)] {
|
||||
static FLUENT_DARK_EXT: &str = include_str!("../assets/advotracker/fluent_dark.ron");
|
||||
static FLUENT_LIGHT_EXT: &str = include_str!("../assets/advotracker/fluent_light.ron");
|
||||
}
|
||||
}
|
||||
|
||||
// German localization file.
|
||||
static ADVOTRACKER_DE_DE: &str = include_str!("../assets/advotracker/advotracker_de_DE.ron");
|
||||
@@ -53,7 +60,9 @@ static ADVOTRACKER_DE_DE: &str = include_str!("../assets/advotracker/advotracker
|
||||
/// Get the active language environment.
|
||||
fn get_lang() -> String {
|
||||
// get system environment
|
||||
let mut lang = env::var("LANG").unwrap_or("C".to_string());
|
||||
let mut lang = env::var("LANG").unwrap_or_else(|_| "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
|
||||
dotenv().ok();
|
||||
@@ -64,22 +73,47 @@ fn get_lang() -> String {
|
||||
Err(e) => { info!(target: "advotracker", "{}", e) }
|
||||
}
|
||||
trace!(target: "advotracker", lang = ?lang);
|
||||
|
||||
// return the active language
|
||||
lang
|
||||
}
|
||||
|
||||
// /// Extend and register theme assets.
|
||||
// fn theme() -> Theme {
|
||||
// register_default_fonts(Theme::from_config(
|
||||
// ThemeConfig::from(FLUENT_DARK_EXT)
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT))
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
||||
// // ThemeConfig::from(FLUENT_LIGHT_EXT)
|
||||
// // .extend(ThemeConfig::from(THEME_FLUENT))
|
||||
// // .extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
|
||||
// // .extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
||||
// ))
|
||||
// }
|
||||
cfg_if! {
|
||||
if #[cfg(windows)] {
|
||||
/// Extend and register theme assets.
|
||||
fn theme() -> Theme {
|
||||
register_default_fonts(Theme::from_config(
|
||||
ThemeConfig::from(DEFAULT_DARK_EXT)
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT))
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT_COLORS_DARK))
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT_FONTS)),
|
||||
))
|
||||
}
|
||||
fn theme_fluent() -> Theme {
|
||||
register_fluent_fonts(Theme::from_config(
|
||||
ThemeConfig::from(FLUENT_DARK_EXT)
|
||||
.extend(ThemeConfig::from(THEME_FLUENT))
|
||||
.extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
|
||||
.extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
||||
))
|
||||
// register_fluent_fonts(Theme::from_config(
|
||||
// ThemeConfig::from(FLUENT_LIGHT_EXT)
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT))
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
|
||||
// .extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
|
||||
}
|
||||
} else {
|
||||
/// Extend and register theme assets.
|
||||
fn theme() -> Theme {
|
||||
register_default_fonts(Theme::from_config(
|
||||
ThemeConfig::from(DEFAULT_DARK_EXT)
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT))
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT_COLORS_DARK))
|
||||
.extend(ThemeConfig::from(THEME_DEFAULT_FONTS)),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
use parse_args::parse_args;
|
||||
@@ -114,7 +148,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let mut state = t!("state.started", lang);
|
||||
let mut res = t!("parse.environment", lang);
|
||||
trace!(target: "advotracker", message = ?res, state = ?state);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
trace!(target: "advotracker", environment = "system", lang = ?lang);
|
||||
trace!(target: "advotracker", machine = ?&machine_kind);
|
||||
|
||||
@@ -122,7 +156,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
res = t!("parse.environment", lang);
|
||||
trace!(target: "advotracker", environment = "envy", lang = ?lang);
|
||||
state = t!("state.finished", lang);
|
||||
trace!(target: "advotracker", message = ?res, state = ?state);
|
||||
trace!(target: "advotracker", process = ?res, state = ?state);
|
||||
|
||||
// initialize viperus structure
|
||||
let mut viperus = Viperus::new();
|
||||
@@ -136,6 +170,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
state = t!("state.finished", lang);
|
||||
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
|
||||
res = t!("main.started", lang);
|
||||
state = t!("state.started", lang);
|
||||
@@ -144,21 +182,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// use this only if you want to run it as web application.
|
||||
orbtk::initialize();
|
||||
|
||||
// if no dictionary is set for the default language e.g. english the content of the text property will drawn.
|
||||
// Preset localization and language from given environment.
|
||||
// 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()
|
||||
.language("en_US")
|
||||
.language(&lang)
|
||||
.dictionary("de_DE", ADVOTRACKER_DE_DE)
|
||||
.build();
|
||||
|
||||
Application::from_name("nwx.advotracker")
|
||||
.localization(localization)
|
||||
.theme(theme())
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
.title("AdvoTracker - DirectCall")
|
||||
.position((500.0, 100.0))
|
||||
.size(580.0, 320.0)
|
||||
.size(800.0, 600.0)
|
||||
//.min_width(460.0)
|
||||
//.min_height(180.0)
|
||||
//.min_height(380.0)
|
||||
.resizeable(true)
|
||||
.child(main_view::MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
|
||||
@@ -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("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
|
||||
viperus.add_default("export_file", String::from(""));
|
||||
viperus.add_default("test_policy_number", 123456789);
|
||||
viperus.add_default("test_policy_number", String::from("9999999992"));
|
||||
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("username", String::from("nctalkbot"));
|
||||
@@ -139,7 +139,7 @@ SMR Unerledigt: 089 92529 60222")
|
||||
|
||||
// preset the prefix for relevant environment variables ("ADVOTRACKER_")
|
||||
let mut env_prefix: String = crate_name!().to_uppercase();
|
||||
env_prefix.push_str("_");
|
||||
env_prefix.push('_');
|
||||
viperus.set_env_prefix(&env_prefix);
|
||||
|
||||
// enable caching and automatic update of environment values
|
||||
|
||||
@@ -8,16 +8,12 @@
|
||||
//use chrono::{Local, DateTime};
|
||||
use locales::t;
|
||||
use std::error::Error;
|
||||
//use std::collections::HashMap;
|
||||
use tracing::trace;
|
||||
|
||||
//use crate::db::redis;
|
||||
//use crate::data::structures::{PolicyCode, PolicyDataList, PolicyData};
|
||||
|
||||
/// export as csv format
|
||||
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
||||
/// https://blog.burntsushi.net/csv/
|
||||
pub fn export(p: &mut String, lang: &String) -> Result<(), Box<dyn Error>> {
|
||||
pub fn export(p: &mut String, lang: &str) -> Result<(), Box<dyn Error>> {
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
//use std::ffi::OsStr;
|
||||
|
||||
@@ -5,5 +5,8 @@
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
/// Send ticketdata via email
|
||||
pub mod send_ticketdata;
|
||||
|
||||
/// Exporting Allianz DirecCall data
|
||||
pub mod allianzdirectcall;
|
||||
|
||||
122
advotracker/src/services/exports/send_ticketdata.rs
Normal file
122
advotracker/src/services/exports/send_ticketdata.rs
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use lettre::{
|
||||
message::{header, MultiPart, SinglePart},
|
||||
Message, SmtpTransport, Transport,
|
||||
transport::smtp::authentication::Credentials,
|
||||
};
|
||||
use locales::t;
|
||||
use maud::html;
|
||||
use std::error::Error;
|
||||
//use std::process;
|
||||
use tracing::{info, error, trace};
|
||||
|
||||
use crate::data::structures::Email;
|
||||
|
||||
/// send ticket data via eMail
|
||||
pub fn sendticketdata(email: &Email, lang: &str) -> Result<(), Box<dyn Error>> {
|
||||
let mut res = t!("sendticketdata.export.started", lang);
|
||||
let mut state = t!("state.started", lang);
|
||||
trace!(target: "sendticketdata", process = ?res, state = ?state);
|
||||
|
||||
// The html we want to send.
|
||||
// It uses https://crates.io/crates/maud
|
||||
let html = html! {
|
||||
head {
|
||||
title { (email.subject) " (" (email.policy_code) ")" }
|
||||
style type="text/css" {
|
||||
"h2, h4 { font-family: Arial, Helvetica, sans-serif; }"
|
||||
}
|
||||
}
|
||||
div style="display: flex; flex-direction: column; align-items: center;" {
|
||||
// compose with variables and strings
|
||||
h2 { (email.subject) " (" (email.policy_code) ")" }
|
||||
p { "Vers.-Schein/Schadennummer: " (email.policy_code) }
|
||||
p { "Versicherungsnehmer: " (email.policy_holder) }
|
||||
p { "Selbstbehalt: "(email.deductible) }
|
||||
p { "Rückrufnummer: " (email.callback_number) }
|
||||
p { "Erreichbarkeit: " (email.callback_date) }
|
||||
p { "Rechtsproblem: "(email.harm_type) }
|
||||
p { "Rechtsrat: "(email.ivr_comment) }
|
||||
}
|
||||
};
|
||||
|
||||
let ascii_body = String::new()
|
||||
+ &"Vers.-Schein/Schadennummer".to_string() + &(email.policy_code) + &"\n"
|
||||
+ &"Versicherungsnehmer: ".to_string() + &(email.policy_holder) + &"\n"
|
||||
+ &"Selbstbehalt: ".to_string() + &(email.deductible) + &"\n"
|
||||
+ &"Rückrufnummer: ".to_string()+ &(email.callback_number) + &"\n"
|
||||
+ &"Erreichbarkeit: ".to_string() + &(email.callback_date) + &"\n"
|
||||
+ &"Rechtsproblem: ".to_string() + &(email.harm_type) + &"\n"
|
||||
+ &"Rechtsrat: ".to_string() + &(email.ivr_comment) + &"\n";
|
||||
|
||||
info!("email body: {:?}", ascii_body);
|
||||
|
||||
let message = Message::builder()
|
||||
//.reply_to("Kanzlei Hiedemann <info@hiedemann.de>".parse().unwrap())
|
||||
.to("Kanzlei Hiedemann <info@hiedemann.de>".parse().unwrap())
|
||||
.cc(" <ralf.zerres@networkx.de>".parse().unwrap())
|
||||
.reply_to((email.mail_reply).parse().unwrap())
|
||||
//.to((email.mail_to).parse().unwrap())
|
||||
//.cc((email.mail_cc).parse().unwrap())
|
||||
//.bcc((email.mail_bcc).parse().unwrap())
|
||||
.from((email.mail_from).parse().unwrap())
|
||||
.subject(String::new()
|
||||
+ &email.subject.to_string()
|
||||
+ &" (".to_string()
|
||||
+ &email.policy_code.to_string()
|
||||
+ &")".to_string()
|
||||
)
|
||||
.multipart(
|
||||
MultiPart::alternative() // This is composed of two parts.
|
||||
.singlepart(
|
||||
SinglePart::builder()
|
||||
.header(header::ContentType(
|
||||
"text/plain; charset=utf8".parse().unwrap(),
|
||||
))
|
||||
.body(String::from(ascii_body)),
|
||||
)
|
||||
.singlepart(
|
||||
SinglePart::builder()
|
||||
.header(header::ContentType(
|
||||
"text/html; charset=utf8".parse().unwrap(),
|
||||
))
|
||||
.body(html.into_string()),
|
||||
),
|
||||
)
|
||||
.expect("failed to build email");
|
||||
|
||||
|
||||
info!("message: {:?}", message);
|
||||
|
||||
// Create credential for remote authentication (username, password)
|
||||
// WIP: get credentials from config file / cli
|
||||
let creds = Credentials::new("info@kanzlei.hiedemann.de".to_string(), "17info67$".to_string());
|
||||
|
||||
|
||||
|
||||
// Open a remote connection to relay server (port 2525)
|
||||
// WIP: get relay address from config file / cli
|
||||
let mailer = SmtpTransport::relay("hiedemannsbs.kanzlei.hiedemann.de")
|
||||
.unwrap()
|
||||
.credentials(creds)
|
||||
.build();
|
||||
|
||||
// Send the email
|
||||
match mailer.send(&message) {
|
||||
Ok(_) => info!("Email sent successfully!"),
|
||||
Err(e) => error!("Could not send email: {:?}", e),
|
||||
}
|
||||
|
||||
trace!(target: "sendticketdata", email = ?email);
|
||||
state = t!("state.finished", lang);
|
||||
res = t!("sendticketdata.export.finished", lang);
|
||||
trace!(target: "sendticketdata", process = ?res, state = ?state);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -23,7 +23,7 @@ use crate::data::structures::{PolicyCode, PolicyDataList, PolicyData};
|
||||
pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
||||
policy_numbers: &mut HashMap<u64, PolicyCode>,
|
||||
policy_data_count: &mut u64,
|
||||
lang: &String)
|
||||
lang: &str)
|
||||
-> Result<(u64, Duration), Box<dyn Error>> {
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -24,7 +24,7 @@ fn import() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
fn main() {
|
||||
if let Err(err) = import() {
|
||||
println!("error running example: {}", err);
|
||||
println!("import error: {}", err);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
79
advotracker/src/widgets/configuration/configuration_state.rs
Normal file
79
advotracker/src/widgets/configuration/configuration_state.rs
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::widgets::configuration::configuration_view::ConfigurationView;
|
||||
|
||||
/// Valid `actions` that are handled as state changes in the `Configuration` widget.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum ConfigurationAction {
|
||||
SaveConfiguration,
|
||||
LoadConfiguration,
|
||||
}
|
||||
|
||||
/// Define valid configuration data.
|
||||
/// This structure is serialized and saved inside the OS dependent settings file.
|
||||
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
||||
struct ConfigurationData(
|
||||
pub String,
|
||||
pub String
|
||||
);
|
||||
|
||||
/// Valid `structures` that are handled inside the state of the `Configuration` widget.
|
||||
#[derive(Debug, Default, AsAny)]
|
||||
pub struct ConfigurationState {}
|
||||
|
||||
impl State for ConfigurationState {
|
||||
fn messages(
|
||||
&mut self,
|
||||
mut messages: MessageReader,
|
||||
registry: &mut Registry,
|
||||
ctx: &mut Context<'_>,
|
||||
) {
|
||||
for message in messages.read::<ConfigurationAction>() {
|
||||
match message {
|
||||
ConfigurationAction::LoadConfiguration => {
|
||||
registry
|
||||
.get::<Settings>("settings")
|
||||
.load_async::<ConfigurationData>(
|
||||
"configuration_data".to_string(), ctx.entity()
|
||||
);
|
||||
}
|
||||
ConfigurationAction::SaveConfiguration => {
|
||||
let configuration_file: String = ConfigurationView::configuration_file_clone(&ctx.widget());
|
||||
let language_id: String = ConfigurationView::language_id_clone(&ctx.widget());
|
||||
registry
|
||||
.get::<Settings>("settings")
|
||||
.save_async(
|
||||
"configuration_data".to_string(),
|
||||
ConfigurationData(
|
||||
configuration_file,
|
||||
language_id
|
||||
),
|
||||
ctx.entity(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// save the result
|
||||
for message in messages.read::<SettingsResult<()>>() {
|
||||
println!("Result {:?}", message);
|
||||
}
|
||||
|
||||
// load result
|
||||
for message in messages.read::<SettingsResult<ConfigurationData>>() {
|
||||
if let Ok(data) = message {
|
||||
ConfigurationView::configuration_file_set(&mut ctx.widget(), data.0);
|
||||
ConfigurationView::language_id_set(&mut ctx.widget(), data.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
139
advotracker/src/widgets/configuration/configuration_view.rs
Normal file
139
advotracker/src/widgets/configuration/configuration_view.rs
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::{
|
||||
data::constants::*,
|
||||
widgets::configuration::configuration_state::{ConfigurationAction, ConfigurationState},
|
||||
};
|
||||
|
||||
// Macro that initializes the widget structures/variables for our view
|
||||
widget!(
|
||||
ConfigurationView<ConfigurationState> {
|
||||
configuration_file: String,
|
||||
language_id: String
|
||||
}
|
||||
);
|
||||
|
||||
/// The template implementation of the configuration view
|
||||
/// All GUI elements are styled using the "style" attribute referencing to a ron based css
|
||||
impl Template for ConfigurationView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
self.child(
|
||||
Grid::new()
|
||||
.id(ID_CONFIGURATION_FORM)
|
||||
.style("configuration_form")
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(120)
|
||||
.push(12)
|
||||
.push("auto")
|
||||
)
|
||||
.rows(Rows::create()
|
||||
.push("auto") // Header_Bar
|
||||
.push(4) // Seperator
|
||||
.push("auto") // Configuartion_File
|
||||
.push(4) // Seperator
|
||||
.push("auto") // Language_ID
|
||||
.push(12) // Seperator
|
||||
.push("auto"), // Action
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_CONFIGURATION_HEADER)
|
||||
.h_align("start")
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.text("Configuration settings")
|
||||
.style("header")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_CONFIGURATION_LABEL_CONFIG_FILE)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(2))
|
||||
.v_align("center")
|
||||
.h_align("end")
|
||||
.text("Configuration file")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_CONFIGURATION_CONFIG_FILE)
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(2))
|
||||
.text(("configuration_file", id))
|
||||
.water_mark("Filename...")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_CONFIGURATION_LABEL_LANGUAGE_ID)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(4))
|
||||
.v_align("center")
|
||||
.h_align("end")
|
||||
.text("Language Id")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_CONFIGURATION_LANGUAGE_ID)
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(4))
|
||||
.text(("language_id", id))
|
||||
.water_mark("Locale Identifier...")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
.h_align("center")
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(6))
|
||||
.attach(Grid::column_span(3))
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push("auto")
|
||||
.push(8)
|
||||
.push("auto")
|
||||
)
|
||||
.rows(Rows::create()
|
||||
.push("auto")
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.style("button_single_content")
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(0))
|
||||
.text("Load")
|
||||
.on_click(move |ctx, _| {
|
||||
ctx.send_message(ConfigurationAction::LoadConfiguration, id);
|
||||
true
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.text("Save")
|
||||
.style("button_single_content")
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(0))
|
||||
.on_click(move |ctx, _| {
|
||||
ctx.send_message(ConfigurationAction::SaveConfiguration, id);
|
||||
true
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
12
advotracker/src/widgets/configuration/mod.rs
Normal file
12
advotracker/src/widgets/configuration/mod.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
/// The configuration state
|
||||
pub mod configuration_state;
|
||||
|
||||
/// The configuration view
|
||||
pub mod configuration_view;
|
||||
@@ -8,6 +8,7 @@
|
||||
use dotenv::dotenv;
|
||||
use serde::Deserialize;
|
||||
use std::env;
|
||||
use substring::Substring;
|
||||
use tracing::{info, trace};
|
||||
|
||||
use orbtk::prelude::*;
|
||||
@@ -28,10 +29,11 @@ struct Environment {
|
||||
|
||||
/// Provides generic methods to handle states of datatypes.
|
||||
pub trait GlobalState {
|
||||
/// Get the active language environment.
|
||||
fn get_lang() -> String {
|
||||
// get system environment
|
||||
let mut lang = env::var("LANG").unwrap_or("C".to_string());
|
||||
let mut lang = env::var("LANG").unwrap_or_else(|_| "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
|
||||
dotenv().ok();
|
||||
@@ -42,17 +44,28 @@ pub trait GlobalState {
|
||||
Err(e) => { info!(target: "advotracker", "{}", e) }
|
||||
}
|
||||
trace!(target: "advotracker", lang = ?lang);
|
||||
|
||||
// return the active language
|
||||
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.
|
||||
// fn navigate(&self, to: Entity, ctx: &mut Context<'_>) {
|
||||
// if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget {
|
||||
// let mut old_focused_element = ctx.get_widget(old_focused_element);
|
||||
// old_focused_element.set("focused", false);
|
||||
// //old_focused_element.update_theme_by_state(false);
|
||||
// if let Some(old_focused_element) = *Window::focus_state_ref(&ctx.window()).focused_entity() {
|
||||
// ctx.push_event_by_window(FocusEvent::RemoveFocus(old_focused_element));
|
||||
// }
|
||||
// ctx.window().get_mut::<Global>("global").focused_widget = None;
|
||||
// ctx.widget().set("visibility", Visibility::Collapsed);
|
||||
// ctx.get_widget(to).set("visibility", Visibility::Visible);
|
||||
// }
|
||||
@@ -62,7 +75,6 @@ pub trait GlobalState {
|
||||
/// in users 'settings directory'. The directory location is OS dependant
|
||||
/// (Windows: AppData, Unix: XDG_CONFIG_HOME, MacOS: $HOME/Library/Preferences).
|
||||
/// The data is stored in filename PROP_ADVOTRACKER (here: `advotracker.ron`)
|
||||
|
||||
fn save(&self, registry: &mut Registry, ctx: &mut Context<'_>) {
|
||||
registry
|
||||
.get::<Settings>("settings")
|
||||
|
||||
40
advotracker/src/widgets/localization/localization_state.rs
Normal file
40
advotracker/src/widgets/localization/localization_state.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::widgets::localization::localization_view::LocalizationView;
|
||||
|
||||
#[derive(AsAny, Debug, Default)]
|
||||
pub struct LocalizationState {
|
||||
change_language: bool,
|
||||
}
|
||||
|
||||
impl LocalizationState {
|
||||
pub fn change_language(&mut self) {
|
||||
self.change_language = true;
|
||||
}
|
||||
}
|
||||
|
||||
impl State for LocalizationState {
|
||||
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
|
||||
if !self.change_language {
|
||||
return;
|
||||
}
|
||||
|
||||
let index = *LocalizationView::selected_index_ref(&ctx.widget()) as usize;
|
||||
let selected_language = LocalizationView::languages_ref(&ctx.widget())[index].clone();
|
||||
|
||||
match selected_language.as_str() {
|
||||
"English" => ctx.set_language("en_US"),
|
||||
"German" => ctx.set_language("de_DE"),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
self.change_language = false;
|
||||
}
|
||||
}
|
||||
97
advotracker/src/widgets/localization/localization_view.rs
Normal file
97
advotracker/src/widgets/localization/localization_view.rs
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::{
|
||||
data::constants::*,
|
||||
widgets::localization::localization_state::LocalizationState,
|
||||
};
|
||||
|
||||
type List = Vec<String>;
|
||||
|
||||
// Macro that initializes the widget structures/variables for our view
|
||||
widget!(LocalizationView<LocalizationState> {
|
||||
languages: List,
|
||||
selected_index: i32 }
|
||||
);
|
||||
|
||||
/// The template implementation of the localization view
|
||||
/// All GUI elements are styled using the "style" attribute referencing to a ron based css
|
||||
impl Template for LocalizationView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
let languages = vec!["English".to_string(), "German".to_string()];
|
||||
let count = languages.len();
|
||||
|
||||
self.languages(languages)
|
||||
.selected_index(1)
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_LOCALIZATION_FORM)
|
||||
.margin(4)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(120)
|
||||
.push(12)
|
||||
.push(150)
|
||||
)
|
||||
.rows(Rows::create()
|
||||
.push("auto")
|
||||
.push(4)
|
||||
.push("auto")
|
||||
.push(4)
|
||||
.push("auto")
|
||||
.push(12)
|
||||
.push("auto"),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_LOCALIZATION_HEADER)
|
||||
.h_align("start")
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.text("Localization dialog")
|
||||
.style("header")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_LOCALIZATION_LABEL_LANGUAGE_NAME)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(2))
|
||||
.v_align("center")
|
||||
.h_align("end")
|
||||
.text("Language ID")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ComboBox::new()
|
||||
.id(ID_LOCALIZATION_LANGUAGES)
|
||||
.count(count)
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(2))
|
||||
.items_builder(move |bc, index| {
|
||||
let text = bc.get_widget(id)
|
||||
.get::<Vec<String>>("languages")[index]
|
||||
.clone();
|
||||
TextBlock::new()
|
||||
.id(ID_LOCALIZATION_LANGUAGE_NAME)
|
||||
.v_align("center")
|
||||
.text(text)
|
||||
.build(bc)
|
||||
})
|
||||
.on_changed("selected_index", move |states, _| {
|
||||
states.get_mut::<LocalizationState>(id).change_language();
|
||||
})
|
||||
.selected_index(id)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
12
advotracker/src/widgets/localization/mod.rs
Normal file
12
advotracker/src/widgets/localization/mod.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
/// The localization state
|
||||
pub mod localization_state;
|
||||
|
||||
/// The localizatin view
|
||||
pub mod localization_view;
|
||||
@@ -8,12 +8,17 @@
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::{
|
||||
data::structures::PolicyCheck,
|
||||
data::{
|
||||
constants::*,
|
||||
structures::PolicyCheck,
|
||||
},
|
||||
widgets::configuration::configuration_view::ConfigurationView,
|
||||
widgets::policycheck::policycheck_view::PolicycheckView,
|
||||
widgets::localization::localization_view::LocalizationView,
|
||||
//widgets::menu::menu_view::MenuView,
|
||||
widgets::ticketdata::ticketdata_view::TicketdataView,
|
||||
};
|
||||
|
||||
type List = Vec<String>;
|
||||
|
||||
// [START] views
|
||||
|
||||
widget!(MainView {
|
||||
@@ -22,13 +27,18 @@ widget!(MainView {
|
||||
// policylist_view: u32,
|
||||
// policydata_view: u32,
|
||||
policycheck_view: PolicyCheck
|
||||
//ticketdata_view: TicketData
|
||||
});
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
let ticketdata_view = TicketdataView::new()
|
||||
.build(ctx);
|
||||
|
||||
let policycheck_view = PolicycheckView::new()
|
||||
//.policy_number_count(0)
|
||||
//.policylist_view(id)
|
||||
.target(ticketdata_view.0)
|
||||
//.policy_number_count(0)
|
||||
//.policylist_view(id)
|
||||
.build(ctx);
|
||||
|
||||
// let policylist_view = PolicyListView::new()
|
||||
@@ -45,7 +55,7 @@ impl Template for MainView {
|
||||
// .build(ctx);
|
||||
|
||||
self.name("MainView")
|
||||
.policycheck_view(PolicyCheck::default())
|
||||
//.policycheck_view(PolicyCheck::default())
|
||||
// //.policycheck_view(0)
|
||||
// .policydata_view(policydata_view.0)
|
||||
// //.policylist_view(PolicyList::default())
|
||||
@@ -54,265 +64,13 @@ impl Template for MainView {
|
||||
// .child(policylist_view)
|
||||
.child(
|
||||
TabWidget::new()
|
||||
.tab("Policynumber check", policycheck_view)
|
||||
.tab("Localization", LocalizationView::new().build(ctx))
|
||||
.tab("Configuration", ConfigurationView::new().build(ctx))
|
||||
.tab(ID_POLICY_CHECK_VIEW, policycheck_view)
|
||||
.tab(ID_TICKET_DATA_VIEW, ticketdata_view)
|
||||
.tab(ID_LOCALIZATION_VIEW, LocalizationView::new().build(ctx))
|
||||
.tab(ID_CONFIGURATION_VIEW, ConfigurationView::new().build(ctx))
|
||||
//.tab(ID_MENU_VIEW, MenuView::new().build(ctx))
|
||||
.build(ctx),
|
||||
)
|
||||
//.child(policycheck_view)
|
||||
}
|
||||
}
|
||||
|
||||
widget!(LocalizationView<LocalizationState> {
|
||||
languages: List,
|
||||
selected_index: i32 }
|
||||
);
|
||||
|
||||
impl Template for LocalizationView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
let languages = vec!["English".to_string(), "German".to_string()];
|
||||
let count = languages.len();
|
||||
|
||||
self.languages(languages).selected_index(1).child(
|
||||
Stack::new()
|
||||
.width(120)
|
||||
.margin(16)
|
||||
.spacing(8)
|
||||
.child(TextBlock::new().text("Hello").build(ctx))
|
||||
.child(TextBlock::new().text("User").build(ctx))
|
||||
.child(TextBlock::new().text("Localization dialog").build(ctx))
|
||||
.child(
|
||||
ComboBox::new()
|
||||
.count(count)
|
||||
.items_builder(move |bc, index| {
|
||||
let text = bc.get_widget(id)
|
||||
.get::<Vec<String>>("languages")[index]
|
||||
.clone();
|
||||
TextBlock::new().v_align("center").text(text).build(bc)
|
||||
})
|
||||
.on_changed("selected_index", move |states, _| {
|
||||
states.get_mut::<LocalizationState>(id).change_language();
|
||||
})
|
||||
.selected_index(id)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
widget!(
|
||||
ConfigurationView<ConfigurationState> {
|
||||
configuration_file: String,
|
||||
language_id: String
|
||||
}
|
||||
);
|
||||
|
||||
impl Template for ConfigurationView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
self.child(
|
||||
Grid::new()
|
||||
.margin(4)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(120)
|
||||
.push(12)
|
||||
.push("auto")
|
||||
)
|
||||
.rows(Rows::create()
|
||||
.push("auto")
|
||||
.push(4)
|
||||
.push("auto")
|
||||
.push(4)
|
||||
.push("auto")
|
||||
.push(12)
|
||||
.push("auto"),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.h_align("start")
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.text("Configuration settings")
|
||||
.style("header")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(2))
|
||||
.v_align("center")
|
||||
.h_align("end")
|
||||
.text("Configuration file")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(2))
|
||||
.text(("configuration_file", id))
|
||||
.water_mark("Filename...")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(4))
|
||||
.v_align("center")
|
||||
.h_align("end")
|
||||
.text("Language Id")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(4))
|
||||
.text(("language_id", id))
|
||||
.water_mark("Locale Identifier...")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
.h_align("center")
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(6))
|
||||
.attach(Grid::column_span(3))
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push("auto")
|
||||
.push(8)
|
||||
.push("auto")
|
||||
)
|
||||
.rows(Rows::create()
|
||||
.push("auto")
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.style("button_single_content")
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(0))
|
||||
.text("load")
|
||||
.on_click(move |ctx, _| {
|
||||
ctx.send_message(ConfigurationAction::LoadConfiguration, id);
|
||||
true
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.text("save")
|
||||
.style("button_single_content")
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(0))
|
||||
.on_click(move |ctx, _| {
|
||||
ctx.send_message(ConfigurationAction::SaveConfiguration, id);
|
||||
true
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// [END] views
|
||||
|
||||
// [START] states
|
||||
|
||||
#[derive(AsAny, Debug, Default)]
|
||||
struct LocalizationState {
|
||||
change_language: bool,
|
||||
}
|
||||
|
||||
impl LocalizationState {
|
||||
fn change_language(&mut self) {
|
||||
self.change_language = true;
|
||||
}
|
||||
}
|
||||
|
||||
impl State for LocalizationState {
|
||||
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
|
||||
if !self.change_language {
|
||||
return;
|
||||
}
|
||||
|
||||
let index = *LocalizationView::selected_index_ref(&ctx.widget()) as usize;
|
||||
let selected_language = LocalizationView::languages_ref(&ctx.widget())[index].clone();
|
||||
|
||||
match selected_language.as_str() {
|
||||
"English" => ctx.set_language("en_US"),
|
||||
"German" => ctx.set_language("de_DE"),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
self.change_language = false;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, AsAny)]
|
||||
struct ConfigurationState {}
|
||||
|
||||
impl State for ConfigurationState {
|
||||
fn messages(
|
||||
&mut self,
|
||||
mut messages: MessageReader,
|
||||
registry: &mut Registry,
|
||||
ctx: &mut Context<'_>,
|
||||
) {
|
||||
for message in messages.read::<ConfigurationAction>() {
|
||||
match message {
|
||||
ConfigurationAction::LoadConfiguration => registry
|
||||
.get::<Settings>("settings")
|
||||
.load_async::<ConfigurationData>("configuration_data".to_string(), ctx.entity()),
|
||||
ConfigurationAction::SaveConfiguration => {
|
||||
let configuration_file: String = ConfigurationView::configuration_file_clone(&ctx.widget());
|
||||
let language_id: String = ConfigurationView::language_id_clone(&ctx.widget());
|
||||
registry.get::<Settings>("settings").save_async(
|
||||
"configuration_data".to_string(),
|
||||
ConfigurationData(
|
||||
configuration_file,
|
||||
language_id
|
||||
),
|
||||
ctx.entity(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// save result
|
||||
for message in messages.read::<SettingsResult<()>>() {
|
||||
println!("Result {:?}", message);
|
||||
}
|
||||
|
||||
// load result
|
||||
for message in messages.read::<SettingsResult<ConfigurationData>>() {
|
||||
if let Ok(data) = message {
|
||||
ConfigurationView::configuration_file_set(&mut ctx.widget(), data.0);
|
||||
ConfigurationView::language_id_set(&mut ctx.widget(), data.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// [END] states
|
||||
|
||||
// [START] Configuration data
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
enum ConfigurationAction {
|
||||
SaveConfiguration,
|
||||
LoadConfiguration,
|
||||
}
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ConfigurationData(
|
||||
pub String,
|
||||
pub String
|
||||
);
|
||||
|
||||
// [END] Configuration data
|
||||
|
||||
427
advotracker/src/widgets/menu/menu_state.rs
Normal file
427
advotracker/src/widgets/menu/menu_state.rs
Normal file
@@ -0,0 +1,427 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2021 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 tracing::{info, trace};
|
||||
|
||||
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,
|
||||
RemoveMenu,
|
||||
RemoveMenuToggleTheme,
|
||||
SetTheme,
|
||||
UpdateMenuRelativePosition
|
||||
}
|
||||
|
||||
/// Valid `structures` that are handled inside the state of the `Menu` widget.
|
||||
#[derive(AsAny, Default)]
|
||||
pub struct MenuState {
|
||||
action: Option<MenuAction>,
|
||||
menu: Option<Entity>,
|
||||
//menu_toggle_theme: Option<Entity>
|
||||
menu_toggle_theme: Entity
|
||||
}
|
||||
|
||||
/// Method definitions, that react on any given state change inside the `Menu` widget.
|
||||
impl MenuState {
|
||||
/// Create a toggle_theme menu as a child of the given parent
|
||||
/// Select the active theme from a `ComboBox` offering a list of valid `themes`
|
||||
fn _create_menu_toggle_theme(&mut self, _ctx: &mut Context<'_>) {
|
||||
self.action = Some(MenuAction::CreateMenuToggleTheme);
|
||||
}
|
||||
|
||||
/// Remove the menu popup box
|
||||
fn remove_menu(&mut self, ctx: &mut Context<'_>) {
|
||||
self.action = Some(MenuAction::RemoveMenu);
|
||||
ctx.remove_child(ctx.entity());
|
||||
println!("Popup {:?} removed.", ctx.entity());
|
||||
}
|
||||
|
||||
/// Remove the menu popup box
|
||||
fn _remove_menu_toggle_theme(&mut self, _ctx: &mut Context<'_>) {
|
||||
self.action = Some(MenuAction::RemoveMenuToggleTheme);
|
||||
}
|
||||
|
||||
/// Sets a new action.
|
||||
pub fn set_action(&mut self, action: MenuAction) {
|
||||
self.action = action.into();
|
||||
}
|
||||
|
||||
/// Update the relative position of the menu overlay
|
||||
fn _update_menu_relative_position(&mut self) {
|
||||
println!("TODO: Update relative position of menu {}.", ID_MENU_POPUP);
|
||||
//self.action = Some(MenuAction::UpdateRelativePosition);
|
||||
}
|
||||
}
|
||||
|
||||
/// 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<'_>) {
|
||||
// }
|
||||
|
||||
/// 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::CreateMenu => {
|
||||
info!("WIP: create a menu popup in MenuState");
|
||||
|
||||
// assign parent entity
|
||||
let parent = ctx.entity();
|
||||
trace!(parent = ?parent);
|
||||
//let parent_name = ctx.get_widget().get::<String16>("text");
|
||||
//trace!(parent = ?parent, parent_name = ?parent_name);
|
||||
|
||||
// assign target -> search for a child of parent with given id
|
||||
let target = ctx
|
||||
.entity_of_child(ID_MENU_BUTTON_MENU)
|
||||
.expect("MenuState: Can't find entity of resource 'ID_MENU_BUTTON_MENU'.");
|
||||
|
||||
trace!(target = ?target.0, entity_of_child = ?ID_MENU_BUTTON_MENU);
|
||||
|
||||
// create the target entity as child of parent
|
||||
let menu_popup = create_menu_popup(parent, &mut ctx.build_context());
|
||||
//let menu_popup = create_popup(target, "Testmenu Popup", &mut ctx.build_context());
|
||||
|
||||
// append the child to target (overlay stays on top of the main tree)
|
||||
ctx.build_context()
|
||||
.append_child_to_overlay(menu_popup)
|
||||
.expect("Failed create an overlay that consumes popup `menu` as its child.");
|
||||
self.menu = Some(menu_popup);
|
||||
|
||||
trace!(menu = ?self.menu);
|
||||
|
||||
// open: is the default
|
||||
//ctx.get_widget(menu).set("open", true);
|
||||
|
||||
info!("CreateMenu: parent {:?}, target: {:?}, popup: {:?}", parent, target, self.menu);
|
||||
}
|
||||
|
||||
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::CreateMenuToggleTheme => {
|
||||
let menu_target = 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 popup
|
||||
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(menu_target, self.menu_toggle_theme);
|
||||
|
||||
ctx.get_widget(self.menu_toggle_theme).clone::<Visibility>("visibility");
|
||||
|
||||
println!("Popup Menu Toggle Theme created: {:?}", self.menu_toggle_theme);
|
||||
}
|
||||
MenuAction::RemoveMenu => {
|
||||
self.remove_menu(ctx);
|
||||
}
|
||||
MenuAction::RemoveMenuToggleTheme => {
|
||||
ctx.remove_child(self.menu_toggle_theme);
|
||||
println!("Popup {:?} removed.", ctx.entity());
|
||||
}
|
||||
MenuAction::UpdateMenuRelativePosition => {
|
||||
if let Some(menu) = self.menu {
|
||||
// let theme_combo_box = ctx.entity_of_child(ID_MENU_TOGGLE_THEME).unwrap();
|
||||
// let selected_index: i32 = ctx.get_widget(theme_combo_box).clone("selected_index");
|
||||
// // let relative_position: RelativePosition =
|
||||
// // ctx.get_widget(ID_MENU_POPUP).clone_or_default("relative_position");
|
||||
// match selected_index {
|
||||
// 0 => {
|
||||
// RelativePosition::relative_position_mut(&mut ctx.widget()).into_bottom();
|
||||
// //RelativePosition::get_mut::<MenuState>("relative_position").into_bottom();
|
||||
// // ctx
|
||||
// // .get_widget(self.ID_MENU_POPUP.unwrap())
|
||||
// // .set("relative_position", relative_position.into_bottom());
|
||||
// },
|
||||
// 1 => RelativePosition::relative_position_mut(&mut ctx.widget()).into_top(),
|
||||
// 2 => RelativePosition::relative_position_mut(&mut ctx.widget()).into_left(),
|
||||
// 3 => RelativePosition::relative_position_mut(&mut ctx.widget()).into_right(),
|
||||
// _ => panic!(),
|
||||
// }
|
||||
println!("Relative position of menu {:?} updated.", menu);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new popup presenting the menu components
|
||||
fn create_menu_popup(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
Popup::new()
|
||||
.id(ID_MENU_POPUP)
|
||||
.name(ID_MENU_POPUP)
|
||||
.target(target.0)
|
||||
.open(true)
|
||||
// WIP: this requires orbtk-develop with PR #304 (new_popup)
|
||||
// Specify the popup position relative to the target
|
||||
//.relative_position(RelativePosition::Bottom(5.0))
|
||||
// Reference target from given Point
|
||||
//.target(Point::new(100.0,100.0))
|
||||
//.style("popup_menu")
|
||||
.width(300.0)
|
||||
.height(100.0)
|
||||
|
||||
.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>(target)
|
||||
.set_action(MenuAction::RemoveMenu);
|
||||
},
|
||||
_ => {
|
||||
println!("KeyHandler: got {:?}", key_event.key);
|
||||
},
|
||||
};
|
||||
true
|
||||
})
|
||||
.child(
|
||||
Container::new()
|
||||
.child(
|
||||
TextBlock::new()
|
||||
//.style("popup_text_block")
|
||||
.h_align("center")
|
||||
.v_align("enter")
|
||||
.text(ID_MENU_POPUP)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_MENU_GRID)
|
||||
.name(ID_MENU_GRID)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push("180") // Menu Button
|
||||
.push("1") // Seperator
|
||||
.push("auto") // Keyboard Shortcut
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.id(ID_MENU_LABEL_ACCOUNT)
|
||||
.name(ID_MENU_LABEL_ACCOUNT)
|
||||
.style("button_menu")
|
||||
//.h_align("start")
|
||||
.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)
|
||||
.name(ID_MENU_LABEL_TOGGLE_THEME)
|
||||
.style("button_menu")
|
||||
//.h_align("start")
|
||||
.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>(target)
|
||||
.set_action(MenuAction::CreateMenuToggleTheme);
|
||||
true
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.id(ID_MENU_LABEL_QUIT)
|
||||
.name(ID_MENU_LABEL_QUIT)
|
||||
.style("button_menu")
|
||||
//.h_align("start")
|
||||
.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)
|
||||
.name(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)
|
||||
}
|
||||
|
||||
|
||||
fn _create_popup(target: Entity, text: &str, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
Popup::new()
|
||||
.id("test_popup")
|
||||
.name("Test Popup")
|
||||
// Reference target from given Entity
|
||||
.target(target.0)
|
||||
// Reference target from given Point
|
||||
//.target(Point::new(0.0, 5.0))
|
||||
// Specify the popup position relative to the target (the button in this case)
|
||||
//.relative_position(RelativePosition::Bottom(5.0))
|
||||
.open(true)
|
||||
.style("popup_form")
|
||||
.width(350.0)
|
||||
.height(100.0)
|
||||
.child(
|
||||
Container::new()
|
||||
.child(
|
||||
TextBlock::new()
|
||||
//.style("popup_text_block")
|
||||
.h_align("center")
|
||||
.text(text)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Create a new popup submenu to toogle the active theme
|
||||
fn create_menu_toggle_theme_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
let themes_count = themes.len();
|
||||
|
||||
Popup::new()
|
||||
.id(ID_MENU_TOGGLE_THEME)
|
||||
.target(id.0)
|
||||
.style("container_menu")
|
||||
.width(280)
|
||||
.height(140)
|
||||
.on_key_down(move | _ctx, key_event | {
|
||||
match key_event.key {
|
||||
Key::Escape => {
|
||||
println!("KeyHandler: got Escape");
|
||||
//ctx.get_mut::<MenuState>(id)
|
||||
// .set_action(MenuAction::RemoveMenuToggleTheme);
|
||||
},
|
||||
_ => {
|
||||
println!("KeyHandler: got {:?}", key_event.key);
|
||||
},
|
||||
};
|
||||
true
|
||||
})
|
||||
.child(
|
||||
ComboBox::new()
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(6))
|
||||
.count(themes_count)
|
||||
.style("combo_box_form")
|
||||
.items_builder(move |ctx, index| {
|
||||
let theme_name =
|
||||
MenuView::themes_ref(&ctx.get_widget(id))[index].clone();
|
||||
TextBlock::new().v_align("center").text(theme_name).build(ctx)
|
||||
})
|
||||
.on_changed("selected_index", move |states, _entity| {
|
||||
states.send_message(MenuAction::SetTheme, id);
|
||||
println!("changed theme.");
|
||||
})
|
||||
.selected_index(id)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
}
|
||||
127
advotracker/src/widgets/menu/menu_view.rs
Normal file
127
advotracker/src/widgets/menu/menu_view.rs
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
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 {
|
||||
let menu_bottom_bar = Container::new()
|
||||
.id(ID_MENU_BOTTOM_BAR)
|
||||
.style(STYLE_BOTTOM_BAR)
|
||||
.attach(Grid::row(3))
|
||||
.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 menu_button_menu = Button::new()
|
||||
.id(ID_MENU_BUTTON_MENU)
|
||||
.name(ID_MENU_BUTTON_MENU)
|
||||
.style("button_single_content")
|
||||
.icon(material_icons_font::MD_MENU)
|
||||
.attach(Grid::column(2))
|
||||
//.min_size(16, 16)
|
||||
//.h_align("end")
|
||||
.h_align("start")
|
||||
.on_click(move |ctx, _| {
|
||||
ctx.send_message(MenuAction::CreateMenu, id);
|
||||
true
|
||||
})
|
||||
.build(ctx);
|
||||
|
||||
let menu_header_bar = Container::new()
|
||||
.id(ID_MENU_HEADER_BAR)
|
||||
.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_MENU_HEADER)
|
||||
.v_align("center")
|
||||
.h_align("left")
|
||||
.text("Ticket Data")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(menu_button_menu)
|
||||
.build(ctx);
|
||||
|
||||
//self.themes(themes).child(MenuState::create_menu(ID_MENU_POPUP, ctx))
|
||||
self.name("MenuView")
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_MENU_VIEW)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(50) // Left margin
|
||||
.push("*") // Content
|
||||
.push(50) // Right margin
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Header_Bar
|
||||
.push(28) // Seperator
|
||||
.push("*") // InputForm
|
||||
.push("auto") // Bottom_Bar
|
||||
)
|
||||
|
||||
.child(menu_header_bar) // Row 0
|
||||
.child(menu_bottom_bar) // Row 3
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
12
advotracker/src/widgets/menu/mod.rs
Normal file
12
advotracker/src/widgets/menu/mod.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
/// The menu view
|
||||
pub mod menu_view;
|
||||
|
||||
/// The menu state
|
||||
pub mod menu_state;
|
||||
@@ -5,17 +5,29 @@
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
/// global helper functions
|
||||
/// Configuration widget.
|
||||
pub mod configuration;
|
||||
|
||||
/// Global helper functions.
|
||||
pub mod global_state;
|
||||
|
||||
/// The starting point (Main View)
|
||||
/// Localization widget.
|
||||
pub mod localization;
|
||||
|
||||
/// The starting point (Main View).
|
||||
pub mod main_view;
|
||||
|
||||
/// The policy check wigdet
|
||||
/// Menu widget.
|
||||
pub mod menu;
|
||||
|
||||
/// Policycheck wigdet.
|
||||
pub mod policycheck;
|
||||
|
||||
// /// The policy data widget
|
||||
// /// Policydata widget.
|
||||
// pub mod policydata;
|
||||
|
||||
// /// The policy lists widget
|
||||
// /// Policylists widget.
|
||||
// pub mod policylist;
|
||||
|
||||
/// Ticketdata wigdet.
|
||||
pub mod ticketdata;
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::data::constants::*;
|
||||
|
||||
widget!(
|
||||
PolicyCheckMenu {
|
||||
is_active: Bool
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
impl Template for PolicyCheckMenu {
|
||||
fn template(self, _id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
// let policy_check_menu_container = Container::new()
|
||||
// .id(ID_POLICY_CHECK_MENU_CONTAINER)
|
||||
// .class(CLASS_MENU)
|
||||
// .attach(Grid::row(3))
|
||||
// .attach(Grid::column(8))
|
||||
// .margin((0.0, 0.0, 4.0, 0.0))
|
||||
// .enabled(false)
|
||||
// .min_size(120.0, 180.0)
|
||||
// .v_align("center")
|
||||
// .on_click(move |ctx, _| {
|
||||
// ctx.get_mut::<PolicyCheckState>(id)
|
||||
// .action(Action::NewEntry(quit));
|
||||
// true
|
||||
// })
|
||||
// .build(ctx);
|
||||
|
||||
// let policycheck_menu_container = Container::new()
|
||||
// .id(ID_POLICY_CHECK_MENU_CONTAINER)
|
||||
// .background("#dfebf5")
|
||||
// .width(200.0)
|
||||
// .height(200.0)
|
||||
// .child(
|
||||
|
||||
// The menu implemented as an overlay
|
||||
//ctx.append_child_to_overlay(policy_check_menu_button).unwrap();
|
||||
|
||||
self.name("PolicyCheckMenu").child(
|
||||
Stack::new()
|
||||
.id(ID_POLICY_CHECK_MENU)
|
||||
.orientation("vertical")
|
||||
.spacing(8)
|
||||
.h_align("center")
|
||||
.child(
|
||||
Button::new()
|
||||
.icon(material_icons_font::MD_VERIFIED_USER)
|
||||
.text("angemeldeter Benutzer")
|
||||
.margin((0, 8, 0, 0))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.icon(material_icons_font::MD_EXIT_TO_APP)
|
||||
.text("Quit")
|
||||
.margin((0, 8, 0, 0))
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use locales::t;
|
||||
use orbtk::prelude::*;
|
||||
|
||||
@@ -8,74 +15,78 @@ use std::time::{Duration, SystemTime};
|
||||
use tracing::{error, info, trace};
|
||||
|
||||
use crate::{
|
||||
widgets::global_state::GlobalState,
|
||||
data::{
|
||||
structures::{PolicyCode, PolicyDataList, PolicyList},
|
||||
constants::*,
|
||||
},
|
||||
services::imports::allianzdirectcall::import,
|
||||
//services::imports::allianzdirectcall::import,
|
||||
services::imports::allianzdirectcall,
|
||||
widgets::global_state::GlobalState,
|
||||
//widgets::menu::menu_view::MenuView,
|
||||
//widgets::policycheck::policycheck_view::PolicycheckView,
|
||||
//widgets::ticketdata::ticketdata_state::TicketdataAction,
|
||||
};
|
||||
|
||||
/// Actions that can execute on the task view.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
/// Enumeration of valid `action variants` that need to be handled as
|
||||
/// state changes for the `PolicycheckView` widget.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum PolicycheckAction {
|
||||
ClearEntry(Entity),
|
||||
ChangeTheme(),
|
||||
SendPolicynumber(),
|
||||
InputTextChanged(Entity),
|
||||
ImportData,
|
||||
OpenMenu(Entity),
|
||||
ParseEntry(Entity),
|
||||
AddProgress(f64),
|
||||
NewTicket,
|
||||
ParsePolicyNumber(Entity),
|
||||
RemoveFocus(Entity),
|
||||
RemovePopup(Entity),
|
||||
ResetProgress,
|
||||
SetMenu(Entity),
|
||||
GetProgress,
|
||||
SetProgress(f64),
|
||||
SetProgressPopup(Entity),
|
||||
RemoveFocus(Entity),
|
||||
RemoveMenu(Entity),
|
||||
RemovePopup(Entity),
|
||||
SetToggleTheme(Entity),
|
||||
SetEntry(Entity),
|
||||
SetVisibility(Entity),
|
||||
TextChanged(Entity, usize),
|
||||
ToggleTheme(Entity)
|
||||
UpdatePolicyCode,
|
||||
UpdateProgress(f64)
|
||||
}
|
||||
|
||||
/// define valid environment variables provided via .env files
|
||||
/// located in the current call directory
|
||||
/// this is primarily used in testing scenarios (eg. debugging)
|
||||
/// Define valid environment variables provided via .env files
|
||||
/// located in the current call directory.
|
||||
/// This is primarily used in testing scenarios (eg. debugging).
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Environment {
|
||||
test_lang: String,
|
||||
rust_log: String,
|
||||
}
|
||||
|
||||
/// Handles the requests from `PolicycheckView`.
|
||||
/// Valid `structures` that are handled inside the state of the `Policycheck` widget.
|
||||
#[derive(AsAny, Default)]
|
||||
pub struct PolicycheckState {
|
||||
action: Option<PolicycheckAction>,
|
||||
actions: Vec<PolicycheckAction>,
|
||||
button_menu: Entity,
|
||||
duration: Duration,
|
||||
label_result: Entity,
|
||||
lang: String,
|
||||
//last_focused: Option<Entity>,
|
||||
button_menu: Entity,
|
||||
policy_data_count: u64,
|
||||
//policy_number: Entity,
|
||||
policy_numbers: HashMap<u64, PolicyCode>,
|
||||
popup_menu: Entity,
|
||||
progress_bar: Entity,
|
||||
progress_count: f64,
|
||||
progress_popup: Entity
|
||||
progress_popup: Entity,
|
||||
// target that recieves messages
|
||||
target: Entity,
|
||||
ticketdata: Entity
|
||||
}
|
||||
|
||||
impl GlobalState for PolicycheckState {}
|
||||
|
||||
/// method definitions, that react on any given state change inside the view
|
||||
/// Method definitions, that react on any given state change inside the `Policycheck` widget.
|
||||
impl PolicycheckState {
|
||||
/// Sets a new action.
|
||||
pub fn action(&mut self, action: PolicycheckAction) {
|
||||
self.action = action.into();
|
||||
}
|
||||
|
||||
/// Create a hashmap (key: policy number, value: policy type).
|
||||
pub fn create_hashmap(&mut self, _ctx: &mut Context<'_>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
pub fn create_hashmap(&mut self, _ctx: &mut Context<'_>)
|
||||
-> Result<(), Box<dyn std::error::Error>> {
|
||||
trace!(target: "advotracker", create_hashmap = "started");
|
||||
|
||||
let policy_list = PolicyList::new("policy list");
|
||||
@@ -91,7 +102,7 @@ impl PolicycheckState {
|
||||
// Wip: use cli parameter stored in viperus ...
|
||||
//let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
||||
let mut csv_import_path = String::from("POLLFNR_WOECHENTLICH.txt");
|
||||
match import(&mut csv_import_path, &mut policy_data,
|
||||
match allianzdirectcall::import(&mut csv_import_path, &mut policy_data,
|
||||
&mut policy_numbers, &mut self.policy_data_count,
|
||||
&self.lang) {
|
||||
Ok((count, duration)) => {
|
||||
@@ -124,21 +135,19 @@ impl PolicycheckState {
|
||||
-> Result<(), Box<dyn std::error::Error>> {
|
||||
// WIP: for now, only import once per session
|
||||
if self.policy_data_count == 0 {
|
||||
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), true);
|
||||
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), true);
|
||||
|
||||
if self.policy_numbers.len() == 0 {
|
||||
if self.policy_numbers.is_empty() {
|
||||
// initialize popup widget
|
||||
//let sender = ctx.send_window_request();
|
||||
self.set_popup_progress(ctx);
|
||||
self.progress_count += 0.33;
|
||||
self.update_progress_bar(ctx);
|
||||
//sender.send(WindowRequest::Redraw).unwrap();
|
||||
|
||||
// for _ in 1..4 {
|
||||
// self.progress_count += 0.33;
|
||||
// self.update_progress_bar(ctx);
|
||||
// sender.send(WindowRequest::Redraw).unwrap();
|
||||
//}
|
||||
for _ in 1..4 {
|
||||
self.progress_count += 0.33;
|
||||
self.update_progress_bar(ctx);
|
||||
ctx.send_message(PolicycheckAction::UpdateProgress(self.progress_count), self.progress_popup);
|
||||
}
|
||||
|
||||
// importing policy code elements from csv-file
|
||||
match self.create_hashmap(ctx) {
|
||||
@@ -152,7 +161,6 @@ impl PolicycheckState {
|
||||
self.progress_count = 1.;
|
||||
self.update_progress_bar(ctx);
|
||||
|
||||
//sender.send(WindowRequest::Redraw).unwrap();
|
||||
}
|
||||
_ => {
|
||||
let res = t!("policy.hashmap.failed", self.lang);
|
||||
@@ -170,19 +178,20 @@ impl PolicycheckState {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Open menu.
|
||||
pub fn open_menu(&mut self, _entity: Entity, ctx: &mut Context<'_>) {
|
||||
//let menu_string = ctx.get_widget(entity).get::<String16>("text");
|
||||
//.child(policycheck_menu);
|
||||
self.set_popup_menu(ctx);
|
||||
/// 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.
|
||||
fn parse_entry(&mut self, policy_check_policy_number: Entity,
|
||||
pub fn parse_entry(&mut self, policy_check_policy_number: Entity,
|
||||
ctx: &mut Context<'_>) {
|
||||
trace!(target: "advotracker", parse_entry = "started");
|
||||
|
||||
let policy_number_string = TextBox::text_clone(&mut ctx.get_widget(policy_check_policy_number));
|
||||
let policy_number_string = TextBox::text_clone(&ctx.get_widget(policy_check_policy_number));
|
||||
let policy_number_length = policy_number_string.len();
|
||||
|
||||
if self.policy_data_count == 0 {
|
||||
@@ -204,20 +213,13 @@ impl PolicycheckState {
|
||||
// Parse policy code: "AS-123456789"
|
||||
// DION VERS POLLFNR
|
||||
// 1 AS 1515735810
|
||||
//Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
//Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), Visibility::Collapsed);
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
||||
Button::background_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("transparent"));
|
||||
//Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Collapsed);
|
||||
|
||||
if policy_number_length == 10 {
|
||||
// cast policy_number_sting to <u64>
|
||||
match policy_number_string.parse::<u64>() {
|
||||
Ok(p) => {
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from(""));
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), String::from(""));
|
||||
|
||||
// match hashmap's key
|
||||
match self.policy_numbers.get(&p) {
|
||||
@@ -228,7 +230,7 @@ impl PolicycheckState {
|
||||
|
||||
let string_result = format!("1-{:?}-{}",
|
||||
policy_code, p);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from(string_result));
|
||||
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"));
|
||||
|
||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
|
||||
@@ -236,8 +238,10 @@ impl PolicycheckState {
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CHECK);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Visible);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
|
||||
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_HINT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
||||
}
|
||||
_ => {
|
||||
// no matching key
|
||||
@@ -252,8 +256,10 @@ impl PolicycheckState {
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
|
||||
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_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -262,17 +268,17 @@ impl PolicycheckState {
|
||||
|
||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
||||
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("Only numbers are valid"));
|
||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||
|
||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
|
||||
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_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,8 +297,10 @@ impl PolicycheckState {
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
|
||||
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_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
}
|
||||
if policy_number_length > 10 {
|
||||
let res = t!("policy.validation.failed", self.lang);
|
||||
@@ -309,17 +317,18 @@ impl PolicycheckState {
|
||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
|
||||
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_HINT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||
}
|
||||
|
||||
trace!(target: "advotracker", parse_entry = "finished");
|
||||
}
|
||||
|
||||
/// Remove the menu popup box
|
||||
fn remove_menu(&mut self, id: Entity, ctx: &mut Context<'_>) {
|
||||
ctx.remove_child(self.popup_menu);
|
||||
println!("Popup {:?} removed !", id);
|
||||
/// parse message 'ParseEntry'
|
||||
pub fn parse_policy_number(&mut self, entity: Entity) {
|
||||
self.actions.push(PolicycheckAction::ParsePolicyNumber(entity));
|
||||
}
|
||||
|
||||
/// Remove the popup box
|
||||
@@ -341,53 +350,47 @@ impl PolicycheckState {
|
||||
// ctx.get_widget(self.policy_check_policy_number).update_theme_by_state(true);
|
||||
// }
|
||||
|
||||
/// Sending message 'UpdatePolicyCode'
|
||||
pub fn send_message_update_policy_code(&mut self, entity: Entity) {
|
||||
println!("WIP: send_message_update_policy_code = {:?}", entity);
|
||||
//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.
|
||||
fn set_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) {
|
||||
if ctx.get_widget(text_box).get::<String16>("text").is_empty() {
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
||||
} else {
|
||||
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_POLICY_CODE), Visibility::Visible);
|
||||
}
|
||||
}
|
||||
|
||||
/// Set a menu
|
||||
fn set_popup_menu(&mut self, ctx: &mut Context<'_>) {
|
||||
let stack = ctx
|
||||
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
|
||||
.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 popup menu overlay
|
||||
self.popup_menu = create_menu(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.popup_menu);
|
||||
|
||||
println!("Popup Menu created: {:?}", self.popup_menu);
|
||||
}
|
||||
|
||||
/// Set a progress popup that updates the import status in a progress bar
|
||||
fn set_popup_progress(&mut self, ctx: &mut Context<'_>) {
|
||||
//println!("Set up Progress popup: {:?}", text_box);
|
||||
// create a stack as a child of entity "ID_POLICY_CHECK_POLICY_NUMBER"
|
||||
let stack = ctx
|
||||
.entity_of_child(ID_POLICY_CHECK_RESULT)
|
||||
.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_RESULT'.");
|
||||
.entity_of_child(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_POLICY_NUMBER'.");
|
||||
let current_entity = ctx.entity();
|
||||
let build_context = &mut ctx.build_context();
|
||||
|
||||
// create the progress_popup widget
|
||||
self.progress_popup = create_popup_progress(current_entity, build_context);
|
||||
info!("set_popup_progress: New entity 'popup_progress' {:?} created", self.progress_popup);
|
||||
|
||||
// create a progress_popup widget as a child of entity "ID_POLICY_CHECK_POLICY_NUMBER"
|
||||
// append the stack inside the progress_popup
|
||||
build_context.append_child(stack, self.progress_popup);
|
||||
|
||||
// make sure we have a progress bar
|
||||
self.progress_bar = ctx
|
||||
.entity_of_child(ID_POLICY_CHECK_PROGRESS_BAR)
|
||||
.expect("PolicycheckState.init: Can't find entity of resource 'ID_POLICY_CHECK_PROGRESS_BAR'.");
|
||||
|
||||
println!("PopupProgress created: {:?}", self.progress_popup);
|
||||
info!("set_popup_progress: New entity 'progress_bar' created: {:?}", self.progress_bar);
|
||||
}
|
||||
|
||||
/// Change visibility of the result label.
|
||||
@@ -399,8 +402,6 @@ impl PolicycheckState {
|
||||
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);
|
||||
}
|
||||
|
||||
//ctx.get_widget(self.label_result).update_theme_by_state(true);
|
||||
}
|
||||
|
||||
/// Update count of elements in the policy data list.
|
||||
@@ -413,39 +414,55 @@ impl PolicycheckState {
|
||||
let res = t!("policy.string.progress_time", self.lang);
|
||||
let string_duration = format!("{}: {:?}", res, self.duration);
|
||||
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_TIME), String::from(string_duration));
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_TIME), string_duration);
|
||||
|
||||
let mut progress_bar = ctx.child(ID_POLICY_CHECK_PROGRESS_BAR);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// upported states for our view
|
||||
/// Supported methods handled inside the `PolicycheckState`
|
||||
impl State for PolicycheckState {
|
||||
/// Initialize the widget state
|
||||
/// Initialize the state of widgets inside `PolicycheckState`
|
||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
let time_start= SystemTime::now();
|
||||
|
||||
trace!(target: "advotracker", policycheck_state = "init", status = "started");
|
||||
|
||||
// Entities
|
||||
// Get language from environment
|
||||
self.lang = PolicycheckState::get_lang();
|
||||
|
||||
// Initialize required entities
|
||||
self.button_menu = ctx
|
||||
.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
|
||||
.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);
|
||||
//Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_0), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
|
||||
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_HINT), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), 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.
|
||||
// // The cargo package identifier (default: 'nwx.advotracker') is used as the
|
||||
@@ -465,7 +482,39 @@ impl State for PolicycheckState {
|
||||
trace!(target: "advotracker", policycheck_state = "init", status = "finished", duration = ?duration);
|
||||
}
|
||||
|
||||
/// Update the widget state.
|
||||
/// Handle messages for `PolicycheckState`.
|
||||
fn messages(
|
||||
&mut self,
|
||||
mut messages: MessageReader,
|
||||
_registry: &mut Registry,
|
||||
ctx: &mut Context<'_>,
|
||||
) {
|
||||
for message in messages.read::<PolicycheckAction>() {
|
||||
match message {
|
||||
PolicycheckAction::UpdateProgress(increment) => {
|
||||
let old_width = ProgressBar::val_clone(&ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
|
||||
|
||||
let new_width = old_width + increment;
|
||||
// Set the ProgressBar's val property to the calculated percentage
|
||||
// (whereas 0.0 means 0%, and 1.0 means 100%)
|
||||
if new_width <= 1. {
|
||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), new_width);
|
||||
} else {
|
||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 1.);
|
||||
}
|
||||
}
|
||||
PolicycheckAction::UpdatePolicyCode => {
|
||||
self.update_policy_code(ctx);
|
||||
}
|
||||
PolicycheckAction::NewTicket => {
|
||||
self.new_ticket(ctx);
|
||||
}
|
||||
_ => { println!("PolicycheckAction: action not implemented!"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Update the state of widgets inside the `Policycheck` view.
|
||||
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
|
||||
// // clear focus on focus moved
|
||||
// if self.last_focused != ctx.window().get::<Global>("global").focused_widget {
|
||||
@@ -477,23 +526,11 @@ impl State for PolicycheckState {
|
||||
// }
|
||||
//}
|
||||
|
||||
if let Some(action) = self.action {
|
||||
match action {
|
||||
PolicycheckAction::AddProgress(increment) => {
|
||||
let old_width = ProgressBar::val_clone(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
|
||||
// Create `actions`, a drained iterator (".." => full range that clears the vector)
|
||||
let actions: Vec<PolicycheckAction> = self.actions.drain(..).collect();
|
||||
|
||||
let new_width = old_width + increment;
|
||||
// Set the ProgressBar's val property to the calculated percentage
|
||||
// (whereas 0.0 means 0 %, and 1.0 means 100 %) to increment the progress
|
||||
if new_width <= 1. {
|
||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), new_width);
|
||||
} else {
|
||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 1.);
|
||||
}
|
||||
}
|
||||
PolicycheckAction::ChangeTheme() => {
|
||||
println!("Changing active theme.");
|
||||
}
|
||||
for action in actions {
|
||||
match action {
|
||||
PolicycheckAction::ClearEntry(policy_check_policy_number) => {
|
||||
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
||||
}
|
||||
@@ -511,19 +548,16 @@ impl State for PolicycheckState {
|
||||
}
|
||||
}
|
||||
}
|
||||
PolicycheckAction::OpenMenu(entity) => {
|
||||
self.open_menu(entity, ctx);
|
||||
PolicycheckAction::NewTicket => {
|
||||
self.new_ticket(ctx);
|
||||
}
|
||||
PolicycheckAction::ParseEntry(text_box) => {
|
||||
PolicycheckAction::ParsePolicyNumber(text_box) => {
|
||||
self.parse_entry(text_box, ctx);
|
||||
}
|
||||
PolicycheckAction::RemoveFocus(policy_check_policy_number) => {
|
||||
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
||||
//ctx.EventAdapter(FocusEvent::RemoveFocus(policy_check_policy_number));
|
||||
}
|
||||
PolicycheckAction::RemoveMenu(entity) => {
|
||||
self.remove_menu(entity, ctx);
|
||||
}
|
||||
PolicycheckAction::RemovePopup(entity) => {
|
||||
self.remove_popup(entity, ctx);
|
||||
}
|
||||
@@ -534,9 +568,6 @@ impl State for PolicycheckState {
|
||||
//self.last_focused = Some();
|
||||
self.set_entry(policy_check_policy_number, ctx);
|
||||
}
|
||||
PolicycheckAction::SetMenu(_entity) => {
|
||||
self.set_popup_menu(ctx);
|
||||
}
|
||||
PolicycheckAction::SetProgress(value) => {
|
||||
if value >= 0. || value <= 1. {
|
||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), value);
|
||||
@@ -552,128 +583,52 @@ impl State for PolicycheckState {
|
||||
PolicycheckAction::TextChanged(entity, _index) => {
|
||||
self.set_entry(entity, ctx);
|
||||
}
|
||||
PolicycheckAction::ToggleTheme(_entity) => {
|
||||
println!("TODO: toggle active theme");
|
||||
//self.toggle_theme(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.
|
||||
// fn update_post_layout(&mut self, _: &mut Registry, _ctx: &mut Context<'_>) {
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/// Create a menu popup
|
||||
fn create_menu(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
Popup::new()
|
||||
.id(ID_POLICY_CHECK_POPUP_MENU)
|
||||
.style("container_menu")
|
||||
.target(target)
|
||||
.open(true)
|
||||
.width(280)
|
||||
.height(140)
|
||||
.on_mouse_down(move |ctx, _| {
|
||||
println!("on_click -> remove_menu()");
|
||||
ctx.get_mut::<PolicycheckState>(target)
|
||||
.action(PolicycheckAction::RemoveMenu(target));
|
||||
true
|
||||
})
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_POLICY_CHECK_MENU)
|
||||
.columns(
|
||||
Columns::create()
|
||||
// Menu Button
|
||||
.push("80")
|
||||
// Seperator
|
||||
.push("1")
|
||||
// Keyboard Shortcut
|
||||
.push("*")
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
.build(),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.id(ID_POLICY_CHECK_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_POLICY_CHECK_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 |states, _| {
|
||||
states.get_mut::<PolicycheckState>(target)
|
||||
.action(PolicycheckAction::ToggleTheme(target));
|
||||
true
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.id(ID_POLICY_CHECK_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_POLICY_CHECK_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 progress popup with update status of an onging data import
|
||||
fn create_popup_progress(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
fn create_popup_progress(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
Popup::new()
|
||||
.id(ID_POLICY_CHECK_POPUP_PROGRESS)
|
||||
.target(target)
|
||||
.target(id.0)
|
||||
.open(true)
|
||||
//.style("popup_progress")
|
||||
.style("popup_progress")
|
||||
.width(280)
|
||||
.height(100)
|
||||
.on_mouse_down(move |ctx, _| {
|
||||
println!("on_click -> remove_popup_progress()");
|
||||
ctx.get_mut::<PolicycheckState>(target)
|
||||
.action(PolicycheckAction::RemovePopup(target));
|
||||
.visibility(Visibility::Visible)
|
||||
.on_click(move |_ctx, _| {
|
||||
println!("create_popup_progress: on_click -> remove_popup(popup_progress)");
|
||||
//ctx.get_mut::<PolicycheckState>(id)
|
||||
// .set_action(PolicycheckAction::RemovePopup(id));
|
||||
true
|
||||
})
|
||||
.child(
|
||||
@@ -685,14 +640,14 @@ fn create_popup_progress(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_PROGRESS_TEXT)
|
||||
//.style("textblock_progress")
|
||||
.font_size(12)
|
||||
.style("textblock_progress")
|
||||
.text("Importing data")
|
||||
.build(ctx)
|
||||
)
|
||||
.child(
|
||||
ProgressBar::new()
|
||||
.id(ID_POLICY_CHECK_PROGRESS_BAR)
|
||||
.style("progress_bar")
|
||||
.val(0)
|
||||
//.width(250)
|
||||
.build(ctx)
|
||||
@@ -700,9 +655,8 @@ fn create_popup_progress(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_PROGRESS_TIME)
|
||||
//.style("textblock_progress")
|
||||
.style("textblock_progress")
|
||||
.h_align("end")
|
||||
.font_size(12)
|
||||
.text("Processing time")
|
||||
.build(ctx)
|
||||
)
|
||||
|
||||
@@ -6,24 +6,33 @@
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
use orbtk::shell::event::Key;
|
||||
|
||||
use crate::{
|
||||
data::{
|
||||
constants::*,
|
||||
structures::PolicyCheck,
|
||||
},
|
||||
widgets::policycheck::policycheck_state::*,
|
||||
//widgets::menu::menu_state::{MenuAction, MenuState},
|
||||
widgets::policycheck::policycheck_state::{PolicycheckAction, PolicycheckState},
|
||||
};
|
||||
|
||||
// Macro that initializes the widget structures/variables for our view
|
||||
// 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> {
|
||||
// holds the language code
|
||||
lang: String,
|
||||
// provides a struct with `PolicyCheck` members
|
||||
policy_check: PolicyCheck,
|
||||
// holds number of imported data
|
||||
policy_data_count: u32,
|
||||
// holds the title string
|
||||
policy_check_title: String,
|
||||
policy_data_count: u32
|
||||
// widget entity that will receive the message
|
||||
target: u32
|
||||
}
|
||||
);
|
||||
|
||||
@@ -32,28 +41,26 @@ widget!(
|
||||
impl Template for PolicycheckView {
|
||||
//fn template(self, policycheck_view: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
let tenent_logo = Container::new()
|
||||
.margin((16, 16, 0, 0))
|
||||
.attach(Grid::column(0))
|
||||
.v_align("center")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
.image("assets/advotracker/hiedemann_logo.png")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_bottom_bar = Container::new()
|
||||
.id(ID_POLICY_CHECK_BOTTOM_BAR)
|
||||
//.style(STYLE_BOTTOM_BAR)
|
||||
.padding(14)
|
||||
.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))
|
||||
@@ -69,14 +76,6 @@ impl Template for PolicycheckView {
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_label_menu = TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_LABEL_MENU)
|
||||
.style("menu")
|
||||
.text("Help Menu")
|
||||
.v_align("center")
|
||||
.h_align("center")
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_button_menu = Button::new()
|
||||
.id(ID_POLICY_CHECK_BUTTON_MENU)
|
||||
.style("button_single_content")
|
||||
@@ -84,10 +83,10 @@ impl Template for PolicycheckView {
|
||||
.attach(Grid::column(2))
|
||||
//.min_size(16, 16)
|
||||
.h_align("end")
|
||||
.on_click(move |ctx, _| {
|
||||
//ctx.get_mut::<PolicycheckState>(policycheck_state)
|
||||
ctx.get_mut::<PolicycheckState>(id)
|
||||
.action(PolicycheckAction::OpenMenu(policy_check_label_menu));
|
||||
.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);
|
||||
@@ -95,233 +94,181 @@ impl Template for PolicycheckView {
|
||||
let policy_check_button_result = Button::new()
|
||||
.id(ID_POLICY_CHECK_BUTTON_RESULT)
|
||||
.style("button_single_content")
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(3))
|
||||
.h_align("start")
|
||||
.v_align("center")
|
||||
.visibility(Visibility::Collapsed)
|
||||
.enabled(false)
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_header_text = TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_HEADER)
|
||||
.attach(Grid::column(0))
|
||||
.style(STYLE_HEADER_TEXT)
|
||||
.text("Validation policy number")
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_header_bar = Container::new()
|
||||
.style(STYLE_HEADER_BAR)
|
||||
.id(ID_POLICY_CHECK_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),
|
||||
)
|
||||
.attach(Grid::column_span(3))
|
||||
.style(STYLE_HEADER_BAR)
|
||||
.child(tenent_logo)
|
||||
.child(policy_check_header_text)
|
||||
.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)
|
||||
println!("ParseEntry: {:?}", entity);
|
||||
ctx.get_mut::<PolicycheckState>(id)
|
||||
.action(PolicycheckAction::ParseEntry(entity));
|
||||
})
|
||||
//.on_changed(|_, entity, _, _| println!("Selection changed: {:?}", entity))
|
||||
// .on_changed(move |ctx, entity, _| {
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .action(Action::SetProgressBox(entity));
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .action(Action::AddProgress(0.5));
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .action(Action::InputTextChanged(entity));
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .action(Action::SetVisibility(entity));
|
||||
// ctx.get_widget(policy_check_label_policy_number).set("visible");
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .action(Action::SetVisility(entity));
|
||||
// })
|
||||
// .on_mouse_down | .on_mouse_move | .on_mouse_up (move |ctx, entity| {
|
||||
// state(id, states).action(Action::AddItem);
|
||||
// })
|
||||
//.on_key_down(move |ctx, _| {
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .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)
|
||||
let policy_check_policy_code = TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_POLICY_CODE)
|
||||
.style("body")
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(5))
|
||||
.orientation("horizontal")
|
||||
.v_align("center")
|
||||
.attach(Grid::column(2))
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_form_action = Container::new()
|
||||
.id(ID_POLICY_CHECK_ACTION_GRID)
|
||||
.attach(Grid::row(3))
|
||||
.attach(Grid::column(1))
|
||||
//.style(STYLE_CONTAINER_ACTION)
|
||||
.padding(14)
|
||||
.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:")
|
||||
Stack::new()
|
||||
//.style(STYLE_STACK_ACTION)
|
||||
.orientation("horizontal")
|
||||
.spacing(50)
|
||||
.child(
|
||||
Button::new()
|
||||
.id(ID_POLICY_CHECK_ACTION_BUTTON_CREATE)
|
||||
.style(STYLE_BUTTON_ACTION)
|
||||
.text("Create ticket")
|
||||
.on_click(move |states, _entity| {
|
||||
//states.get_mut::<PolicycheckState>(id).send_message_update_policynumber(id);
|
||||
//states.send_message(PolicycheckAction::UpdatePolicyCode, policy_check_policy_code);
|
||||
states.send_message(PolicycheckAction::UpdatePolicyCode, id);
|
||||
states.send_message(PolicycheckAction::NewTicket, id);
|
||||
false
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.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)
|
||||
.name(ID_POLICY_CHECK_FORM)
|
||||
.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(),
|
||||
.push("auto") // Label
|
||||
.push("16") // Delimiter
|
||||
.push("200") // Data
|
||||
.push("16") // Delimiter
|
||||
.push("32") // Result-Button
|
||||
.push("4") // Delimeter
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
.push("*")
|
||||
//.build(),
|
||||
.push("auto") // Row 0
|
||||
.push("14") // Seperator
|
||||
.push("auto") // Row 2
|
||||
.push("14") // Seperator
|
||||
.push("auto") // Row 3
|
||||
)
|
||||
|
||||
//.child(policy_check_form_row_0)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_LABEL_POLICY_NUMBER)
|
||||
.style("body")
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(0))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.text("Policy number")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
//.style("body")
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(2))
|
||||
//.lose_focus_on_activation(false)
|
||||
//WIP: localization for water_mark
|
||||
.water_mark("10-stellig")
|
||||
.on_activate(move |states, entity| {
|
||||
// Entity is entered/activated via Mouse/Keyboard
|
||||
states.get_mut::<PolicycheckState>(id).parse_policy_number(entity);
|
||||
})
|
||||
.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)
|
||||
|
||||
//.child(policy_check_form_row_2)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_LABEL_RESULT)
|
||||
.style("body")
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.text("Policy code")
|
||||
.build(ctx),
|
||||
)
|
||||
// .child(
|
||||
// TextBlock::new()
|
||||
// .id(ID_POLICY_CHECK_RESULT)
|
||||
// .style("body")
|
||||
// .attach(Grid::row(2))
|
||||
// .attach(Grid::column(2))
|
||||
// .build(ctx)
|
||||
//)
|
||||
.child(policy_check_policy_code)
|
||||
//.child(policy_check_form_row_2)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_LABEL_HINT)
|
||||
.style("hint")
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(0))
|
||||
//.margin((0, 0, 16, 0))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.text("Error:")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_HINT)
|
||||
.style("hint")
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(2))
|
||||
.build(ctx),
|
||||
)
|
||||
.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 ... 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)
|
||||
// .action(Action::ParseEntry(entity));
|
||||
// })
|
||||
// .on_changed(move |ctx, entity| {
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .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))
|
||||
@@ -330,7 +277,6 @@ impl Template for PolicycheckView {
|
||||
.v_align("top")
|
||||
.orientation("horizontal")
|
||||
.visibility(Visibility::Collapsed)
|
||||
//.spacing("4")
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_DATA_LABEL)
|
||||
@@ -358,40 +304,25 @@ impl Template for PolicycheckView {
|
||||
.id(ID_POLICY_CHECK_WIDGET)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(50)
|
||||
.push("*")
|
||||
.push(50)
|
||||
//.build(),
|
||||
.push(50) // Left margin
|
||||
.push("*") // Content
|
||||
.push(50) // Right margin
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto")
|
||||
.push(28)
|
||||
.push("*")
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
//.build(),
|
||||
.push("auto") // Header_Bar
|
||||
.push(28) // Seperator
|
||||
.push("*") // InputForm
|
||||
.push("auto") // Data_Result
|
||||
.push("auto") // Bottom_Bar
|
||||
)
|
||||
|
||||
// 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)
|
||||
.child(policy_check_header_bar) // row 0
|
||||
.child(policy_check_form) // row 2
|
||||
.child(policy_data_stack) // row 3
|
||||
.child(policy_check_form_action) // row 4
|
||||
.child(policy_check_bottom_bar) // row 5
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// helper to request PolicycheckState
|
||||
//fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut PolicycheckState {
|
||||
// states.get_mut(id)
|
||||
//}
|
||||
|
||||
12
advotracker/src/widgets/ticketdata/mod.rs
Normal file
12
advotracker/src/widgets/ticketdata/mod.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
/// The ticket data state
|
||||
pub mod ticketdata_state;
|
||||
|
||||
/// The tckicket data view
|
||||
pub mod ticketdata_view;
|
||||
223
advotracker/src/widgets/ticketdata/ticketdata_state.rs
Normal file
223
advotracker/src/widgets/ticketdata/ticketdata_state.rs
Normal file
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
//use locales::t;
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use serde::Deserialize;
|
||||
//use std::process;
|
||||
//use std::collections::HashMap;
|
||||
use std::time::SystemTime;
|
||||
use tracing::{info, trace};
|
||||
|
||||
use crate::{
|
||||
data::{constants::*, structures::Email},
|
||||
widgets::global_state::GlobalState,
|
||||
services::exports::send_ticketdata::sendticketdata,
|
||||
widgets::ticketdata::ticketdata_view::TicketdataView,
|
||||
widgets::policycheck::policycheck_state::PolicycheckAction,
|
||||
};
|
||||
|
||||
/// Valid `actions` that are handled as state changes in the `Ticketdata` widget.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum TicketdataAction {
|
||||
ClearEntry(Entity),
|
||||
/// Clear text in the form
|
||||
ClearForm(),
|
||||
ChangeTheme(),
|
||||
//ChangeMailCc(),
|
||||
//ChangeMailTo(),
|
||||
InputTextChanged(Entity),
|
||||
ParseEntry(Entity),
|
||||
RemoveFocus(Entity),
|
||||
SendForm(),
|
||||
SetToggleTheme(Entity),
|
||||
SetEntry(Entity),
|
||||
SetVisibility(Entity),
|
||||
TextChanged(Entity, usize),
|
||||
UpdatePolicyCode(String)
|
||||
}
|
||||
|
||||
/// Define valid environment variables provided via .env files
|
||||
/// located in the current call directory.
|
||||
/// This is primarily used in testing scenarios (eg. debugging).
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Environment {
|
||||
test_lang: String,
|
||||
rust_log: String,
|
||||
}
|
||||
|
||||
/// Valid `structures` that are handled inside the state of the `Ticket` widget.
|
||||
#[derive(AsAny, Default)]
|
||||
pub struct TicketdataState {
|
||||
actions: Vec<TicketdataAction>,
|
||||
button_menu: Entity,
|
||||
// ComboBox item of mail_cc has been changed
|
||||
//pub change_mail_cc: bool,
|
||||
//ComboBox item of mail_to has been changed
|
||||
//pub change_mail_to: bool,
|
||||
//duration: Duration,
|
||||
lang: String,
|
||||
target: Entity
|
||||
}
|
||||
|
||||
impl GlobalState for TicketdataState {}
|
||||
|
||||
/// Method definitions, that react on any given state change inside the `Ticketdata` widget.
|
||||
impl TicketdataState {
|
||||
/// Clear the text property of all children of the given form entity
|
||||
pub fn clear_form(entity: Entity, ctx: &mut Context<'_>) {
|
||||
if let Some(count) = ctx.get_widget(entity).children_count() {
|
||||
info!("Widget name: {:?}", ctx.get_widget(entity).get::<String>("name"));
|
||||
info!("Widget id: {:?}", ctx.get_widget(entity).get::<String>("id"));
|
||||
}
|
||||
|
||||
// form is identified by its id
|
||||
if let form_entity = ctx.child(ID_TICKET_DATA_GRID).entity() {
|
||||
info!("Form id: {:?}", ctx.get_widget(form_entity).get::<String>("id"));
|
||||
info!("Form node name: {:?}", ctx.get_widget(form_entity).get::<String>("name"));
|
||||
|
||||
// Loop through children
|
||||
if let Some(count) = ctx.get_widget(form_entity).children_count() {
|
||||
for c in 1..=count {
|
||||
info!("WIP clear entry of child {:?}", c);
|
||||
//info!("WIP clear entry of child {:?}: {:?}", c, ctx.get_child(form_entity).get::<String>("name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pub fn change_mail_cc(&mut self) {
|
||||
// self.actions.push(TicketdataAction::ChangeMailCc());
|
||||
// }
|
||||
|
||||
// pub fn change_mail_to(&mut self) {
|
||||
// self.actions.push(TicketdataAction::ChangeMailTo());
|
||||
// }
|
||||
|
||||
pub fn send_form(entity: Entity, ctx: &mut Context<'_>, lang: &str) {
|
||||
|
||||
// type conversion (String -> u64)
|
||||
//let policy_code = ctx.child(ID_TICKET_DATA_POLICY_CODE).get::<String>("text").unwrap().parse::<u64>().unwrap();
|
||||
|
||||
// WIP: get selected items ComboBox'es
|
||||
//let mail_cc_index = *TicketdataView::selected_index_ref(&ctx.widget()) as usize;
|
||||
//let mail_cc_selected = TicketdataView::items_mail_cc_ref(&ctx.widget(id))[mail_cc_index].clone();
|
||||
|
||||
// create Email structures
|
||||
let email = Email {
|
||||
// WIP: mail_to -> selected index auslesen
|
||||
//mail_to: ctx.child(ID_TICKET_DATA_MAIL_TO).get::<String>("text").to_string(),
|
||||
// WIP: mail_cc -> selected index auslesen
|
||||
//mail_cc: ctx.child(ID_TICKET_DATA_MAIL_CC).get::<String>("text").to_string(),
|
||||
|
||||
mail_to: PROP_MAIL_TO_1.to_string(),
|
||||
mail_cc: PROP_MAIL_CC_1.to_string(),
|
||||
mail_bcc: PROP_MAIL_BCC_1.to_string(),
|
||||
mail_from: PROP_MAIL_FROM.to_string(),
|
||||
mail_reply: PROP_MAIL_REPLY.to_string(),
|
||||
subject: PROP_MAIL_SUBJECT.to_string(),
|
||||
policy_code: ctx.child(ID_TICKET_DATA_POLICY_CODE).get::<String>("text").to_string(),
|
||||
policy_holder: ctx.child(ID_TICKET_DATA_POLICY_HOLDER).get::<String>("text").to_string(),
|
||||
deductible: ctx.child(ID_TICKET_DATA_DEDUCTIBLE).get::<String>("text").to_string(),
|
||||
callback_number: ctx.child(ID_TICKET_DATA_CALLBACK_NUMBER).get::<String>("text").to_string(),
|
||||
callback_date: ctx.child(ID_TICKET_DATA_CALLBACK_DATE).get::<String>("text").to_string(),
|
||||
harm_type: ctx.child(ID_TICKET_DATA_HARM_TYPE).get::<String>("text").to_string(),
|
||||
ivr_comment: ctx.child(ID_TICKET_DATA_IVR_COMMENT).get::<String>("text").to_string(),
|
||||
};
|
||||
|
||||
info!("WIP: Sending form to construct eMail to {:?}", email);
|
||||
// send email via service
|
||||
if let Err(_e) = sendticketdata(&email, &lang) {
|
||||
Button::icon_brush_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#FF0000"));
|
||||
Button::foreground_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#FF0000"));
|
||||
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_CLEAR);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Supported methods handled inside the `TicketState`
|
||||
impl State for TicketdataState {
|
||||
/// Initialize the state of widgets inside `TicketState`
|
||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
let time_start= SystemTime::now();
|
||||
|
||||
trace!(target: "advotracker", ticketdata_state = "init", status = "started");
|
||||
|
||||
// Initialize required menu button entity
|
||||
self.button_menu = ctx
|
||||
.entity_of_child(ID_TICKET_DATA_BUTTON_MENU)
|
||||
.expect("TicketState.init: Can't find resource entity 'ID_TICKET_DATA_BUTTON_MENU'.");
|
||||
|
||||
// initialize the entity object, that will receive messages
|
||||
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
||||
.expect("TicketState.init: Can't find resource entity 'target'."));
|
||||
|
||||
// Get language from environment
|
||||
self.lang = TicketdataState::get_lang();
|
||||
|
||||
let time_end = SystemTime::now();
|
||||
let duration = time_end.duration_since(time_start);
|
||||
|
||||
trace!(target: "advotracker", ticketdata_state = "init", status = "finished", duration = ?duration);
|
||||
}
|
||||
|
||||
/// The reader component of the message system handing `TicketdataState``
|
||||
fn messages(
|
||||
&mut self,
|
||||
mut messages: MessageReader,
|
||||
_registry: &mut Registry,
|
||||
ctx: &mut Context<'_>,
|
||||
) {
|
||||
for message in messages.read::<TicketdataAction>() {
|
||||
match message {
|
||||
TicketdataAction::ClearForm() => {
|
||||
info!("message: {:?} recieved", message);
|
||||
TicketdataState::clear_form(ctx.entity(), ctx);
|
||||
}
|
||||
TicketdataAction::SendForm() => {
|
||||
info!("message: {:?} recieved", message);
|
||||
TicketdataState::send_form(ctx.entity(), ctx, &self.lang);
|
||||
}
|
||||
_ => { println!("messages: action not implemented!"); }
|
||||
}
|
||||
}
|
||||
|
||||
for message in messages.read::<PolicycheckAction>() {
|
||||
match message {
|
||||
PolicycheckAction::UpdatePolicyCode => {
|
||||
info!("Message received: 'PolicycheckAction::UpdatePolicyCode'");
|
||||
//TextBlock::text_set(&mut ctx.child(ID_TICKET_DATA_POLICY_CODE), policy_code);
|
||||
}
|
||||
_ => { println!("messages: action not implemented!"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
|
||||
let actions: Vec<TicketdataAction> = self.actions.drain(..).collect();
|
||||
|
||||
for action in actions {
|
||||
match action {
|
||||
// TicketdataAction::ChangeMailCc() => {
|
||||
// let index = *TicketdataView::items_ref(&ctx.widget()) as usize;
|
||||
// let selected_index = TicketdataView::items_ref(&ctx.widget())[index].clone();
|
||||
// info!("new selection for mail index: {:?}", selected_index);
|
||||
// }
|
||||
TicketdataAction::ClearForm() => {
|
||||
info!("update: send_message {:?}", action);
|
||||
ctx.send_message(TicketdataAction::ClearForm(), self.target);
|
||||
}
|
||||
TicketdataAction::SendForm() => {
|
||||
//ctx.send_message(TicketdataAction::SendForm(), self.ID_TICKETDATA_FORM);
|
||||
info!("update: send_message {:?}", action);
|
||||
}
|
||||
_ => { println!("TicketdataAction: action not implemented!"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
446
advotracker/src/widgets/ticketdata/ticketdata_view.rs
Normal file
446
advotracker/src/widgets/ticketdata/ticketdata_view.rs
Normal file
@@ -0,0 +1,446 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::{
|
||||
data::constants::*,
|
||||
widgets::ticketdata::ticketdata_state::{TicketdataAction, TicketdataState},
|
||||
};
|
||||
|
||||
// Macro that initializes the widget structures/variables for the policy check view
|
||||
widget!(
|
||||
/// Form to enter data of a ticket record
|
||||
TicketdataView<TicketdataState> {
|
||||
// language used inside the widget
|
||||
lang: String,
|
||||
// title used in the header
|
||||
ticket_data_title: String,
|
||||
// entity id that will receive the messages
|
||||
target: u32
|
||||
}
|
||||
);
|
||||
|
||||
/// The template implementation of the ticket view
|
||||
/// All GUI elements are styled using the "style" attribute referencing to a ron based css
|
||||
impl Template for TicketdataView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||
let tenent_logo = Container::new()
|
||||
.margin((16, 16, 0, 0))
|
||||
.attach(Grid::column(0))
|
||||
.v_align("center")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
.image("assets/advotracker/hiedemann_logo.png")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let ticket_data_bottom_bar = Container::new()
|
||||
.id(ID_TICKET_DATA_BOTTOM_BAR)
|
||||
.style(STYLE_BOTTOM_BAR)
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(1))
|
||||
.attach(Grid::column_span(2))
|
||||
.v_align("end")
|
||||
.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 ticket_data_button_menu = Button::new()
|
||||
.id(ID_TICKET_DATA_BUTTON_MENU)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(2))
|
||||
.h_align("end")
|
||||
.icon(material_icons_font::MD_MENU)
|
||||
//.style("button_single_content")
|
||||
.style(STYLE_BUTTON_MENU)
|
||||
.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 ticket_data_form = Container::new()
|
||||
.id(ID_TICKET_DATA_FORM)
|
||||
.name(ID_TICKET_DATA_FORM)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(1))
|
||||
.style("container_form")
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_TICKET_DATA_GRID)
|
||||
.name(ID_TICKET_DATA_GRID)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push("auto") // Label
|
||||
.push(16) // Delimiter
|
||||
.push("*") // Data
|
||||
.push(32) // Delimiter (2x margin)
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Row 0
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 2
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 4
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 6
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 8
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 10
|
||||
.push(14) // Seperator
|
||||
.push("auto") // Row 12
|
||||
.push(14) // Seperator
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_POLICY_CODE)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(0))
|
||||
.text("Policy code")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_POLICY_CODE)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(2))
|
||||
.text("9999999990")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_POLICY_HOLDER)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.text("Policy holder")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_POLICY_HOLDER)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.water_mark("Name des Versicherungsnehmers")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_DEDUCTIBLE)
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(0))
|
||||
.text("Deductible")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_DEDUCTIBLE)
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.water_mark("im Beratungsgespräch erfragen")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_CALLBACK_NUMBER)
|
||||
.attach(Grid::row(6))
|
||||
.attach(Grid::column(0))
|
||||
.text("Callback number")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_CALLBACK_NUMBER)
|
||||
.attach(Grid::row(6))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.water_mark("wie zu erreichen")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_CALLBACK_DATE)
|
||||
.attach(Grid::row(8))
|
||||
.attach(Grid::column(0))
|
||||
.text("Callback date")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_CALLBACK_DATE)
|
||||
.attach(Grid::row(8))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.water_mark("Rückruf gewünscht um")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_HARM_TYPE)
|
||||
.attach(Grid::row(10))
|
||||
.attach(Grid::column(0))
|
||||
.text("Harm type")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_HARM_TYPE)
|
||||
.name(ID_TICKET_DATA_HARM_TYPE)
|
||||
.attach(Grid::row(10))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.water_mark("Schadenstyp")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_IVR_COMMENT)
|
||||
.attach(Grid::row(12))
|
||||
.attach(Grid::column(0))
|
||||
.text("IVR comment")
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.id(ID_TICKET_DATA_IVR_COMMENT)
|
||||
.attach(Grid::row(12))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.water_mark("Kommentar zur Haftung, bzw. zur Deckung")
|
||||
//.height(48.0)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let ticket_data_form_action = Container::new()
|
||||
.id(ID_TICKET_DATA_ACTION_GRID)
|
||||
.attach(Grid::row(3))
|
||||
.attach(Grid::column(1))
|
||||
//.style(STYLE_CONTAINER_ACTION)
|
||||
.padding(14)
|
||||
.h_align("center")
|
||||
.child(
|
||||
Stack::new()
|
||||
//.style(STYLE_STACK_ACTION)
|
||||
.orientation("horizontal")
|
||||
.spacing(50)
|
||||
.child(
|
||||
Button::new()
|
||||
.id(ID_TICKET_DATA_ACTION_BUTTON_CLEAR)
|
||||
.style(STYLE_BUTTON_ACTION)
|
||||
.text("Clear")
|
||||
.on_click(move |states, _| {
|
||||
states.send_message(TicketdataAction::ClearForm(), id);
|
||||
false
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.id(ID_TICKET_DATA_ACTION_BUTTON_SEND)
|
||||
.style(STYLE_BUTTON_ACTION)
|
||||
.text("Send")
|
||||
//.visibility(Visibility::Collapsed)
|
||||
.on_click(move |states, _entity| {
|
||||
states.send_message(TicketdataAction::SendForm(), id);
|
||||
false
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let ticket_data_form_mail = Container::new()
|
||||
.id(ID_TICKET_DATA_CONTAINER_MAIL)
|
||||
.name(ID_TICKET_DATA_CONTAINER_MAIL)
|
||||
.attach(Grid::row(1))
|
||||
.attach(Grid::column(1))
|
||||
.style(STYLE_CONTAINER_MAIL)
|
||||
.child(
|
||||
Grid::new()
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(16) // Delimiter
|
||||
.push("stretch") // Label
|
||||
.push(16) // Delimiter
|
||||
.push("auto") // MailAddress
|
||||
.push("32") // Delimiter (2x margin)
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Row 0
|
||||
.push(2) // Seperator
|
||||
.push("auto") // Row 2
|
||||
.push(2) // Seperator
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_MAIL_TO)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(1))
|
||||
.style(STYLE_MAIL_LABEL)
|
||||
.text("Recipient (To)")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ComboBox::new()
|
||||
.id(ID_TICKET_DATA_COMBO_BOX_MAIL_TO)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(3))
|
||||
.style(STYLE_MAIL_TO)
|
||||
.on_changed("selected_item", move |states, _entity| {
|
||||
states
|
||||
.get_mut::<TicketdataState>(id);
|
||||
})
|
||||
.items_builder(move |ictx, index| match index {
|
||||
0 => TextBlock::new()
|
||||
.text(PROP_MAIL_TO_1)
|
||||
.h_align("start")
|
||||
.v_align("center")
|
||||
.build(ictx),
|
||||
1 => TextBlock::new()
|
||||
.text(PROP_MAIL_TO_2)
|
||||
.h_align("start")
|
||||
.v_align("center")
|
||||
.build(ictx),
|
||||
2 => TextBlock::new()
|
||||
.text(PROP_MAIL_TO_3)
|
||||
.h_align("start")
|
||||
.v_align("center")
|
||||
.build(ictx),
|
||||
3 => TextBlock::new()
|
||||
.text(PROP_MAIL_TO_4)
|
||||
.h_align("start")
|
||||
.v_align("center")
|
||||
.build(ictx),
|
||||
_ => panic!(),
|
||||
})
|
||||
.count(4)
|
||||
.selected_index(0)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_TICKET_DATA_LABEL_MAIL_CC)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(1))
|
||||
.style(STYLE_MAIL_LABEL)
|
||||
.text("Copie (CC)")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ComboBox::new()
|
||||
.id(ID_TICKET_DATA_MAIL_CC)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(3))
|
||||
.style(STYLE_MAIL_CC)
|
||||
.items_builder(move |ictx, index| match index {
|
||||
0 => TextBlock::new()
|
||||
.text(PROP_MAIL_CC_1)
|
||||
.h_align("start")
|
||||
.v_align("center")
|
||||
.build(ictx),
|
||||
1 => TextBlock::new()
|
||||
.text(PROP_MAIL_CC_2)
|
||||
.h_align("start")
|
||||
.v_align("center")
|
||||
.build(ictx),
|
||||
_ => panic!(),
|
||||
})
|
||||
.count(2)
|
||||
.selected_index(0)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let ticket_data_header_text = TextBlock::new()
|
||||
.id(ID_TICKET_DATA_HEADER)
|
||||
.attach(Grid::column(0))
|
||||
.style(STYLE_HEADER_TEXT)
|
||||
.text("Ticket Data")
|
||||
.build(ctx);
|
||||
|
||||
let ticket_data_header_bar = Container::new()
|
||||
.id(ID_TICKET_DATA_HEADER_BAR)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.style(STYLE_HEADER_BAR)
|
||||
.child(tenent_logo)
|
||||
.child(ticket_data_header_text)
|
||||
.child(ticket_data_button_menu)
|
||||
.build(ctx);
|
||||
|
||||
// Widget: Ticket data view
|
||||
self.id(ID_TICKET_DATA_VIEW)
|
||||
.name(ID_TICKET_DATA_VIEW)
|
||||
.min_height(410.0)
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_TICKET_DATA_GRID)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(50) // Left margin
|
||||
.push("*") // Content
|
||||
.push(50) // Right margin
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Header_Bar
|
||||
.push("auto") // Mail_Form
|
||||
.push("*") // Input_Form
|
||||
.push("auto") // Action
|
||||
.push("auto") // Bottom_Bar
|
||||
)
|
||||
|
||||
.child(ticket_data_header_bar) // row 0
|
||||
.child(ticket_data_form_mail) // row 1
|
||||
.child(ticket_data_form) // row 2
|
||||
.child(ticket_data_form_action) // row 3
|
||||
.child(ticket_data_bottom_bar) // row 4
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user