policycheck_state: import data to hashmap
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -105,9 +105,16 @@ impl PolicyCheckState {
|
|||||||
let text = text_box.text_mut();
|
let text = text_box.text_mut();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn import_data(&mut self, text_block: Entity, ctx: &mut Context<'_>) { // import data
|
/// Import policy numbers into hashmap
|
||||||
// WIP: for now, only import once per session
|
fn import_data(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
//fn import_data(&mut self, entity: Entity, ctx: &mut Context<'_>)
|
||||||
|
// -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
// WIP: for now, only import once per session
|
||||||
if self.policy_data_count == 0 {
|
if self.policy_data_count == 0 {
|
||||||
|
//let mut text_block_wrapper: TextBlockCtx<'_> = text_block(ctx.child("policy_check_result"));
|
||||||
|
//text_block_wrapper.set_enabled(true);
|
||||||
|
//text_block_wrapper.set_text("Importieren der Prüflisten-Elemnte ...");
|
||||||
|
|
||||||
match self.create_hashmap() {
|
match self.create_hashmap() {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
//let res = t!("policy.hashmap.success", lang);
|
//let res = t!("policy.hashmap.success", lang);
|
||||||
@@ -130,7 +137,9 @@ impl PolicyCheckState {
|
|||||||
hashmap_status = "consume",
|
hashmap_status = "consume",
|
||||||
hashmap_entries = ?self.policy_data_count);
|
hashmap_entries = ?self.policy_data_count);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// 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<'_>) {
|
||||||
@@ -155,6 +164,18 @@ impl PolicyCheckState {
|
|||||||
Err(e) => { debug!(target: "advotracker", "{}", e); }
|
Err(e) => { debug!(target: "advotracker", "{}", e); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trace!(target: "advotracker", state = "importing");
|
||||||
|
// match self.import_data() {
|
||||||
|
// Ok(()) => {
|
||||||
|
// trace!(target: "advotracker", import_data = "success");
|
||||||
|
// }
|
||||||
|
// _ => {
|
||||||
|
// error!("Importing data failed!");
|
||||||
|
// trace!(target: "advotracker", import_data = "failed");
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
trace!(target: "advotracker", state = "parsing", policy_number = ?policy_string);
|
trace!(target: "advotracker", state = "parsing", policy_number = ?policy_string);
|
||||||
|
|
||||||
// Parse policy code: "AS-123456789"
|
// Parse policy code: "AS-123456789"
|
||||||
@@ -208,7 +229,6 @@ impl PolicyCheckState {
|
|||||||
let mut text_block_wrapper: TextBlockCtx<'_> = text_block(ctx.child("policy_check_result"));
|
let mut text_block_wrapper: TextBlockCtx<'_> = text_block(ctx.child("policy_check_result"));
|
||||||
text_block_wrapper.set_enabled(true);
|
text_block_wrapper.set_enabled(true);
|
||||||
text_block_wrapper.set_text("Nur Nummern sind zulässig!");
|
text_block_wrapper.set_text("Nur Nummern sind zulässig!");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -261,7 +281,7 @@ impl PolicyCheckState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Change visibility of the result label.
|
/// Change visibility of the result label.
|
||||||
fn set_visibility(&self, entity: Entity, ctx: &mut Context<'_>) {
|
fn set_visibility(&self, entity: Entity, ctx: &mut Context<'_>) {
|
||||||
if ctx.get_widget(entity).get::<String16>("text").is_empty() {
|
if ctx.get_widget(entity).get::<String16>("text").is_empty() {
|
||||||
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_visibility(Visibility::Visible);
|
text_block(ctx.child(ID_POLICY_CHECK_LABEL_RESULT)).set_visibility(Visibility::Visible);
|
||||||
text_block(ctx.child(ID_POLICY_CHECK_BUTTON_RESULT)).set_visibility(Visibility::Visible);
|
text_block(ctx.child(ID_POLICY_CHECK_BUTTON_RESULT)).set_visibility(Visibility::Visible);
|
||||||
@@ -370,5 +390,7 @@ impl State for PolicyCheckState {
|
|||||||
string_data_count = format!("{} {:?}", string_data_count, self.policy_numbers.len());
|
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);
|
text_block(ctx.child(ID_POLICY_DATA_COUNT_BLOCK)).set_text(string_data_count);
|
||||||
|
|
||||||
|
let _ = self.import_data();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user