|
|
|
|
@@ -1,4 +1,3 @@
|
|
|
|
|
//use chrono::{Local, DateTime, Duration};
|
|
|
|
|
use dotenv::dotenv;
|
|
|
|
|
use locales::t;
|
|
|
|
|
use orbtk::{
|
|
|
|
|
@@ -18,7 +17,7 @@ use serde::Deserialize;
|
|
|
|
|
use std::{env, process};
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
use std::time::{Duration, SystemTime};
|
|
|
|
|
use tracing::{debug, error, info, trace};
|
|
|
|
|
use tracing::{error, info, trace};
|
|
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
|
callbacks::global_state::GlobalState,
|
|
|
|
|
@@ -94,8 +93,7 @@ impl PolicyCheckState {
|
|
|
|
|
pub fn create_hashmap(&mut self, _ctx: &mut Context<'_>) -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
|
trace!(target: "advotracker", create_hashmap = "started");
|
|
|
|
|
|
|
|
|
|
let res = t!("policy.string.label_policy_list", self.lang);
|
|
|
|
|
let policy_list = PolicyList::new(res);
|
|
|
|
|
let policy_list = PolicyList::new("policy list");
|
|
|
|
|
trace!(target: "advotracker", policy_list = ?policy_list);
|
|
|
|
|
|
|
|
|
|
// create vector to hold imported data
|
|
|
|
|
@@ -139,13 +137,14 @@ impl PolicyCheckState {
|
|
|
|
|
/// Get the active language environment.
|
|
|
|
|
pub fn get_lang() -> String {
|
|
|
|
|
// get system environment
|
|
|
|
|
let mut lang = env::var("LANG").unwrap_or("en".to_string());
|
|
|
|
|
let mut lang = env::var("LANG").unwrap_or("C".to_string());
|
|
|
|
|
|
|
|
|
|
// testing environment: read from .env file
|
|
|
|
|
dotenv().ok();
|
|
|
|
|
match envy::from_env::<Environment>() {
|
|
|
|
|
Ok(environment) => {
|
|
|
|
|
if environment.test_lang != lang { lang = environment.test_lang; }
|
|
|
|
|
trace!(target: "advotracker", lang = ?lang);
|
|
|
|
|
},
|
|
|
|
|
Err(e) => { info!(target: "advotracker", "{}", e) }
|
|
|
|
|
}
|
|
|
|
|
@@ -157,7 +156,7 @@ impl PolicyCheckState {
|
|
|
|
|
-> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
|
// WIP: for now, only import once per session
|
|
|
|
|
if self.policy_data_count == 0 {
|
|
|
|
|
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true);
|
|
|
|
|
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), true);
|
|
|
|
|
|
|
|
|
|
if self.policy_numbers.len() == 0 {
|
|
|
|
|
// initialize popup widget
|
|
|
|
|
@@ -216,25 +215,21 @@ impl PolicyCheckState {
|
|
|
|
|
ctx: &mut Context<'_>) {
|
|
|
|
|
trace!(target: "advotracker", parse_entry = "started");
|
|
|
|
|
|
|
|
|
|
//let policy_number_string = ctx.get_widget(policy_check_policy_number).get::<String16>("text").as_string();
|
|
|
|
|
let policy_number_string = TextBox::text_clone(&mut ctx.get_widget(policy_check_policy_number));
|
|
|
|
|
let policy_number_length = policy_number_string.len();
|
|
|
|
|
|
|
|
|
|
// // WIP: redundant lang selection (already in main!)
|
|
|
|
|
// let mut lang = env::var("lang").unwrap_or("en".to_string());
|
|
|
|
|
// // testing environment: read from .env file
|
|
|
|
|
// dotenv().ok();
|
|
|
|
|
// match envy::from_env::<Environment>() {
|
|
|
|
|
// Ok(environment) => {
|
|
|
|
|
// if environment.test_lang != lang { lang = environment.test_lang; }
|
|
|
|
|
// },
|
|
|
|
|
// Err(e) => { debug!(target: "advotracker", "{}", e); }
|
|
|
|
|
// }
|
|
|
|
|
if self.policy_data_count == 0 {
|
|
|
|
|
// Load data into hashmap
|
|
|
|
|
match self.import_data(ctx) {
|
|
|
|
|
Ok(()) => {
|
|
|
|
|
trace!(target: "advotracker", policycheck_state = "init", import_data = "success");
|
|
|
|
|
Stack::visibility_set(&mut ctx.child(ID_POLICY_DATA_STACK), Visibility::Visible);
|
|
|
|
|
let policy_data_count_string = format!("{:?}", &self.policy_data_count);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_DATA_COUNT), String::from(&policy_data_count_string));
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Load data into hashmap
|
|
|
|
|
match self.import_data(ctx) {
|
|
|
|
|
Ok(()) => trace!(target: "advotracker", policycheck_state = "init", import_data = "success"),
|
|
|
|
|
Err(e) => trace!(target: "advotracker", policycheck_state = "init", import_data = ?e),
|
|
|
|
|
Err(e) => trace!(target: "advotracker", policycheck_state = "init", import_data = ?e),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trace!(target: "advotracker", state = "parsing", policy_number = ?policy_number_string);
|
|
|
|
|
@@ -242,15 +237,15 @@ impl PolicyCheckState {
|
|
|
|
|
// Parse policy code: "AS-123456789"
|
|
|
|
|
// DION VERS POLLFNR
|
|
|
|
|
// 1 AS 1515735810
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Collapsed);
|
|
|
|
|
Button::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible);
|
|
|
|
|
Button::background_set(&mut ctx.child("policy_check_button_result"), String::from("transparent"));
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
|
|
|
|
Button::background_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("transparent"));
|
|
|
|
|
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Collapsed);
|
|
|
|
|
|
|
|
|
|
if policy_number_length == 10 {
|
|
|
|
|
// cast policy_number_sting to <u64>
|
|
|
|
|
match policy_number_string.parse::<u64>() {
|
|
|
|
|
Ok(p) => {
|
|
|
|
|
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(""));
|
|
|
|
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from(""));
|
|
|
|
|
|
|
|
|
|
// match hashmap's key
|
|
|
|
|
match self.policy_numbers.get(&p) {
|
|
|
|
|
@@ -260,60 +255,58 @@ impl PolicyCheckState {
|
|
|
|
|
policy_number = ?p, policy_code = ?policy_code);
|
|
|
|
|
let string_result = format!("1-{:?}-{}",
|
|
|
|
|
policy_code, p);
|
|
|
|
|
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(string_result));
|
|
|
|
|
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), true);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from(string_result));
|
|
|
|
|
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible);
|
|
|
|
|
let res = t!("policy.validation.button_success", self.lang);
|
|
|
|
|
Button::text_set(&mut ctx.child("policy_check_button_result"), String::from(res));
|
|
|
|
|
Button::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible);
|
|
|
|
|
Button::icon_set(&mut ctx.child("policy_check_button_result"), material_icons_font::MD_CHECK);
|
|
|
|
|
Button::icon_brush_set(&mut ctx.child("policy_check_button_result"), String::from("#008000"));
|
|
|
|
|
Button::foreground_set(&mut ctx.child("policy_check_button_result"), String::from("#008000"));
|
|
|
|
|
Button::background_set(&mut ctx.child("policy_check_button_result"), String::from("transparent"));
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
|
|
|
|
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
|
|
|
|
|
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#008000"));
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
_ => {
|
|
|
|
|
// no matching key
|
|
|
|
|
let res = t!("policy.validation.failed", self.lang);
|
|
|
|
|
trace!(target: "advotracker", state = ?res, policy_number = ?p);
|
|
|
|
|
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible);
|
|
|
|
|
let res = t!("policy.validation.button_failed", self.lang);
|
|
|
|
|
Button::text_set(&mut ctx.child("policy_check_button_result"), String::from(res));
|
|
|
|
|
Button::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible);
|
|
|
|
|
Button::icon_set(&mut ctx.child("policy_check_button_result"), material_icons_font::MD_CLEAR);
|
|
|
|
|
Button::icon_brush_set(&mut ctx.child("policy_check_button_result"), String::from("#FF0000"));
|
|
|
|
|
Button::foreground_set(&mut ctx.child("policy_check_button_result"), String::from("#FF0000"));
|
|
|
|
|
let res = t!("policy.validation.not_found", self.lang);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(res));
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible);
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from("The given policy number is invalid"));
|
|
|
|
|
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
|
|
|
|
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
|
|
|
|
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
|
|
|
|
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Err(e) => {
|
|
|
|
|
trace!(target: "advotracker", state = "error", error_type = "invalid type", error = ?e);
|
|
|
|
|
|
|
|
|
|
Button::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible);
|
|
|
|
|
Button::icon_set(&mut ctx.child("policy_check_button_result"), material_icons_font::MD_CLEAR);
|
|
|
|
|
Button::icon_brush_set(&mut ctx.child("policy_check_button_result"), String::from("#FF0000"));
|
|
|
|
|
Button::foreground_set(&mut ctx.child("policy_check_button_result"), String::from("#FF0000"));
|
|
|
|
|
let res = t!("policy.validation.invalid_input", self.lang);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(res));
|
|
|
|
|
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true);
|
|
|
|
|
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), true);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from("Only numbers are valid"));
|
|
|
|
|
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
|
|
|
|
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
|
|
|
|
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
|
|
|
|
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if policy_number_length < 10 {
|
|
|
|
|
let res = t!("policy.validation.to_short", self.lang);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(res));
|
|
|
|
|
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true);
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible);
|
|
|
|
|
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), true);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from("Policy number is to short"));
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
|
|
|
|
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
|
|
|
|
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
|
|
|
|
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
|
|
|
|
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
|
|
|
|
}
|
|
|
|
|
if policy_number_length > 10 {
|
|
|
|
|
let res = t!("policy.validation.to_long", self.lang);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child("policy_check_result"), String::from(res));
|
|
|
|
|
TextBlock::enabled_set(&mut ctx.child("policy_check_result"), true);
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible);
|
|
|
|
|
TextBlock::enabled_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), true);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_RESULT), String::from("Policy number is to long"));
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
|
|
|
|
Button::icon_brush_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
|
|
|
|
Button::foreground_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), String::from("#FF0000"));
|
|
|
|
|
Button::icon_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), material_icons_font::MD_CLEAR);
|
|
|
|
|
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trace!(target: "advotracker", parse_entry = "finished");
|
|
|
|
|
@@ -342,11 +335,11 @@ impl PolicyCheckState {
|
|
|
|
|
/// Change status of given text box to edit mode.
|
|
|
|
|
fn set_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) {
|
|
|
|
|
if ctx.get_widget(text_box).get::<String16>("text").is_empty() {
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Collapsed);
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child("policy_check_button_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);
|
|
|
|
|
} else {
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child("policy_check_label_result"), Visibility::Visible);
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child("policy_check_button_result"), Visibility::Visible);
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Visible);
|
|
|
|
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_BUTTON_RESULT), Visibility::Visible);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -359,13 +352,6 @@ impl PolicyCheckState {
|
|
|
|
|
self.menu = create_menu(current_entity, build_context);
|
|
|
|
|
let _menu = build_context.append_child_to_overlay(self.menu)
|
|
|
|
|
.expect("PolicyCheckState: Can't create overlay as child of entity");
|
|
|
|
|
|
|
|
|
|
let label_account = t!("policy.menu.label_account", self.lang);
|
|
|
|
|
Button::text_set(&mut ctx.child(ID_POLICY_CHECK_MENU_LABEL_ACCOUNT), String::from(label_account));
|
|
|
|
|
let label_quit = t!("policy.menu.label_quit", self.lang);
|
|
|
|
|
Button::text_set(&mut ctx.child(ID_POLICY_CHECK_MENU_LABEL_QUIT), String::from(label_quit));
|
|
|
|
|
let label_toggle_theme = t!("policy.menu.label_toggle_theme", self.lang);
|
|
|
|
|
Button::text_set(&mut ctx.child(ID_POLICY_CHECK_MENU_LABEL_TOGGLE_THEME), String::from(label_toggle_theme));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Set a progress popup that updates the import status in a progress bar
|
|
|
|
|
@@ -377,8 +363,7 @@ impl PolicyCheckState {
|
|
|
|
|
let current_entity = ctx.entity;
|
|
|
|
|
let build_context = &mut ctx.build_context();
|
|
|
|
|
|
|
|
|
|
let res = t!("policy.string.progress_text", self.lang);
|
|
|
|
|
self.progress_popup = create_popup_progress(current_entity, &res, build_context);
|
|
|
|
|
self.progress_popup = create_popup_progress(current_entity, build_context);
|
|
|
|
|
|
|
|
|
|
// create a progress_popup widget as a child of entity "ID_POLICY_CHECK_POLICY_NUMBER"
|
|
|
|
|
build_context.append_child(stack, self.progress_popup);
|
|
|
|
|
@@ -460,30 +445,12 @@ impl State for PolicyCheckState {
|
|
|
|
|
.entity_of_child(ID_POLICY_CHECK_LABEL_RESULT)
|
|
|
|
|
.expect("PolicyCheckState.init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'.");
|
|
|
|
|
|
|
|
|
|
// WIP: redundant lang selection (already in main!)
|
|
|
|
|
let mut lang = env::var("lang").unwrap_or("en".to_string());
|
|
|
|
|
// testing environment: read from .env file
|
|
|
|
|
dotenv().ok();
|
|
|
|
|
match envy::from_env::<Environment>() {
|
|
|
|
|
Ok(environment) => {
|
|
|
|
|
if environment.test_lang != lang { lang = environment.test_lang; }
|
|
|
|
|
},
|
|
|
|
|
Err(e) => { debug!(target: "advotracker", "{}", e); }
|
|
|
|
|
}
|
|
|
|
|
self.lang = lang;
|
|
|
|
|
|
|
|
|
|
// Constants
|
|
|
|
|
let res = t!("policy.string.header", self.lang);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_HEADER), String::from(res));
|
|
|
|
|
|
|
|
|
|
let res = t!("policy.string.label_policy_number", self.lang);
|
|
|
|
|
let string_label_policy_number = format!("{}:", res);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_POLICY_NUMBER), String::from(string_label_policy_number));
|
|
|
|
|
|
|
|
|
|
let res = t!("policy.string.label_result", self.lang);
|
|
|
|
|
let string_label_result = format!("{}:", res);
|
|
|
|
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), String::from(string_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);
|
|
|
|
|
|
|
|
|
|
// Preset localization with given environment lang
|
|
|
|
|
self.lang = PolicyCheckState::get_lang();
|
|
|
|
|
ctx.set_language(&self.lang);
|
|
|
|
|
|
|
|
|
|
// // Load the saved data from a file in 'ron' format into our data structure.
|
|
|
|
|
// // The cargo package identifier (default: 'nwx.advotracker') is used as the
|
|
|
|
|
@@ -605,23 +572,9 @@ impl State for PolicyCheckState {
|
|
|
|
|
self.action = None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Update the view after the layout is rendered.
|
|
|
|
|
fn update_post_layout(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
|
|
|
|
// WIP: redundant lang selection (already in main!)
|
|
|
|
|
let mut lang = env::var("lang").unwrap_or("en".to_string());
|
|
|
|
|
// testing environment: read from .env file
|
|
|
|
|
dotenv().ok();
|
|
|
|
|
match envy::from_env::<Environment>() {
|
|
|
|
|
Ok(environment) => {
|
|
|
|
|
if environment.test_lang != lang { lang = environment.test_lang; }
|
|
|
|
|
},
|
|
|
|
|
Err(e) => { debug!(target: "advotracker", "{}", e); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let res = t!("policy.string.data_count", lang);
|
|
|
|
|
let string_data_count = format!("{}: {:?}", res, self.policy_numbers.len());
|
|
|
|
|
TextBlock::text_set(&mut ctx.child(ID_POLICY_DATA_COUNT_BLOCK), String::from(string_data_count));
|
|
|
|
|
}
|
|
|
|
|
// /// Update the view after the layout is rendered.
|
|
|
|
|
// fn update_post_layout(&mut self, _: &mut Registry, _ctx: &mut Context<'_>) {
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Create a menu popup
|
|
|
|
|
@@ -708,7 +661,7 @@ fn create_menu(menu: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Create a progress popup with update status of an onging data import
|
|
|
|
|
fn create_popup_progress(target: Entity, text: &str, ctx: &mut BuildContext<'_>) -> Entity {
|
|
|
|
|
fn create_popup_progress(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
|
|
|
|
Popup::new()
|
|
|
|
|
.id(ID_POLICY_CHECK_POPUP_PROGRESS)
|
|
|
|
|
.target(target)
|
|
|
|
|
@@ -725,14 +678,15 @@ fn create_popup_progress(target: Entity, text: &str, ctx: &mut BuildContext<'_>)
|
|
|
|
|
.child(
|
|
|
|
|
Container::new()
|
|
|
|
|
.style("container_progress")
|
|
|
|
|
.child( Stack::new()
|
|
|
|
|
.child(
|
|
|
|
|
Stack::new()
|
|
|
|
|
.style("stack_progress")
|
|
|
|
|
.child(
|
|
|
|
|
TextBlock::new()
|
|
|
|
|
.id(ID_POLICY_CHECK_PROGRESS_TEXT)
|
|
|
|
|
//.style("textblock_progress")
|
|
|
|
|
.font_size(12)
|
|
|
|
|
.text(text)
|
|
|
|
|
.text("Importing data")
|
|
|
|
|
.build(ctx)
|
|
|
|
|
)
|
|
|
|
|
.child(
|
|
|
|
|
@@ -748,6 +702,7 @@ fn create_popup_progress(target: Entity, text: &str, ctx: &mut BuildContext<'_>)
|
|
|
|
|
//.style("textblock_progress")
|
|
|
|
|
.h_align("end")
|
|
|
|
|
.font_size(12)
|
|
|
|
|
.text("Processing time")
|
|
|
|
|
.build(ctx)
|
|
|
|
|
)
|
|
|
|
|
.build(ctx)
|
|
|
|
|
|