widget:policycheck: enable ClearPolicyNumber
* new action button "Clear", "New ticket" * enable needed send_message routine * create action method * update visibility state of involved view properties Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -13,7 +13,8 @@ Dictionary (
|
|||||||
// policycheck_view
|
// policycheck_view
|
||||||
"Check result": "Prüfungsergebnis",
|
"Check result": "Prüfungsergebnis",
|
||||||
"Checklist elements: ": "Prüflistenelemente: ",
|
"Checklist elements: ": "Prüflistenelemente: ",
|
||||||
"Create ticket": "Ticket erstellen"
|
"Clear": "Zurücksetzen",
|
||||||
|
"Create ticket": "Ticket erstellen",
|
||||||
"Importing data": "Importiere Datensätze",
|
"Importing data": "Importiere Datensätze",
|
||||||
"Only numbers are valid": "Nur Nummern sind zulässig",
|
"Only numbers are valid": "Nur Nummern sind zulässig",
|
||||||
"Error:": "Fehler:",
|
"Error:": "Fehler:",
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ use crate::{
|
|||||||
/// state changes for the `PolicycheckView` widget.
|
/// state changes for the `PolicycheckView` widget.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum PolicycheckAction {
|
pub enum PolicycheckAction {
|
||||||
ClearEntry(Entity),
|
ClearPolicyNumber,
|
||||||
ChangeTheme(),
|
ChangeTheme(),
|
||||||
SendPolicynumber(),
|
SendPolicynumber(),
|
||||||
InputTextChanged(Entity),
|
InputTextChanged(Entity),
|
||||||
@@ -126,9 +126,12 @@ impl PolicycheckState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Clear text in text box.
|
/// Clear text in text box.
|
||||||
//pub fn _clear_entry(&mut self, id: Entity, ctx: &mut Context<'_>) {
|
pub fn clear_policy_number(&mut self, ctx: &mut Context<'_>) {
|
||||||
// TextBox::text_set(&mut ctx.widget(), String::from(""));
|
TextBox::text_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_NUMBER), String::from(""));
|
||||||
//}
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||||
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_POLICY_CODE), Visibility::Collapsed);
|
||||||
|
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Collapsed);
|
||||||
|
}
|
||||||
|
|
||||||
/// Import policy numbers into hashmap
|
/// Import policy numbers into hashmap
|
||||||
fn import_data(&mut self, ctx: &mut Context<'_>)
|
fn import_data(&mut self, ctx: &mut Context<'_>)
|
||||||
@@ -213,8 +216,8 @@ 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_ACTION_STACK), 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_ACTION_STACK), Visibility::Collapsed);
|
|
||||||
|
|
||||||
if policy_number_length == 10 {
|
if policy_number_length == 10 {
|
||||||
// cast policy_number_sting to <u64>
|
// cast policy_number_sting to <u64>
|
||||||
@@ -246,7 +249,7 @@ impl PolicycheckState {
|
|||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
||||||
|
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Visible);
|
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Visible);
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_BUTTON_CLEAR), Visibility::Visible);
|
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_BUTTON_CLEAR), Visibility::Visible);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -460,7 +463,7 @@ impl State for PolicycheckState {
|
|||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_HINT), Visibility::Collapsed);
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_HINT), Visibility::Collapsed);
|
||||||
|
|
||||||
Button::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Collapsed);
|
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Collapsed);
|
||||||
|
|
||||||
|
|
||||||
//self.policy_number = Entity::from(ctx.widget().try_clone::<u32>(ID_POLICY_CHECK_POLICY_NUMBER)
|
//self.policy_number = Entity::from(ctx.widget().try_clone::<u32>(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||||
@@ -500,9 +503,9 @@ impl State for PolicycheckState {
|
|||||||
) {
|
) {
|
||||||
for message in messages.read::<PolicycheckAction>() {
|
for message in messages.read::<PolicycheckAction>() {
|
||||||
match message {
|
match message {
|
||||||
//PolicycheckAction::ClearEntry(id) => {
|
PolicycheckAction::ClearPolicyNumber => {
|
||||||
// self.clear_entry(id, ctx);
|
self.clear_policy_number(ctx);
|
||||||
//}
|
}
|
||||||
PolicycheckAction::NewTicket => {
|
PolicycheckAction::NewTicket => {
|
||||||
self.new_ticket(ctx);
|
self.new_ticket(ctx);
|
||||||
}
|
}
|
||||||
@@ -543,8 +546,9 @@ impl State for PolicycheckState {
|
|||||||
|
|
||||||
for action in actions {
|
for action in actions {
|
||||||
match action {
|
match action {
|
||||||
PolicycheckAction::ClearEntry(policy_check_policy_number) => {
|
PolicycheckAction::ClearPolicyNumber => {
|
||||||
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
println!("clear entry");
|
||||||
|
self.clear_policy_number(ctx);
|
||||||
}
|
}
|
||||||
PolicycheckAction::InputTextChanged(entity) => {
|
PolicycheckAction::InputTextChanged(entity) => {
|
||||||
println!("entry changed: {}", TextBox::text_clone(&ctx.get_widget(entity)));
|
println!("entry changed: {}", TextBox::text_clone(&ctx.get_widget(entity)));
|
||||||
|
|||||||
@@ -143,9 +143,9 @@ impl Template for PolicycheckView {
|
|||||||
Button::new()
|
Button::new()
|
||||||
.id(ID_POLICY_CHECK_ACTION_BUTTON_CLEAR)
|
.id(ID_POLICY_CHECK_ACTION_BUTTON_CLEAR)
|
||||||
.style(STYLE_BUTTON_ACTION)
|
.style(STYLE_BUTTON_ACTION)
|
||||||
.text("Create ticket")
|
.text("Clear")
|
||||||
.on_click(move |states, _entity| {
|
.on_click(move |states, _entity| {
|
||||||
states.send_message(PolicycheckAction::ClearEntry, id);
|
states.send_message(PolicycheckAction::ClearPolicyNumber, id);
|
||||||
false
|
false
|
||||||
})
|
})
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
|
|||||||
Reference in New Issue
Block a user