fix: problems with prop dropping
This commit is contained in:
parent
845d64c981
commit
a96581cbf0
4 changed files with 115 additions and 50 deletions
|
|
@ -251,6 +251,7 @@ pub fn InventoryPopup(
|
|||
let item = items.get().into_iter().find(|i| i.id == item_id)?;
|
||||
let handle_drop = handle_drop.clone();
|
||||
let is_dropping = dropping.get();
|
||||
let is_droppable = item.is_droppable;
|
||||
|
||||
Some(view! {
|
||||
<div class="mt-4 pt-4 border-t border-gray-700">
|
||||
|
|
@ -260,15 +261,25 @@ pub fn InventoryPopup(
|
|||
<p class="text-gray-400 text-sm">
|
||||
{if item.is_transferable { "Transferable" } else { "Not transferable" }}
|
||||
{if item.is_portable { " \u{2022} Portable" } else { "" }}
|
||||
{if is_droppable { " \u{2022} Droppable" } else { " \u{2022} Essential" }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
// Drop button
|
||||
// Drop button - disabled for non-droppable (essential) props
|
||||
<button
|
||||
type="button"
|
||||
class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50"
|
||||
on:click=move |_| handle_drop(item_id)
|
||||
disabled=is_dropping
|
||||
class=if is_droppable {
|
||||
"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50"
|
||||
} else {
|
||||
"px-4 py-2 bg-gray-600 text-gray-400 rounded-lg cursor-not-allowed"
|
||||
}
|
||||
on:click=move |_| {
|
||||
if is_droppable {
|
||||
handle_drop(item_id);
|
||||
}
|
||||
}
|
||||
disabled=is_dropping || !is_droppable
|
||||
title=if is_droppable { "" } else { "Essential prop cannot be dropped" }
|
||||
>
|
||||
{if is_dropping { "Dropping..." } else { "Drop" }}
|
||||
</button>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue