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
|
||||
"Check result": "Prüfungsergebnis",
|
||||
"Checklist elements: ": "Prüflistenelemente: ",
|
||||
"Create ticket": "Ticket erstellen"
|
||||
"Clear": "Zurücksetzen",
|
||||
"Create ticket": "Ticket erstellen",
|
||||
"Importing data": "Importiere Datensätze",
|
||||
"Only numbers are valid": "Nur Nummern sind zulässig",
|
||||
"Error:": "Fehler:",
|
||||
|
||||
@@ -31,7 +31,7 @@ use crate::{
|
||||
/// state changes for the `PolicycheckView` widget.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum PolicycheckAction {
|
||||
ClearEntry(Entity),
|
||||
ClearPolicyNumber,
|
||||
ChangeTheme(),
|
||||
SendPolicynumber(),
|
||||
InputTextChanged(Entity),
|
||||
@@ -126,9 +126,12 @@ impl PolicycheckState {
|
||||
}
|
||||
|
||||
/// Clear text in text box.
|
||||
//pub fn _clear_entry(&mut self, id: Entity, ctx: &mut Context<'_>) {
|
||||
// TextBox::text_set(&mut ctx.widget(), String::from(""));
|
||||
//}
|
||||
pub fn clear_policy_number(&mut self, ctx: &mut Context<'_>) {
|
||||
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
|
||||
fn import_data(&mut self, ctx: &mut Context<'_>)
|
||||
@@ -213,8 +216,8 @@ impl PolicycheckState {
|
||||
// Parse policy code: "AS-123456789"
|
||||
// DION VERS POLLFNR
|
||||
// 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::visibility_set(&mut ctx.child(ID_POLICY_CHECK_ACTION_STACK), Visibility::Collapsed);
|
||||
|
||||
if policy_number_length == 10 {
|
||||
// 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_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);
|
||||
}
|
||||
_ => {
|
||||
@@ -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_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)
|
||||
@@ -500,9 +503,9 @@ impl State for PolicycheckState {
|
||||
) {
|
||||
for message in messages.read::<PolicycheckAction>() {
|
||||
match message {
|
||||
//PolicycheckAction::ClearEntry(id) => {
|
||||
// self.clear_entry(id, ctx);
|
||||
//}
|
||||
PolicycheckAction::ClearPolicyNumber => {
|
||||
self.clear_policy_number(ctx);
|
||||
}
|
||||
PolicycheckAction::NewTicket => {
|
||||
self.new_ticket(ctx);
|
||||
}
|
||||
@@ -543,8 +546,9 @@ impl State for PolicycheckState {
|
||||
|
||||
for action in actions {
|
||||
match action {
|
||||
PolicycheckAction::ClearEntry(policy_check_policy_number) => {
|
||||
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
||||
PolicycheckAction::ClearPolicyNumber => {
|
||||
println!("clear entry");
|
||||
self.clear_policy_number(ctx);
|
||||
}
|
||||
PolicycheckAction::InputTextChanged(entity) => {
|
||||
println!("entry changed: {}", TextBox::text_clone(&ctx.get_widget(entity)));
|
||||
|
||||
@@ -143,9 +143,9 @@ impl Template for PolicycheckView {
|
||||
Button::new()
|
||||
.id(ID_POLICY_CHECK_ACTION_BUTTON_CLEAR)
|
||||
.style(STYLE_BUTTON_ACTION)
|
||||
.text("Create ticket")
|
||||
.text("Clear")
|
||||
.on_click(move |states, _entity| {
|
||||
states.send_message(PolicycheckAction::ClearEntry, id);
|
||||
states.send_message(PolicycheckAction::ClearPolicyNumber, id);
|
||||
false
|
||||
})
|
||||
.build(ctx),
|
||||
|
||||
Reference in New Issue
Block a user