feat: add an artificial task to empty the inbox #135
@@ -2,8 +2,9 @@ use crate::components::task_list::TaskList;
|
||||
use crate::hooks::use_tasks_with_subtasks_in_category;
|
||||
use crate::internationalization::LocaleFromLanguageIdentifier;
|
||||
use crate::models::category::Category;
|
||||
use crate::models::task::TaskWithSubtasks;
|
||||
use chrono::Local;
|
||||
use crate::models::task::{Task, TaskWithSubtasks};
|
||||
use crate::route::Route;
|
||||
use chrono::{Local, NaiveDateTime};
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_free_icons::Icon;
|
||||
use dioxus_free_icons::icons::fa_solid_icons::{FaCalendarCheck, FaCalendarXmark, FaWater};
|
||||
@@ -42,6 +43,7 @@ pub(crate) fn CategoryTodayTaskList() -> Element {
|
||||
.cloned()
|
||||
.collect::<Vec<TaskWithSubtasks>>();
|
||||
let long_term_tasks = use_tasks_with_subtasks_in_category(Category::LongTerm)?;
|
||||
let inbox_tasks = use_tasks_with_subtasks_in_category(Category::Inbox)?;
|
||||
|
||||
rsx! {
|
||||
div {
|
||||
@@ -116,9 +118,33 @@ pub(crate) fn CategoryTodayTaskList() -> Element {
|
||||
}
|
||||
}
|
||||
}
|
||||
div {
|
||||
TaskList {
|
||||
tasks: today_tasks
|
||||
}
|
||||
if !inbox_tasks.is_empty() {
|
||||
Link {
|
||||
to: Route::CategoryInboxPage {},
|
||||
TaskList {
|
||||
is_interactive: false,
|
||||
tasks: vec![
|
||||
TaskWithSubtasks {
|
||||
task: Task {
|
||||
id: 0,
|
||||
title: t!("empty-inbox")._upper_first(),
|
||||
deadline: None,
|
||||
category: Category::Inbox,
|
||||
project_id: None,
|
||||
created_at: NaiveDateTime::default(),
|
||||
updated_at: NaiveDateTime::default()
|
||||
},
|
||||
subtasks: Vec::new()
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,12 @@ use dioxus::dioxus_core::Element;
|
||||
use dioxus::prelude::*;
|
||||
|
||||
#[component]
|
||||
pub(crate) fn TaskList(tasks: Vec<TaskWithSubtasks>, class: Option<&'static str>) -> Element {
|
||||
pub(crate) fn TaskList(
|
||||
tasks: Vec<TaskWithSubtasks>,
|
||||
/// Whether to open and complete tasks on clicks.
|
||||
is_interactive: Option<bool>,
|
||||
class: Option<&'static str>,
|
||||
) -> Element {
|
||||
let navigator = use_navigator();
|
||||
rsx! {
|
||||
div {
|
||||
@@ -34,6 +39,9 @@ pub(crate) fn TaskList(tasks: Vec<TaskWithSubtasks>, class: Option<&'static str>
|
||||
onclick: {
|
||||
let task = task.clone();
|
||||
move |_| {
|
||||
if let Some(false) = is_interactive {
|
||||
return;
|
||||
}
|
||||
*TASK_BEING_EDITED.write() = Some(task.task.clone());
|
||||
navigator.push(Route::TaskFormPage);
|
||||
}
|
||||
@@ -49,6 +57,9 @@ pub(crate) fn TaskList(tasks: Vec<TaskWithSubtasks>, class: Option<&'static str>
|
||||
// To prevent editing the task.
|
||||
event.stop_propagation();
|
||||
async move {
|
||||
if let Some(false) = is_interactive {
|
||||
return;
|
||||
}
|
||||
let _ = complete_task(task.task.id).await;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ yesterday = včera
|
||||
today = dnes
|
||||
tomorrow = zítra
|
||||
overdue = zpožděné
|
||||
empty-inbox = vyprázdnit schránku
|
||||
|
||||
## Date and time formats
|
||||
date-format = %-d. %B
|
||||
|
||||
@@ -4,6 +4,7 @@ yesterday = yesterday
|
||||
today = today
|
||||
tomorrow = tomorrow
|
||||
overdue = overdue
|
||||
empty-inbox = empty the inbox
|
||||
|
||||
## Date and time formats
|
||||
date-format = %B %-d
|
||||
|
||||
Reference in New Issue
Block a user