ticketdata: code cleanup
This commit is contained in:
@@ -18,7 +18,8 @@ use crate::{
|
|||||||
data::{constants::*, structures::Email},
|
data::{constants::*, structures::Email},
|
||||||
widgets::global_state::GlobalState,
|
widgets::global_state::GlobalState,
|
||||||
services::exports::send_ticketdata::sendticketdata,
|
services::exports::send_ticketdata::sendticketdata,
|
||||||
widgets::policycheck::policycheck_state::{PolicycheckAction, PolicycheckState},
|
widgets::ticketdata::ticketdata_view::TicketdataView,
|
||||||
|
widgets::policycheck::policycheck_state::PolicycheckAction,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Valid `actions` that are handled as state changes in the `Ticketdata` widget.
|
/// Valid `actions` that are handled as state changes in the `Ticketdata` widget.
|
||||||
@@ -28,12 +29,15 @@ pub enum TicketdataAction {
|
|||||||
/// Clear text in the form
|
/// Clear text in the form
|
||||||
ClearForm(),
|
ClearForm(),
|
||||||
ChangeTheme(),
|
ChangeTheme(),
|
||||||
|
//ChangeMailCc(),
|
||||||
|
//ChangeMailTo(),
|
||||||
InputTextChanged(Entity),
|
InputTextChanged(Entity),
|
||||||
ParseEntry(Entity),
|
ParseEntry(Entity),
|
||||||
RemoveFocus(Entity),
|
RemoveFocus(Entity),
|
||||||
|
SendForm(),
|
||||||
SetToggleTheme(Entity),
|
SetToggleTheme(Entity),
|
||||||
SetEntry(Entity),
|
SetEntry(Entity),
|
||||||
SendForm(), SetVisibility(Entity),
|
SetVisibility(Entity),
|
||||||
TextChanged(Entity, usize),
|
TextChanged(Entity, usize),
|
||||||
UpdatePolicyCode(String)
|
UpdatePolicyCode(String)
|
||||||
}
|
}
|
||||||
@@ -68,7 +72,7 @@ impl TicketdataState {
|
|||||||
info!("Widget id: {:?}", ctx.get_widget(entity).get::<String>("id"));
|
info!("Widget id: {:?}", ctx.get_widget(entity).get::<String>("id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// identify the form by its id
|
// form is identified by its id
|
||||||
if let form_entity = ctx.child(ID_TICKET_DATA_GRID).entity() {
|
if let form_entity = ctx.child(ID_TICKET_DATA_GRID).entity() {
|
||||||
info!("Form id: {:?}", ctx.get_widget(form_entity).get::<String>("id"));
|
info!("Form id: {:?}", ctx.get_widget(form_entity).get::<String>("id"));
|
||||||
info!("Form node name: {:?}", ctx.get_widget(form_entity).get::<String>("name"));
|
info!("Form node name: {:?}", ctx.get_widget(form_entity).get::<String>("name"));
|
||||||
@@ -81,27 +85,16 @@ impl TicketdataState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// let Some(count) = ctx.child(ID_TICKET_DATA_GRID).entitry().children_count() {
|
|
||||||
// for c in 1..=count {
|
|
||||||
// println!("WIP clear entry of child {:?}", c);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//let mut children = vec![];
|
|
||||||
//get_all_children(&mut children, entity, ecm.entity_store());
|
|
||||||
//trace!("Children {:?}: {:?}", children.len(), children);
|
|
||||||
//println!("Child name: {:?}", ctx.try_child("ticket_data_form"));
|
|
||||||
//TextBlock::text_set(&mut ctx.child(ID_TICKET_DATA_POLICY_HOLDER), "");
|
|
||||||
//println!("Number of childs: {:?}", count);
|
|
||||||
//for c in 1..=count {
|
|
||||||
// println!("WIP clear entry of child {:?}", c);
|
|
||||||
// children = get_all_children()
|
|
||||||
//println!("Child {:?}: Entity: {:?}", c, ctx.child_from_index(c));
|
|
||||||
//println!("Text: {:?}", ctx.get_widget(entity).entity_of_child(entity));
|
|
||||||
//TextBlock::text_set(&mut ctx.child(ID_TICKET_DATA_POLICY_HOLDER), "");
|
|
||||||
//}
|
|
||||||
//TextBox::text_set(&mut ctx.widget(entity), String::from(""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pub fn change_mail_cc(&mut self) {
|
||||||
|
// self.actions.push(TicketdataAction::ChangeMailCc());
|
||||||
|
// }
|
||||||
|
|
||||||
|
// pub fn change_mail_to(&mut self) {
|
||||||
|
// self.actions.push(TicketdataAction::ChangeMailTo());
|
||||||
|
// }
|
||||||
|
|
||||||
pub fn send_form(entity: Entity, ctx: &mut Context<'_>, lang: &str) {
|
pub fn send_form(entity: Entity, ctx: &mut Context<'_>, lang: &str) {
|
||||||
|
|
||||||
// type conversion (String -> u64)
|
// type conversion (String -> u64)
|
||||||
@@ -135,7 +128,7 @@ impl TicketdataState {
|
|||||||
|
|
||||||
info!("WIP: Sending form to construct eMail to {:?}", email);
|
info!("WIP: Sending form to construct eMail to {:?}", email);
|
||||||
// send email via service
|
// send email via service
|
||||||
if let Err(e) = sendticketdata(&email, &lang) {
|
if let Err(_e) = sendticketdata(&email, &lang) {
|
||||||
Button::icon_brush_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#FF0000"));
|
Button::icon_brush_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#FF0000"));
|
||||||
Button::foreground_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#FF0000"));
|
Button::foreground_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), String::from("#FF0000"));
|
||||||
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_CLEAR);
|
Button::icon_set(&mut ctx.child(ID_TICKET_DATA_ACTION_BUTTON_SEND), material_icons_font::MD_CLEAR);
|
||||||
@@ -151,13 +144,14 @@ impl State for TicketdataState {
|
|||||||
|
|
||||||
trace!(target: "advotracker", ticketdata_state = "init", status = "started");
|
trace!(target: "advotracker", ticketdata_state = "init", status = "started");
|
||||||
|
|
||||||
// Initialize required entities
|
// Initialize required menu button entity
|
||||||
self.button_menu = ctx
|
self.button_menu = ctx
|
||||||
.entity_of_child(ID_TICKET_DATA_BUTTON_MENU)
|
.entity_of_child(ID_TICKET_DATA_BUTTON_MENU)
|
||||||
.expect("TicketState.init: Can't find resource entity 'ID_TICKET_DATA_BUTTON_MENU'.");
|
.expect("TicketState.init: Can't find resource entity 'ID_TICKET_DATA_BUTTON_MENU'.");
|
||||||
|
|
||||||
|
// initialize the entity object, that will receive messages
|
||||||
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
|
||||||
.expect("TicketState.init: Can't find resource entity 'target'."));
|
.expect("TicketState.init: Can't find resource entity 'target'."));
|
||||||
|
|
||||||
// Get language from environment
|
// Get language from environment
|
||||||
self.lang = TicketdataState::get_lang();
|
self.lang = TicketdataState::get_lang();
|
||||||
@@ -168,6 +162,7 @@ impl State for TicketdataState {
|
|||||||
trace!(target: "advotracker", ticketdata_state = "init", status = "finished", duration = ?duration);
|
trace!(target: "advotracker", ticketdata_state = "init", status = "finished", duration = ?duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The reader component of the message system handing `TicketdataState``
|
||||||
fn messages(
|
fn messages(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut messages: MessageReader,
|
mut messages: MessageReader,
|
||||||
@@ -187,6 +182,7 @@ impl State for TicketdataState {
|
|||||||
_ => { println!("messages: action not implemented!"); }
|
_ => { println!("messages: action not implemented!"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for message in messages.read::<PolicycheckAction>() {
|
for message in messages.read::<PolicycheckAction>() {
|
||||||
match message {
|
match message {
|
||||||
PolicycheckAction::UpdatePolicyCode => {
|
PolicycheckAction::UpdatePolicyCode => {
|
||||||
@@ -198,7 +194,7 @@ impl State for TicketdataState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
|
||||||
let actions: Vec<TicketdataAction> = self.actions.drain(..).collect();
|
let actions: Vec<TicketdataAction> = self.actions.drain(..).collect();
|
||||||
|
|
||||||
for action in actions {
|
for action in actions {
|
||||||
|
|||||||
@@ -5,10 +5,7 @@
|
|||||||
* SPDX-License-Identifier: (0BSD or MIT)
|
* SPDX-License-Identifier: (0BSD or MIT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use orbtk::{
|
use orbtk::prelude::*;
|
||||||
prelude::*,
|
|
||||||
//shell::event::Key,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::constants::*,
|
data::constants::*,
|
||||||
|
|||||||
Reference in New Issue
Block a user