Extract events from create issue
This commit is contained in:
parent
08375b5ee2
commit
4e5f2101df
21
web/src/modals/issues_create/events.rs
Normal file
21
web/src/modals/issues_create/events.rs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
use seed::prelude::{ev, Ev, EventHandler};
|
||||||
|
|
||||||
|
use crate::modals::issues_create::Type;
|
||||||
|
|
||||||
|
type EvHandler = EventHandler<crate::Msg>;
|
||||||
|
|
||||||
|
pub fn on_click_submit_action(issue_type: Type) -> EvHandler {
|
||||||
|
ev(Ev::Click, move |ev| {
|
||||||
|
ev.stop_propagation();
|
||||||
|
ev.prevent_default();
|
||||||
|
Some(issue_type.submit_action())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn on_click_close_modal() -> EvHandler {
|
||||||
|
ev(Ev::Click, |ev| {
|
||||||
|
ev.stop_propagation();
|
||||||
|
ev.prevent_default();
|
||||||
|
Some(crate::Msg::ModalDropped)
|
||||||
|
})
|
||||||
|
}
|
@ -2,6 +2,7 @@ pub use model::*;
|
|||||||
pub use update::*;
|
pub use update::*;
|
||||||
pub use view::*;
|
pub use view::*;
|
||||||
|
|
||||||
|
mod events;
|
||||||
mod model;
|
mod model;
|
||||||
mod update;
|
mod update;
|
||||||
mod view;
|
mod view;
|
||||||
|
@ -14,7 +14,7 @@ use crate::components::styled_select::{SelectVariant, StyledSelect};
|
|||||||
use crate::components::styled_select_child::StyledSelectOption;
|
use crate::components::styled_select_child::StyledSelectOption;
|
||||||
use crate::components::styled_textarea::StyledTextarea;
|
use crate::components::styled_textarea::StyledTextarea;
|
||||||
use crate::modals::epic_field;
|
use crate::modals::epic_field;
|
||||||
use crate::modals::issues_create::{Model as AddIssueModal, Type};
|
use crate::modals::issues_create::{events, Model as AddIssueModal, Type};
|
||||||
use crate::model::Model;
|
use crate::model::Model;
|
||||||
use crate::shared::validate::Validator;
|
use crate::shared::validate::Validator;
|
||||||
use crate::{FieldId, Msg};
|
use crate::{FieldId, Msg};
|
||||||
@ -92,11 +92,7 @@ pub fn view(model: &Model, modal: &AddIssueModal) -> Node<Msg> {
|
|||||||
variant: ButtonVariant::Primary,
|
variant: ButtonVariant::Primary,
|
||||||
text: Some(issue_type.submit_label()),
|
text: Some(issue_type.submit_label()),
|
||||||
class_list: "action submit actionButton",
|
class_list: "action submit actionButton",
|
||||||
on_click: Some(mouse_ev(Ev::Click, move |ev| {
|
on_click: Some(events::on_click_submit_action(issue_type)),
|
||||||
ev.stop_propagation();
|
|
||||||
ev.prevent_default();
|
|
||||||
Some(issue_type.submit_action())
|
|
||||||
})),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.render()
|
.render()
|
||||||
@ -105,11 +101,7 @@ pub fn view(model: &Model, modal: &AddIssueModal) -> Node<Msg> {
|
|||||||
variant: ButtonVariant::Empty,
|
variant: ButtonVariant::Empty,
|
||||||
class_list: "action cancel actionButton",
|
class_list: "action cancel actionButton",
|
||||||
text: Some("Cancel"),
|
text: Some("Cancel"),
|
||||||
on_click: Some(mouse_ev(Ev::Click, |ev| {
|
on_click: Some(events::on_click_close_modal()),
|
||||||
ev.stop_propagation();
|
|
||||||
ev.prevent_default();
|
|
||||||
Some(Msg::ModalDropped)
|
|
||||||
})),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.render();
|
.render();
|
||||||
|
Loading…
Reference in New Issue
Block a user