Merge remote-tracking branch 'NWX/wip-orbtk' into no_locales
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -37,6 +37,6 @@ testing = ["orbtk/debug"]
|
|||||||
|
|
||||||
[package.metadata.bundle]
|
[package.metadata.bundle]
|
||||||
name = "advotracker"
|
name = "advotracker"
|
||||||
identifier = "rzerres.advotracker"
|
identifier = "nwx.advotracker"
|
||||||
short_description = "Online legal advice helper."
|
short_description = "Online legal advice helper."
|
||||||
description = "Supports lawyers to capture relevant data encountered during an online legal advice.\n"
|
description = "Supports lawyers to capture relevant data encountered during an online legal advice.\n"
|
||||||
|
|||||||
@@ -35,60 +35,58 @@ impl State for MainViewState {
|
|||||||
if let Some(action) = self.action {
|
if let Some(action) = self.action {
|
||||||
match action {
|
match action {
|
||||||
Action::AddItem => {
|
Action::AddItem => {
|
||||||
let len = ctx.widget().get::<List>("list").len();
|
let len = main_view(ctx.widget()).list().len();
|
||||||
|
|
||||||
if len < 5 {
|
if len < 5 {
|
||||||
ctx.widget()
|
main_view(ctx.widget())
|
||||||
.get_mut::<List>("list")
|
.list_mut()
|
||||||
.push(format!("Item {}", len + 1));
|
.push(format!("Item {}", len + 1));
|
||||||
ctx.child("items").set("count", len + 1);
|
ctx.child("items").set::<usize>("blub", len + 1);
|
||||||
ctx.child("remove-item-button").set("enabled", true);
|
items_widget(ctx.child("items")).set_count(len + 1);
|
||||||
|
button(ctx.child("remove-item-button")).set_enabled(true);
|
||||||
|
|
||||||
if len == 4 {
|
if len == 4 {
|
||||||
ctx.child("add-item-button").set("enabled", false);
|
button(ctx.child("add-item-button")).set_enabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action::RemoveItem => {
|
Action::RemoveItem => {
|
||||||
let len = ctx.widget().get::<List>("list").len();
|
let len = main_view(ctx.widget()).list().len();
|
||||||
if len > 0 {
|
if len > 0 {
|
||||||
ctx.widget().get_mut::<List>("list").remove(len - 1);
|
main_view(ctx.widget()).list_mut().remove(len - 1);
|
||||||
ctx.child("items").set("count", len - 1);
|
items_widget(ctx.child("items")).set_count(len - 1);
|
||||||
ctx.child("add-item-button").set("enabled", true);
|
button(ctx.child("add-item-button")).set_enabled(true);
|
||||||
|
|
||||||
if len == 1 {
|
if len == 1 {
|
||||||
ctx.child("remove-item-button").set("enabled", false);
|
button(ctx.child("remove-item-button")).set_enabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action::IncrementCounter => {
|
Action::IncrementCounter => {
|
||||||
*ctx.widget().get_mut::<usize>("counter") += 1;
|
*main_view(ctx.widget()).counter_mut() += 1;
|
||||||
|
|
||||||
let counter = *ctx.widget().get::<usize>("counter");
|
let counter = *main_view(ctx.widget()).counter();
|
||||||
|
|
||||||
ctx.widget().set(
|
main_view(ctx.widget())
|
||||||
"result",
|
.set_result(String16::from(format!("Button count: {}", counter)));
|
||||||
String16::from(format!("Button count: {}", counter)),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
Action::ClearText => {
|
Action::ClearText => {
|
||||||
ctx.widget().set("text_one", String16::from(""));
|
main_view(ctx.widget()).set_text_one(String16::default());
|
||||||
ctx.widget().set("text_two", String16::from(""));
|
main_view(ctx.widget()).set_text_two(String16::default());
|
||||||
}
|
}
|
||||||
Action::EntryActivated(entity) => {
|
Action::EntryActivated(entity) => {
|
||||||
let mut widget = ctx.get_widget(entity);
|
let mut text_box = text_box(ctx.get_widget(entity));
|
||||||
let text = widget.get_mut::<String16>("text");
|
let text = text_box.text_mut();
|
||||||
println!("submitting {}", text);
|
println!("submitting {}", text);
|
||||||
text.clear();
|
text.clear();
|
||||||
}
|
}
|
||||||
Action::EntryChanged(entity) => {
|
Action::EntryChanged(entity) => {
|
||||||
let widget = ctx.get_widget(entity);
|
println!("entry changed: {}", text_box(ctx.get_widget(entity)).text());
|
||||||
let text = widget.get::<String16>("text");
|
|
||||||
println!("entry changed: {}", text);
|
|
||||||
}
|
}
|
||||||
Action::ValueChanged(entity) => {
|
Action::ValueChanged(entity) => {
|
||||||
let val =
|
let val = ((slider(ctx.get_widget(entity)).val()).floor() as i32).to_string();
|
||||||
((*ctx.get_widget(entity).get::<f64>("val")).floor() as i32).to_string();
|
|
||||||
ctx.child("value_text").set("text", String16::from(val));
|
text_block(ctx.child("value_text")).set_text(String16::from(val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,12 +97,11 @@ impl State for MainViewState {
|
|||||||
fn update_post_layout(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
fn update_post_layout(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||||
let mut selection_string = "Selected:".to_string();
|
let mut selection_string = "Selected:".to_string();
|
||||||
|
|
||||||
for index in &ctx.widget().get::<SelectedIndices>("selected_indices").0 {
|
for index in &main_view(ctx.widget()).selected_indices().0 {
|
||||||
selection_string = format!("{} {}", selection_string, index);
|
selection_string = format!("{} {}", selection_string, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.child("selection")
|
text_block(ctx.child("selection")).set_text(selection_string);
|
||||||
.set("text", String16::from(selection_string));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,14 +171,14 @@ impl Template for MainView {
|
|||||||
.combo_box_list_count(10)
|
.combo_box_list_count(10)
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.margin(8.0)
|
.margin(8.)
|
||||||
.columns(
|
.columns(
|
||||||
Columns::new()
|
Columns::new()
|
||||||
.add(132.0)
|
.add(132.)
|
||||||
.add(16.0)
|
.add(16.)
|
||||||
.add(132.0)
|
.add(132.)
|
||||||
.add(16.0)
|
.add(16.)
|
||||||
.add(132.0),
|
.add(132.),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Stack::new()
|
Stack::new()
|
||||||
@@ -191,8 +188,8 @@ impl Template for MainView {
|
|||||||
.child(
|
.child(
|
||||||
Button::new()
|
Button::new()
|
||||||
.text("Button")
|
.text("Button")
|
||||||
.margin((0.0, 8.0, 0.0, 0.0))
|
.margin((0., 8., 0., 0.))
|
||||||
.icon(material_font_icons::CHECK_FONT_ICON)
|
.icon(material_icons_font_ttf::MD_CHECK)
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(1))
|
||||||
.on_click(move |states, _| {
|
.on_click(move |states, _| {
|
||||||
@@ -206,8 +203,8 @@ impl Template for MainView {
|
|||||||
.text("Primary")
|
.text("Primary")
|
||||||
.element("button")
|
.element("button")
|
||||||
.class("primary")
|
.class("primary")
|
||||||
.margin((0.0, 8.0, 0.0, 0.0))
|
.margin((0., 8., 0., 0.))
|
||||||
.icon(material_font_icons::CHECK_FONT_ICON)
|
.icon(material_icons_font_ttf::MD_360)
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(2))
|
.attach(Grid::row(2))
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
@@ -216,7 +213,8 @@ impl Template for MainView {
|
|||||||
ToggleButton::new()
|
ToggleButton::new()
|
||||||
.class("single_content")
|
.class("single_content")
|
||||||
.text("ToggleButton")
|
.text("ToggleButton")
|
||||||
.margin((0.0, 8.0, 0.0, 0.0))
|
.margin((0., 8., 2., 0.))
|
||||||
|
.icon(material_icons_font_ttf::MD_ALARM_ON)
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(3))
|
.attach(Grid::row(3))
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
@@ -224,21 +222,21 @@ impl Template for MainView {
|
|||||||
.child(
|
.child(
|
||||||
CheckBox::new()
|
CheckBox::new()
|
||||||
.text("CheckBox")
|
.text("CheckBox")
|
||||||
.margin((0.0, 8.0, 0.0, 0.0))
|
.margin((0., 8., 0., 0.))
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(4))
|
.attach(Grid::row(4))
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Switch::new()
|
Switch::new()
|
||||||
.margin((0.0, 8.0, 0.0, 0.0))
|
.margin((0., 8., 0., 0.))
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(5))
|
.attach(Grid::row(5))
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.margin((0.0, 8.0, 0.0, 0.0))
|
.margin((0., 8., 0., 0.))
|
||||||
.element("h1")
|
.element("h1")
|
||||||
.id("value_text")
|
.id("value_text")
|
||||||
.text("0")
|
.text("0")
|
||||||
@@ -262,7 +260,7 @@ impl Template for MainView {
|
|||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.class("body")
|
.class("body")
|
||||||
.text(("result", id))
|
.text(("result", id))
|
||||||
.margin((0.0, 8.0, 0.0, 0.0))
|
.margin((0., 8., 0., 0.))
|
||||||
.attach(Grid::column(2))
|
.attach(Grid::column(2))
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(1))
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
@@ -271,7 +269,7 @@ impl Template for MainView {
|
|||||||
TextBox::new()
|
TextBox::new()
|
||||||
.water_mark("TextBox...")
|
.water_mark("TextBox...")
|
||||||
.text(("text_one", id))
|
.text(("text_one", id))
|
||||||
.margin((0.0, 8.0, 0.0, 0.0))
|
.margin((0., 8., 0., 0.))
|
||||||
.attach(Grid::column(2))
|
.attach(Grid::column(2))
|
||||||
.attach(Grid::row(2))
|
.attach(Grid::row(2))
|
||||||
.on_activate(move |states, entity| {
|
.on_activate(move |states, entity| {
|
||||||
@@ -286,7 +284,7 @@ impl Template for MainView {
|
|||||||
TextBox::new()
|
TextBox::new()
|
||||||
.water_mark("TextBox...")
|
.water_mark("TextBox...")
|
||||||
.text(("text_two", id))
|
.text(("text_two", id))
|
||||||
.margin((0.0, 8.0, 0.0, 0.0))
|
.margin((0., 8., 0., 0.))
|
||||||
.attach(Grid::column(2))
|
.attach(Grid::column(2))
|
||||||
.attach(Grid::row(2))
|
.attach(Grid::row(2))
|
||||||
.on_activate(move |states, entity| {
|
.on_activate(move |states, entity| {
|
||||||
@@ -299,8 +297,10 @@ impl Template for MainView {
|
|||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new()
|
Button::new()
|
||||||
.margin((0.0, 8.0, 0.0, 0.0))
|
.margin((0., 8., 0., 0.))
|
||||||
.class("single_content")
|
.class("single_content")
|
||||||
|
.margin((0., 8., 8., 0.))
|
||||||
|
.icon(material_icons_font_ttf::MD_CLEAR)
|
||||||
.text("clear text")
|
.text("clear text")
|
||||||
.on_click(move |states, _| {
|
.on_click(move |states, _| {
|
||||||
state(id, states).action(Action::ClearText);
|
state(id, states).action(Action::ClearText);
|
||||||
@@ -310,8 +310,8 @@ impl Template for MainView {
|
|||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
NumericBox::new()
|
NumericBox::new()
|
||||||
.margin((0.0, 8.0, 0.0, 0.0))
|
.margin((-0., 8., 0., 0.))
|
||||||
.max(123.0)
|
.max(123.)
|
||||||
.step(0.123)
|
.step(0.123)
|
||||||
.val(0.123)
|
.val(0.123)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
@@ -323,14 +323,14 @@ impl Template for MainView {
|
|||||||
.rows(
|
.rows(
|
||||||
Rows::new()
|
Rows::new()
|
||||||
.add("auto")
|
.add("auto")
|
||||||
.add(32.0)
|
.add(32.)
|
||||||
.add(16.0)
|
.add(16.)
|
||||||
.add(204.0)
|
.add(204.)
|
||||||
.add("auto")
|
.add("auto")
|
||||||
.add(192.0)
|
.add(192.)
|
||||||
.add("auto"),
|
.add("auto"),
|
||||||
)
|
)
|
||||||
.columns(Columns::new().add("*").add(4.0).add("*"))
|
.columns(Columns::new().add("*").add(4.).add("*"))
|
||||||
.attach(Grid::column(4))
|
.attach(Grid::column(4))
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
@@ -350,7 +350,7 @@ impl Template for MainView {
|
|||||||
.get::<Vec<String>>("combo_box_list")[index]
|
.get::<Vec<String>>("combo_box_list")[index]
|
||||||
.clone();
|
.clone();
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.margin((0.0, 0.0, 0.0, 2.0))
|
.margin((0., 0., 0., 2.))
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
.text(text)
|
.text(text)
|
||||||
.build(bc)
|
.build(bc)
|
||||||
@@ -359,7 +359,7 @@ impl Template for MainView {
|
|||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::column_span(3))
|
.attach(Grid::column_span(3))
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(1))
|
||||||
.margin((0.0, 8.0, 0.0, 0.0))
|
.margin((0., 8., 0., 0.))
|
||||||
.count(("combo_box_list_count", id))
|
.count(("combo_box_list_count", id))
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
@@ -367,18 +367,18 @@ impl Template for MainView {
|
|||||||
ItemsWidget::new()
|
ItemsWidget::new()
|
||||||
.element("items-widget")
|
.element("items-widget")
|
||||||
.id("items")
|
.id("items")
|
||||||
.padding((4.0, 4.0, 4.0, 2.0))
|
.padding((4., 4., 4., 2.))
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::column_span(3))
|
.attach(Grid::column_span(3))
|
||||||
.attach(Grid::row(3))
|
.attach(Grid::row(3))
|
||||||
.margin((0.0, 0.0, 0.0, 8.0))
|
.margin((0., 0., 0., 8.))
|
||||||
.items_builder(move |bc, index| {
|
.items_builder(move |bc, index| {
|
||||||
let text = bc.get_widget(id).get::<Vec<String>>("list")
|
let text = bc.get_widget(id).get::<Vec<String>>("list")
|
||||||
[index]
|
[index]
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
Button::new()
|
Button::new()
|
||||||
.margin((0.0, 0.0, 0.0, 2.0))
|
.margin((0., 0., 0., 2.))
|
||||||
.text(text)
|
.text(text)
|
||||||
.build(bc)
|
.build(bc)
|
||||||
})
|
})
|
||||||
@@ -390,12 +390,12 @@ impl Template for MainView {
|
|||||||
.element("button")
|
.element("button")
|
||||||
.class("single_content")
|
.class("single_content")
|
||||||
.id("remove-item-button")
|
.id("remove-item-button")
|
||||||
.icon(material_font_icons::MINUS_FONT_ICON)
|
.icon(material_icons_font_ttf::MD_REMOVE_CIRCLE)
|
||||||
.on_click(move |states, _| {
|
.on_click(move |states, _| {
|
||||||
state(id, states).action(Action::RemoveItem);
|
state(id, states).action(Action::RemoveItem);
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
.min_width(0.0)
|
.min_width(0.)
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(4))
|
.attach(Grid::row(4))
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
@@ -405,12 +405,12 @@ impl Template for MainView {
|
|||||||
.element("button")
|
.element("button")
|
||||||
.class("single_content")
|
.class("single_content")
|
||||||
.id("add-item-button")
|
.id("add-item-button")
|
||||||
.icon(material_font_icons::ADD_FONT_ICON)
|
.icon(material_icons_font_ttf::MD_ADD_CIRCLE)
|
||||||
.on_click(move |states, _| {
|
.on_click(move |states, _| {
|
||||||
state(id, states).action(Action::AddItem);
|
state(id, states).action(Action::AddItem);
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
.min_width(0.0)
|
.min_width(0.)
|
||||||
.attach(Grid::column(2))
|
.attach(Grid::column(2))
|
||||||
.attach(Grid::row(4))
|
.attach(Grid::row(4))
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
@@ -421,14 +421,14 @@ impl Template for MainView {
|
|||||||
.attach(Grid::column_span(3))
|
.attach(Grid::column_span(3))
|
||||||
.attach(Grid::row(5))
|
.attach(Grid::row(5))
|
||||||
.selected_indices(id)
|
.selected_indices(id)
|
||||||
.margin((0.0, 16.0, 0.0, 8.0))
|
.margin((0., 16., 0., 8.))
|
||||||
.items_builder(move |bc, index| {
|
.items_builder(move |bc, index| {
|
||||||
let text = bc
|
let text = bc
|
||||||
.get_widget(id)
|
.get_widget(id)
|
||||||
.get::<Vec<String>>("selection_list")[index]
|
.get::<Vec<String>>("selection_list")[index]
|
||||||
.clone();
|
.clone();
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.margin((0.0, 0.0, 0.0, 2.0))
|
.margin((0., 0., 0., 2.))
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
.text(text)
|
.text(text)
|
||||||
.build(bc)
|
.build(bc)
|
||||||
@@ -441,7 +441,7 @@ impl Template for MainView {
|
|||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.element("text-block")
|
.element("text-block")
|
||||||
.id("selection")
|
.id("selection")
|
||||||
.max_width(120.0)
|
.max_width(120.)
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::column_span(3))
|
.attach(Grid::column_span(3))
|
||||||
.attach(Grid::row(6))
|
.attach(Grid::row(6))
|
||||||
@@ -463,8 +463,8 @@ fn main() {
|
|||||||
.window(|ctx| {
|
.window(|ctx| {
|
||||||
Window::new()
|
Window::new()
|
||||||
.title("OrbTk - widgets example")
|
.title("OrbTk - widgets example")
|
||||||
.position((100.0, 100.0))
|
.position((100., 100.))
|
||||||
.size(468.0, 730.0)
|
.size(468., 730.)
|
||||||
.resizeable(true)
|
.resizeable(true)
|
||||||
.child(MainView::new().build(ctx))
|
.child(MainView::new().build(ctx))
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
.top_bar {
|
||||||
|
padding-left: 4;
|
||||||
|
padding-right: 4;
|
||||||
|
min-height: 52;
|
||||||
|
background: #475b6e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottom_bar {
|
||||||
|
height: 40;
|
||||||
|
background: #475b6e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
font-size: 24;
|
||||||
|
font-family: "Roboto Medium";
|
||||||
|
}
|
||||||
|
|
||||||
|
text_box.inplace {
|
||||||
|
color: #dfebf5;
|
||||||
|
background: transparent;
|
||||||
|
border-color: transparent;
|
||||||
|
border-width: 1;
|
||||||
|
border-radius: 2;
|
||||||
|
padding: 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
text_box.inplace:focus {
|
||||||
|
background: #3b434a;
|
||||||
|
border-color: #5b0f22;
|
||||||
|
/* border-color: #f8de4c; */
|
||||||
|
}
|
||||||
|
|
||||||
|
text_box.inplace:empty {
|
||||||
|
color: #9E9E9E
|
||||||
|
border-color: #5b0f22;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
.icon_only {
|
||||||
|
background: #5b0f22;
|
||||||
|
*/ background: transparent; */
|
||||||
|
icon-color: #fffffff;
|
||||||
|
spacing: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon_only:active {
|
||||||
|
background: #5b0f22;
|
||||||
|
icon-color: #fffffff;
|
||||||
|
/* icon-color: #516475; */
|
||||||
|
/* icon-color: #dfebf5; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon_only:disabled {
|
||||||
|
icon-color: #fffffff;
|
||||||
|
/* icon-color: #949ca5; */
|
||||||
|
background: #fffffff;
|
||||||
|
/* background: transparent; */
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
items-widget {
|
||||||
|
padding: 0;
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.transparent {
|
||||||
|
icon-color: transparent;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.transparent:active {
|
||||||
|
icon-color: transparent;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item_button {
|
||||||
|
background: transparent;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.separator {
|
||||||
|
background: #212121;
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,15 +8,15 @@
|
|||||||
use orbtk::prelude::*;
|
use orbtk::prelude::*;
|
||||||
|
|
||||||
//use crate::data::keys;
|
//use crate::data::keys;
|
||||||
// use crate::{
|
use crate::{
|
||||||
// //data::structures::PolicyList,
|
data::structures::PolicyList,
|
||||||
// data::keys::*
|
data::keys::*
|
||||||
// };
|
};
|
||||||
|
|
||||||
/// Provides generic methods to handle states of datatypes (e.g. used in `PolicyList`).
|
/// Provides generic methods to handle states of datatypes (e.g. used in `PolicyList`).
|
||||||
pub trait GlobalState {
|
pub trait GlobalState {
|
||||||
/// Navigates to the given entity.
|
/// Navigates to the given entity.
|
||||||
fn navigate(&self, to: Entity, ctx: &mut Context) {
|
fn navigate(&self, to: Entity, ctx: &mut Context<'_>) {
|
||||||
if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget {
|
if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget {
|
||||||
let mut old_focused_element = ctx.get_widget(old_focused_element);
|
let mut old_focused_element = ctx.get_widget(old_focused_element);
|
||||||
old_focused_element.set("focused", false);
|
old_focused_element.set("focused", false);
|
||||||
@@ -28,7 +28,7 @@ pub trait GlobalState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the text of a widget.
|
/// Get the text of a widget.
|
||||||
fn get_text(&self, ctx: &mut Context, entity: Entity) -> Option<String> {
|
fn get_text(&self, ctx: &mut Context<'_>, entity: Entity) -> Option<String> {
|
||||||
let mut widget = ctx.get_widget(entity);
|
let mut widget = ctx.get_widget(entity);
|
||||||
|
|
||||||
let entry = widget.get_mut::<String>("text");
|
let entry = widget.get_mut::<String>("text");
|
||||||
@@ -41,14 +41,19 @@ pub trait GlobalState {
|
|||||||
Some(copy)
|
Some(copy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the data.
|
/// Save the our data structure and convert it to `ron` file format.
|
||||||
// fn save(&self, registry: &mut Registry, ctx: &mut Context) {
|
/// The cargo package identifier (here: 'nwx.advotracker') is taken to create the app directory.
|
||||||
// registry
|
/// in users 'settings directory'. The directory location is OS dependant
|
||||||
// .get::<Settings>("settings")
|
/// (Windows: AppData, Unix: XDG_CONFIG_HOME, MacOS: $HOME/Library/Preferences).
|
||||||
// .save(
|
/// The data is stored in filename PROP_ADVOTRACKER (here: `advotracker.ron`)
|
||||||
// PROP_POLICY_LIST,
|
|
||||||
// ctx.widget().get::<PolicyList>(PROP_POLICY_LIST),
|
fn save(&self, registry: &mut Registry, ctx: &mut Context<'_>) {
|
||||||
// )
|
registry
|
||||||
// .unwrap();
|
.get::<Settings>("settings")
|
||||||
// }
|
.save(
|
||||||
|
PROP_ADVOTRACKER,
|
||||||
|
ctx.widget().get::<PolicyList>(PROP_ADVOTRACKER),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ pub fn is_valid(policy_number: &usize, policy_list: &PolicyDataList,
|
|||||||
|
|
||||||
let dt_start: DateTime<Local> = Local::now();
|
let dt_start: DateTime<Local> = Local::now();
|
||||||
|
|
||||||
trace!(target: "csv-test",
|
trace!(target: "advotracker",
|
||||||
process = "policy.validation",
|
process = ?res,
|
||||||
state = "started",
|
state = ?state,
|
||||||
policy_number = ?policy_number,
|
policy_number = ?policy_number,
|
||||||
policy_list = ?policy_list.name,
|
policy_list = ?policy_list.name,
|
||||||
elements = ?policy_list.policy_data.len(),
|
elements = ?policy_list.policy_data.len(),
|
||||||
@@ -37,13 +37,13 @@ pub fn is_valid(policy_number: &usize, policy_list: &PolicyDataList,
|
|||||||
policy_number, policy_code);
|
policy_number, policy_code);
|
||||||
info!("policy-check => {} ({:?})", policy_number, policy_code);
|
info!("policy-check => {} ({:?})", policy_number, policy_code);
|
||||||
result = true;
|
result = true;
|
||||||
trace!(target: "csv-test",
|
trace!(target: "advotracker",
|
||||||
policy_number = ?policy_number,
|
policy_number = ?policy_number,
|
||||||
validation = "success",
|
validation = "success",
|
||||||
policy_code = ?policy_code);
|
policy_code = ?policy_code);
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
println!("Noop! Number isn't valid!");
|
println!("Noop! Number isn't valid!");
|
||||||
info!("policy-check => {}", policy_number);
|
info!("policy-check => {}", policy_number);
|
||||||
trace!(target: "csv-test",
|
trace!(target: "csv-test",
|
||||||
policy_number = ?policy_number,
|
policy_number = ?policy_number,
|
||||||
|
|||||||
@@ -5,11 +5,6 @@
|
|||||||
* SPDX-License-Identifier: (0BSD or MIT)
|
* SPDX-License-Identifier: (0BSD or MIT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use dotenv::dotenv;
|
|
||||||
use orbtk::prelude::*;
|
|
||||||
use serde::Deserialize;
|
|
||||||
use std::{env, process};
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use tracing::{debug, trace};
|
use tracing::{debug, trace};
|
||||||
|
|
||||||
use crate::services::imports::allianzdirectcall::import;
|
use crate::services::imports::allianzdirectcall::import;
|
||||||
@@ -30,6 +25,7 @@ pub enum Action {
|
|||||||
ParseEntry(Entity),
|
ParseEntry(Entity),
|
||||||
RemoveFocus(Entity),
|
RemoveFocus(Entity),
|
||||||
SetEntry(Entity),
|
SetEntry(Entity),
|
||||||
|
SetVisibility(Entity),
|
||||||
TextChanged(Entity, usize),
|
TextChanged(Entity, usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,8 +39,8 @@ struct Environment {
|
|||||||
#[derive(Default, AsAny)]
|
#[derive(Default, AsAny)]
|
||||||
pub struct PolicyCheckState {
|
pub struct PolicyCheckState {
|
||||||
action: Option<Action>,
|
action: Option<Action>,
|
||||||
|
label_result_text_block: Entity,
|
||||||
last_focused: Option<Entity>,
|
last_focused: Option<Entity>,
|
||||||
pub text_box: Entity,
|
|
||||||
menu_button: Entity,
|
menu_button: Entity,
|
||||||
policy_number_valid: bool,
|
policy_number_valid: bool,
|
||||||
policy_number_count: usize,
|
policy_number_count: usize,
|
||||||
@@ -53,6 +49,7 @@ pub struct PolicyCheckState {
|
|||||||
|
|
||||||
impl GlobalState for PolicyCheckState {}
|
impl GlobalState for PolicyCheckState {}
|
||||||
|
|
||||||
|
/// method definitions, that react on any given state change inside the view
|
||||||
impl PolicyCheckState {
|
impl PolicyCheckState {
|
||||||
/// Sets a new action.
|
/// Sets a new action.
|
||||||
pub fn action(&mut self, action: Action) {
|
pub fn action(&mut self, action: Action) {
|
||||||
@@ -80,12 +77,7 @@ impl PolicyCheckState {
|
|||||||
|
|
||||||
let mut policy_numbers : HashMap<usize, PolicyCode> = HashMap::new();
|
let mut policy_numbers : HashMap<usize, PolicyCode> = HashMap::new();
|
||||||
|
|
||||||
//let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
// Wip: use cli parameter stored in viperus ...
|
||||||
let mut csv_import_path = String::from("POLLFNR_WOECHENTLICH.txt");
|
|
||||||
println!("Importing from: {:?}", csv_import_path);
|
|
||||||
match import(&mut csv_import_path, &mut policy_data,
|
|
||||||
&mut policy_numbers, &lang) {
|
|
||||||
Ok(count) => {
|
|
||||||
self.policy_number_count = count;
|
self.policy_number_count = count;
|
||||||
println!("Imported {:?} records", self.policy_number_count);
|
println!("Imported {:?} records", self.policy_number_count);
|
||||||
}
|
}
|
||||||
@@ -97,19 +89,18 @@ impl PolicyCheckState {
|
|||||||
|
|
||||||
// move results to the golbal accessible instance
|
// move results to the golbal accessible instance
|
||||||
self.policy_numbers = policy_numbers;
|
self.policy_numbers = policy_numbers;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clear text in text box.
|
/// Clear text in text box.
|
||||||
pub fn clear_entry(&mut self, text_box: Entity, ctx: &mut Context) {
|
pub fn clear_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) {
|
||||||
let mut text_box = TextBox::get(ctx.get_widget(text_box));
|
let mut text_box = TextBox::get(ctx.get_widget(text_box));
|
||||||
let text = text_box.text_mut();
|
let text = text_box.text_mut();
|
||||||
println!("reset {}", text);
|
println!("reset {}", text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Open menu.
|
/// Open menu.
|
||||||
pub fn open_menu(&mut self, text_block: Entity, ctx: &mut Context) {
|
pub fn open_menu(&mut self, text_block: Entity, ctx: &mut Context<'_>) {
|
||||||
let mut text_block = TextBlock::get(ctx.get_widget(text_block));
|
let mut text_block = TextBlock::get(ctx.get_widget(text_block));
|
||||||
let text = text_block.text_mut();
|
let text = text_block.text_mut();
|
||||||
println!("Menu text: {}", text);
|
println!("Menu text: {}", text);
|
||||||
@@ -120,6 +111,8 @@ impl PolicyCheckState {
|
|||||||
let policy_string = ctx.get_widget(policy_check_policy_number).get::<String16>("text").as_string();
|
let policy_string = ctx.get_widget(policy_check_policy_number).get::<String16>("text").as_string();
|
||||||
let policy_number_length = policy_string.len();
|
let policy_number_length = policy_string.len();
|
||||||
|
|
||||||
|
trace!(target: "advotracker", state = "parsing", policy_number = ?policy_string);
|
||||||
|
|
||||||
// Parse policy code: "AS-123456789"
|
// Parse policy code: "AS-123456789"
|
||||||
// DION VERS POLLFNR
|
// DION VERS POLLFNR
|
||||||
// 1 AS 1515735810
|
// 1 AS 1515735810
|
||||||
@@ -156,60 +149,42 @@ impl PolicyCheckState {
|
|||||||
_ => {
|
_ => {
|
||||||
//let res = t!("policy.validation.failed", lang);
|
//let res = t!("policy.validation.failed", lang);
|
||||||
//println!("{:?}", res);
|
//println!("{:?}", res);
|
||||||
println!("Nuup! Number isn't valid!");
|
trace!(target: "advotracker", state = "failed",
|
||||||
|
policy_number = ?p);
|
||||||
|
println!("Noop! Number isn't valid!");
|
||||||
|
result_wrapper.set_enabled(true);
|
||||||
|
result_wrapper.set_text("noop, ungültig!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
trace!(target: "advotracker", state = "error", error_type = "invalid type");
|
||||||
println!("invalid: {}", e);
|
println!("invalid: {}", e);
|
||||||
// Feedback
|
// Feedback
|
||||||
println!("Please enter an integer!");
|
println!("Please enter an integer!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//ctx.get_widget(text_box).set("policy_number_valid", true);
|
|
||||||
//ctx.get_widget(policy_check_policy_number).set("policy_check_result", true);
|
|
||||||
//TextBox::get(ctx.child("policy_check_result")).set_foreground(colors::LINK_WATER_COLOR);
|
|
||||||
}
|
}
|
||||||
if policy_number_length < 10 {
|
if policy_number_length < 10 {
|
||||||
println!("Policy number is to short!");
|
println!("Policy number is to short!");
|
||||||
|
let mut text_block_wrapper: TextBlockCtx<'_> = text_block(ctx.child("policy_check_result"));
|
||||||
|
text_block_wrapper.set_enabled(true);
|
||||||
|
text_block_wrapper.set_text("zu kurz!");
|
||||||
|
//ctx.get_widget(policy_check_policy_number).set("policy_check_result", true);
|
||||||
//ctx.child(ID_POLICY_CHECK_POLICY_NUMBER).set("text", String::from(""));
|
//ctx.child(ID_POLICY_CHECK_POLICY_NUMBER).set("text", String::from(""));
|
||||||
|
|
||||||
//ctx.child(ID_POLICY_CHECK_RESULT).set("text", String::from("Policy number is to short!"));
|
|
||||||
// ctx.get_widget(policy_check_policy_number).set("policy_number_valid", true);
|
|
||||||
//policy_check_view(ctx.widget())
|
|
||||||
// .set_policy_check_result(String16::from(format!("Given Number is to small: {}", policy_number_length)));
|
|
||||||
//let mut text_box = text_box(ctx.get_widget(Entity));
|
|
||||||
//let text = text_box.text;
|
|
||||||
//println!("submitting {}", text);
|
|
||||||
//text.clear();
|
|
||||||
// TextBock: set "visibility", "text"
|
|
||||||
//policycheck_view(ctx.widget())
|
|
||||||
// .list_mut()
|
|
||||||
// .push(format!("Item {}", len + 1));
|
|
||||||
//ctx.child("items").set::<usize>("blub", len + 1);
|
|
||||||
//TextBox::get(ctx.child("policy_check_result")).set_foreground("#ffffff");
|
|
||||||
//text_block::get(ctx.child(policy_check_result)).set_background("#5b0f22");
|
|
||||||
//policy_check_result(ctx.child("items")).set_count(len + 1);
|
|
||||||
}
|
}
|
||||||
if policy_number_length > 10 {
|
if policy_number_length > 10 {
|
||||||
println!("Policy number is to big!");
|
println!("Policy number is to big!");
|
||||||
//TextBox::get(ctx.child("text_box")).set_foreground("#ffffff");
|
let mut text_block_wrapper: TextBlockCtx<'_> = text_block(ctx.child("policy_check_result"));
|
||||||
//TextBox::get(ctx.child("text_box")).set_background("#5b0f22");
|
text_block_wrapper.set_enabled(true);
|
||||||
|
text_block_wrapper.set_text("zu lang!");
|
||||||
}
|
}
|
||||||
|
|
||||||
//if let policy_number = policy_check_policy_number.text() {
|
|
||||||
// match policy_number {
|
|
||||||
// _ => {
|
|
||||||
// println!("policynumber: {} is valid!", policy_number);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If TextBox 'policy_check_policy_number' is empty, disable button "clear"
|
/// If TextBox 'policy_check_policy_number' is empty, disable button "clear"
|
||||||
/// otherwise enabled it.
|
/// otherwise enabled it.
|
||||||
// fn set_check_button(&self, text_box: Entity, ctx: &mut Context) {
|
// fn set_policy_check_clear_button(&self, policy_check_policy_number: Entity, ctx: &mut Context<' >) {
|
||||||
// if ctx.get_widget(clear_button).get::<String>("policy_check_policy_number").is_empty() {
|
// if ctx.get_widget(clear_button).get::<String>("policy_check_policy_number").is_empty() {
|
||||||
// ctx.get_widget(self.policy_check_clear_button).set("enabled", false);
|
// ctx.get_widget(self.policy_check_clear_button).set("enabled", false);
|
||||||
// } else {
|
// } else {
|
||||||
@@ -220,10 +195,17 @@ impl PolicyCheckState {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
/// Change status of given text box to edit mode.
|
/// Change status of given text box to edit mode.
|
||||||
fn set_entry(&self, text_box: Entity, ctx: &mut Context) {
|
fn set_entry(&self, policy_check_policy_number: Entity, ctx: &mut Context<'_>) {
|
||||||
if *ctx.get_widget(text_box).get::<bool>("focused") {
|
if *ctx.get_widget(policy_check_policy_number).get::<bool>("focused") {
|
||||||
ctx.get_widget(text_box).set("enabled", false);
|
//let mut my_ctx: WidgetContainer<'_> = ctx.widget();
|
||||||
ctx.push_event_by_window(FocusEvent::RemoveFocus(text_box));
|
//let mut child: WidgetContainer<'_> = ctx.get_widget(policy_check_policy_number);
|
||||||
|
//ctx.get_widget(policy_check_policy_number).set("enabled", true);
|
||||||
|
let mut text_box_wrapper: TextBoxCtx<'_> = text_box(ctx.child("policy_check_policy_number"));
|
||||||
|
//ctx.push_event_by_window(FocusEvent::RemoveFocus(policy_check_policy_number));
|
||||||
|
text_box_wrapper.set_visibility( Visibility::Visible);
|
||||||
|
text_box_wrapper.set_enabled(true);
|
||||||
|
text_box_wrapper.set_text("");
|
||||||
|
text_box_wrapper.set_water_mark("Neue Eingabe ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,39 +213,89 @@ impl PolicyCheckState {
|
|||||||
ctx.push_event_by_window(FocusEvent::RemoveFocus(old_focused_element));
|
ctx.push_event_by_window(FocusEvent::RemoveFocus(old_focused_element));
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.get_widget(text_box).set("enabled", true);
|
}
|
||||||
|
|
||||||
// select all
|
/// Change visibility of the result label
|
||||||
ctx.get_widget(text_box)
|
fn set_visibility(&self, entity: Entity, ctx: &mut Context<'_>) {
|
||||||
.get_mut::<TextSelection>("text_selection")
|
if ctx.get_widget(entity).get::<String16>("text").is_empty() {
|
||||||
.start_index = 0;
|
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_visibility(Visibility::Visible);
|
||||||
ctx.get_widget(text_box)
|
} else {
|
||||||
.get_mut::<TextSelection>("text_selection")
|
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_visibility(Visibility::Collapsed);
|
||||||
.length = ctx.get_widget(text_box).get::<String>("policy_number").len();
|
//ctx.get_widget(self.policy_check_label_policy_number).set("enabled", false);
|
||||||
ctx.push_event_by_window(FocusEvent::RequestFocus(text_box));
|
}
|
||||||
|
|
||||||
|
ctx.get_widget(self.label_result_text_block).update_theme_by_state(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update count of elements in the policy data list.
|
||||||
|
fn update_data_count(&self, ctx: &mut Context<'_>) {
|
||||||
|
// old api syntax
|
||||||
|
let data_list_count = ctx.widget().get::<PolicyDataList>(PROP_POLICY_DATA_LIST).len();
|
||||||
|
ctx.widget().set(PROP_POLICY_DATA_COUNT, data_list_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// upported states for our view
|
||||||
impl State for PolicyCheckState {
|
impl State for PolicyCheckState {
|
||||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
|
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||||
// self.button = ctx
|
self.menu_button = ctx
|
||||||
// .entity_of_child(ID_POLICY_CHECK_MENU_BUTTON)
|
.entity_of_child(ID_POLICY_CHECK_MENU_BUTTON)
|
||||||
// .expect("PolicyCheckState.init: Can't find child 'Menu button'.");
|
.expect("PolicyCheckState.init: Can't find entity id defined as resource 'ID_POLICY_CHECK_POLICY_MENU_BUTTON'.");
|
||||||
self.text_box = ctx
|
// self.policy_number_text_box = ctx
|
||||||
.entity_of_child(ID_POLICY_CHECK_POLICY_NUMBER)
|
// .entity_of_child(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||||
.expect("PolicyCheckState.init: Can't find child 'Text Box'.");
|
// .expect("PolicyCheckState.init: Can't find entity id defined as resource 'ID_POLICY_CHECK_POLICY_NUMBER'.");
|
||||||
// self.text_block = ctx
|
|
||||||
// .entity_of_child(ID_POLICY_CHECK_RESULT)
|
|
||||||
// .expect("PolicyCheckState.init: Can't find child 'Text Block'.");
|
|
||||||
|
|
||||||
|
// import data
|
||||||
|
// WIP: for now, only import once per session
|
||||||
|
if self.policy_data_count == 0 {
|
||||||
|
match self.create_hashmap() {
|
||||||
|
Ok(()) => {
|
||||||
|
//let res = t!("policy.hashmap.success", lang);
|
||||||
|
//println!("{:?}", res);
|
||||||
|
info!("hashmap has: {:?} entries", self.policy_data_count);
|
||||||
|
trace!(target: "advotracker",
|
||||||
|
hashmap_status = "new import",
|
||||||
|
hashmap_entries = ?self.policy_data_count);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
// let res = t!("policy.hashmap.failed", lang);
|
||||||
|
// println
|
||||||
|
// !("{:?}", res);
|
||||||
|
error!("Creation of a hashmap failed!");
|
||||||
|
trace!(target: "advotracker", hashmap_status = "failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println!("Already imported {} records.", self.policy_data_count);
|
||||||
|
trace!(target: "advotracker",
|
||||||
|
hashmap_status = "consume",
|
||||||
|
hashmap_entries = ?self.policy_data_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
// // 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
|
||||||
|
// // app directory name. The directory location is OS dependant
|
||||||
|
// // (Windows: AppData, Unix: XDG_CONFIG_HOME, MacOS: $HOME/Library/Preferences).
|
||||||
|
// // The filename is taken from the propertey PROP_ADVOTRACKER (default: 'advotracker'.ron).
|
||||||
|
// if let Ok(policy_data) = registry
|
||||||
|
// .get::<Settings>("settings")
|
||||||
|
// .load::<PolicyDataList>(PROP_ADVOTRACKER)
|
||||||
|
// {
|
||||||
|
// ctx.widget().set(PROP_ADVOTRACKER, policy_data);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// number of elements in the restored policy data
|
||||||
|
//policy_data_count = policy_data.len().clone;
|
||||||
|
//self.update_data_count(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context) {
|
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
|
||||||
// clear focus on focus moved
|
// clear focus on focus moved
|
||||||
if self.last_focused != ctx.window().get::<Global>("global").focused_widget {
|
if self.last_focused != ctx.window().get::<Global>("global").focused_widget {
|
||||||
if let Some(last_focused) = self.last_focused {
|
if let Some(last_focused) = self.last_focused {
|
||||||
ctx.get_widget(last_focused).set("focused", false);
|
ctx.get_widget(last_focused).set("focused", false);
|
||||||
|
// widget is unvisible, but takes space to be considered
|
||||||
ctx.get_widget(last_focused)
|
ctx.get_widget(last_focused)
|
||||||
.set("visibility", Visibility::Collapsed);
|
.set("visibility", Visibility::Collapsed);
|
||||||
}
|
}
|
||||||
@@ -271,27 +303,35 @@ impl State for PolicyCheckState {
|
|||||||
|
|
||||||
if let Some(action) = self.action {
|
if let Some(action) = self.action {
|
||||||
match action {
|
match action {
|
||||||
Action::ClearEntry(text_box) => {
|
Action::ClearEntry(policy_check_policy_number) => {
|
||||||
self.clear_entry(text_box, ctx);
|
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
||||||
}
|
}
|
||||||
Action::InputTextChanged(text_box) => {
|
|
||||||
//self.set_check_button(text_box, ctx);
|
Action::InputTextChanged(entity) => {
|
||||||
|
//println!("entry changed: {}", text_box(ctx.get_widget(entity)).text());
|
||||||
|
//self.set_check_button(policy_check_label_policy_number, ctx);
|
||||||
|
self.set_visibility(entity, ctx);
|
||||||
}
|
}
|
||||||
Action::OpenMenu(text_block) => {
|
Action::OpenMenu(text_block) => {
|
||||||
self.open_menu(text_block, ctx);
|
self.open_menu(text_block, ctx);
|
||||||
}
|
}
|
||||||
Action::ParseEntry(text_box) => {
|
Action::ParseEntry(text_box) => {
|
||||||
self.parse_entry(text_box, ctx);
|
self.parse_entry(text_box, ctx);
|
||||||
|
ctx.get_widget(text_box).get::<String16>("text").as_string();
|
||||||
//self.parse_entry(text_box, &mut policy_numbers,
|
//self.parse_entry(text_box, &mut policy_numbers,
|
||||||
// &lang, ctx);
|
// &lang, ctx);
|
||||||
}
|
}
|
||||||
Action::RemoveFocus(text_box) => {
|
Action::RemoveFocus(policy_check_policy_number) => {
|
||||||
ctx.get_widget(text_box).set("enabled", false);
|
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
||||||
ctx.push_event_by_window(FocusEvent::RemoveFocus(text_box));
|
ctx.push_event_by_window(FocusEvent::RemoveFocus(policy_check_policy_number));
|
||||||
}
|
}
|
||||||
Action::SetEntry(text_box) => {
|
Action::SetEntry(policy_check_policy_number) => {
|
||||||
self.last_focused = Some(text_box);
|
//self.last_focused = Some();
|
||||||
self.set_entry(text_box, ctx);
|
self.set_entry(policy_check_policy_number, ctx);
|
||||||
|
}
|
||||||
|
Action::SetVisibility(entity) => {
|
||||||
|
//text_block(ctx.child(entity).set_visibility(Visibility::Visible));
|
||||||
|
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_visibility(Visibility::Collapsed);
|
||||||
}
|
}
|
||||||
Action::TextChanged(entity, _index) => {
|
Action::TextChanged(entity, _index) => {
|
||||||
self.set_entry(entity, ctx);
|
self.set_entry(entity, ctx);
|
||||||
@@ -300,4 +340,16 @@ impl State for PolicyCheckState {
|
|||||||
}
|
}
|
||||||
self.action = None;
|
self.action = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_post_layout(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||||
|
let string_result = "Prüfungsergebnis:".to_string();
|
||||||
|
//string_result = format!("{} {:?}", string_result, self.??;
|
||||||
|
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_text(string_result);
|
||||||
|
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_visibility(Visibility::Collapsed);
|
||||||
|
|
||||||
|
let mut string_data_count = "Prüflisten-Elemente:".to_string();
|
||||||
|
string_data_count = format!("{} {:?}", string_data_count, self.policy_numbers.len());
|
||||||
|
|
||||||
|
text_block(ctx.child(ID_POLICY_DATA_COUNT_BLOCK)).set_text(string_data_count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,17 +17,18 @@ pub static CLASS_SEPERATOR: &str = "seperator";
|
|||||||
// Widget IDs (DCES: Entity[id] => [Component1, .. , Component<n>] -> data or state)
|
// Widget IDs (DCES: Entity[id] => [Component1, .. , Component<n>] -> data or state)
|
||||||
pub static ID_POLICY_CHECK_FORM: &str = "policy_check_form";
|
pub static ID_POLICY_CHECK_FORM: &str = "policy_check_form";
|
||||||
pub static ID_POLICY_CHECK_HEADER: &str = "policy_check_header";
|
pub static ID_POLICY_CHECK_HEADER: &str = "policy_check_header";
|
||||||
//pub static ID_POLICY_CHECK_ITEMS_WIDGET: &str = "policy_check_items_widget";
|
pub static ID_POLICY_CHECK_ITEMS_WIDGET: &str = "policy_check_items_widget";
|
||||||
pub static ID_POLICY_CHECK_CLEAR_BUTTON: &str = "policy_check_clear_button";
|
pub static ID_POLICY_CHECK_CLEAR_BUTTON: &str = "policy_check_clear_button";
|
||||||
pub static ID_POLICY_CHECK_MENU_BUTTON: &str = "policy_check_menu_button";
|
pub static ID_POLICY_CHECK_MENU_BUTTON: &str = "policy_check_menu_button";
|
||||||
pub static ID_POLICY_CHECK_LABEL_POLICY_NUMBER: &str = "policy_check_label_policy_number";
|
pub static ID_POLICY_CHECK_LABEL_POLICY_NUMBER: &str = "policy_check_label_policy_number";
|
||||||
pub static ID_POLICY_CHECK_LABEL_RESULT: &str = "policy_check_label_result";
|
pub static ID_POLICY_CHECK_LABEL_RESULT: &str = "policy_check_label_result";
|
||||||
pub static ID_POLICY_CHECK_MENU_TEXT_BLOCK: &str = "policy_check_menu_text_block";
|
pub static ID_POLICY_CHECK_MENU_TEXT_BLOCK: &str = "policy_check_menu_text_block";
|
||||||
pub static ID_POLICY_CHECK_RESULT: &str = "policy_check_result";
|
|
||||||
pub static ID_POLICY_CHECK_POLICY_NUMBER: &str = "policy_check_policy_number";
|
pub static ID_POLICY_CHECK_POLICY_NUMBER: &str = "policy_check_policy_number";
|
||||||
|
pub static ID_POLICY_CHECK_RESULT: &str = "policy_check_result";
|
||||||
pub static ID_POLICY_CHECK_WIDGET: &str = "policy_check_widget";
|
pub static ID_POLICY_CHECK_WIDGET: &str = "policy_check_widget";
|
||||||
|
|
||||||
pub static ID_POLICY_DATA_ADD_BUTTON: &str = "policy_data_add_button";
|
pub static ID_POLICY_DATA_ADD_BUTTON: &str = "policy_data_add_button";
|
||||||
|
pub static ID_POLICY_DATA_COUNT_BLOCK: &str = "policy_data_count_block";
|
||||||
pub static ID_POLICY_DATA_ITEMS_WIDGET: &str = "policy_data_items_widget";
|
pub static ID_POLICY_DATA_ITEMS_WIDGET: &str = "policy_data_items_widget";
|
||||||
//pub static ID_POLICY_DATA_TEXT_BOX: &str = "policy_data_text_box";
|
//pub static ID_POLICY_DATA_TEXT_BOX: &str = "policy_data_text_box";
|
||||||
pub static ID_POLICY_DATA_DATE_INSERTED: &str = "policy_data_date_inserted";
|
pub static ID_POLICY_DATA_DATE_INSERTED: &str = "policy_data_date_inserted";
|
||||||
@@ -43,8 +44,8 @@ pub static ID_POLICY_LIST_ITEMS_WIDGET: &str = "policy_list_items_widget";
|
|||||||
//pub static ID_POLICY_LIST_TEXT_BLOCK: &str = "policy_list_text_block";
|
//pub static ID_POLICY_LIST_TEXT_BLOCK: &str = "policy_list_text_block";
|
||||||
|
|
||||||
// Component Values (Properties)
|
// Component Values (Properties)
|
||||||
|
pub static PROP_ADVOTRACKER: &str = "advotracker";
|
||||||
pub static PROP_POLICY_CHECK: &str = "policy_check";
|
pub static PROP_POLICY_CHECK: &str = "policy_check";
|
||||||
pub static PROP_POLICY_CHECK_LIST: &str = "policy_check_list";
|
|
||||||
|
|
||||||
pub static PROP_POLICY_DATA_LIST: &str = "policy_data_list";
|
pub static PROP_POLICY_DATA_LIST: &str = "policy_data_list";
|
||||||
pub static PROP_POLICY_DATA_COUNT: &str = "policy_data_count";
|
pub static PROP_POLICY_DATA_COUNT: &str = "policy_data_count";
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
|
use orbtk::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// An enumeration of valid policy codes.
|
/// An enumeration of valid policy codes.
|
||||||
@@ -144,10 +145,14 @@ pub struct HarmType {
|
|||||||
pub struct PolicyCheck {
|
pub struct PolicyCheck {
|
||||||
/// Versicherungsschein-Prüfnummer
|
/// Versicherungsschein-Prüfnummer
|
||||||
pub policy_check_number: String,
|
pub policy_check_number: String,
|
||||||
|
/// Referenz zum Versicherungsschein-Typ
|
||||||
|
pub dion: u8,
|
||||||
|
/// Referenz zum Versicherungsschein-Typ
|
||||||
|
pub policy_code: PolicyCode,
|
||||||
/// Referenz zur Versicherungsschein-Nummer
|
/// Referenz zur Versicherungsschein-Nummer
|
||||||
pub policy_number: String,
|
pub policy_number: usize,
|
||||||
/// Validitätsergebnis
|
/// Validitätsergebnis
|
||||||
pub policy_number_valid: bool
|
pub policy_number_status: Status
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PolicyCheck {
|
impl PolicyCheck {
|
||||||
@@ -335,3 +340,7 @@ pub struct AllianzPolicyNumber {
|
|||||||
// pub struct AllianzPolicyNumberList {
|
// pub struct AllianzPolicyNumberList {
|
||||||
// records: Vec<AllianzPolicyNumber>
|
// records: Vec<AllianzPolicyNumber>
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
into_property_source!(PolicyCheck);
|
||||||
|
into_property_source!(PolicyDataList);
|
||||||
|
into_property_source!(PolicyList);
|
||||||
|
|||||||
@@ -5,10 +5,14 @@
|
|||||||
* SPDX-License-Identifier: (0BSD or MIT)
|
* SPDX-License-Identifier: (0BSD or MIT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//#[macro_use]
|
||||||
|
//extern crate lazy_static;
|
||||||
|
|
||||||
//use chrono::{Local, DateTime};
|
//use chrono::{Local, DateTime};
|
||||||
//use serde::{Deserialize, Serialize};
|
//use serde::{Deserialize, Serialize};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{env, process};
|
use std::env;
|
||||||
|
//use std::process;
|
||||||
//use std::{error::Error, process};
|
//use std::{error::Error, process};
|
||||||
//use std::collections::HashMap;
|
//use std::collections::HashMap;
|
||||||
use tracing::{debug, trace, Level};
|
use tracing::{debug, trace, Level};
|
||||||
@@ -32,8 +36,8 @@ struct Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//#[cfg(feature = "light-theme")]
|
//#[cfg(feature = "light-theme")]
|
||||||
//static STYLESHEET: &'static str = include_str!("../resources/stylesheets/advotracker.css");
|
static STYLESHEET: &'static str = include_str!("../resources/stylesheets/advotracker.css");
|
||||||
static STYLESHEET: &'static str = include_str!("../resources/stylesheets/policyholder-check.css");
|
//static STYLESHEET: &'static str = include_str!("../resources/stylesheets/policyholder-check.css");
|
||||||
|
|
||||||
fn get_theme() -> ThemeValue {
|
fn get_theme() -> ThemeValue {
|
||||||
//ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
//ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
||||||
@@ -51,8 +55,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
use viperus::Viperus;
|
use viperus::Viperus;
|
||||||
|
|
||||||
//use advotracker::callbacks::policy_check::is_valid;
|
//use advotracker::callbacks::policy_check::is_valid;
|
||||||
use advotracker::services::imports::allianzdirectcall::*;
|
//use advotracker::data::structures::{PolicyCode, PolicyDataList, PolicyList};
|
||||||
use advotracker::data::structures::{PolicyCode, PolicyDataList, PolicyList};
|
// WIP: can't push pointer by value to widget, call import in widget callback for now
|
||||||
|
//use advotracker::services::imports::allianzdirectcall::*;
|
||||||
|
|
||||||
//static DEFAULT_FILTER: &str = concat!(module_path!(), "=", "trace");
|
//static DEFAULT_FILTER: &str = concat!(module_path!(), "=", "trace");
|
||||||
|
|
||||||
@@ -86,6 +91,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// initialize viperus structure
|
// initialize viperus structure
|
||||||
let mut viperus = Viperus::new();
|
let mut viperus = Viperus::new();
|
||||||
|
|
||||||
|
// lazy_static! {
|
||||||
|
// static ref VIPERUS: Viperus + 'static = { let mut viperus = Viperus::new(); };
|
||||||
|
// static ref VIPERUS_COUNT: usize = VIPERUS.len();
|
||||||
|
// }
|
||||||
|
// lazy_static! {
|
||||||
|
// static ref HASHMAP: HashMap<usize, PolicyCode> = {
|
||||||
|
// let mut policy_numbers = HashMap::new();
|
||||||
|
// policy_numbers
|
||||||
|
// }
|
||||||
|
// static ref COUNT: usize = HASHMAP.len();
|
||||||
|
// println!("The map has {} entries.", *COUNT);
|
||||||
|
// }
|
||||||
|
|
||||||
// parse commandline arguments
|
// parse commandline arguments
|
||||||
trace!(target: "csv-test", process = "parse.arguments", state = "started");
|
trace!(target: "csv-test", process = "parse.arguments", state = "started");
|
||||||
|
|
||||||
@@ -98,45 +116,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
trace!(target: "csv-test", process = "main", state = "started");
|
trace!(target: "csv-test", process = "main", state = "started");
|
||||||
|
|
||||||
// moved to callback: checkview_state.rs
|
// moved to callback: checkview_state.rs
|
||||||
// // 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");
|
|
||||||
// println!("Policy Data List {:?} ", policy_data.name);
|
|
||||||
|
|
||||||
// let mut policy_numbers : HashMap<usize, PolicyCode> = HashMap::new();
|
|
||||||
|
|
||||||
// let mut csv_import_path = viperus.get::<String>("import_file").unwrap();
|
|
||||||
// match import(&mut csv_import_path, &mut policy_data,
|
|
||||||
// &mut policy_numbers, &lang) {
|
|
||||||
// Ok(count) => {
|
|
||||||
// println!("Imported {:?} records", count);
|
|
||||||
// }
|
|
||||||
// Err(err) => {
|
|
||||||
// println!("error running Csv-Test: {}", err);
|
|
||||||
// process::exit(1);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// // test if policy_number is_valid
|
|
||||||
// let test_policy_number = VIPERUS.get::<i32>("test_policy_number").unwrap() as usize;
|
|
||||||
// trace!(target: "csv-test", test_policy_number = ?test_policy_number);
|
|
||||||
// match policy_numbers.get(&test_policy_number) {
|
|
||||||
// Some(&policy_code) => {
|
|
||||||
// let res = t!("policy.validation.success", lang);
|
|
||||||
// println!("{:?}", res);
|
|
||||||
// println!("policy_number: {} ({:?})",
|
|
||||||
// test_policy_number, policy_code);
|
|
||||||
// }
|
|
||||||
// _ => {
|
|
||||||
// let res = t!("policy.validation.failed", lang);
|
|
||||||
// println!("{:?}", res);
|
|
||||||
// //println!("Nuup! Number isn't valid!");
|
|
||||||
// },
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Application::from_name("rzerres.advotracker")
|
Application::from_name("rzerres.advotracker")
|
||||||
.window(move |ctx| {
|
.window(move |ctx| {
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
|||||||
|
|
||||||
let dt_start: DateTime<Local> = Local::now();
|
let dt_start: DateTime<Local> = Local::now();
|
||||||
|
|
||||||
|
trace!(target: "advotrackerd", process = "import", state = "started", date_start = ?dt_start.to_string());
|
||||||
|
|
||||||
// Note: slash syntax also workd on Windows!
|
// Note: slash syntax also workd on Windows!
|
||||||
let path = Path::new(p);
|
let path = Path::new(p);
|
||||||
|
|
||||||
@@ -42,7 +44,7 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
|||||||
let file = File::open(path)?;
|
let file = File::open(path)?;
|
||||||
trace!(target: "advotrackerd", extension = ?extension, file = ?file);
|
trace!(target: "advotrackerd", extension = ?extension, file = ?file);
|
||||||
|
|
||||||
// Build the CSV reader and iterate over each record.
|
// Build the CSV reader
|
||||||
let mut csv_reader = csv::ReaderBuilder::new()
|
let mut csv_reader = csv::ReaderBuilder::new()
|
||||||
.has_headers(true)
|
.has_headers(true)
|
||||||
.delimiter(b' ')
|
.delimiter(b' ')
|
||||||
@@ -55,15 +57,15 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
|||||||
trace!(target: "advotrackerd", header = ?headers);
|
trace!(target: "advotrackerd", header = ?headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
//for result in csv_reader.records() {
|
// Iterate over each record, deserialize und write to our structures
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
for result in csv_reader.deserialize() {
|
for result in csv_reader.deserialize() {
|
||||||
// The iterator yields Result<StringRecord, Error>, so we check the
|
// The iterator yields Result<StringRecord, Error>, so we check the
|
||||||
// error here.
|
// error here.
|
||||||
let record: PolicyData = result?;
|
let record: PolicyData = result?;
|
||||||
//let record: data::AllianzPolicyNumber = result?;
|
//if verbose > 3 {
|
||||||
// if debug ...
|
// println!("{:?}", record);
|
||||||
// println!("{:?}", record);
|
//}
|
||||||
|
|
||||||
// WIP: write to redis backend
|
// WIP: write to redis backend
|
||||||
// append the policy_number to the HashMap
|
// append the policy_number to the HashMap
|
||||||
@@ -82,22 +84,19 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
|||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
// Takes a reference and returns Option<&V>
|
// Takes a reference and returns Option<&V>
|
||||||
let test_policy_number : usize = 1511111111;
|
let my_policy_numbers : [usize; 2] = [1511111111, 9999999993];
|
||||||
match data_list.get(test_policy_number) {
|
assert_eq!(my_policy_numbers, [1511111111, 9999999993]);
|
||||||
Some(policy_code) => {
|
for p in &my_policy_numbers {
|
||||||
println!("Policy-Number {:?} {:?}",
|
match policy_numbers.get(&p) {
|
||||||
test_policy_number, policy_code);
|
Some(policy_code) => {
|
||||||
},
|
println!("Test: Policy-Number {:?} => Policy-Type {:?}, as expected!",
|
||||||
_ => println!("1. No number found!"),
|
p, policy_code);
|
||||||
|
},
|
||||||
|
_ => println!("Test: Policy-Number {:?} => not valid, can't dereference the Policy-Type as expected", p),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let test_policy_number_2 : usize = 9999999991;
|
trace!(target: "advotrackerd", process = "import", state = "finished", date_stop = ?dt_end.to_string());
|
||||||
match data_list.get(test_policy_number_2) {
|
|
||||||
Some(policy_code) => { println!("Policy-Number: {:?} {:?}",
|
|
||||||
test_policy_number, policy_code);
|
|
||||||
},
|
|
||||||
_ => println!("2. No number found!"),
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(count)
|
Ok(count)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,12 @@ widget!(MainView {
|
|||||||
// policy_data_list: PolicyDataList,
|
// policy_data_list: PolicyDataList,
|
||||||
// policylist_view: u32,
|
// policylist_view: u32,
|
||||||
// policydata_view: u32,
|
// policydata_view: u32,
|
||||||
// policydata_view: u32,
|
//policycheck_view: u32
|
||||||
policy_number_count: usize,
|
policycheck_view: PolicyCheck
|
||||||
policycheck_view: u32
|
|
||||||
});
|
});
|
||||||
|
|
||||||
impl Template for MainView {
|
impl Template for MainView {
|
||||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||||
let policycheck_view = PolicyCheckView::new()
|
let policycheck_view = PolicyCheckView::new()
|
||||||
//.policy_number_count(0)
|
//.policy_number_count(0)
|
||||||
//.policylist_view(id)
|
//.policylist_view(id)
|
||||||
@@ -41,8 +40,7 @@ impl Template for MainView {
|
|||||||
// .build(ctx);
|
// .build(ctx);
|
||||||
|
|
||||||
self.name("MainView")
|
self.name("MainView")
|
||||||
.policy_number_count(0)
|
.policycheck_view(PolicyCheck::default())
|
||||||
//.policycheck_view(PolicyCheck::default())
|
|
||||||
// //.policycheck_view(0)
|
// //.policycheck_view(0)
|
||||||
// .policydata_view(policydata_view.0)
|
// .policydata_view(policydata_view.0)
|
||||||
// //.policylist_view(PolicyList::default())
|
// //.policylist_view(PolicyList::default())
|
||||||
|
|||||||
@@ -14,43 +14,21 @@ use crate::{
|
|||||||
//policycheck_state::{Action, PolicyCheckState},
|
//policycheck_state::{Action, PolicyCheckState},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Macro that initializes the widget structures/variables for our view (essential!)
|
||||||
widget!(
|
widget!(
|
||||||
/// Dialog to enter a policy identifier/number.
|
/// Dialog to enter a policy identifier/number.
|
||||||
/// This identifier is checked agains a map of valid policy codes.
|
/// This identifier is checked agains a map of valid policy codes.
|
||||||
PolicyCheckView<PolicyCheckState> {
|
PolicyCheckView<PolicyCheckState> {
|
||||||
policy_check: PolicyCheck,
|
policy_check: PolicyCheck,
|
||||||
//policy_check_list: PolicyCheckList,
|
|
||||||
policy_check_title: String16,
|
policy_check_title: String16,
|
||||||
policy_check_number: String16,
|
policy_data_count: u32
|
||||||
policy_check_number_valid: bool,
|
|
||||||
policy_check_result: String16,
|
|
||||||
policy_data_count: u32,
|
|
||||||
//policylist_view: u32,
|
|
||||||
title: String
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// The template implementation for our View
|
||||||
impl Template for PolicyCheckView {
|
impl Template for PolicyCheckView {
|
||||||
fn template(self, id: Entity, ctx: &mut BuildContext)-> Self {
|
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||||
// collect the DCES elements of our 'policy check' view
|
|
||||||
// let items_widget = ItemsWidget::new()
|
|
||||||
// .id(ID_POLICY_CHECK_ITEMS_WIDGET)
|
|
||||||
// .v_align("start")
|
|
||||||
// .items_builder(move |ctx, index| {
|
|
||||||
// let mut title = "".to_string();
|
|
||||||
|
|
||||||
// if let Some(policy_check) = ctx
|
|
||||||
// .get_widget(id)
|
|
||||||
// .get::<PolicyCheckList>(PROP_POLICY_CHECK_LIST)
|
|
||||||
// .get(index)
|
|
||||||
// {
|
|
||||||
// title = policy_check.title.clone();
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .count((PROP_POLICY_DATA_COUNT, id))
|
|
||||||
// .build(ctx);
|
|
||||||
|
|
||||||
|
|
||||||
let policy_check_menu_text_block = TextBlock::new()
|
let policy_check_menu_text_block = TextBlock::new()
|
||||||
.foreground("#3b434a")
|
.foreground("#3b434a")
|
||||||
.text("Help Menu")
|
.text("Help Menu")
|
||||||
@@ -82,24 +60,21 @@ impl Template for PolicyCheckView {
|
|||||||
})
|
})
|
||||||
.build(ctx);
|
.build(ctx);
|
||||||
|
|
||||||
// let policy_check_text_box = TextBox::new()
|
|
||||||
// .id(ID_POLICY_CHECK_TEXT_BOX)
|
let policy_data_count_block = TextBlock::new()
|
||||||
// .attach(Grid::row(4))
|
.id(ID_POLICY_DATA_COUNT_BLOCK)
|
||||||
// .attach(Grid::row(0))
|
//.class(CLASS_TEXT_BLOCK)
|
||||||
// .attach(Grid::column(0))
|
.attach(Grid::row(2))
|
||||||
// .v_align("top")
|
.attach(Grid::column(0))
|
||||||
// .margin((4.0, 0.0, 0.0, 0.0))
|
.attach(Grid::column_span(3))
|
||||||
// .lost_focus_on_activation(false)
|
.margin((0., 0., 0., 16.))
|
||||||
// //.text(("policy_number", id))
|
.h_align("end")
|
||||||
// // .on_activate(move |ctx, entity| {
|
.v_align("end")
|
||||||
// // ctx.get_mut::<PolicyCheckState>(id)
|
.enabled(true)
|
||||||
// // .action(Action::ParseEntry(entity));
|
.min_width(250.0)
|
||||||
// // })
|
.min_height(45.0)
|
||||||
// // .on_changed(move |ctx, entity| {
|
.text("Anzahl Prüfsätze:")
|
||||||
// // ctx.get_mut::<PolicyCheckState>(id)
|
.build(ctx);
|
||||||
// // .action(Action::InputTextChanged(entity));
|
|
||||||
// // })
|
|
||||||
// .build(ctx);
|
|
||||||
|
|
||||||
// let policy_check_menu_container = Container::new()
|
// let policy_check_menu_container = Container::new()
|
||||||
// .id(ID_POLICY_CHECK_MENU_CONTAINER)
|
// .id(ID_POLICY_CHECK_MENU_CONTAINER)
|
||||||
@@ -129,253 +104,266 @@ impl Template for PolicyCheckView {
|
|||||||
|
|
||||||
// Starter page: check for valid policy number
|
// Starter page: check for valid policy number
|
||||||
self.name("PolicyCheckView")
|
self.name("PolicyCheckView")
|
||||||
//.policy_check_view(PolicyCheck::default())
|
// initialize struct consuming the derived default macro
|
||||||
|
.policy_check(PolicyCheck::default())
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.id(ID_POLICY_CHECK_WIDGET)
|
.id(ID_POLICY_CHECK_WIDGET)
|
||||||
.background("#fafafa")
|
.background("#fafafa")
|
||||||
.columns(
|
.columns(
|
||||||
Columns::new()
|
Columns::new()
|
||||||
.add(84.0)
|
.add(84.0)
|
||||||
.add("*")
|
.add("*")
|
||||||
.add(50.0)
|
.add(50.0)
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::new()
|
Rows::new()
|
||||||
// Top Bar
|
// Top Bar
|
||||||
.add("auto")
|
.add("auto")
|
||||||
.add(1.0)
|
.add(1.0)
|
||||||
// Content
|
// Content
|
||||||
.add("*")
|
.add("*")
|
||||||
.add(1.0)
|
.add(1.0)
|
||||||
// Bottom Bar
|
// Bottom Bar
|
||||||
.add(52.0)
|
.add(52.0)
|
||||||
/* .add("auto") */
|
/* .add("auto") */
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
// Header Bar
|
// Header Bar
|
||||||
.child(
|
.child(
|
||||||
//.border_color("transparent")
|
//.border_color("transparent")
|
||||||
Container::new()
|
Container::new()
|
||||||
//.class(CLASS_TOP_BAR)
|
//.class(CLASS_TOP_BAR)
|
||||||
.attach(Grid::row(0))
|
.attach(Grid::row(0))
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::column_span(3))
|
.attach(Grid::column_span(3))
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
//.class(CLASS_HEADER)
|
//.class(CLASS_HEADER)
|
||||||
.class("h1")
|
.class("h1")
|
||||||
//.class(".myheader")
|
//.class(".myheader")
|
||||||
.id(ID_POLICY_CHECK_HEADER)
|
.id(ID_POLICY_CHECK_HEADER)
|
||||||
//.font_size(24)
|
//.font_size(24)
|
||||||
//.font("Roboto Medium")
|
//.font("Roboto Medium")
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
.h_align("center")
|
.h_align("center")
|
||||||
.margin((32.0, 32.0, 32.0, 32.0))
|
.margin((32.0, 32.0, 32.0, 32.0))
|
||||||
.text("Validierung Versicherungsnummer")
|
.text("Validierung Versicherungsnummer")
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(policy_check_menu_button)
|
.child(policy_check_menu_button)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Container::new()
|
Container::new()
|
||||||
.class("separator")
|
.class("separator")
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(1))
|
||||||
.attach(Grid::column_span(3))
|
.attach(Grid::column_span(3))
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
// Policy Check Form
|
// Policy Check Form
|
||||||
.child(
|
.child(
|
||||||
Container::new()
|
Container::new()
|
||||||
//.class(CLASS_POLICY_CHECK_FORM)
|
//.class(CLASS_POLICY_CHECK_FORM)
|
||||||
.attach(Grid::row(2))
|
.attach(Grid::row(2))
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::column_span(3))
|
.attach(Grid::column_span(3))
|
||||||
.margin((16.0, 26.0, 26.0, 16.0))
|
.margin((16.0, 26.0, 26.0, 16.0))
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.id(ID_POLICY_CHECK_FORM)
|
.id(ID_POLICY_CHECK_FORM)
|
||||||
.columns(
|
.columns(
|
||||||
Columns::new()
|
Columns::new()
|
||||||
// Labels
|
// Labels
|
||||||
.add("220.0")
|
.add("220.0")
|
||||||
// Seperator
|
// Seperator
|
||||||
.add("16.0")
|
.add("16.0")
|
||||||
// Values
|
// Values
|
||||||
.add("100.0")
|
.add("100.0")
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::new()
|
Rows::new()
|
||||||
.add("64.0")
|
.add("64.0")
|
||||||
.add("64.0")
|
.add("64.0")
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
// Labels
|
// Labels
|
||||||
Stack::new()
|
Stack::new()
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(0))
|
.attach(Grid::row(0))
|
||||||
.orientation("vertical")
|
.orientation("vertical")
|
||||||
//.v_align("center")
|
//.v_align("center")
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.id(ID_POLICY_CHECK_LABEL_POLICY_NUMBER)
|
.id(ID_POLICY_CHECK_LABEL_POLICY_NUMBER)
|
||||||
//.class(CLASS_TEXT_BLOCK)
|
//.class(CLASS_TEXT_BLOCK)
|
||||||
.margin((0.0, 0.0, 16.0, 16.0))
|
.margin((0.0, 0.0, 16.0, 16.0))
|
||||||
.h_align("end")
|
.h_align("end")
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
.min_width(250.0)
|
.min_width(250.0)
|
||||||
.min_height(45.0)
|
.min_height(45.0)
|
||||||
//.size(250.0, 45.0)
|
//.size(250.0, 45.0)
|
||||||
.text("Versicherungsnummer:")
|
.text("Versicherungsnummer:")
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.id(ID_POLICY_CHECK_LABEL_RESULT)
|
.id(ID_POLICY_CHECK_LABEL_RESULT)
|
||||||
//.class(CLASS_TEXT_BLOCK)
|
.class(CLASS_TEXT_BLOCK)
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(2))
|
.attach(Grid::row(1))
|
||||||
.margin((0.0, 0.0, 16.0, 0.0))
|
.margin((0.0, 0.0, 16.0, 0.0))
|
||||||
.h_align("end")
|
.h_align("end")
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
.min_width(250.0)
|
.min_width(250.0)
|
||||||
//.min_size(120.0, 180.0)
|
.text("Result:")
|
||||||
//.text("Ergebnis:")
|
.build(ctx),
|
||||||
//.text("Result:")
|
)
|
||||||
.build(ctx),
|
.build(ctx)
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.child(
|
||||||
)
|
// Values
|
||||||
.child(
|
Stack::new()
|
||||||
// Values
|
.attach(Grid::column(1))
|
||||||
Stack::new()
|
.attach(Grid::row(0))
|
||||||
.attach(Grid::column(1))
|
//.attach(Grid::column_span(3))
|
||||||
.attach(Grid::row(0))
|
.orientation("vertical")
|
||||||
//.attach(Grid::column_span(3))
|
//.margin((16.0, 16.0, 16.0, 16.0))
|
||||||
.orientation("vertical")
|
//.child(policy_check_text_box)
|
||||||
//.margin((16.0, 16.0, 16.0, 16.0))
|
.child(
|
||||||
//.child(policy_check_text_box)
|
TextBox::new()
|
||||||
.child(
|
.id(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||||
TextBox::new()
|
.h_align("start")
|
||||||
.id(ID_POLICY_CHECK_POLICY_NUMBER)
|
.width(280.0)
|
||||||
.h_align("start")
|
.min_width(200.0)
|
||||||
.width(250.0)
|
.margin((0.0, 0.0, 0.0, 16.0))
|
||||||
.min_width(200.0)
|
.lost_focus_on_activation(false)
|
||||||
.margin((0.0, 0.0, 0.0, 16.0))
|
.water_mark("Nummer 10-stellig")
|
||||||
.lost_focus_on_activation(false)
|
.text("")
|
||||||
.water_mark("10-stellige Nummer (ohne 'AS')")
|
.on_activate(move |ctx, entity| {
|
||||||
.text("")
|
// Entity is entered/activated via Mouse/Keyboard
|
||||||
.on_activate(move |ctx, entity| {
|
println!("activation finished!");
|
||||||
// Entity is entered/activated via Mouse/Keyboard
|
ctx.get_mut::<PolicyCheckState>(id)
|
||||||
ctx.get_mut::<PolicyCheckState>(id)
|
.action(Action::ParseEntry(entity));
|
||||||
.action(Action::ParseEntry(entity));
|
})
|
||||||
})
|
.on_changed(move |ctx, entity| {
|
||||||
.on_changed(move |ctx, entity| {
|
// Element value has changed
|
||||||
// Element value has changed
|
ctx.get_mut::<PolicyCheckState>(id)
|
||||||
ctx.get_mut::<PolicyCheckState>(id)
|
.action(Action::InputTextChanged(entity));
|
||||||
.action(Action::InputTextChanged(entity));
|
ctx.get_mut::<PolicyCheckState>(id)
|
||||||
})
|
.action(Action::SetVisibility(entity));
|
||||||
.build(ctx),
|
//ctx.get_widget(policy_check_label_policy_number).set("visible");
|
||||||
)
|
// ctx.get_mut::<PolicyCheckState>(id)
|
||||||
|
// .action(Action::SetVisility(entity));
|
||||||
|
})
|
||||||
|
// .on_mouse_down | .on_mouse_move | .on_mouse_up (move |ctx, entity| {
|
||||||
|
// state(id, states).action(Action::AddItem);
|
||||||
|
// })
|
||||||
|
// .on_click(move |states, _| {
|
||||||
|
// state(id, states).action(Action::AddItem);
|
||||||
|
// true
|
||||||
|
// })
|
||||||
|
.build(ctx),
|
||||||
|
)
|
||||||
|
//.icon(material_icons_font_ttf::MD_ADD_CIRCLE)
|
||||||
// .child()
|
// .child()
|
||||||
// NumericBox::new()
|
// NumericBox::new()
|
||||||
// .id(ID_POLICY_CHECK_POLICY_NUMBER)
|
// .id(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||||
// .h_align("start")
|
// .h_align("start")
|
||||||
// .width(250.0)
|
// .width(250.0)
|
||||||
// .min(1000000000)
|
// .min(1000000000)
|
||||||
// .max(9999999999)
|
// .max(9999999999)
|
||||||
// .val(0)
|
// .val(0)
|
||||||
// .min_width(200.0)
|
// .min_width(200.0)
|
||||||
// .margin((0.0, 0.0, 0.0, 16.0))
|
// .margin((0.0, 0.0, 0.0, 16.0))
|
||||||
// //.lost_focus_on_activation(false)
|
// //.lost_focus_on_activation(false)
|
||||||
// //.water_mark("10-stellige Nummer (ohne 'AS')")
|
// //.water_mark("10-stellige Nummer (ohne 'AS')")
|
||||||
// //.text("")
|
// //.text("")
|
||||||
// //.on_activate(move |ctx, entity| {
|
// //.on_activate(move |ctx, entity| {
|
||||||
// // ctx.get_mut::<PolicyCheckState>(id)
|
// // ctx.get_mut::<PolicyCheckState>(id)
|
||||||
// // .action(Action::ParseEntry(entity));
|
// // .action(Action::ParseEntry(entity));
|
||||||
// //})
|
// //})
|
||||||
// // .on_changed(move |ctx, entity| {
|
// // .on_changed(move |ctx, entity| {
|
||||||
// // ctx.get_mut::<PolicyCheckState>(id)
|
// // ctx.get_mut::<PolicyCheckState>(id)
|
||||||
// // .action(Action::InputTextChanged(entity));
|
// // .action(Action::InputTextChanged(entity));
|
||||||
// // })
|
// // })
|
||||||
// // .on_update(move |ctx, entity| {
|
// // .on_update(move |ctx, entity| {
|
||||||
// // ctx.get_mut::<PolicyCheckState>(id)
|
// // ctx.get_mut::<PolicyCheckState>(id)
|
||||||
// // .action(Action::InputTextChanged(entity));
|
// // .action(Action::InputTextChanged(entity));
|
||||||
// // })
|
// // })
|
||||||
// .build(ctx),
|
// .build(ctx),
|
||||||
//)
|
//)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.id(ID_POLICY_CHECK_RESULT)
|
.id(ID_POLICY_CHECK_RESULT)
|
||||||
.attach(Grid::column(1))
|
//.id("policy_check_result")
|
||||||
.attach(Grid::row(1))
|
.h_align("start")
|
||||||
.h_align("start")
|
.attach(Grid::column(1))
|
||||||
.width(250.0)
|
.attach(Grid::row(1))
|
||||||
.min_width(200.0)
|
.text("")
|
||||||
.margin((0.0, 0.0, 0.0, 16.0))
|
.width(250.)
|
||||||
.text("")
|
|
||||||
//.margin((4.0, 0.0, 0.0, 0.0))
|
//.margin((4.0, 0.0, 0.0, 0.0))
|
||||||
//.lost_focus_on_activation(false)
|
//.lost_focus_on_activation(false)
|
||||||
// .on_activate(move |ctx, entity| {
|
// .on_activate(move |ctx, entity| {
|
||||||
// ctx.get_mut::<PolicyCheckState>(id)
|
// ctx.get_mut::<PolicyCheckState>(id)
|
||||||
// .action(Action::ParseEntry(entity));
|
// .action(Action::ParseEntry(entity));
|
||||||
// })
|
// })
|
||||||
// .on_changed(move |ctx, entity| {
|
// .on_changed(move |ctx, entity| {
|
||||||
// ctx.get_mut::<PolicyCheckState>(id)
|
// ctx.get_mut::<PolicyCheckState>(id)
|
||||||
// .action(Action::InputTextChanged(entity));
|
// .action(Action::InputTextChanged(entity));
|
||||||
// })
|
// })
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Container::new()
|
Container::new()
|
||||||
.class("separator")
|
.class("")
|
||||||
.attach(Grid::row(3))
|
.attach(Grid::row(3))
|
||||||
.attach(Grid::column_span(3))
|
.attach(Grid::column_span(3))
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
|
.child(policy_data_count_block)
|
||||||
// Bottom bar
|
// Bottom bar
|
||||||
.child(
|
.child(
|
||||||
Container::new()
|
Container::new()
|
||||||
.class(CLASS_BOTTOM_BAR)
|
.class(CLASS_BOTTOM_BAR)
|
||||||
.attach(Grid::row(4))
|
.attach(Grid::row(4))
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::column_span(3))
|
.attach(Grid::column_span(3))
|
||||||
.v_align("end")
|
.v_align("end")
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.element("logo_customer")
|
.element("logo_customer")
|
||||||
.margin((9.0, 16.0, 16.0, 9.0))
|
.margin((9.0, 16.0, 16.0, 9.0))
|
||||||
|
.attach(Grid::column(0))
|
||||||
|
.attach(Grid::row(1))
|
||||||
|
.h_align("start")
|
||||||
|
.v_align("center")
|
||||||
|
.child(
|
||||||
|
ImageWidget::new()
|
||||||
|
.image("resources/images/hiedemann_logo.png")
|
||||||
|
.build(ctx),
|
||||||
|
)
|
||||||
|
.build(ctx),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
Grid::new()
|
||||||
|
.element("logo_vendor")
|
||||||
|
.margin((9.0, 16.0, 16.0, 9.0))
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(5))
|
||||||
.h_align("start")
|
|
||||||
.v_align("center")
|
|
||||||
.child(
|
|
||||||
ImageWidget::new()
|
|
||||||
.image("resources/images/hiedemann_logo.png")
|
|
||||||
.build(ctx),
|
|
||||||
)
|
|
||||||
.build(ctx),
|
|
||||||
)
|
|
||||||
.child(
|
|
||||||
Grid::new()
|
|
||||||
.element("logo_vendor")
|
|
||||||
.margin((9.0, 16.0, 16.0, 9.0))
|
|
||||||
.attach(Grid::column(0))
|
|
||||||
.attach(Grid::row(4))
|
|
||||||
.h_align("end")
|
.h_align("end")
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
.child(
|
.child(
|
||||||
|
|||||||
Reference in New Issue
Block a user