add todos
This commit is contained in:
@@ -370,6 +370,7 @@ impl Trip {
|
||||
}
|
||||
}
|
||||
(TripInfo::build(trip_edit_attribute, trip))
|
||||
(TripTodoList::build(trip))
|
||||
(TripComment::build(trip))
|
||||
(TripItems::build(active_category, trip))
|
||||
}
|
||||
@@ -794,6 +795,113 @@ impl TripInfo {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TripTodo;
|
||||
|
||||
impl TripTodo {
|
||||
#[tracing::instrument]
|
||||
pub fn build(trip_id: &Uuid, todo: &models::trips::todos::Todo) -> Markup {
|
||||
let done = todo.is_done();
|
||||
html!(
|
||||
li
|
||||
."flex"
|
||||
."flex-row"
|
||||
."justify-start"
|
||||
."items-stretch"
|
||||
."bg-green-50"[done]
|
||||
."bg-red-50"[!done]
|
||||
."hover:bg-white"[!done]
|
||||
."h-full"
|
||||
{
|
||||
@if done {
|
||||
a
|
||||
."flex"
|
||||
."flex-row"
|
||||
."aspect-square"
|
||||
href={
|
||||
"/trips/" (trip_id)
|
||||
"/todo/" (todo.id)
|
||||
"/undone"
|
||||
}
|
||||
hx-post={
|
||||
"/trips/" (trip_id)
|
||||
"/todo/" (todo.id)
|
||||
"/undone"
|
||||
}
|
||||
hx-target="closest li"
|
||||
hx-swap="outerHTML"
|
||||
{
|
||||
span
|
||||
."mdi"
|
||||
."m-auto"
|
||||
."text-xl"
|
||||
."mdi-check"
|
||||
{}
|
||||
}
|
||||
} @else {
|
||||
a
|
||||
."flex"
|
||||
."flex-row"
|
||||
."aspect-square"
|
||||
href={
|
||||
"/trips/" (trip_id)
|
||||
"/todo/" (todo.id)
|
||||
"/done"
|
||||
}
|
||||
hx-post={
|
||||
"/trips/" (trip_id)
|
||||
"/todo/" (todo.id)
|
||||
"/done"
|
||||
}
|
||||
hx-target="closest li"
|
||||
hx-swap="outerHTML"
|
||||
{
|
||||
span
|
||||
."mdi"
|
||||
."m-auto"
|
||||
."text-xl"
|
||||
."mdi-checkbox-blank-outline"
|
||||
{}
|
||||
}
|
||||
}
|
||||
span
|
||||
."p-2"
|
||||
{
|
||||
(todo.description)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TripTodoList;
|
||||
|
||||
impl TripTodoList {
|
||||
#[tracing::instrument]
|
||||
pub fn build(trip: &models::trips::Trip) -> Markup {
|
||||
let todos = trip.todos();
|
||||
html!(
|
||||
div {
|
||||
h1 ."text-xl" ."mb-5" { "Todos" }
|
||||
|
||||
@if todos.is_empty() {
|
||||
p { "no todos" }
|
||||
|
||||
} @else {
|
||||
|
||||
ul
|
||||
."flex"
|
||||
."flex-col"
|
||||
{
|
||||
@for todo in trip.todos() {
|
||||
(TripTodo::build(&trip.id, &todo))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TripComment;
|
||||
|
||||
impl TripComment {
|
||||
|
||||
Reference in New Issue
Block a user