Merge modal and modals
This commit is contained in:
parent
23c6cd1a8c
commit
915ff46281
@ -23,7 +23,6 @@ pub use {changes::*, fields::*, images::*};
|
|||||||
mod changes;
|
mod changes;
|
||||||
mod fields;
|
mod fields;
|
||||||
mod images;
|
mod images;
|
||||||
mod modal;
|
|
||||||
mod modals;
|
mod modals;
|
||||||
mod model;
|
mod model;
|
||||||
mod pages;
|
mod pages;
|
||||||
@ -235,7 +234,7 @@ fn update(msg: Msg, model: &mut model::Model, orders: &mut impl Orders<Msg>) {
|
|||||||
aside::update(&msg, model, orders);
|
aside::update(&msg, model, orders);
|
||||||
navbar_left::update(&msg, model, orders);
|
navbar_left::update(&msg, model, orders);
|
||||||
}
|
}
|
||||||
crate::modal::update(&msg, model, orders);
|
crate::modals::update(&msg, model, orders);
|
||||||
|
|
||||||
match model.page {
|
match model.page {
|
||||||
Page::Project | Page::AddIssue | Page::EditIssue(..) => {
|
Page::Project | Page::AddIssue | Page::EditIssue(..) => {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
model::{IssueModal, Model},
|
model::{IssueModal, Model},
|
||||||
shared::{styled_field::StyledField, styled_select::StyledSelect, ToChild, ToNode},
|
shared::styled_field::StyledField,
|
||||||
|
shared::styled_select::StyledSelect,
|
||||||
|
shared::{ToChild, ToNode},
|
||||||
FieldId, Msg,
|
FieldId, Msg,
|
||||||
},
|
},
|
||||||
jirs_data::EpicId,
|
jirs_data::EpicId,
|
@ -1,7 +1,9 @@
|
|||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
modal::issues::epic_field,
|
modals::{
|
||||||
modals::issues_create::{Model as AddIssueModal, Type},
|
epic_field,
|
||||||
|
issues_create::{Model as AddIssueModal, Type},
|
||||||
|
},
|
||||||
model::Model,
|
model::Model,
|
||||||
shared::{
|
shared::{
|
||||||
styled_button::StyledButton, styled_date_time_input::StyledDateTimeInput,
|
styled_button::StyledButton, styled_date_time_input::StyledDateTimeInput,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
modal::issues::epic_field,
|
modals::{
|
||||||
modals::{issues_edit::Model as EditIssueModal, time_tracking::time_tracking_field},
|
epic_field, issues_edit::Model as EditIssueModal, time_tracking::time_tracking_field,
|
||||||
|
},
|
||||||
model::{ModalType, Model},
|
model::{ModalType, Model},
|
||||||
shared::{
|
shared::{
|
||||||
styled_avatar::StyledAvatar, styled_button::StyledButton, styled_editor::StyledEditor,
|
styled_avatar::StyledAvatar, styled_button::StyledButton, styled_editor::StyledEditor,
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
pub use {epic_field::*, update::*, view::*};
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
pub mod debug;
|
pub mod debug;
|
||||||
pub mod issue_statuses_delete;
|
pub mod issue_statuses_delete;
|
||||||
@ -5,3 +7,7 @@ pub mod issues_create;
|
|||||||
pub mod issues_delete;
|
pub mod issues_delete;
|
||||||
pub mod issues_edit;
|
pub mod issues_edit;
|
||||||
pub mod time_tracking;
|
pub mod time_tracking;
|
||||||
|
|
||||||
|
mod epic_field;
|
||||||
|
mod update;
|
||||||
|
mod view;
|
||||||
|
@ -2,7 +2,6 @@ use {
|
|||||||
crate::{
|
crate::{
|
||||||
model::{ModalType, Model},
|
model::{ModalType, Model},
|
||||||
shared::{
|
shared::{
|
||||||
find_issue,
|
|
||||||
styled_button::StyledButton,
|
styled_button::StyledButton,
|
||||||
styled_field::StyledField,
|
styled_field::StyledField,
|
||||||
styled_input::{StyledInput, StyledInputState},
|
styled_input::{StyledInput, StyledInputState},
|
||||||
@ -17,8 +16,6 @@ use {
|
|||||||
seed::{prelude::*, *},
|
seed::{prelude::*, *},
|
||||||
};
|
};
|
||||||
|
|
||||||
// use crate::shared::styled_select_child::*;
|
|
||||||
|
|
||||||
pub fn value_for_time_tracking(v: &Option<i32>, time_tracking_type: &TimeTracking) -> String {
|
pub fn value_for_time_tracking(v: &Option<i32>, time_tracking_type: &TimeTracking) -> String {
|
||||||
match (time_tracking_type, v.as_ref()) {
|
match (time_tracking_type, v.as_ref()) {
|
||||||
(TimeTracking::Untracked, _) => "".to_string(),
|
(TimeTracking::Untracked, _) => "".to_string(),
|
||||||
@ -29,10 +26,9 @@ pub fn value_for_time_tracking(v: &Option<i32>, time_tracking_type: &TimeTrackin
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(model: &Model, issue_id: IssueId) -> Node<Msg> {
|
pub fn view(model: &Model, issue_id: IssueId) -> Node<Msg> {
|
||||||
let _issue = match find_issue(model, issue_id) {
|
if model.issues_by_id.get(&issue_id).is_none() {
|
||||||
Some(issue) => issue,
|
return Node::Empty;
|
||||||
_ => return empty![],
|
}
|
||||||
};
|
|
||||||
|
|
||||||
let edit_issue_modal = match model.modals.get(0) {
|
let edit_issue_modal = match model.modals.get(0) {
|
||||||
Some(ModalType::EditIssue(_, modal)) => modal,
|
Some(ModalType::EditIssue(_, modal)) => modal,
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
model::{self, ModalType, Model, Page},
|
model::{ModalType, Model, Page},
|
||||||
shared::{
|
shared::go_to_board,
|
||||||
find_issue, go_to_board,
|
|
||||||
styled_confirm_modal::StyledConfirmModal,
|
|
||||||
styled_modal::{StyledModal, Variant as ModalVariant},
|
|
||||||
ToNode,
|
|
||||||
},
|
|
||||||
ws::send_ws_msg,
|
ws::send_ws_msg,
|
||||||
FieldChange, FieldId, Msg, OperationKind, ResourceKind,
|
FieldChange, FieldId, Msg, OperationKind, ResourceKind,
|
||||||
},
|
},
|
||||||
@ -14,9 +9,7 @@ use {
|
|||||||
seed::{prelude::*, *},
|
seed::{prelude::*, *},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod issues;
|
pub fn update(msg: &Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||||
|
|
||||||
pub fn update(msg: &Msg, model: &mut model::Model, orders: &mut impl Orders<Msg>) {
|
|
||||||
match msg {
|
match msg {
|
||||||
Msg::ModalDropped => match model.modals.pop() {
|
Msg::ModalDropped => match model.modals.pop() {
|
||||||
Some(ModalType::EditIssue(..)) | Some(ModalType::AddIssue(..)) => {
|
Some(ModalType::EditIssue(..)) | Some(ModalType::AddIssue(..)) => {
|
||||||
@ -74,50 +67,6 @@ pub fn update(msg: &Msg, model: &mut model::Model, orders: &mut impl Orders<Msg>
|
|||||||
issue_statuses_delete::update(msg, model, orders);
|
issue_statuses_delete::update(msg, model, orders);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(model: &model::Model) -> Node<Msg> {
|
|
||||||
use crate::modals::{issue_statuses_delete, issues_create, issues_edit};
|
|
||||||
let modals: Vec<Node<Msg>> = model
|
|
||||||
.modals
|
|
||||||
.iter()
|
|
||||||
.map(|modal| match modal {
|
|
||||||
ModalType::EditIssue(issue_id, modal) => {
|
|
||||||
if let Some(_issue) = find_issue(model, *issue_id) {
|
|
||||||
let details = issues_edit::view(model, modal.as_ref());
|
|
||||||
StyledModal::build()
|
|
||||||
.variant(ModalVariant::Center)
|
|
||||||
.width(1040)
|
|
||||||
.children(vec![details])
|
|
||||||
.build()
|
|
||||||
.into_node()
|
|
||||||
} else {
|
|
||||||
empty![]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ModalType::DeleteIssueConfirm(_id) => crate::modals::issues_delete::view(model),
|
|
||||||
ModalType::AddIssue(modal) => issues_create::view(model, modal),
|
|
||||||
ModalType::DeleteCommentConfirm(comment_id) => {
|
|
||||||
let comment_id = *comment_id;
|
|
||||||
StyledConfirmModal::build()
|
|
||||||
.title("Are you sure you want to delete this comment?")
|
|
||||||
.message("Once you delete, it's gone for good.")
|
|
||||||
.confirm_text("Delete comment")
|
|
||||||
.on_confirm(mouse_ev(Ev::Click, move |_| Msg::DeleteComment(comment_id)))
|
|
||||||
.build()
|
|
||||||
.into_node()
|
|
||||||
}
|
|
||||||
ModalType::TimeTracking(issue_id) => {
|
|
||||||
crate::modals::time_tracking::view(model, *issue_id)
|
|
||||||
}
|
|
||||||
ModalType::DeleteIssueStatusModal(delete_issue_modal) => {
|
|
||||||
issue_statuses_delete::view(model, delete_issue_modal.delete_id)
|
|
||||||
}
|
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
ModalType::DebugModal => crate::modals::debug::view(model),
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
section![id!["modals"], modals]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn push_add_modal(model: &mut Model, _orders: &mut impl Orders<Msg>) {
|
fn push_add_modal(model: &mut Model, _orders: &mut impl Orders<Msg>) {
|
||||||
use crate::modals::issues_create::Model;
|
use crate::modals::issues_create::Model;
|
||||||
model.modals.push(ModalType::AddIssue(Box::new(Model {
|
model.modals.push(ModalType::AddIssue(Box::new(Model {
|
||||||
@ -133,7 +82,7 @@ fn push_edit_modal(issue_id: i32, model: &mut Model, orders: &mut impl Orders<Ms
|
|||||||
.map(|p| p.time_tracking)
|
.map(|p| p.time_tracking)
|
||||||
.unwrap_or_else(|| TimeTracking::Untracked);
|
.unwrap_or_else(|| TimeTracking::Untracked);
|
||||||
let modal = {
|
let modal = {
|
||||||
let issue = match find_issue(model, issue_id) {
|
let issue = match model.issues_by_id.get(&issue_id) {
|
||||||
Some(issue) => issue,
|
Some(issue) => issue,
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
51
jirs-client/src/modals/view.rs
Normal file
51
jirs-client/src/modals/view.rs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
use {
|
||||||
|
crate::{
|
||||||
|
model::*, shared::styled_confirm_modal::StyledConfirmModal,
|
||||||
|
shared::styled_modal::StyledModal, shared::ToNode, Msg,
|
||||||
|
},
|
||||||
|
seed::{prelude::*, *},
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn view(model: &Model) -> Node<Msg> {
|
||||||
|
use crate::modals::{issue_statuses_delete, issues_create, issues_edit};
|
||||||
|
let modals: Vec<Node<Msg>> = model
|
||||||
|
.modals
|
||||||
|
.iter()
|
||||||
|
.map(|modal| match modal {
|
||||||
|
ModalType::EditIssue(issue_id, modal) => {
|
||||||
|
if let Some(_issue) = model.issues_by_id.get(issue_id) {
|
||||||
|
let details = issues_edit::view(model, modal.as_ref());
|
||||||
|
StyledModal::build()
|
||||||
|
.variant(crate::shared::styled_modal::Variant::Center)
|
||||||
|
.width(1040)
|
||||||
|
.children(vec![details])
|
||||||
|
.build()
|
||||||
|
.into_node()
|
||||||
|
} else {
|
||||||
|
empty![]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ModalType::DeleteIssueConfirm(_id) => crate::modals::issues_delete::view(model),
|
||||||
|
ModalType::AddIssue(modal) => issues_create::view(model, modal),
|
||||||
|
ModalType::DeleteCommentConfirm(comment_id) => {
|
||||||
|
let comment_id = *comment_id;
|
||||||
|
StyledConfirmModal::build()
|
||||||
|
.title("Are you sure you want to delete this comment?")
|
||||||
|
.message("Once you delete, it's gone for good.")
|
||||||
|
.confirm_text("Delete comment")
|
||||||
|
.on_confirm(mouse_ev(Ev::Click, move |_| Msg::DeleteComment(comment_id)))
|
||||||
|
.build()
|
||||||
|
.into_node()
|
||||||
|
}
|
||||||
|
ModalType::TimeTracking(issue_id) => {
|
||||||
|
crate::modals::time_tracking::view(model, *issue_id)
|
||||||
|
}
|
||||||
|
ModalType::DeleteIssueStatusModal(delete_issue_modal) => {
|
||||||
|
issue_statuses_delete::view(model, delete_issue_modal.delete_id)
|
||||||
|
}
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
ModalType::DebugModal => crate::modals::debug::view(model),
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
section![id!["modals"], modals]
|
||||||
|
}
|
@ -3,7 +3,6 @@ use {
|
|||||||
model::{Model, Page},
|
model::{Model, Page},
|
||||||
resolve_page, Msg,
|
resolve_page, Msg,
|
||||||
},
|
},
|
||||||
jirs_data::*,
|
|
||||||
seed::{prelude::*, *},
|
seed::{prelude::*, *},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,10 +62,6 @@ pub fn go_to(url: &str, orders: &mut impl Orders<Msg>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_issue(model: &'_ Model, issue_id: IssueId) -> Option<&'_ Issue> {
|
|
||||||
model.issues.iter().find(|issue| issue.id == issue_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait ToNode {
|
pub trait ToNode {
|
||||||
fn into_node(self) -> Node<Msg>;
|
fn into_node(self) -> Node<Msg>;
|
||||||
}
|
}
|
||||||
@ -78,7 +73,7 @@ pub fn divider() -> Node<Msg> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner_layout(model: &Model, page_name: &str, children: &[Node<Msg>]) -> Node<Msg> {
|
pub fn inner_layout(model: &Model, page_name: &str, children: &[Node<Msg>]) -> Node<Msg> {
|
||||||
let modal_node = crate::modal::view(model);
|
let modal_node = crate::modals::view(model);
|
||||||
article![
|
article![
|
||||||
modal_node,
|
modal_node,
|
||||||
C!["inner-layout", "innerPage"],
|
C!["inner-layout", "innerPage"],
|
||||||
@ -91,7 +86,7 @@ pub fn inner_layout(model: &Model, page_name: &str, children: &[Node<Msg>]) -> N
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_layout(model: &Model, page_name: &str, children: Vec<Node<Msg>>) -> Node<Msg> {
|
pub fn outer_layout(model: &Model, page_name: &str, children: Vec<Node<Msg>>) -> Node<Msg> {
|
||||||
let modal = crate::modal::view(model);
|
let modal = crate::modals::view(model);
|
||||||
article![
|
article![
|
||||||
C!["outer-layout", "outerPage"],
|
C!["outer-layout", "outerPage"],
|
||||||
id![page_name],
|
id![page_name],
|
||||||
|
Loading…
Reference in New Issue
Block a user