migration, adding categories, small fixes
This commit is contained in:
@@ -13,6 +13,7 @@ impl Inventory {
|
||||
div ."p-8" ."grid" ."grid-cols-4" ."gap-3" {
|
||||
div ."col-span-2" {
|
||||
(InventoryCategoryList::build(&state, &categories))
|
||||
(InventoryNewCategoryForm::build())
|
||||
}
|
||||
div ."col-span-2" {
|
||||
h1 ."text-2xl" ."mb-5" ."text-center" { "Items" }
|
||||
@@ -409,3 +410,53 @@ impl InventoryNewItemForm {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct InventoryNewCategoryForm;
|
||||
|
||||
impl InventoryNewCategoryForm {
|
||||
pub fn build() -> Markup {
|
||||
html!(
|
||||
form
|
||||
name="new-category"
|
||||
id="new-category"
|
||||
action="/inventory/category/"
|
||||
target="_self"
|
||||
method="post"
|
||||
."mt-8" ."p-5" ."border-2" ."border-gray-200" {
|
||||
div ."mb-5" ."flex" ."flex-row" ."items-center" {
|
||||
span ."mdi" ."mdi-playlist-plus" ."text-2xl" ."mr-4" {}
|
||||
p ."inline" ."text-xl" { "Add new category" }
|
||||
}
|
||||
div ."w-11/12" ."mx-auto" {
|
||||
div ."pb-8" {
|
||||
div ."flex" ."flex-row" ."justify-center" ."items-start"{
|
||||
label for="name" .font-bold ."w-1/2" ."p-2" ."text-center" { "Name" }
|
||||
span ."w-1/2" {
|
||||
input type="text" id="new-category-name" name="new-category-name"
|
||||
."block"
|
||||
."w-full"
|
||||
."p-2"
|
||||
."bg-gray-50"
|
||||
."border-2"
|
||||
."rounded"
|
||||
."focus:outline-none"
|
||||
."focus:bg-white"
|
||||
."focus:border-purple-500"
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
input type="submit" value="Add"
|
||||
."py-2"
|
||||
."border-2"
|
||||
."rounded"
|
||||
."border-gray-300"
|
||||
."mx-auto"
|
||||
."w-full" {
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,61 +411,73 @@ impl TripInfo {
|
||||
."flex-wrap"
|
||||
."gap-2"
|
||||
."justify-between"
|
||||
// as we have a gap between the elements, we have
|
||||
// to completely skip an element when there are no
|
||||
// active or inactive items, otherwise we get the gap
|
||||
// between the empty (invisible) item, throwing off
|
||||
// the margins
|
||||
{
|
||||
@let types = trip.types();
|
||||
div
|
||||
."flex"
|
||||
."flex-row"
|
||||
."flex-wrap"
|
||||
."gap-2"
|
||||
."justify-start"
|
||||
{
|
||||
@for triptype in types.iter().filter(|t| t.active) {
|
||||
a href=(format!("type/{}/remove", triptype.id)) {
|
||||
li
|
||||
."border"
|
||||
."rounded-2xl"
|
||||
."py-0.5"
|
||||
."px-2"
|
||||
."bg-green-100"
|
||||
."cursor-pointer"
|
||||
."flex"
|
||||
."flex-column"
|
||||
."items-center"
|
||||
."hover:bg-red-200"
|
||||
."gap-1"
|
||||
{
|
||||
span { (triptype.name) }
|
||||
span ."mdi" ."mdi-delete" ."text-sm" {}
|
||||
@let active_triptypes = types.iter().filter(|t| t.active).collect::<Vec<&TripType>>();
|
||||
@let inactive_triptypes = types.iter().filter(|t| !t.active).collect::<Vec<&TripType>>();
|
||||
|
||||
@if !active_triptypes.is_empty() {
|
||||
div
|
||||
."flex"
|
||||
."flex-row"
|
||||
."flex-wrap"
|
||||
."gap-2"
|
||||
."justify-start"
|
||||
{
|
||||
@for triptype in active_triptypes {
|
||||
a href=(format!("type/{}/remove", triptype.id)) {
|
||||
li
|
||||
."border"
|
||||
."rounded-2xl"
|
||||
."py-0.5"
|
||||
."px-2"
|
||||
."bg-green-100"
|
||||
."cursor-pointer"
|
||||
."flex"
|
||||
."flex-column"
|
||||
."items-center"
|
||||
."hover:bg-red-200"
|
||||
."gap-1"
|
||||
{
|
||||
span { (triptype.name) }
|
||||
span ."mdi" ."mdi-delete" ."text-sm" {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
div
|
||||
."flex"
|
||||
."flex-row"
|
||||
."flex-wrap"
|
||||
."gap-2"
|
||||
."justify-start"
|
||||
{
|
||||
@for triptype in types.iter().filter(|t| !t.active) {
|
||||
a href=(format!("type/{}/add", triptype.id)) {
|
||||
li
|
||||
."border"
|
||||
."rounded-2xl"
|
||||
."py-0.5"
|
||||
."px-2"
|
||||
."bg-gray-100"
|
||||
."cursor-pointer"
|
||||
."flex"
|
||||
."flex-column"
|
||||
."items-center"
|
||||
."hover:bg-green-200"
|
||||
."gap-1"
|
||||
."opacity-60"
|
||||
{
|
||||
span { (triptype.name) }
|
||||
span ."mdi" ."mdi-plus" ."text-sm" {}
|
||||
@if !inactive_triptypes.is_empty() {
|
||||
div
|
||||
."flex"
|
||||
."flex-row"
|
||||
."flex-wrap"
|
||||
."gap-2"
|
||||
."justify-start"
|
||||
{
|
||||
@for triptype in inactive_triptypes {
|
||||
a href=(format!("type/{}/add", triptype.id)) {
|
||||
li
|
||||
."border"
|
||||
."rounded-2xl"
|
||||
."py-0.5"
|
||||
."px-2"
|
||||
."bg-gray-100"
|
||||
."cursor-pointer"
|
||||
."flex"
|
||||
."flex-column"
|
||||
."items-center"
|
||||
."hover:bg-green-200"
|
||||
."gap-1"
|
||||
."opacity-60"
|
||||
{
|
||||
span { (triptype.name) }
|
||||
span ."mdi" ."mdi-plus" ."text-sm" {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user