policycheck: functionality cleanup
* sorting * string usage Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -1,11 +1,5 @@
|
|||||||
use orbtk::prelude::*;
|
use orbtk::prelude::*;
|
||||||
|
|
||||||
// use orbtk::theme::DEFAULT_THEME_CSS;
|
|
||||||
// use orbtk::theme::LIGHT_THEME_EXTENSION_CSS;
|
|
||||||
|
|
||||||
// //#[cfg(feature = "light-theme")]
|
|
||||||
// static WIDGET_EXT: &'static str = include_str!("../../resources/stylesheets/policyholder_check.css");
|
|
||||||
|
|
||||||
// fn get_theme() -> ThemeValue {
|
// fn get_theme() -> ThemeValue {
|
||||||
// //ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
// //ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
||||||
// ThemeValue::create_from_css(DEFAULT_THEME_CSS)
|
// ThemeValue::create_from_css(DEFAULT_THEME_CSS)
|
||||||
@@ -15,12 +9,8 @@ use orbtk::prelude::*;
|
|||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
enum Action {
|
enum Action {
|
||||||
//ClearText,
|
|
||||||
EntryActivated(Entity),
|
EntryActivated(Entity),
|
||||||
EntryChanged(Entity),
|
EntryChanged(Entity)
|
||||||
//ValueChanged(Entity),
|
|
||||||
//ValueOk,
|
|
||||||
//ValueNone,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(AsAny)]
|
#[derive(AsAny)]
|
||||||
@@ -58,23 +48,16 @@ impl State for MainViewState {
|
|||||||
// //ctx.widget().set("policynumber", background("#5b0f22"));
|
// //ctx.widget().set("policynumber", background("#5b0f22"));
|
||||||
//}
|
//}
|
||||||
Action::EntryActivated(entity) => {
|
Action::EntryActivated(entity) => {
|
||||||
let mut text_box = TextBox::get(ctx.get_widget(entity));
|
//let text = ctx.get_widget(entity).clone::<String>("text");
|
||||||
let text = text_box.text_mut();
|
let widget = ctx.get_widget(entity);
|
||||||
//let mut widget = ctx.get_widget(entity);
|
let text = widget.get::<String>("text");
|
||||||
//let text = widget.get_mut::<String16>("text");
|
|
||||||
println!("got value policynumber: {}", text);
|
println!("got value policynumber: {}", text);
|
||||||
//text.clear();
|
|
||||||
}
|
}
|
||||||
Action::EntryChanged(entity) => {
|
Action::EntryChanged(entity) => {
|
||||||
let widget = ctx.get_widget(entity);
|
let widget = ctx.get_widget(entity);
|
||||||
let text = widget.get::<String16>("text");
|
let text = widget.get::<String>("text");
|
||||||
println!("entry changed: {}", text);
|
println!("entry changed: {}", text);
|
||||||
}
|
}
|
||||||
// Action::ValueChanged(entity) => {
|
|
||||||
// let val =
|
|
||||||
// ((*ctx.get_widget(entity).get::<f64>("val")).floor() as i32).to_string();
|
|
||||||
// ctx.child("value_text").set("text", String16::from(val));
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.action = None;
|
self.action = None;
|
||||||
@@ -85,7 +68,6 @@ impl State for MainViewState {
|
|||||||
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
|
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.text(text)
|
.text(text)
|
||||||
//.element("text-block")
|
|
||||||
.style("header")
|
.style("header")
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
}
|
}
|
||||||
@@ -101,26 +83,19 @@ widget!(
|
|||||||
impl Template for MainView {
|
impl Template for MainView {
|
||||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||||
self.name("MainView").child(
|
self.name("MainView").child(
|
||||||
//.result("Anzahl Versicherungsnummern: 0")
|
|
||||||
//.result("Policyholders count: 0").sum_policynumbers(0)
|
|
||||||
//.sum_policynumbers(0)
|
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.background("#fafafa")
|
.background("#fafafa")
|
||||||
//.width(200.0)
|
|
||||||
//.height(360.0)
|
|
||||||
.columns(
|
.columns(
|
||||||
Columns::new()
|
Columns::create()
|
||||||
.add(150.0)
|
.push(150.0)
|
||||||
.add("*")
|
.push("*")
|
||||||
//.add(120.0)
|
.push(150.0)
|
||||||
//.add("auto")
|
|
||||||
.add(150.0)
|
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::new()
|
Rows::create()
|
||||||
.add("*")
|
.push("*")
|
||||||
.add("*")
|
.push("*")
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
@@ -140,27 +115,22 @@ impl Template for MainView {
|
|||||||
.child(create_header(ctx, "Validierung Versicherungsnummer"))
|
.child(create_header(ctx, "Validierung Versicherungsnummer"))
|
||||||
.child(
|
.child(
|
||||||
TextBox::new()
|
TextBox::new()
|
||||||
//.class("text_box")
|
|
||||||
// overwriting the class defaults
|
|
||||||
/* .background("transparent")
|
|
||||||
.foreground("#9dafbf")
|
.foreground("#9dafbf")
|
||||||
.background("#fafafa")
|
.background("#fafafa")
|
||||||
/* .foreground(colors::LINK_WATER_COLOR) */
|
|
||||||
.border_brush("#5b0f22")
|
.border_brush("#5b0f22")
|
||||||
.border_width(5)
|
.border_width(5)
|
||||||
.border_radius(15) */
|
.border_radius(15)
|
||||||
//.name("policynumber")
|
//.name("policynumber")
|
||||||
.focused(true)
|
.focused(true)
|
||||||
.water_mark("Versicherungs-Nr...")
|
.water_mark("Versicherungs-Nr...")
|
||||||
//.text("Number policyholder", id)
|
|
||||||
.text(("policynumber", id))
|
.text(("policynumber", id))
|
||||||
.font_size(24.0)
|
.font_size(24.0)
|
||||||
.h_align("stretch")
|
.h_align("stretch")
|
||||||
.on_activate(move |states, entity| {
|
.on_activate(move |ctx, entity| {
|
||||||
state(id, states).action(Action::EntryActivated(entity));
|
state(id, ctx).action(Action::EntryActivated(entity));
|
||||||
})
|
})
|
||||||
.on_changed(move |states, entity| {
|
.on_changed("text", move |ctx, entity| {
|
||||||
state(id, states).action(Action::EntryChanged(entity));
|
state(id, ctx).action(Action::EntryChanged(entity));
|
||||||
})
|
})
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
@@ -180,28 +150,28 @@ impl Template for MainView {
|
|||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
//.element("logo_customer")
|
//.class("logo_customer")
|
||||||
.margin((9.0, 16.0, 16.0, 9.0))
|
.margin((9.0, 16.0, 16.0, 9.0))
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(1))
|
||||||
.v_align("end")
|
.v_align("end")
|
||||||
.child(
|
.child(
|
||||||
ImageWidget::new()
|
ImageWidget::new()
|
||||||
.image("./resources/images/hiedemann_logo.png")
|
.image("assets/images/customer_logo.png")
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
//.element("logo_vendor")
|
//.class("logo_vendor")
|
||||||
.margin((9.0, 16.0, 16.0, 9.0))
|
.margin((9.0, 16.0, 16.0, 9.0))
|
||||||
.attach(Grid::column(2))
|
.attach(Grid::column(2))
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(1))
|
||||||
.v_align("end")
|
.v_align("end")
|
||||||
.child(
|
.child(
|
||||||
ImageWidget::new()
|
ImageWidget::new()
|
||||||
.image("./resources/images/networkx_logo.png")
|
.image("assets/images/networkx_logo.png")
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ use crate::{
|
|||||||
/// Valid `actions` that are handled as state changes in the `Policycheck` widget.
|
/// Valid `actions` that are handled as state changes in the `Policycheck` widget.
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum PolicycheckAction {
|
pub enum PolicycheckAction {
|
||||||
AddProgress(f64),
|
|
||||||
ClearEntry(Entity),
|
ClearEntry(Entity),
|
||||||
ChangeTheme(),
|
ChangeTheme(),
|
||||||
InputTextChanged(Entity),
|
InputTextChanged(Entity),
|
||||||
@@ -37,12 +36,14 @@ pub enum PolicycheckAction {
|
|||||||
RemoveFocus(Entity),
|
RemoveFocus(Entity),
|
||||||
RemovePopup(Entity),
|
RemovePopup(Entity),
|
||||||
ResetProgress,
|
ResetProgress,
|
||||||
|
GetProgress,
|
||||||
SetProgress(f64),
|
SetProgress(f64),
|
||||||
SetProgressPopup(Entity),
|
SetProgressPopup(Entity),
|
||||||
SetToggleTheme(Entity),
|
SetToggleTheme(Entity),
|
||||||
SetEntry(Entity),
|
SetEntry(Entity),
|
||||||
SetVisibility(Entity),
|
SetVisibility(Entity),
|
||||||
TextChanged(Entity, usize)
|
TextChanged(Entity, usize),
|
||||||
|
UpdateProgress(f64)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Define valid environment variables provided via .env files
|
/// Define valid environment variables provided via .env files
|
||||||
@@ -74,7 +75,8 @@ impl GlobalState for PolicycheckState {}
|
|||||||
/// Method definitions, that react on any given state change inside the `Policycheck` widget.
|
/// Method definitions, that react on any given state change inside the `Policycheck` widget.
|
||||||
impl PolicycheckState {
|
impl PolicycheckState {
|
||||||
/// Create a hashmap (key: policy number, value: policy type).
|
/// Create a hashmap (key: policy number, value: policy type).
|
||||||
pub fn create_hashmap(&mut self, _ctx: &mut Context<'_>) -> 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");
|
trace!(target: "advotracker", create_hashmap = "started");
|
||||||
|
|
||||||
let policy_list = PolicyList::new("policy list");
|
let policy_list = PolicyList::new("policy list");
|
||||||
@@ -125,18 +127,17 @@ impl PolicycheckState {
|
|||||||
if self.policy_data_count == 0 {
|
if self.policy_data_count == 0 {
|
||||||
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), true);
|
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), true);
|
||||||
|
|
||||||
if self.policy_numbers.len() == 0 {
|
if self.policy_numbers.is_empty() {
|
||||||
// initialize popup widget
|
// initialize popup widget
|
||||||
self.set_popup_progress(ctx);
|
self.set_popup_progress(ctx);
|
||||||
self.progress_count += 0.33;
|
self.progress_count += 0.33;
|
||||||
self.update_progress_bar(ctx);
|
self.update_progress_bar(ctx);
|
||||||
//sender.send(WindowRequest::Redraw).unwrap();
|
|
||||||
|
|
||||||
// for _ in 1..4 {
|
for _ in 1..4 {
|
||||||
// self.progress_count += 0.33;
|
self.progress_count += 0.33;
|
||||||
// self.update_progress_bar(ctx);
|
self.update_progress_bar(ctx);
|
||||||
// sender.send(WindowRequest::Redraw).unwrap();
|
ctx.send_message(PolicycheckAction::UpdateProgress(self.progress_count), self.progress_popup);
|
||||||
//}
|
}
|
||||||
|
|
||||||
// importing policy code elements from csv-file
|
// importing policy code elements from csv-file
|
||||||
match self.create_hashmap(ctx) {
|
match self.create_hashmap(ctx) {
|
||||||
@@ -150,7 +151,6 @@ impl PolicycheckState {
|
|||||||
self.progress_count = 1.;
|
self.progress_count = 1.;
|
||||||
self.update_progress_bar(ctx);
|
self.update_progress_bar(ctx);
|
||||||
|
|
||||||
//sender.send(WindowRequest::Redraw).unwrap();
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let res = t!("policy.hashmap.failed", self.lang);
|
let res = t!("policy.hashmap.failed", self.lang);
|
||||||
@@ -173,7 +173,7 @@ impl PolicycheckState {
|
|||||||
ctx: &mut Context<'_>) {
|
ctx: &mut Context<'_>) {
|
||||||
trace!(target: "advotracker", parse_entry = "started");
|
trace!(target: "advotracker", parse_entry = "started");
|
||||||
|
|
||||||
let policy_number_string = TextBox::text_clone(&mut ctx.get_widget(policy_check_policy_number));
|
let policy_number_string = TextBox::text_clone(&ctx.get_widget(policy_check_policy_number));
|
||||||
let policy_number_length = policy_number_string.len();
|
let policy_number_length = policy_number_string.len();
|
||||||
|
|
||||||
if self.policy_data_count == 0 {
|
if self.policy_data_count == 0 {
|
||||||
@@ -195,14 +195,7 @@ impl PolicycheckState {
|
|||||||
// Parse policy code: "AS-123456789"
|
// Parse policy code: "AS-123456789"
|
||||||
// DION VERS POLLFNR
|
// DION VERS POLLFNR
|
||||||
// 1 AS 1515735810
|
// 1 AS 1515735810
|
||||||
//Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
|
||||||
//Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
|
|
||||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
|
||||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), Visibility::Collapsed);
|
|
||||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
|
||||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
|
||||||
Button::background_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("transparent"));
|
Button::background_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("transparent"));
|
||||||
//Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Collapsed);
|
|
||||||
|
|
||||||
if policy_number_length == 10 {
|
if policy_number_length == 10 {
|
||||||
// cast policy_number_sting to <u64>
|
// cast policy_number_sting to <u64>
|
||||||
@@ -219,7 +212,7 @@ impl PolicycheckState {
|
|||||||
|
|
||||||
let string_result = format!("1-{:?}-{}",
|
let string_result = format!("1-{:?}-{}",
|
||||||
policy_code, p);
|
policy_code, p);
|
||||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from(string_result));
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), string_result);
|
||||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#008000"));
|
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#008000"));
|
||||||
|
|
||||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
|
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
|
||||||
@@ -227,8 +220,10 @@ impl PolicycheckState {
|
|||||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CHECK);
|
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CHECK);
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||||
|
|
||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Visible);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), Visibility::Visible);
|
||||||
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
||||||
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// no matching key
|
// no matching key
|
||||||
@@ -243,8 +238,10 @@ impl PolicycheckState {
|
|||||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||||
|
|
||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), 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_2), Visibility::Visible);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -253,17 +250,17 @@ impl PolicycheckState {
|
|||||||
|
|
||||||
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
TextBox::foreground_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from("#FF0000"));
|
||||||
|
|
||||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
|
||||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("Only numbers are valid"));
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HINT), String::from("Only numbers are valid"));
|
||||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
|
||||||
|
|
||||||
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||||
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
||||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||||
|
|
||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), 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_2), Visibility::Visible);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -282,8 +279,10 @@ impl PolicycheckState {
|
|||||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||||
|
|
||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), 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_2), Visibility::Visible);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), Visibility::Collapsed);
|
||||||
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||||
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||||
}
|
}
|
||||||
if policy_number_length > 10 {
|
if policy_number_length > 10 {
|
||||||
let res = t!("policy.validation.failed", self.lang);
|
let res = t!("policy.validation.failed", self.lang);
|
||||||
@@ -300,8 +299,10 @@ impl PolicycheckState {
|
|||||||
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||||
|
|
||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), 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_2), Visibility::Visible);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), Visibility::Collapsed);
|
||||||
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Visible);
|
||||||
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
trace!(target: "advotracker", parse_entry = "finished");
|
trace!(target: "advotracker", parse_entry = "finished");
|
||||||
@@ -335,10 +336,10 @@ impl PolicycheckState {
|
|||||||
fn set_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) {
|
fn set_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) {
|
||||||
if ctx.get_widget(text_box).get::<String16>("text").is_empty() {
|
if ctx.get_widget(text_box).get::<String16>("text").is_empty() {
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Collapsed);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), Visibility::Collapsed);
|
||||||
} else {
|
} else {
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), Visibility::Visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,18 +354,16 @@ impl PolicycheckState {
|
|||||||
|
|
||||||
// create the progress_popup widget
|
// create the progress_popup widget
|
||||||
self.progress_popup = create_popup_progress(current_entity, build_context);
|
self.progress_popup = create_popup_progress(current_entity, build_context);
|
||||||
println!("New entity `progress_popup` created: {:?}", self.progress_popup);
|
info!("set_popup_progress: New entity 'popup_progress' {:?} created", self.progress_popup);
|
||||||
|
|
||||||
// append the stack inside the progress_popup
|
// append the stack inside the progress_popup
|
||||||
build_context.append_child(stack, self.progress_popup);
|
build_context.append_child(stack, self.progress_popup);
|
||||||
|
|
||||||
// make sure we have a
|
// make sure we have a progress bar
|
||||||
self.progress_bar = ctx
|
self.progress_bar = ctx
|
||||||
.entity_of_child(ID_POLICY_CHECK_PROGRESS_BAR)
|
.entity_of_child(ID_POLICY_CHECK_PROGRESS_BAR)
|
||||||
.expect("PolicycheckState.init: Can't find entity of resource 'ID_POLICY_CHECK_PROGRESS_BAR'.");
|
.expect("PolicycheckState.init: Can't find entity of resource 'ID_POLICY_CHECK_PROGRESS_BAR'.");
|
||||||
println!("New entity `progress_bar` created: {:?}", self.progress_bar);
|
info!("set_popup_progress: New entity 'progress_bar' created: {:?}", self.progress_bar);
|
||||||
|
|
||||||
println!("function `set_popup_progress()` finished!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Change visibility of the result label.
|
/// Change visibility of the result label.
|
||||||
@@ -376,8 +375,6 @@ impl PolicycheckState {
|
|||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ctx.get_widget(self.label_result).update_theme_by_state(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update count of elements in the policy data list.
|
/// Update count of elements in the policy data list.
|
||||||
@@ -390,7 +387,7 @@ impl PolicycheckState {
|
|||||||
let res = t!("policy.string.progress_time", self.lang);
|
let res = t!("policy.string.progress_time", self.lang);
|
||||||
let string_duration = format!("{}: {:?}", res, self.duration);
|
let string_duration = format!("{}: {:?}", res, self.duration);
|
||||||
|
|
||||||
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_TIME), String::from(string_duration));
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_TIME), string_duration);
|
||||||
|
|
||||||
let mut progress_bar = ctx.child(ID_POLICY_CHECK_PROGRESS_BAR);
|
let mut progress_bar = ctx.child(ID_POLICY_CHECK_PROGRESS_BAR);
|
||||||
progress_bar.set::<f64>("val", self.progress_count);
|
progress_bar.set::<f64>("val", self.progress_count);
|
||||||
@@ -405,6 +402,9 @@ impl State for PolicycheckState {
|
|||||||
|
|
||||||
trace!(target: "advotracker", policycheck_state = "init", status = "started");
|
trace!(target: "advotracker", policycheck_state = "init", status = "started");
|
||||||
|
|
||||||
|
// Get language from environment
|
||||||
|
self.lang = PolicycheckState::get_lang();
|
||||||
|
|
||||||
// Initialize required entities
|
// Initialize required entities
|
||||||
self.button_menu = ctx
|
self.button_menu = ctx
|
||||||
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
|
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
|
||||||
@@ -414,15 +414,10 @@ impl State for PolicycheckState {
|
|||||||
.entity_of_child(ID_POLICY_CHECK_LABEL_RESULT)
|
.entity_of_child(ID_POLICY_CHECK_LABEL_RESULT)
|
||||||
.expect("PolicycheckState.init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'.");
|
.expect("PolicycheckState.init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'.");
|
||||||
|
|
||||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), Visibility::Collapsed);
|
||||||
//Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_0), Visibility::Collapsed);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_1), Visibility::Collapsed);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
|
|
||||||
|
|
||||||
// Preset localization with given environment lang
|
|
||||||
self.lang = PolicycheckState::get_lang();
|
|
||||||
ctx.set_language(&self.lang);
|
|
||||||
|
|
||||||
// // Load the saved data from a file in 'ron' format into our data structure.
|
// // Load the saved data from a file in 'ron' format into our data structure.
|
||||||
// // The cargo package identifier (default: 'nwx.advotracker') is used as the
|
// // The cargo package identifier (default: 'nwx.advotracker') is used as the
|
||||||
@@ -450,21 +445,19 @@ impl State for PolicycheckState {
|
|||||||
ctx: &mut Context<'_>,
|
ctx: &mut Context<'_>,
|
||||||
) {
|
) {
|
||||||
for message in messages.read::<PolicycheckAction>() {
|
for message in messages.read::<PolicycheckAction>() {
|
||||||
match message {
|
if let PolicycheckAction::UpdateProgress(increment) = message {
|
||||||
PolicycheckAction::AddProgress(increment) => {
|
println!("Message received");
|
||||||
let old_width = ProgressBar::val_clone(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
|
let old_width = ProgressBar::val_clone(&ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
|
||||||
|
|
||||||
let new_width = old_width + increment;
|
let new_width = old_width + increment;
|
||||||
// Set the ProgressBar's val property to the calculated percentage
|
// Set the ProgressBar's val property to the calculated percentage
|
||||||
// (whereas 0.0 means 0%, and 1.0 means 100%)
|
// (whereas 0.0 means 0%, and 1.0 means 100%)
|
||||||
if new_width <= 1. {
|
if new_width <= 1. {
|
||||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), new_width);
|
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), new_width);
|
||||||
} else {
|
} else {
|
||||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 1.);
|
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 1.);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,7 +500,6 @@ impl State for PolicycheckState {
|
|||||||
//ctx.EventAdapter(FocusEvent::RemoveFocus(policy_check_policy_number));
|
//ctx.EventAdapter(FocusEvent::RemoveFocus(policy_check_policy_number));
|
||||||
}
|
}
|
||||||
PolicycheckAction::RemovePopup(entity) => {
|
PolicycheckAction::RemovePopup(entity) => {
|
||||||
//println!("WIP: remove popup");
|
|
||||||
self.remove_popup(entity, ctx);
|
self.remove_popup(entity, ctx);
|
||||||
}
|
}
|
||||||
PolicycheckAction::ResetProgress => {
|
PolicycheckAction::ResetProgress => {
|
||||||
@@ -548,11 +540,12 @@ impl State for PolicycheckState {
|
|||||||
fn create_popup_progress(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
fn create_popup_progress(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||||
Popup::new()
|
Popup::new()
|
||||||
.id(ID_POLICY_CHECK_POPUP_PROGRESS)
|
.id(ID_POLICY_CHECK_POPUP_PROGRESS)
|
||||||
.target(id)
|
.target(id.0)
|
||||||
.open(true)
|
.open(true)
|
||||||
.style("popup_progress")
|
.style("popup_progress")
|
||||||
.width(280)
|
.width(280)
|
||||||
.height(100)
|
.height(100)
|
||||||
|
.visibility(Visibility::Visible)
|
||||||
.on_click(move |ctx, _| {
|
.on_click(move |ctx, _| {
|
||||||
println!("create_popup_progress: on_click -> remove_popup(popup_progress)");
|
println!("create_popup_progress: on_click -> remove_popup(popup_progress)");
|
||||||
ctx.get_mut::<PolicycheckState>(id)
|
ctx.get_mut::<PolicycheckState>(id)
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ impl Template for PolicycheckView {
|
|||||||
//fn template(self, policycheck_view: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
//fn template(self, policycheck_view: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||||
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||||
let policy_check_bottom_bar = Container::new()
|
let policy_check_bottom_bar = Container::new()
|
||||||
|
.id(ID_POLICY_CHECK_BOTTOM_BAR)
|
||||||
//.style(STYLE_BOTTOM_BAR)
|
//.style(STYLE_BOTTOM_BAR)
|
||||||
|
.padding(14)
|
||||||
.attach(Grid::row(4))
|
.attach(Grid::row(4))
|
||||||
.attach(Grid::column(1))
|
.attach(Grid::column(1))
|
||||||
.attach(Grid::column_span(2))
|
.attach(Grid::column_span(2))
|
||||||
@@ -89,6 +91,8 @@ impl Template for PolicycheckView {
|
|||||||
let policy_check_button_result = Button::new()
|
let policy_check_button_result = Button::new()
|
||||||
.id(ID_POLICY_CHECK_BUTTON_RESULT)
|
.id(ID_POLICY_CHECK_BUTTON_RESULT)
|
||||||
.style("button_single_content")
|
.style("button_single_content")
|
||||||
|
.attach(Grid::row(0))
|
||||||
|
.attach(Grid::column(3))
|
||||||
.h_align("start")
|
.h_align("start")
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
.visibility(Visibility::Collapsed)
|
.visibility(Visibility::Collapsed)
|
||||||
@@ -96,6 +100,7 @@ impl Template for PolicycheckView {
|
|||||||
.build(ctx);
|
.build(ctx);
|
||||||
|
|
||||||
let policy_check_header_bar = Container::new()
|
let policy_check_header_bar = Container::new()
|
||||||
|
.id(ID_POLICY_CHECK_HEADER_BAR)
|
||||||
.style(STYLE_HEADER_BAR)
|
.style(STYLE_HEADER_BAR)
|
||||||
.attach(Grid::row(0))
|
.attach(Grid::row(0))
|
||||||
.attach(Grid::column(1))
|
.attach(Grid::column(1))
|
||||||
@@ -116,208 +121,118 @@ impl Template for PolicycheckView {
|
|||||||
.child(policy_check_button_menu)
|
.child(policy_check_button_menu)
|
||||||
.build(ctx);
|
.build(ctx);
|
||||||
|
|
||||||
let policy_check_form_row_0 = Stack::new()
|
|
||||||
// 1st row
|
|
||||||
.id(ID_POLICY_CHECK_FORM_ROW_0)
|
|
||||||
.attach(Grid::row(0))
|
|
||||||
.attach(Grid::column(0))
|
|
||||||
.attach(Grid::column_span(5))
|
|
||||||
.orientation("horizontal")
|
|
||||||
.v_align("center")
|
|
||||||
//.h_align("center")
|
|
||||||
.child(
|
|
||||||
TextBlock::new()
|
|
||||||
.id(ID_POLICY_CHECK_LABEL_POLICY_NUMBER)
|
|
||||||
.style("body")
|
|
||||||
.attach(Grid::row(0))
|
|
||||||
.attach(Grid::column(0))
|
|
||||||
.margin((0, 0, 16, 0))
|
|
||||||
.h_align("end")
|
|
||||||
.v_align("center")
|
|
||||||
.width(300)
|
|
||||||
.min_width(300)
|
|
||||||
.text("Policy number")
|
|
||||||
.build(ctx),
|
|
||||||
)
|
|
||||||
.child(
|
|
||||||
TextBox::new()
|
|
||||||
.attach(Grid::row(0))
|
|
||||||
.attach(Grid::column(2))
|
|
||||||
.id(ID_POLICY_CHECK_POLICY_NUMBER)
|
|
||||||
.h_align("start")
|
|
||||||
.lose_focus_on_activation(false)
|
|
||||||
//WIP: localization for water_mark
|
|
||||||
.water_mark("10-stellig")
|
|
||||||
.on_activate(move |ctx, entity| {
|
|
||||||
// Entity is entered/activated via Mouse/Keyboard
|
|
||||||
//ctx.get_mut::<PolicycheckState>(policy_check_view)
|
|
||||||
ctx.get_mut::<PolicycheckState>(id)
|
|
||||||
.set_action(PolicycheckAction::ParseEntry(entity));
|
|
||||||
})
|
|
||||||
//.on_changed(|_, entity, _, _| println!("Selection changed: {:?}", entity))
|
|
||||||
// .on_changed(move |ctx, entity, _| {
|
|
||||||
// ctx.get_mut::<PolicycheckState>(id)
|
|
||||||
// .set_action(Action::SetProgressBox(entity));
|
|
||||||
// ctx.get_mut::<PolicycheckState>(id)
|
|
||||||
// .set_action(Action::AddProgress(0.5));
|
|
||||||
// ctx.get_mut::<PolicycheckState>(id)
|
|
||||||
// .set_action(Action::InputTextChanged(entity));
|
|
||||||
// ctx.get_mut::<PolicycheckState>(id)
|
|
||||||
// .set_action(Action::SetVisibility(entity));
|
|
||||||
// ctx.get_widget(policy_check_label_policy_number).set("visible");
|
|
||||||
// ctx.get_mut::<PolicycheckState>(id)
|
|
||||||
// .set_action(Action::SetVisility(entity));
|
|
||||||
// })
|
|
||||||
// .on_mouse_down | .on_mouse_move | .on_mouse_up (move |ctx, entity| {
|
|
||||||
// state(id, states).set_action(Action::AddItem);
|
|
||||||
// })
|
|
||||||
.on_key_down(move |_, key_event| {
|
|
||||||
if key_event.key == Key::A(true) {
|
|
||||||
println!("A key down");
|
|
||||||
}
|
|
||||||
// ctx.get_mut::<PolicycheckState>(id)
|
|
||||||
// .set_action(Action::ImportData);
|
|
||||||
true
|
|
||||||
})
|
|
||||||
.build(ctx),
|
|
||||||
)
|
|
||||||
.child(policy_check_button_result)
|
|
||||||
.build(ctx);
|
|
||||||
|
|
||||||
let policy_check_form_row_1 = Stack::new()
|
|
||||||
// 2nd row
|
|
||||||
.id(ID_POLICY_CHECK_FORM_ROW_1)
|
|
||||||
.attach(Grid::row(1))
|
|
||||||
.attach(Grid::column(0))
|
|
||||||
.attach(Grid::column_span(5))
|
|
||||||
.orientation("horizontal")
|
|
||||||
.v_align("center")
|
|
||||||
//.h_align("center")
|
|
||||||
.child(
|
|
||||||
TextBlock::new()
|
|
||||||
.id(ID_POLICY_CHECK_LABEL_RESULT)
|
|
||||||
.style("body")
|
|
||||||
.attach(Grid::row(1))
|
|
||||||
.attach(Grid::column(0))
|
|
||||||
.margin((0, 0, 16, 0))
|
|
||||||
.h_align("end")
|
|
||||||
.v_align("center")
|
|
||||||
.width(300)
|
|
||||||
.min_width(300)
|
|
||||||
.text("Policy code")
|
|
||||||
.build(ctx),
|
|
||||||
)
|
|
||||||
.child(
|
|
||||||
TextBlock::new()
|
|
||||||
.id(ID_POLICY_CHECK_RESULT)
|
|
||||||
.style("body")
|
|
||||||
.attach(Grid::row(1))
|
|
||||||
.attach(Grid::column(2))
|
|
||||||
.h_align("start")
|
|
||||||
.v_align("center")
|
|
||||||
.text("empty")
|
|
||||||
.build(ctx)
|
|
||||||
)
|
|
||||||
.build(ctx);
|
|
||||||
|
|
||||||
let policy_check_form_row_2 = Stack::new()
|
|
||||||
// 3nd row
|
|
||||||
.id(ID_POLICY_CHECK_FORM_ROW_2)
|
|
||||||
.attach(Grid::row(2))
|
|
||||||
.attach(Grid::column(0))
|
|
||||||
.attach(Grid::column_span(5))
|
|
||||||
.orientation("horizontal")
|
|
||||||
.v_align("center")
|
|
||||||
.h_align("center")
|
|
||||||
.child(
|
|
||||||
TextBlock::new()
|
|
||||||
.id(ID_POLICY_CHECK_LABEL_HINT)
|
|
||||||
//.style("hint")
|
|
||||||
.attach(Grid::row(2))
|
|
||||||
.attach(Grid::column(0))
|
|
||||||
.margin((0, 0, 16, 0))
|
|
||||||
.h_align("end")
|
|
||||||
.v_align("center")
|
|
||||||
.width(300)
|
|
||||||
.min_width(300)
|
|
||||||
.font_size(11.)
|
|
||||||
.text("Error:")
|
|
||||||
.build(ctx),
|
|
||||||
)
|
|
||||||
.child(
|
|
||||||
TextBlock::new()
|
|
||||||
.id(ID_POLICY_CHECK_HINT)
|
|
||||||
//.style("hint")
|
|
||||||
.attach(Grid::row(2))
|
|
||||||
.attach(Grid::column(2))
|
|
||||||
.h_align("start")
|
|
||||||
.v_align("center")
|
|
||||||
.font_size(11)
|
|
||||||
.build(ctx)
|
|
||||||
)
|
|
||||||
.build(ctx);
|
|
||||||
|
|
||||||
let policy_check_form = Container::new()
|
let policy_check_form = Container::new()
|
||||||
.id(ID_POLICY_CHECK_FORM)
|
.id(ID_POLICY_CHECK_FORM)
|
||||||
.min_width(420)
|
.name(ID_POLICY_CHECK_FORM)
|
||||||
.attach(Grid::row(2))
|
.attach(Grid::row(2))
|
||||||
.attach(Grid::column(1))
|
.attach(Grid::column(1))
|
||||||
.style("container_form")
|
.style("container_form")
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.id(ID_POLICY_CHECK_FORM)
|
.id(ID_POLICY_CHECK_FORM)
|
||||||
.width(450)
|
|
||||||
.min_width(400)
|
|
||||||
.columns(
|
.columns(
|
||||||
Columns::create()
|
Columns::create()
|
||||||
// Label
|
.push("auto") // Label
|
||||||
.push("300")
|
.push("16") // Delimiter
|
||||||
// Seperator
|
.push("200") // Data
|
||||||
.push("16")
|
.push("16") // Delimiter
|
||||||
// Values
|
.push("32") // Result-Button
|
||||||
.push("auto")
|
.push("4") // Delimeter
|
||||||
// Seperator
|
|
||||||
.push("16")
|
|
||||||
// Result-Button
|
|
||||||
.push("32")
|
|
||||||
//.build(),
|
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
.push("auto")
|
.push("auto") // Row 0
|
||||||
.push("auto")
|
.push("14") // Seperator
|
||||||
.push("*")
|
.push("auto") // Row 2
|
||||||
//.build(),
|
.push("14") // Seperator
|
||||||
|
.push("auto") // Row 3
|
||||||
|
)
|
||||||
|
|
||||||
|
//.child(policy_check_form_row_0)
|
||||||
|
.child(
|
||||||
|
TextBlock::new()
|
||||||
|
.id(ID_POLICY_CHECK_LABEL_POLICY_NUMBER)
|
||||||
|
.style("body")
|
||||||
|
.attach(Grid::row(0))
|
||||||
|
.attach(Grid::column(0))
|
||||||
|
.h_align("end")
|
||||||
|
.v_align("center")
|
||||||
|
.text("Policy number")
|
||||||
|
.build(ctx),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
TextBox::new()
|
||||||
|
.id(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||||
|
//.style("body")
|
||||||
|
.attach(Grid::row(0))
|
||||||
|
.attach(Grid::column(2))
|
||||||
|
//.lose_focus_on_activation(false)
|
||||||
|
//WIP: localization for water_mark
|
||||||
|
.water_mark("10-stellig")
|
||||||
|
.on_activate(move |ctx, entity| {
|
||||||
|
// Entity is entered/activated via Mouse/Keyboard
|
||||||
|
//ctx.get_mut::<PolicycheckState>(policy_check_view)
|
||||||
|
ctx.get_mut::<PolicycheckState>(id)
|
||||||
|
.set_action(PolicycheckAction::ParseEntry(entity));
|
||||||
|
})
|
||||||
|
.on_key_down(move |_, key_event| {
|
||||||
|
if key_event.key == Key::A(true) {
|
||||||
|
println!("A key down");
|
||||||
|
}
|
||||||
|
// ctx.get_mut::<PolicycheckState>(id)
|
||||||
|
// .set_action(Action::ImportData);
|
||||||
|
true
|
||||||
|
})
|
||||||
|
.build(ctx)
|
||||||
|
)
|
||||||
|
.child(policy_check_button_result)
|
||||||
|
|
||||||
|
//.child(policy_check_form_row_2)
|
||||||
|
.child(
|
||||||
|
TextBlock::new()
|
||||||
|
.id(ID_POLICY_CHECK_LABEL_RESULT)
|
||||||
|
.style("body")
|
||||||
|
.attach(Grid::row(2))
|
||||||
|
.attach(Grid::column(0))
|
||||||
|
.h_align("end")
|
||||||
|
.v_align("center")
|
||||||
|
.text("Policy code")
|
||||||
|
.build(ctx),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
TextBlock::new()
|
||||||
|
.id(ID_POLICY_CHECK_RESULT)
|
||||||
|
.style("body")
|
||||||
|
.attach(Grid::row(2))
|
||||||
|
.attach(Grid::column(2))
|
||||||
|
.build(ctx)
|
||||||
|
)
|
||||||
|
|
||||||
|
//.child(policy_check_form_row_2)
|
||||||
|
.child(
|
||||||
|
TextBlock::new()
|
||||||
|
.id(ID_POLICY_CHECK_LABEL_HINT)
|
||||||
|
.style("hint")
|
||||||
|
.attach(Grid::row(4))
|
||||||
|
.attach(Grid::column(0))
|
||||||
|
//.margin((0, 0, 16, 0))
|
||||||
|
.h_align("end")
|
||||||
|
.v_align("center")
|
||||||
|
.text("Error:")
|
||||||
|
.build(ctx),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
TextBlock::new()
|
||||||
|
.id(ID_POLICY_CHECK_HINT)
|
||||||
|
.style("hint")
|
||||||
|
.attach(Grid::row(4))
|
||||||
|
.attach(Grid::column(2))
|
||||||
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(policy_check_form_row_0)
|
|
||||||
.child(policy_check_form_row_1)
|
|
||||||
.child(policy_check_form_row_2)
|
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.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
|
// row3: only shown, if we read in `policy numbers` in
|
||||||
// a hashmap as values
|
// a hashmap as values
|
||||||
@@ -329,7 +244,6 @@ impl Template for PolicycheckView {
|
|||||||
.v_align("top")
|
.v_align("top")
|
||||||
.orientation("horizontal")
|
.orientation("horizontal")
|
||||||
.visibility(Visibility::Collapsed)
|
.visibility(Visibility::Collapsed)
|
||||||
//.spacing("4")
|
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.id(ID_POLICY_DATA_LABEL)
|
.id(ID_POLICY_DATA_LABEL)
|
||||||
@@ -357,40 +271,24 @@ impl Template for PolicycheckView {
|
|||||||
.id(ID_POLICY_CHECK_WIDGET)
|
.id(ID_POLICY_CHECK_WIDGET)
|
||||||
.columns(
|
.columns(
|
||||||
Columns::create()
|
Columns::create()
|
||||||
.push(50)
|
.push(50) // Left margin
|
||||||
.push("*")
|
.push("*") // Content
|
||||||
.push(50)
|
.push(50) // Right margin
|
||||||
//.build(),
|
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
.push("auto")
|
.push("auto") // Header_Bar
|
||||||
.push(28)
|
.push(28) // Seperator
|
||||||
.push("*")
|
.push("*") // InputForm
|
||||||
.push("auto")
|
.push("auto") // Data_Result
|
||||||
.push("auto")
|
.push("auto") // Bottom_Bar
|
||||||
//.build(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// row 0: Policy Check Header
|
.child(policy_check_header_bar) // row 0
|
||||||
.child(policy_check_header_bar)
|
.child(policy_check_form) // row 2
|
||||||
|
.child(policy_data_stack) // row 3
|
||||||
// row 1: Seperator
|
.child(policy_check_bottom_bar) // row 4
|
||||||
|
|
||||||
// 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),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper to request PolicycheckState
|
|
||||||
//fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut PolicycheckState {
|
|
||||||
// states.get_mut(id)
|
|
||||||
//}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user