Files
advotracker/frontend/src/policycheck_view.rs
Ralf Zerres c4b992f41a frontend: policycheck: component to check the validity of a given policy code
* policycheck_view: user GUI to interact with (orbtk Widget)
* policycheck_state: rust code with helper methods

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-06-19 17:44:47 +02:00

160 lines
3.6 KiB
Rust

use orbtk::prelude::*;
use crate::{
//data::PolicyList,
keys::*,
policycheck_state::{Action, PolicyCheckState},
};
type ListIndex = Option<usize>;
widget!(
/// Starter page that offers the dialog to enter an identifier of a policy.
/// This identifier is checked agains a map of valid policy codes.
PolicyCheckView<PolicyCheckState> {
//is_valid: bool,
title: String,
policy_check_text_box: String
}
);
impl Template for PolicyCheckView {
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
let policy_code_text_box = TextBox::new()
.id(ID_POLICY_CHECK_TEXT_BOX)
.attach(Grid::row(4))
.v_align("center")
.margin((4.0, 0.0, 0.0, 0.0))
.lost_focus_on_activation(false)
.on_activate(move |ctx, entity| {
ctx.get_mut::<PolicyCheckState>(id)
.action(Action::ParseEntry(entity));
})
.on_changed(move |ctx, entity| {
ctx.get_mut::<PolicyCheckState>(id)
.action(Action::InputTextChanged(entity));
})
.build(ctx);
// Check policy identifier page
self.name("Policy check")
.child(
Grid::new()
.id(ID_POLICY_CHECK_WIDGET)
.v_align("start")
.background("#fafafa")
.columns(
Columns::new()
.add(150.0)
.add("*")
.add(150.0)
.build(),
)
.rows(
Rows::new()
.add(52.0)
.add(1.0)
.add("*")
.add(1.0)
.add("*")
.build(),
)
// Top Bar
.child(
Container::new()
.class(CLASS_TOP_BAR)
.attach(Grid::row(0))
.attach(Grid::column(0))
.attach(Grid::column_span(3))
.child(
Grid::new()
.margin((4.0, 24.0, 24.0, 4.0))
.child(
TextBlock::new()
.class(CLASS_HEADER)
.v_align("center")
.h_align("center")
//.text("Validation number policyholder"))
.text("Validierung Versicherungsnummer")
.build(ctx),
)
.build(ctx),
)
.build(ctx),
)
.child(
Container::new()
.class("separator")
.attach(Grid::row(1))
.attach(Grid::column_span(3))
.build(ctx),
)
.child(
Stack::new()
.spacing(8.0)
.orientation("vertical")
.h_align("center")
.child(policy_code_text_box)
.child(
TextBlock::new()
.class("text_box")
.element("text-block")
.id("result")
.min_width(80.0)
.max_width(180.0)
//.text("Result:")
.text("Ergebnis:")
.build(ctx),
)
.build(ctx),
)
.child(
Container::new()
.class("separator")
.attach(Grid::row(3))
.attach(Grid::column_span(3))
.build(ctx),
)
// Bottom bar
.child(
Container::new()
.class(CLASS_BOTTOM_BAR)
.attach(Grid::row(4))
.attach(Grid::column(0))
.attach(Grid::column_span(3))
.child(
Grid::new()
.element("logo_customer")
.margin((9.0, 16.0, 16.0, 9.0))
.attach(Grid::column(0))
.attach(Grid::row(1))
.v_align("end")
.child(
ImageWidget::new()
.image("../resources/images/hiedemann_logo.png")
.build(ctx),
)
.build(ctx),
)
.child(
Grid::new()
.element("logo_vendor")
.margin((9.0, 16.0, 16.0, 9.0))
.attach(Grid::column(2))
.attach(Grid::row(1))
.v_align("end")
.child(
ImageWidget::new()
.image("../resources/images/networkx_logo.png")
.build(ctx),
)
.build(ctx),
)
.build(ctx),
)
.build(ctx),
)
}
}