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 view::*;
|
||||
|
||||
mod events;
|
||||
mod model;
|
||||
mod update;
|
||||
mod view;
|
||||
|
@ -14,7 +14,7 @@ use crate::components::styled_select::{SelectVariant, StyledSelect};
|
||||
use crate::components::styled_select_child::StyledSelectOption;
|
||||
use crate::components::styled_textarea::StyledTextarea;
|
||||
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::shared::validate::Validator;
|
||||
use crate::{FieldId, Msg};
|
||||
@ -92,11 +92,7 @@ pub fn view(model: &Model, modal: &AddIssueModal) -> Node<Msg> {
|
||||
variant: ButtonVariant::Primary,
|
||||
text: Some(issue_type.submit_label()),
|
||||
class_list: "action submit actionButton",
|
||||
on_click: Some(mouse_ev(Ev::Click, move |ev| {
|
||||
ev.stop_propagation();
|
||||
ev.prevent_default();
|
||||
Some(issue_type.submit_action())
|
||||
})),
|
||||
on_click: Some(events::on_click_submit_action(issue_type)),
|
||||
..Default::default()
|
||||
}
|
||||
.render()
|
||||
@ -105,11 +101,7 @@ pub fn view(model: &Model, modal: &AddIssueModal) -> Node<Msg> {
|
||||
variant: ButtonVariant::Empty,
|
||||
class_list: "action cancel actionButton",
|
||||
text: Some("Cancel"),
|
||||
on_click: Some(mouse_ev(Ev::Click, |ev| {
|
||||
ev.stop_propagation();
|
||||
ev.prevent_default();
|
||||
Some(Msg::ModalDropped)
|
||||
})),
|
||||
on_click: Some(events::on_click_close_modal()),
|
||||
..Default::default()
|
||||
}
|
||||
.render();
|
||||
|
Loading…
Reference in New Issue
Block a user