Compare commits
13 Commits
wip_messag
...
wip_toggle
| Author | SHA1 | Date | |
|---|---|---|---|
| fafd38f210 | |||
| 667a2e39bf | |||
| c90099e1cf | |||
| 9624567dbd | |||
| 014b98bd85 | |||
| 8fd512b83f | |||
| 85f9fdf7db | |||
| c4d6506dee | |||
| 646955c0fb | |||
| df6bae482c | |||
| 00ad56ce71 | |||
| 6350d14ce7 | |||
| e8a86e8afd |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +1,6 @@
|
||||
[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: 51e747ef6d...d29c747d7b
@@ -3,14 +3,13 @@
|
||||
# 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.5"
|
||||
version = "0.1.4"
|
||||
authors = ["Ralf Zerres <ralf.zerres@networkx.de>"]
|
||||
description = "Frontend component that supports lawyers to capture relevant data encountered during an online legal advice."
|
||||
readme = "README.md"
|
||||
@@ -19,29 +19,24 @@ 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 = []
|
||||
@@ -51,18 +46,3 @@ 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"
|
||||
|
||||
@@ -13,8 +13,7 @@ Dictionary (
|
||||
// policycheck_view
|
||||
"Validation policy number": "Prüfung Versicherungsnummer",
|
||||
"Policy number": "Versicherungsnummer",
|
||||
"Policy code": "Vers.-Schein/Schadennummer",
|
||||
"Policy holder": "Versicherungsnehmer",
|
||||
"Policy code": "ID der Vers.-Nummer",
|
||||
"Checklist elements: ": "Prüflistenelemente: ",
|
||||
"Check result": "Prüfungsergebnis",
|
||||
"Importing data": "Importiere Datensätze",
|
||||
@@ -30,18 +29,6 @@ Dictionary (
|
||||
"Toggle theme": "Thema wechseln",
|
||||
"Quit": "Beenden",
|
||||
|
||||
// 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",
|
||||
|
||||
// localization view
|
||||
"Language ID": "Sprache ID",
|
||||
"Localization dialog": "Lokalisierungs-Dialog",
|
||||
@@ -53,7 +40,7 @@ Dictionary (
|
||||
"Configuration file": "Konfigurationsdatei",
|
||||
"Language Id": "Sprach-Id",
|
||||
"Default theme": "Standard-Thema",
|
||||
"Load": "Laden",
|
||||
"Save": "Speichern",
|
||||
"load": "laden",
|
||||
"save": "speichern"
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,52 +1,19 @@
|
||||
Theme (
|
||||
styles: {
|
||||
"button_action": (
|
||||
"button_menu": (
|
||||
base: "button",
|
||||
properties: {
|
||||
//"background": "transparent",
|
||||
"border_radius": 3,
|
||||
"h_align": "center",
|
||||
"v_align": "center",
|
||||
"padding": 4,
|
||||
"border_radius": 0,
|
||||
},
|
||||
),
|
||||
"button_menu": (
|
||||
base: "button_single_content",
|
||||
"container_form": (
|
||||
base: "container",
|
||||
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,
|
||||
"padding": 14,
|
||||
"border_width": 1,
|
||||
"border_radius": 0,
|
||||
"border_brush": "$CONTAINER_BORDER",
|
||||
},
|
||||
),
|
||||
"configuration_form": (
|
||||
@@ -55,133 +22,33 @@ Theme (
|
||||
"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",
|
||||
//"border_width": 1,
|
||||
//"border_radius": 0,
|
||||
"border_brush": "$CONTAINER_BORDER",
|
||||
},
|
||||
),
|
||||
"popup_progress": (
|
||||
base: "popup",
|
||||
properties: {
|
||||
//"background": "$BACKGROUND",
|
||||
"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",
|
||||
},
|
||||
),
|
||||
"stack_progress": (
|
||||
base: "container",
|
||||
properties: {
|
||||
"spacing": 10,
|
||||
},
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../../../data/POLLFNR_WOECHENTLICH.txt
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* 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(())
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// The starting point (Main View).
|
||||
pub mod main_view;
|
||||
|
||||
/// Receiver widget
|
||||
pub mod receiver;
|
||||
|
||||
/// Sender widget.
|
||||
pub mod sender;
|
||||
@@ -1,5 +0,0 @@
|
||||
/// The reciever state
|
||||
pub mod receiver_state;
|
||||
|
||||
/// The receiver view
|
||||
pub mod receiver_view;
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* 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)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
/// The sender state
|
||||
pub mod sender_state;
|
||||
|
||||
/// The sender view
|
||||
pub mod sender_view;
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* 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'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* 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
advotracker/src/bin/csv-test/POLLFNR_WOECHENTLICH.txt
Symbolic link
1
advotracker/src/bin/csv-test/POLLFNR_WOECHENTLICH.txt
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../advotrackerd/data/POLLFNR_WOECHENTLICH.txt
|
||||
98
advotracker/src/bin/csv-test/locales/csv-test_json.bak
Normal file
98
advotracker/src/bin/csv-test/locales/csv-test_json.bak
Normal file
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,9 @@ use chrono::{Local, DateTime};
|
||||
use locales::t;
|
||||
//use serde::{Deserialize, Serialize};
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
env,
|
||||
{error::Error, process},
|
||||
//path::{Path, PathBuf},
|
||||
};
|
||||
use std::env;
|
||||
use std::{error::Error, process};
|
||||
use std::collections::HashMap;
|
||||
use tracing::{debug, trace, Level};
|
||||
|
||||
use advotracker::data::structures::{PolicyCode, PolicyList, PolicyDataList, PolicyData};
|
||||
@@ -52,6 +49,14 @@ fn export(p: &mut String, lang: &String) -> Result<u64, Box<dyn Error>> {
|
||||
// Note: slash syntax also works on Windows!
|
||||
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);
|
||||
@@ -98,6 +103,10 @@ 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
|
||||
@@ -324,8 +333,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
state = t!("state.started", lang);
|
||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||
|
||||
// create policy structures
|
||||
let policy_list = PolicyList::new("Allianz Versicherungsnummen-Liste");
|
||||
// importing policy code elements from csv-file
|
||||
let policy_list = PolicyList::new("Allianz Versicherungsnummen-List");
|
||||
println!("Policy List {:?} ", policy_list.name);
|
||||
|
||||
let mut policy_data = PolicyDataList::new("Allianz-Import 20200628");
|
||||
@@ -346,9 +355,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
|
||||
// test if policy_number is_valid
|
||||
// type conversion (viperus String -> u64)
|
||||
let test_policy_number = v.get::<String>("test_policy_number").unwrap().parse::<u64>().unwrap();
|
||||
let test_policy_number = v.get::<i32>("test_policy_number").unwrap() as u64;
|
||||
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
|
||||
@@ -385,25 +394,3 @@ 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", String::from("9999999992"));
|
||||
v.add_default("test_policy_number", 123456789);
|
||||
v.add_default("to_email_address_file", String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"));
|
||||
v.add_default("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::<String>("test_policy_number").unwrap_or_default()
|
||||
v.get::<i32>("test_policy_number").unwrap_or_default()
|
||||
);
|
||||
// println!(
|
||||
// "username: {:?}",
|
||||
@@ -1,5 +1,11 @@
|
||||
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)
|
||||
@@ -9,8 +15,12 @@ use orbtk::prelude::*;
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
enum Action {
|
||||
//ClearText,
|
||||
EntryActivated(Entity),
|
||||
EntryChanged(Entity)
|
||||
EntryChanged(Entity),
|
||||
//ValueChanged(Entity),
|
||||
//ValueOk,
|
||||
//ValueNone,
|
||||
}
|
||||
|
||||
#[derive(AsAny)]
|
||||
@@ -48,16 +58,23 @@ impl State for MainViewState {
|
||||
// //ctx.widget().set("policynumber", background("#5b0f22"));
|
||||
//}
|
||||
Action::EntryActivated(entity) => {
|
||||
//let text = ctx.get_widget(entity).clone::<String>("text");
|
||||
let widget = ctx.get_widget(entity);
|
||||
let text = widget.get::<String>("text");
|
||||
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");
|
||||
println!("got value policynumber: {}", text);
|
||||
//text.clear();
|
||||
}
|
||||
Action::EntryChanged(entity) => {
|
||||
let widget = ctx.get_widget(entity);
|
||||
let text = widget.get::<String>("text");
|
||||
let text = widget.get::<String16>("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;
|
||||
@@ -68,6 +85,7 @@ impl State for MainViewState {
|
||||
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
|
||||
TextBlock::new()
|
||||
.text(text)
|
||||
//.element("text-block")
|
||||
.style("header")
|
||||
.build(ctx)
|
||||
}
|
||||
@@ -83,19 +101,26 @@ 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::create()
|
||||
.push(150.0)
|
||||
.push("*")
|
||||
.push(150.0)
|
||||
Columns::new()
|
||||
.add(150.0)
|
||||
.add("*")
|
||||
//.add(120.0)
|
||||
//.add("auto")
|
||||
.add(150.0)
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("*")
|
||||
.push("*")
|
||||
Rows::new()
|
||||
.add("*")
|
||||
.add("*")
|
||||
.build(),
|
||||
)
|
||||
.child(
|
||||
@@ -115,22 +140,27 @@ 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 |ctx, entity| {
|
||||
state(id, ctx).action(Action::EntryActivated(entity));
|
||||
.on_activate(move |states, entity| {
|
||||
state(id, states).action(Action::EntryActivated(entity));
|
||||
})
|
||||
.on_changed("text", move |ctx, entity| {
|
||||
state(id, ctx).action(Action::EntryChanged(entity));
|
||||
.on_changed(move |states, entity| {
|
||||
state(id, states).action(Action::EntryChanged(entity));
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
@@ -150,28 +180,28 @@ impl Template for MainView {
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
//.class("logo_customer")
|
||||
//.element("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("assets/images/customer_logo.png")
|
||||
.image("./resources/images/hiedemann_logo.png")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
//.class("logo_vendor")
|
||||
//.element("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("assets/images/networkx_logo.png")
|
||||
.image("./resources/images/networkx_logo.png")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
|
||||
@@ -1,52 +1,20 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* Copyright 2020 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: &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_SEPERATOR: &str = "seperator";
|
||||
//pub static STYLE_ITEM_BUTTON: &str = "item_button";
|
||||
pub static STYLE_MENU: &str = "menu";
|
||||
pub static STYLE_STACK_ACTION: &str = "stack_action";
|
||||
pub static STYLE_BUTTON_MENU: &str = "button_menu";
|
||||
pub static STYLE_STACK_MENU: &str = "stack_menu";
|
||||
|
||||
// Widget IDs (DCES: Entity[id] => [Component1, .. , Component<n>] -> data or state)
|
||||
pub static ID_CONFIGURATION_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";
|
||||
@@ -54,50 +22,37 @@ pub static ID_CONFIGURATION_CONFIG_FILE: &str = "configuration_config_file";
|
||||
pub static ID_CONFIGURATION_LABEL_LANGUAGE_ID: &str = "configuration_label_language_id";
|
||||
pub static ID_CONFIGURATION_LANGUAGE_ID: &str = "configuration_language_id";
|
||||
|
||||
pub static ID_LOCALIZATION_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_MAIN_GRID: &str = "main_grid";
|
||||
pub static ID_MAIN_TABWIDGET: &str = "main_tabwidget";
|
||||
pub static ID_MAIN_BUTTON_MENU: &str = "main_button_menu";
|
||||
|
||||
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 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_FORM: &str = "policy_check_form";
|
||||
pub static ID_POLICY_CHECK_FORM_ROW_0: &str = "policy_check_form_row_0";
|
||||
pub static ID_POLICY_CHECK_FORM_ROW_1: &str = "policy_check_form_row_1";
|
||||
pub static ID_POLICY_CHECK_FORM_ROW_2: &str = "policy_check_form_row_2";
|
||||
pub static ID_POLICY_CHECK_HEADER: &str = "policy_check_header";
|
||||
pub static ID_POLICY_CHECK_ITEMS_WIDGET: &str = "policy_check_items_widget";
|
||||
pub static ID_POLICY_CHECK_BUTTON_RESULT: &str = "policy_check_button_result";
|
||||
pub static ID_POLICY_CHECK_BUTTON_MENU: &str = "policy_check_button_menu";
|
||||
pub static ID_POLICY_CHECK_DATA_COUNT_BLOCK: &str = "policy_check_data_count_block";
|
||||
pub static ID_POLICY_CHECK_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_POLICY_NUMBER: &str = "policy_check_policy_number";
|
||||
pub static ID_POLICY_CHECK_POPUP_PROGRESS: &str = "policy_check_popup_progress";
|
||||
pub static ID_POLICY_CHECK_PROGRESS_BAR: &str = "policy_check_progress_bar";
|
||||
pub static ID_POLICY_CHECK_PROGRESS_TIME: &str = "policy_check_progress_time";
|
||||
@@ -121,44 +76,13 @@ 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";
|
||||
// Component Values (Properties)
|
||||
pub static PROP_ADVOTRACKER: &str = "advotracker";
|
||||
pub static PROP_POLICY_CHECK: &str = "policy_check";
|
||||
pub static PROP_POLICY_PROGRESS_COUNT: &str = "policy_progress_count";
|
||||
|
||||
pub static PROP_POLICY_DATA_LIST: &str = "policy_data_list";
|
||||
pub static PROP_POLICY_DATA_COUNT: &str = "policy_data_count";
|
||||
|
||||
pub static PROP_POLICY_LIST: &str = "policy_list";
|
||||
pub static PROP_POLICY_LIST_COUNT: &str = "policy_list_count";
|
||||
|
||||
@@ -110,39 +110,6 @@ 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 {
|
||||
@@ -190,6 +157,20 @@ 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 {
|
||||
@@ -260,7 +241,7 @@ pub struct PolicyDataList {
|
||||
|
||||
/// implements the helper methods, to manage policy data collections.
|
||||
impl PolicyDataList {
|
||||
/// Prüfung auf Versicherungselemente
|
||||
/// Prüfung ob Versicherungselemente .
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.policy_data.is_empty()
|
||||
}
|
||||
|
||||
@@ -225,16 +225,6 @@
|
||||
"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",
|
||||
|
||||
@@ -18,7 +18,6 @@ use cfg_if::cfg_if;
|
||||
use serde::Deserialize;
|
||||
use std::env;
|
||||
//use std::process;
|
||||
use substring::Substring;
|
||||
use tracing::{info, trace, Level};
|
||||
|
||||
use orbtk::{
|
||||
@@ -60,9 +59,7 @@ 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_else(|_| "C".to_string());
|
||||
lang = lang.substring(0,5).to_string(); // "de_DE.UTF-8" -> "de_DE"
|
||||
info!("GUI-Language: preset to {:?}", lang);
|
||||
let mut lang = env::var("LANG").unwrap_or("C".to_string());
|
||||
|
||||
// testing environment: read from .env file
|
||||
dotenv().ok();
|
||||
@@ -73,8 +70,6 @@ fn get_lang() -> String {
|
||||
Err(e) => { info!(target: "advotracker", "{}", e) }
|
||||
}
|
||||
trace!(target: "advotracker", lang = ?lang);
|
||||
|
||||
// return the active language
|
||||
lang
|
||||
}
|
||||
|
||||
@@ -148,7 +143,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", process = ?res, state = ?state);
|
||||
trace!(target: "advotracker", message = ?res, state = ?state);
|
||||
trace!(target: "advotracker", environment = "system", lang = ?lang);
|
||||
trace!(target: "advotracker", machine = ?&machine_kind);
|
||||
|
||||
@@ -156,7 +151,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", process = ?res, state = ?state);
|
||||
trace!(target: "advotracker", message = ?res, state = ?state);
|
||||
|
||||
// initialize viperus structure
|
||||
let mut viperus = Viperus::new();
|
||||
@@ -170,10 +165,6 @@ 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);
|
||||
@@ -182,13 +173,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// use this only if you want to run it as web application.
|
||||
orbtk::initialize();
|
||||
|
||||
// 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);
|
||||
// if no dictionary is set for the default language e.g. english the content of the text property will drawn.
|
||||
let localization = RonLocalization::create()
|
||||
.language(&lang)
|
||||
.language("en_US")
|
||||
.dictionary("de_DE", ADVOTRACKER_DE_DE)
|
||||
.build();
|
||||
|
||||
@@ -199,9 +186,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Window::new()
|
||||
.title("AdvoTracker - DirectCall")
|
||||
.position((500.0, 100.0))
|
||||
.size(800.0, 600.0)
|
||||
.size(580.0, 320.0)
|
||||
//.min_width(460.0)
|
||||
//.min_height(380.0)
|
||||
//.min_height(180.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", String::from("9999999992"));
|
||||
viperus.add_default("test_policy_number", 123456789);
|
||||
viperus.add_default("to_email_address_file", String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"));
|
||||
viperus.add_default("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('_');
|
||||
env_prefix.push_str("_");
|
||||
viperus.set_env_prefix(&env_prefix);
|
||||
|
||||
// enable caching and automatic update of environment values
|
||||
|
||||
@@ -8,12 +8,16 @@
|
||||
//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: &str) -> Result<(), Box<dyn Error>> {
|
||||
pub fn export(p: &mut String, lang: &String) -> Result<(), Box<dyn Error>> {
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
//use std::ffi::OsStr;
|
||||
|
||||
@@ -5,8 +5,5 @@
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
/// Send ticketdata via email
|
||||
pub mod send_ticketdata;
|
||||
|
||||
/// Exporting Allianz DirecCall data
|
||||
pub mod allianzdirectcall;
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
* 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: &str)
|
||||
lang: &String)
|
||||
-> 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!("import error: {}", err);
|
||||
println!("error running example: {}", err);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,19 +39,13 @@ impl State for ConfigurationState {
|
||||
) {
|
||||
for message in messages.read::<ConfigurationAction>() {
|
||||
match message {
|
||||
ConfigurationAction::LoadConfiguration => {
|
||||
registry
|
||||
ConfigurationAction::LoadConfiguration => registry
|
||||
.get::<Settings>("settings")
|
||||
.load_async::<ConfigurationData>(
|
||||
"configuration_data".to_string(), ctx.entity()
|
||||
);
|
||||
}
|
||||
.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(
|
||||
registry.get::<Settings>("settings").save_async(
|
||||
"configuration_data".to_string(),
|
||||
ConfigurationData(
|
||||
configuration_file,
|
||||
@@ -63,7 +57,7 @@ impl State for ConfigurationState {
|
||||
}
|
||||
}
|
||||
|
||||
// save the result
|
||||
// save result
|
||||
for message in messages.read::<SettingsResult<()>>() {
|
||||
println!("Result {:?}", message);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ impl Template for ConfigurationView {
|
||||
self.child(
|
||||
Grid::new()
|
||||
.id(ID_CONFIGURATION_FORM)
|
||||
.style("configuration_form")
|
||||
.style(configuration_form)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(120)
|
||||
@@ -35,13 +35,13 @@ impl Template for ConfigurationView {
|
||||
.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
|
||||
.push("auto")
|
||||
.push(4)
|
||||
.push("auto")
|
||||
.push(4)
|
||||
.push("auto")
|
||||
.push(12)
|
||||
.push("auto"),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
@@ -112,7 +112,7 @@ impl Template for ConfigurationView {
|
||||
.style("button_single_content")
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(0))
|
||||
.text("Load")
|
||||
.text("load")
|
||||
.on_click(move |ctx, _| {
|
||||
ctx.send_message(ConfigurationAction::LoadConfiguration, id);
|
||||
true
|
||||
@@ -121,7 +121,7 @@ impl Template for ConfigurationView {
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.text("Save")
|
||||
.text("save")
|
||||
.style("button_single_content")
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(0))
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
use dotenv::dotenv;
|
||||
use serde::Deserialize;
|
||||
use std::env;
|
||||
use substring::Substring;
|
||||
use tracing::{info, trace};
|
||||
|
||||
use orbtk::prelude::*;
|
||||
@@ -29,11 +28,10 @@ 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_else(|_| "C".to_string());
|
||||
lang = lang.substring(0,5).to_string(); // "de_DE.UTF-8" -> "de_DE"
|
||||
info!("GUI-Language: preset to {:?}", lang);
|
||||
let mut lang = env::var("LANG").unwrap_or("C".to_string());
|
||||
|
||||
// testing environment: read from .env file
|
||||
dotenv().ok();
|
||||
@@ -44,28 +42,17 @@ 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) = *Window::focus_state_ref(&ctx.window()).focused_entity() {
|
||||
// ctx.push_event_by_window(FocusEvent::RemoveFocus(old_focused_element));
|
||||
// if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget {
|
||||
// let mut old_focused_element = ctx.get_widget(old_focused_element);
|
||||
// old_focused_element.set("focused", false);
|
||||
// //old_focused_element.update_theme_by_state(false);
|
||||
// }
|
||||
// ctx.window().get_mut::<Global>("global").focused_widget = None;
|
||||
// ctx.widget().set("visibility", Visibility::Collapsed);
|
||||
// ctx.get_widget(to).set("visibility", Visibility::Visible);
|
||||
// }
|
||||
@@ -75,6 +62,7 @@ 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")
|
||||
|
||||
@@ -8,15 +8,11 @@
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::{
|
||||
data::{
|
||||
constants::*,
|
||||
structures::PolicyCheck,
|
||||
},
|
||||
widgets::configuration::configuration_view::ConfigurationView,
|
||||
data::structures::PolicyCheck,
|
||||
widgets::policycheck::policycheck_view::PolicycheckView,
|
||||
widgets::localization::localization_view::LocalizationView,
|
||||
//widgets::menu::menu_view::MenuView,
|
||||
widgets::ticketdata::ticketdata_view::TicketdataView,
|
||||
widgets::configuration::configuration_view::ConfigurationView,
|
||||
widgets::menu::menu_view::MenuView,
|
||||
};
|
||||
|
||||
// [START] views
|
||||
@@ -27,16 +23,11 @@ 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()
|
||||
.target(ticketdata_view.0)
|
||||
//.policy_number_count(0)
|
||||
//.policylist_view(id)
|
||||
.build(ctx);
|
||||
@@ -55,7 +46,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())
|
||||
@@ -64,11 +55,10 @@ impl Template for MainView {
|
||||
// .child(policylist_view)
|
||||
.child(
|
||||
TabWidget::new()
|
||||
.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))
|
||||
.tab("Policynumber check", policycheck_view)
|
||||
.tab("Localization", LocalizationView::new().build(ctx))
|
||||
.tab("Configuration", ConfigurationView::new().build(ctx))
|
||||
.tab("Menu", MenuView::new().build(ctx))
|
||||
.build(ctx),
|
||||
)
|
||||
//.child(policycheck_view)
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
/*
|
||||
* advotracker - Hotline tackingtool for Advocats
|
||||
*
|
||||
* Copyright 2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
use orbtk::prelude::*;
|
||||
use orbtk::shell::event::Key;
|
||||
use tracing::{info, trace};
|
||||
|
||||
use std::process;
|
||||
|
||||
@@ -22,59 +21,88 @@ use crate::{
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum MenuAction {
|
||||
CreateMenu,
|
||||
CreateMenuToggleTheme,
|
||||
CreateMenuToggleTheme(Entity),
|
||||
RemoveMenu,
|
||||
RemoveMenuToggleTheme,
|
||||
SetTheme,
|
||||
UpdateMenuRelativePosition
|
||||
RemoveMenuToggleTheme(Entity),
|
||||
SetTheme
|
||||
}
|
||||
|
||||
/// Valid `structures` that are handled inside the state of the `Menu` widget.
|
||||
#[derive(AsAny, Default)]
|
||||
pub struct MenuState {
|
||||
action: Option<MenuAction>,
|
||||
menu: Option<Entity>,
|
||||
//menu_toggle_theme: Option<Entity>
|
||||
menu: 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);
|
||||
/// Set a menu holding all valid menu elements
|
||||
/// The elements are ordered compontents inside a stack
|
||||
pub fn create_menu(&mut self, ctx: &mut Context<'_>) {
|
||||
// create a stack as a child of the given component
|
||||
let stack = ctx
|
||||
.entity_of_child(ID_MENU_BUTTON)
|
||||
.expect("PolicycheckState: Can't find entity of resource 'ID_MENU_BUTTON'.");
|
||||
//.entity_of_child(<PolicycheckView>ID_MENU_BUTTON)
|
||||
//.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_POPUP_MENU'.");
|
||||
let current_entity = ctx.entity();
|
||||
let build_context = &mut ctx.build_context();
|
||||
|
||||
// create a new popup menu overlay
|
||||
self.menu = create_menu_popup(current_entity, build_context);
|
||||
|
||||
// create a menu_popup widget as a child of entity "ID_POLICY_CHECK_BUTTON_MENU"
|
||||
build_context.append_child(stack, self.menu);
|
||||
|
||||
println!("Popup Menu created: {:?}", self.menu);
|
||||
}
|
||||
|
||||
/// Set a toggle_theme menu
|
||||
/// Select the active theme from a `ComboBox` offering a list of valid `themes``
|
||||
fn create_menu_toggle_theme(&mut self, ctx: &mut Context<'_>) {
|
||||
let stack = ctx
|
||||
.entity_of_child(ID_MENU_LABEL_TOGGLE_THEME)
|
||||
.expect("MenuState: Can't find entity of resource 'ID_MENU_LABEL_TOGGLE_THEME'.");
|
||||
let current_entity = ctx.entity();
|
||||
let build_context = &mut ctx.build_context();
|
||||
|
||||
// create a new menu overlay
|
||||
self.menu_toggle_theme = create_menu_toggle_theme_popup(current_entity, build_context);
|
||||
|
||||
// create a menu_popup widget as a child of entity "ID_POPUP_MENU"
|
||||
build_context.append_child(stack, self.menu_toggle_theme);
|
||||
|
||||
println!("Popup Menu Toggle Theme created: {:?}", self.menu_toggle_theme);
|
||||
}
|
||||
|
||||
/// Remove the menu popup box
|
||||
fn remove_menu(&mut self, ctx: &mut Context<'_>) {
|
||||
self.action = Some(MenuAction::RemoveMenu);
|
||||
ctx.remove_child(ctx.entity());
|
||||
println!("Popup {:?} removed.", 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);
|
||||
fn remove_menu_toggle_theme(&mut self, id: Entity, ctx: &mut Context<'_>) {
|
||||
ctx.remove_child(self.menu_toggle_theme);
|
||||
println!("Popup {:?} removed !", id);
|
||||
}
|
||||
|
||||
/// Sets a new action.
|
||||
pub fn set_action(&mut self, action: MenuAction) {
|
||||
self.action = action.into();
|
||||
}
|
||||
|
||||
/// 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<'_>) {
|
||||
// }
|
||||
/// Initialize the state of widgets inside `MenuState`
|
||||
fn init(&mut self, _: &mut Registry, _ctx: &mut Context<'_>) {
|
||||
// Initialize required entities
|
||||
// let menu_button = ctx
|
||||
// .entity_of_child(ID_MENU_STACK)
|
||||
// .expect("MenuState.init: Can't find resource entity 'PolicycheckView::ID_POLICY_CHECK_BUTTON_MENU'.");
|
||||
}
|
||||
|
||||
/// Handle messages for the `MenuState`
|
||||
fn messages(
|
||||
@@ -85,40 +113,6 @@ impl State for MenuState {
|
||||
) {
|
||||
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());
|
||||
|
||||
@@ -141,8 +135,8 @@ impl State for MenuState {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,51 +145,18 @@ impl State for MenuState {
|
||||
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::CreateMenu => {
|
||||
println!("MenuAction::CreateMenu(_entity)");
|
||||
self.create_menu(ctx);
|
||||
}
|
||||
MenuAction::CreateMenuToggleTheme(_entity) => {
|
||||
self.create_menu_toggle_theme(ctx);
|
||||
}
|
||||
MenuAction::RemoveMenu => {
|
||||
self.remove_menu(ctx);
|
||||
}
|
||||
MenuAction::RemoveMenuToggleTheme => {
|
||||
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);
|
||||
}
|
||||
MenuAction::RemoveMenuToggleTheme(entity) => {
|
||||
self.remove_menu_toggle_theme(entity, ctx);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
@@ -204,21 +165,14 @@ impl State for MenuState {
|
||||
}
|
||||
|
||||
/// Create a new popup presenting the menu components
|
||||
fn create_menu_popup(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
pub fn create_menu_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
Popup::new()
|
||||
.id(ID_MENU_POPUP)
|
||||
.name(ID_MENU_POPUP)
|
||||
.target(target.0)
|
||||
.style("container_menu")
|
||||
.target(id)
|
||||
.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)
|
||||
|
||||
.width(280)
|
||||
.height(140)
|
||||
.on_key_down(move | ctx, key_event | {
|
||||
match key_event.key {
|
||||
Key::Q(..) => {
|
||||
@@ -229,7 +183,7 @@ fn create_menu_popup(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
},
|
||||
Key::Escape => {
|
||||
println!("KeyHandler: got Escape");
|
||||
ctx.get_mut::<MenuState>(target)
|
||||
ctx.get_mut::<MenuState>(id)
|
||||
.set_action(MenuAction::RemoveMenu);
|
||||
},
|
||||
_ => {
|
||||
@@ -238,43 +192,30 @@ fn create_menu_popup(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
};
|
||||
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("80") // Menu Button
|
||||
.push("1") // Seperator
|
||||
.push("auto") // Keyboard Shortcut
|
||||
.push("*") // Keyboard Shortcut
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
.build(),
|
||||
)
|
||||
.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))
|
||||
.attach(Grid::column_span(2))
|
||||
.icon(material_icons_font::MD_PERSON)
|
||||
.text("Account")
|
||||
.build(ctx),
|
||||
@@ -282,30 +223,26 @@ fn create_menu_popup(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
.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))
|
||||
.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
|
||||
})
|
||||
// .on_click(move |ctx, _| {
|
||||
// ctx.get_mut::<MenuState>(id)
|
||||
// .set_action(MenuAction::SetTheme(id));
|
||||
// true
|
||||
// })
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.id(ID_MENU_LABEL_QUIT)
|
||||
.name(ID_MENU_LABEL_QUIT)
|
||||
.style("button_menu")
|
||||
//.h_align("start")
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
//.attach(Grid::column_span(2))
|
||||
.attach(Grid::column_span(2))
|
||||
.icon(material_icons_font::MD_SETTINGS_POWER)
|
||||
.text("Quit")
|
||||
.on_mouse_down(move |_states, _| {
|
||||
@@ -316,8 +253,7 @@ fn create_menu_popup(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_MENU_SHORTCUT_QUIT)
|
||||
.name(ID_MENU_SHORTCUT_QUIT)
|
||||
//.style("button_menu")
|
||||
.style("button_menu")
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(2))
|
||||
.margin((0, 0, 16, 0))
|
||||
@@ -331,93 +267,30 @@ fn create_menu_popup(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
.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();
|
||||
pub fn create_menu_toggle_theme_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
//let themes_count = themes.len();
|
||||
//ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), new_width);
|
||||
|
||||
Popup::new()
|
||||
.id(ID_MENU_TOGGLE_THEME)
|
||||
.target(id.0)
|
||||
.style("container_menu")
|
||||
.target(id)
|
||||
.open(true)
|
||||
.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| {
|
||||
//.count(themes_count)
|
||||
.items_builder(move |build_ctx, index| {
|
||||
let theme_name =
|
||||
MenuView::themes_ref(&ctx.get_widget(id))[index].clone();
|
||||
TextBlock::new().v_align("center").text(theme_name).build(ctx)
|
||||
MenuView::themes_ref(&build_ctx.get_widget(id))[index].clone();
|
||||
TextBlock::new().v_align("center").text(theme_name).build(build_ctx)
|
||||
})
|
||||
.on_changed("selected_index", move |states, _entity| {
|
||||
states.send_message(MenuAction::SetTheme, id);
|
||||
.on_changed("selected_index", move |ctx, _| {
|
||||
ctx.send_message(MenuAction::SetTheme, id);
|
||||
println!("changed theme.");
|
||||
})
|
||||
.selected_index(id)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
use orbtk::prelude::*;
|
||||
|
||||
use crate::data::constants::*;
|
||||
@@ -26,101 +27,55 @@ widget!(
|
||||
/// 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);
|
||||
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 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()
|
||||
//self.themes(themes).child(MenuState::create_menu(ID_MENU_POPUP, ctx))
|
||||
self.themes(themes).child(
|
||||
Stack::new()
|
||||
.id(ID_MENU_STACK)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.style("header")
|
||||
.id(ID_MENU_HEADER)
|
||||
.v_align("center")
|
||||
.h_align("left")
|
||||
.text("Ticket Data")
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(0))
|
||||
.style("small_text")
|
||||
.text("Select theme")
|
||||
.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
|
||||
Button::new()
|
||||
//.id("button_menu")
|
||||
.id(ID_MENU_BUTTON)
|
||||
.style("button_single_content")
|
||||
.icon(material_icons_font::MD_MENU)
|
||||
.attach(Grid::column(2))
|
||||
.h_align("end")
|
||||
.on_click(move |ctx, _| {
|
||||
println!("WIP: open menu popup from MenuView");
|
||||
ctx.get_mut::<MenuState>(id)
|
||||
.set_action(MenuAction::CreateMenu);
|
||||
true
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.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),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -28,6 +28,3 @@ pub mod policycheck;
|
||||
|
||||
// /// Policylists widget.
|
||||
// pub mod policylist;
|
||||
|
||||
/// Ticketdata wigdet.
|
||||
pub mod ticketdata;
|
||||
|
||||
@@ -19,37 +19,30 @@ use crate::{
|
||||
structures::{PolicyCode, PolicyDataList, PolicyList},
|
||||
constants::*,
|
||||
},
|
||||
//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,
|
||||
//services::imports::allianzdirectcall::import,
|
||||
services::imports::allianzdirectcall,
|
||||
};
|
||||
|
||||
/// Enumeration of valid `action variants` that need to be handled as
|
||||
/// state changes for the `PolicycheckView` widget.
|
||||
#[derive(Debug, Clone)]
|
||||
/// Valid `actions` that are handled as state changes in the `Policycheck` widget.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum PolicycheckAction {
|
||||
AddProgress(f64),
|
||||
ClearEntry(Entity),
|
||||
ChangeTheme(),
|
||||
SendPolicynumber(),
|
||||
InputTextChanged(Entity),
|
||||
ImportData,
|
||||
NewTicket,
|
||||
ParsePolicyNumber(Entity),
|
||||
ParseEntry(Entity),
|
||||
RemoveFocus(Entity),
|
||||
RemovePopup(Entity),
|
||||
ResetProgress,
|
||||
GetProgress,
|
||||
SetProgress(f64),
|
||||
SetProgressPopup(Entity),
|
||||
SetToggleTheme(Entity),
|
||||
SetEntry(Entity),
|
||||
SetVisibility(Entity),
|
||||
TextChanged(Entity, usize),
|
||||
UpdatePolicyCode,
|
||||
UpdateProgress(f64)
|
||||
TextChanged(Entity, usize)
|
||||
}
|
||||
|
||||
/// Define valid environment variables provided via .env files
|
||||
@@ -64,20 +57,16 @@ struct Environment {
|
||||
/// Valid `structures` that are handled inside the state of the `Policycheck` widget.
|
||||
#[derive(AsAny, Default)]
|
||||
pub struct PolicycheckState {
|
||||
actions: Vec<PolicycheckAction>,
|
||||
button_menu: Entity,
|
||||
action: Option<PolicycheckAction>,
|
||||
duration: Duration,
|
||||
label_result: Entity,
|
||||
lang: String,
|
||||
button_menu: Entity,
|
||||
policy_data_count: u64,
|
||||
//policy_number: Entity,
|
||||
policy_numbers: HashMap<u64, PolicyCode>,
|
||||
progress_bar: Entity,
|
||||
progress_count: f64,
|
||||
progress_popup: Entity,
|
||||
// target that recieves messages
|
||||
target: Entity,
|
||||
ticketdata: Entity
|
||||
progress_popup: Entity
|
||||
}
|
||||
|
||||
impl GlobalState for PolicycheckState {}
|
||||
@@ -85,8 +74,7 @@ impl GlobalState for PolicycheckState {}
|
||||
/// Method definitions, that react on any given state change inside the `Policycheck` widget.
|
||||
impl PolicycheckState {
|
||||
/// 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");
|
||||
@@ -135,19 +123,20 @@ 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_POLICY_CODE), true);
|
||||
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), true);
|
||||
|
||||
if self.policy_numbers.is_empty() {
|
||||
if self.policy_numbers.len() == 0 {
|
||||
// initialize popup widget
|
||||
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);
|
||||
ctx.send_message(PolicycheckAction::UpdateProgress(self.progress_count), self.progress_popup);
|
||||
}
|
||||
// for _ in 1..4 {
|
||||
// self.progress_count += 0.33;
|
||||
// self.update_progress_bar(ctx);
|
||||
// sender.send(WindowRequest::Redraw).unwrap();
|
||||
//}
|
||||
|
||||
// importing policy code elements from csv-file
|
||||
match self.create_hashmap(ctx) {
|
||||
@@ -161,6 +150,7 @@ impl PolicycheckState {
|
||||
self.progress_count = 1.;
|
||||
self.update_progress_bar(ctx);
|
||||
|
||||
//sender.send(WindowRequest::Redraw).unwrap();
|
||||
}
|
||||
_ => {
|
||||
let res = t!("policy.hashmap.failed", self.lang);
|
||||
@@ -178,20 +168,12 @@ impl PolicycheckState {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Create new ticket
|
||||
pub fn new_ticket(&mut self, ctx: &mut Context<'_>) {
|
||||
println!("WIP: new ticket.");
|
||||
self(ticketdata_view.0);
|
||||
//ctx.widget().get_mut::<TicketdataView>(0).
|
||||
//ctx.get_widget(self.ticketdata_view);
|
||||
}
|
||||
|
||||
/// Parse validity of the given policy number.
|
||||
pub fn parse_entry(&mut self, policy_check_policy_number: Entity,
|
||||
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(&ctx.get_widget(policy_check_policy_number));
|
||||
let policy_number_string = TextBox::text_clone(&mut ctx.get_widget(policy_check_policy_number));
|
||||
let policy_number_length = policy_number_string.len();
|
||||
|
||||
if self.policy_data_count == 0 {
|
||||
@@ -213,13 +195,20 @@ 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_POLICY_CODE), String::from(""));
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from(""));
|
||||
|
||||
// match hashmap's key
|
||||
match self.policy_numbers.get(&p) {
|
||||
@@ -230,7 +219,7 @@ impl PolicycheckState {
|
||||
|
||||
let string_result = format!("1-{:?}-{}",
|
||||
policy_code, p);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), string_result);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from(string_result));
|
||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#008000"));
|
||||
|
||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
|
||||
@@ -238,10 +227,8 @@ 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);
|
||||
|
||||
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);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Visible);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
|
||||
}
|
||||
_ => {
|
||||
// no matching key
|
||||
@@ -256,10 +243,8 @@ 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);
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -268,17 +253,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);
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -297,10 +282,8 @@ 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);
|
||||
|
||||
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);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
|
||||
}
|
||||
if policy_number_length > 10 {
|
||||
let res = t!("policy.validation.failed", self.lang);
|
||||
@@ -317,20 +300,13 @@ 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);
|
||||
|
||||
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);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Visible);
|
||||
}
|
||||
|
||||
trace!(target: "advotracker", parse_entry = "finished");
|
||||
}
|
||||
|
||||
/// parse message 'ParseEntry'
|
||||
pub fn parse_policy_number(&mut self, entity: Entity) {
|
||||
self.actions.push(PolicycheckAction::ParsePolicyNumber(entity));
|
||||
}
|
||||
|
||||
/// Remove the popup box
|
||||
fn remove_popup(&mut self, id: Entity, ctx: &mut Context<'_>) {
|
||||
ctx.remove_child(self.progress_popup);
|
||||
@@ -350,23 +326,19 @@ 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));
|
||||
/// Sets a new action.
|
||||
pub fn set_action(&mut self, action: PolicycheckAction) {
|
||||
self.action = action.into();
|
||||
}
|
||||
|
||||
/// 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_POLICY_CODE), Visibility::Collapsed);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), 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_POLICY_CODE), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,16 +353,18 @@ impl PolicycheckState {
|
||||
|
||||
// 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);
|
||||
println!("New entity `progress_popup` created: {:?}", self.progress_popup);
|
||||
|
||||
// append the stack inside the progress_popup
|
||||
build_context.append_child(stack, self.progress_popup);
|
||||
|
||||
// make sure we have a progress bar
|
||||
// make sure we have a
|
||||
self.progress_bar = ctx
|
||||
.entity_of_child(ID_POLICY_CHECK_PROGRESS_BAR)
|
||||
.expect("PolicycheckState.init: Can't find entity of resource 'ID_POLICY_CHECK_PROGRESS_BAR'.");
|
||||
info!("set_popup_progress: New entity 'progress_bar' created: {:?}", self.progress_bar);
|
||||
println!("New entity `progress_bar` created: {:?}", self.progress_bar);
|
||||
|
||||
println!("function `set_popup_progress()` finished!");
|
||||
}
|
||||
|
||||
/// Change visibility of the result label.
|
||||
@@ -402,6 +376,8 @@ impl PolicycheckState {
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||
}
|
||||
|
||||
//ctx.get_widget(self.label_result).update_theme_by_state(true);
|
||||
}
|
||||
|
||||
/// Update count of elements in the policy data list.
|
||||
@@ -414,19 +390,11 @@ 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_duration);
|
||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_TIME), String::from(string_duration));
|
||||
|
||||
let mut progress_bar = ctx.child(ID_POLICY_CHECK_PROGRESS_BAR);
|
||||
progress_bar.set::<f64>("val", self.progress_count);
|
||||
}
|
||||
|
||||
/// Update the policy code policy data list.
|
||||
fn update_policy_code(&self, _ctx: &mut Context<'_>) {
|
||||
println!("update internal: policy_code");
|
||||
//let policy_code = ctx.widget().get::<PolicycheckState>(ID_POLICY_CHECK_POLICY_CODE);
|
||||
//ctx.widget().set(PROP_POLICY_DATA_COUNT, policy_code);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Supported methods handled inside the `PolicycheckState`
|
||||
@@ -437,32 +405,24 @@ impl State for PolicycheckState {
|
||||
|
||||
trace!(target: "advotracker", policycheck_state = "init", status = "started");
|
||||
|
||||
// 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_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);
|
||||
//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);
|
||||
|
||||
//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'."));
|
||||
// Preset localization with given environment lang
|
||||
self.lang = PolicycheckState::get_lang();
|
||||
ctx.set_language(&self.lang);
|
||||
|
||||
// // Load the saved data from a file in 'ron' format into our data structure.
|
||||
// // The cargo package identifier (default: 'nwx.advotracker') is used as the
|
||||
@@ -491,8 +451,8 @@ impl State for PolicycheckState {
|
||||
) {
|
||||
for message in messages.read::<PolicycheckAction>() {
|
||||
match message {
|
||||
PolicycheckAction::UpdateProgress(increment) => {
|
||||
let old_width = ProgressBar::val_clone(&ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
|
||||
PolicycheckAction::AddProgress(increment) => {
|
||||
let old_width = ProgressBar::val_clone(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
|
||||
|
||||
let new_width = old_width + increment;
|
||||
// Set the ProgressBar's val property to the calculated percentage
|
||||
@@ -503,13 +463,7 @@ impl State for PolicycheckState {
|
||||
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!"); }
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -526,10 +480,7 @@ impl State for PolicycheckState {
|
||||
// }
|
||||
//}
|
||||
|
||||
// Create `actions`, a drained iterator (".." => full range that clears the vector)
|
||||
let actions: Vec<PolicycheckAction> = self.actions.drain(..).collect();
|
||||
|
||||
for action in actions {
|
||||
if let Some(action) = self.action {
|
||||
match action {
|
||||
PolicycheckAction::ClearEntry(policy_check_policy_number) => {
|
||||
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
||||
@@ -548,10 +499,7 @@ impl State for PolicycheckState {
|
||||
}
|
||||
}
|
||||
}
|
||||
PolicycheckAction::NewTicket => {
|
||||
self.new_ticket(ctx);
|
||||
}
|
||||
PolicycheckAction::ParsePolicyNumber(text_box) => {
|
||||
PolicycheckAction::ParseEntry(text_box) => {
|
||||
self.parse_entry(text_box, ctx);
|
||||
}
|
||||
PolicycheckAction::RemoveFocus(policy_check_policy_number) => {
|
||||
@@ -559,6 +507,7 @@ impl State for PolicycheckState {
|
||||
//ctx.EventAdapter(FocusEvent::RemoveFocus(policy_check_policy_number));
|
||||
}
|
||||
PolicycheckAction::RemovePopup(entity) => {
|
||||
//println!("WIP: remove popup");
|
||||
self.remove_popup(entity, ctx);
|
||||
}
|
||||
PolicycheckAction::ResetProgress => {
|
||||
@@ -583,31 +532,11 @@ impl State for PolicycheckState {
|
||||
PolicycheckAction::TextChanged(entity, _index) => {
|
||||
self.set_entry(entity, ctx);
|
||||
}
|
||||
PolicycheckAction::UpdatePolicyCode => {
|
||||
self.update_policy_code(ctx);
|
||||
|
||||
//info!("Message send: 'PolicycheckAction::UpdatePolicyNumber({:?}) -> {:?}'", policy_number, self.target);
|
||||
//let policy_number = (&mut ctx.get_widget(entity).get::<String>("text"));
|
||||
//let policy_number = ctx.get_widget(ID_POLICY_CHECK_POLICY_NUMBER).get::<text>("text");
|
||||
//ctx.send_message(PolicycheckAction::UpdatePolicyCode("AS-1-4711".to_string()), self.target);
|
||||
//ctx.send_message(PolicycheckAction::UpdatePolicyCode, self.target);
|
||||
|
||||
//let mut widget_container : WidgetContainer = ctx.widget();
|
||||
//widget_container.get::<String16>("text");
|
||||
//let polnum: TextBox = TextBox::get(ctx.child(ID_POLICY_CHECK_POLICY_NUMBER));
|
||||
//println!("Policy number: {:?}", polnum);
|
||||
|
||||
//let policy_number = ctx.get_widget(self.policy_check_policy_number);
|
||||
//let policy_number2 = TextBox::text_clone(&ctx.get_widget(ID_POLICY_CHECK_POLICY_NUMBER));
|
||||
|
||||
//let policy_number_string = ctx.get_widget(entity).get::<String16>("text").is_empty();
|
||||
//let policy_number = TextBox::text_clone(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER));
|
||||
//ctx.send_message(PolicycheckAction::UpdatePolicyNumber(policy_check_policy_number), self.target);
|
||||
//info!("Message send: 'PolicycheckAction::UpdatePolicyNumber({:?}) -> {:?}'", policy_check_policy_number, self.target);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
// Reset action
|
||||
self.action = None;
|
||||
}
|
||||
|
||||
// /// Update the view after the layout is rendered.
|
||||
@@ -619,16 +548,15 @@ impl State for PolicycheckState {
|
||||
fn create_popup_progress(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
Popup::new()
|
||||
.id(ID_POLICY_CHECK_POPUP_PROGRESS)
|
||||
.target(id.0)
|
||||
.target(id)
|
||||
.open(true)
|
||||
.style("popup_progress")
|
||||
.width(280)
|
||||
.height(100)
|
||||
.visibility(Visibility::Visible)
|
||||
.on_click(move |_ctx, _| {
|
||||
.on_click(move |ctx, _| {
|
||||
println!("create_popup_progress: on_click -> remove_popup(popup_progress)");
|
||||
//ctx.get_mut::<PolicycheckState>(id)
|
||||
// .set_action(PolicycheckAction::RemovePopup(id));
|
||||
ctx.get_mut::<PolicycheckState>(id)
|
||||
.set_action(PolicycheckAction::RemovePopup(id));
|
||||
true
|
||||
})
|
||||
.child(
|
||||
|
||||
@@ -23,16 +23,10 @@ widget!(
|
||||
/// 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,
|
||||
// widget entity that will receive the message
|
||||
target: u32
|
||||
policy_data_count: u32
|
||||
}
|
||||
);
|
||||
|
||||
@@ -41,9 +35,16 @@ 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))
|
||||
let policy_check_bottom_bar = Container::new()
|
||||
//.style(STYLE_BOTTOM_BAR)
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(1))
|
||||
.attach(Grid::column_span(2))
|
||||
.v_align("end")
|
||||
.child(
|
||||
Container::new()
|
||||
.child( Container::new()
|
||||
.margin((0, 16, 16, 0))
|
||||
.v_align("center")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
@@ -51,16 +52,10 @@ impl Template for PolicycheckView {
|
||||
.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")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Container::new()
|
||||
.attach(Grid::column(1))
|
||||
@@ -94,120 +89,88 @@ 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()
|
||||
.id(ID_POLICY_CHECK_HEADER_BAR)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.style(STYLE_HEADER_BAR)
|
||||
.child(tenent_logo)
|
||||
.child(policy_check_header_text)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(1))
|
||||
.attach(Grid::column_span(2))
|
||||
.child(
|
||||
Grid::new()
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.style("header")
|
||||
.id(ID_POLICY_CHECK_HEADER)
|
||||
.v_align("center")
|
||||
.h_align("left")
|
||||
.text("Validation policy number")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(policy_check_button_menu)
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_policy_code = TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_POLICY_CODE)
|
||||
.style("body")
|
||||
.attach(Grid::row(2))
|
||||
.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(
|
||||
Stack::new()
|
||||
//.style(STYLE_STACK_ACTION)
|
||||
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")
|
||||
.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),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_form = Container::new()
|
||||
.id(ID_POLICY_CHECK_FORM)
|
||||
.name(ID_POLICY_CHECK_FORM)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(1))
|
||||
.style("container_form")
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_POLICY_CHECK_FORM)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push("auto") // Label
|
||||
.push("16") // Delimiter
|
||||
.push("200") // Data
|
||||
.push("16") // Delimiter
|
||||
.push("32") // Result-Button
|
||||
.push("4") // Delimeter
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Row 0
|
||||
.push("14") // Seperator
|
||||
.push("auto") // Row 2
|
||||
.push("14") // Seperator
|
||||
.push("auto") // Row 3
|
||||
)
|
||||
|
||||
//.child(policy_check_form_row_0)
|
||||
.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()
|
||||
.id(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
//.style("body")
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(2))
|
||||
//.lose_focus_on_activation(false)
|
||||
.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 |states, entity| {
|
||||
.on_activate(move |ctx, entity| {
|
||||
// Entity is entered/activated via Mouse/Keyboard
|
||||
states.get_mut::<PolicycheckState>(id).parse_policy_number(entity);
|
||||
//ctx.get_mut::<PolicycheckState>(policy_check_view)
|
||||
ctx.get_mut::<PolicycheckState>(id)
|
||||
.set_action(PolicycheckAction::ParseEntry(entity));
|
||||
})
|
||||
//.on_changed(|_, entity, _, _| println!("Selection changed: {:?}", entity))
|
||||
// .on_changed(move |ctx, entity, _| {
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .set_action(Action::SetProgressBox(entity));
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .set_action(Action::AddProgress(0.5));
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .set_action(Action::InputTextChanged(entity));
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .set_action(Action::SetVisibility(entity));
|
||||
// ctx.get_widget(policy_check_label_policy_number).set("visible");
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .set_action(Action::SetVisility(entity));
|
||||
// })
|
||||
// .on_mouse_down | .on_mouse_move | .on_mouse_up (move |ctx, entity| {
|
||||
// state(id, states).set_action(Action::AddItem);
|
||||
// })
|
||||
.on_key_down(move |_, key_event| {
|
||||
if key_event.key == Key::A(true) {
|
||||
println!("A key down");
|
||||
@@ -216,56 +179,145 @@ impl Template for PolicycheckView {
|
||||
// .set_action(Action::ImportData);
|
||||
true
|
||||
})
|
||||
.build(ctx)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(policy_check_button_result)
|
||||
.build(ctx);
|
||||
|
||||
//.child(policy_check_form_row_2)
|
||||
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(2))
|
||||
.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(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_RESULT)
|
||||
.style("body")
|
||||
.attach(Grid::row(1))
|
||||
.attach(Grid::column(2))
|
||||
.h_align("start")
|
||||
.v_align("center")
|
||||
.text("empty")
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_form_row_2 = Stack::new()
|
||||
// 3nd row
|
||||
.id(ID_POLICY_CHECK_FORM_ROW_2)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(5))
|
||||
.orientation("horizontal")
|
||||
.v_align("center")
|
||||
.h_align("center")
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_LABEL_HINT)
|
||||
.style("hint")
|
||||
.attach(Grid::row(4))
|
||||
//.style("hint")
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
//.margin((0, 0, 16, 0))
|
||||
.margin((0, 0, 16, 0))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.width(300)
|
||||
.min_width(300)
|
||||
.font_size(11.)
|
||||
.text("Error:")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_HINT)
|
||||
.style("hint")
|
||||
.attach(Grid::row(4))
|
||||
//.style("hint")
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(2))
|
||||
.build(ctx),
|
||||
.h_align("start")
|
||||
.v_align("center")
|
||||
.font_size(11)
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_form = Container::new()
|
||||
.id(ID_POLICY_CHECK_FORM)
|
||||
.min_width(420)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(1))
|
||||
.style("container_form")
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_POLICY_CHECK_FORM)
|
||||
.width(450)
|
||||
.min_width(400)
|
||||
.columns(
|
||||
Columns::create()
|
||||
// Label
|
||||
.push("300")
|
||||
// Seperator
|
||||
.push("16")
|
||||
// Values
|
||||
.push("auto")
|
||||
// Seperator
|
||||
.push("16")
|
||||
// Result-Button
|
||||
.push("32")
|
||||
//.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
.push("*")
|
||||
//.build(),
|
||||
)
|
||||
.child(policy_check_form_row_0)
|
||||
.child(policy_check_form_row_1)
|
||||
.child(policy_check_form_row_2)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
// WIP: this widget type should handle our target natively
|
||||
// but it isn't able to get textinput, nor handle usize values
|
||||
// ... yet
|
||||
let _policy_check_numeric_box = NumericBox::new()
|
||||
.id(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
.h_align("start")
|
||||
.width(100)
|
||||
//.min(<usize>1000000000)
|
||||
//.max(<usize>9999999999)
|
||||
.val(0)
|
||||
.min_width(95)
|
||||
.margin((0, 0, 0, 16))
|
||||
// WIP code @kivimango
|
||||
// .on_activate(move |ctx, entity| {
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .set_action(Action::ParseEntry(entity));
|
||||
// })
|
||||
// .on_changed(move |ctx, entity| {
|
||||
// ctx.get_mut::<PolicycheckState>(id)
|
||||
// .set_action(Action::InputTextChanged(entity));
|
||||
//})
|
||||
.build(ctx);
|
||||
|
||||
// row3: only shown, if we read in `policy numbers` in
|
||||
// a hashmap as values
|
||||
@@ -277,6 +329,7 @@ impl Template for PolicycheckView {
|
||||
.v_align("top")
|
||||
.orientation("horizontal")
|
||||
.visibility(Visibility::Collapsed)
|
||||
//.spacing("4")
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_DATA_LABEL)
|
||||
@@ -304,25 +357,40 @@ impl Template for PolicycheckView {
|
||||
.id(ID_POLICY_CHECK_WIDGET)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.push(50) // Left margin
|
||||
.push("*") // Content
|
||||
.push(50) // Right margin
|
||||
.push(50)
|
||||
.push("*")
|
||||
.push(50)
|
||||
//.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.push("auto") // Header_Bar
|
||||
.push(28) // Seperator
|
||||
.push("*") // InputForm
|
||||
.push("auto") // Data_Result
|
||||
.push("auto") // Bottom_Bar
|
||||
.push("auto")
|
||||
.push(28)
|
||||
.push("*")
|
||||
.push("auto")
|
||||
.push("auto")
|
||||
//.build(),
|
||||
)
|
||||
|
||||
.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
|
||||
// row 0: Policy Check Header
|
||||
.child(policy_check_header_bar)
|
||||
|
||||
// row 1: Seperator
|
||||
|
||||
// row 2: Policy Check Form
|
||||
.child(policy_check_form)
|
||||
|
||||
// row 3: Sum HashMap elements
|
||||
.child(policy_data_stack)
|
||||
|
||||
// row 4: Policy Check Bottom
|
||||
.child(policy_check_bottom_bar)
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// helper to request PolicycheckState
|
||||
//fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut PolicycheckState {
|
||||
// states.get_mut(id)
|
||||
//}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
@@ -1,223 +0,0 @@
|
||||
/*
|
||||
* 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!"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,446 +0,0 @@
|
||||
/*
|
||||
* 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