feat: add command for quickly creating an item
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
4ad8120cb5
commit
832587b51d
@ -6,6 +6,7 @@ pub enum Commands {
|
|||||||
WriteQuit,
|
WriteQuit,
|
||||||
Archive,
|
Archive,
|
||||||
CreateSection { name: String },
|
CreateSection { name: String },
|
||||||
|
CreateItem { name: String },
|
||||||
Edit,
|
Edit,
|
||||||
|
|
||||||
ShowAll,
|
ShowAll,
|
||||||
@ -40,6 +41,9 @@ impl CommandParser {
|
|||||||
"cs" | "create-section" => rest.first().map(|name| Commands::CreateSection {
|
"cs" | "create-section" => rest.first().map(|name| Commands::CreateSection {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
}),
|
}),
|
||||||
|
"ci" | "create-item" => Some(Commands::CreateItem {
|
||||||
|
name: rest.join(" ").to_string(),
|
||||||
|
}),
|
||||||
"e" | "edit" => Some(Commands::Edit),
|
"e" | "edit" => Some(Commands::Edit),
|
||||||
"show-all" => Some(Commands::ShowAll),
|
"show-all" => Some(Commands::ShowAll),
|
||||||
"hide-done" => Some(Commands::HideDone),
|
"hide-done" => Some(Commands::HideDone),
|
||||||
|
@ -6,7 +6,8 @@ use ratatui::{prelude::*, widgets::*};
|
|||||||
use crate::{
|
use crate::{
|
||||||
command_parser::Commands,
|
command_parser::Commands,
|
||||||
commands::{
|
commands::{
|
||||||
batch::BatchCommand, create_section::CreateSectionCommandExt,
|
batch::BatchCommand, create_item::CreateItemCommandExt,
|
||||||
|
create_section::CreateSectionCommandExt,
|
||||||
open_update_item_dialog::OpenUpdateItemDialogCommandExt, toggle_item::ToggleItemCommandExt,
|
open_update_item_dialog::OpenUpdateItemDialogCommandExt, toggle_item::ToggleItemCommandExt,
|
||||||
update_graph::UpdateGraphCommandExt, Command, IntoCommand,
|
update_graph::UpdateGraphCommandExt, Command, IntoCommand,
|
||||||
},
|
},
|
||||||
@ -241,7 +242,7 @@ impl<'a> GraphExplorer<'a> {
|
|||||||
Commands::CreateSection { name } => {
|
Commands::CreateSection { name } => {
|
||||||
if !name.is_empty() {
|
if !name.is_empty() {
|
||||||
let mut path = self.get_current_path();
|
let mut path = self.get_current_path();
|
||||||
path.push(name.replace(" ", "-").replace(".", "-"));
|
path.push(name.replace(".", "-"));
|
||||||
|
|
||||||
// self.state
|
// self.state
|
||||||
// .commander
|
// .commander
|
||||||
@ -258,6 +259,21 @@ impl<'a> GraphExplorer<'a> {
|
|||||||
batch.with(cmd.into_command());
|
batch.with(cmd.into_command());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Commands::CreateItem { name } => {
|
||||||
|
if !name.is_empty() {
|
||||||
|
let mut path = self.get_current_path();
|
||||||
|
path.push(name.replace(".", " "));
|
||||||
|
let cmd = self.state.create_item_command().command(
|
||||||
|
&self.inner.root,
|
||||||
|
&path.iter().map(|i| i.as_str()).collect_vec(),
|
||||||
|
name,
|
||||||
|
"",
|
||||||
|
&hyperlog_core::log::ItemState::default(),
|
||||||
|
);
|
||||||
|
|
||||||
|
batch.with(cmd.into_command());
|
||||||
|
}
|
||||||
|
}
|
||||||
Commands::Edit => {
|
Commands::Edit => {
|
||||||
if let Some(item) = self.get_current_item() {
|
if let Some(item) = self.get_current_item() {
|
||||||
let path = self.get_current_path();
|
let path = self.get_current_path();
|
||||||
|
Loading…
Reference in New Issue
Block a user