mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-16 08:20:39 +08:00
Bubble up input values from new issue form
This commit is contained in:
+29
-5
@@ -1,11 +1,13 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use radicle::cob::thread::Comment;
|
||||
use radicle::cob::thread::CommentId;
|
||||
|
||||
use radicle::cob::issue::Issue;
|
||||
use radicle::cob::issue::IssueId;
|
||||
use tuirealm::tui::layout::Constraint;
|
||||
use tuirealm::tui::layout::Direction;
|
||||
use tuirealm::tui::layout::Layout;
|
||||
use tuirealm::tui::layout::{Constraint, Direction, Layout};
|
||||
use tuirealm::StateValue;
|
||||
|
||||
|
||||
use super::common::container::{Container, LabeledContainer};
|
||||
use super::common::context::{ContextBar, Progress};
|
||||
@@ -252,6 +254,11 @@ pub struct NewForm {
|
||||
}
|
||||
|
||||
impl NewForm {
|
||||
pub const INPUT_TITLE: &str = "title";
|
||||
pub const INPUT_TAGS: &str = "tags";
|
||||
pub const INPUT_ASSIGNESS: &str = "assignees";
|
||||
pub const INPUT_DESCRIPTION: &str = "description";
|
||||
|
||||
pub fn new(theme: &Theme) -> Self {
|
||||
use tuirealm::props::Layout;
|
||||
|
||||
@@ -300,8 +307,25 @@ impl WidgetComponent for NewForm {
|
||||
fn perform(&mut self, _properties: &Props, cmd: Cmd) -> CmdResult {
|
||||
match self.form.perform(cmd) {
|
||||
CmdResult::Submit(State::Vec(values)) => {
|
||||
println!("{:?}", values);
|
||||
CmdResult::None
|
||||
let inputs = HashMap::from([
|
||||
(
|
||||
Self::INPUT_TITLE.to_owned(),
|
||||
values.get(0).unwrap_or(&StateValue::None).clone(),
|
||||
),
|
||||
(
|
||||
Self::INPUT_TAGS.to_owned(),
|
||||
values.get(1).unwrap_or(&StateValue::None).clone(),
|
||||
),
|
||||
(
|
||||
Self::INPUT_ASSIGNESS.to_owned(),
|
||||
values.get(2).unwrap_or(&StateValue::None).clone(),
|
||||
),
|
||||
(
|
||||
Self::INPUT_DESCRIPTION.to_owned(),
|
||||
values.get(3).unwrap_or(&StateValue::None).clone(),
|
||||
),
|
||||
]);
|
||||
CmdResult::Submit(State::Map(inputs))
|
||||
}
|
||||
_ => CmdResult::None,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user