Summary of Fixes
Issue 1: Slot Name Mismatch - Equipment modal used armor, accessory but API uses chest, accessory_1 - Updated to all 8 API slots: weapon, off_hand, helmet, chest, gloves, boots, accessory_1, accessory_2 Issue 2: HTMX Request Not Firing (the real blocker) - onclick=closeModal() was removing the button from DOM before HTMX could send the request - Changed to hx-on::after-request=closeModal() so modal closes after the request completes
This commit is contained in:
@@ -1323,6 +1323,10 @@ def inventory_equip(session_id: str):
|
||||
if not item_id:
|
||||
return '<div class="error">No item selected</div>', 400
|
||||
|
||||
if not slot:
|
||||
logger.warning("equip_missing_slot", item_id=item_id)
|
||||
return '<div class="error">No equipment slot specified</div>', 400
|
||||
|
||||
try:
|
||||
# Get session to find character
|
||||
session_response = client.get(f'/api/v1/sessions/{session_id}')
|
||||
@@ -1333,17 +1337,14 @@ def inventory_equip(session_id: str):
|
||||
return '<div class="error">No character found</div>', 400
|
||||
|
||||
# Equip the item via API
|
||||
payload = {'item_id': item_id}
|
||||
if slot:
|
||||
payload['slot'] = slot
|
||||
|
||||
payload = {'item_id': item_id, 'slot': slot}
|
||||
client.post(f'/api/v1/characters/{character_id}/inventory/equip', payload)
|
||||
|
||||
# Return updated character panel
|
||||
return redirect(url_for('game.character_panel', session_id=session_id))
|
||||
|
||||
except APIError as e:
|
||||
logger.error("failed_to_equip_item", session_id=session_id, item_id=item_id, error=str(e))
|
||||
logger.error("failed_to_equip_item", session_id=session_id, item_id=item_id, slot=slot, error=str(e))
|
||||
return f'<div class="error">Failed to equip item: {e}</div>', 500
|
||||
|
||||
|
||||
|
||||
@@ -12,14 +12,17 @@ Displays character's equipped gear and inventory summary
|
||||
|
||||
{# Modal Body #}
|
||||
<div class="modal-body">
|
||||
{# Equipment Grid #}
|
||||
{# Equipment Grid - All 8 slots matching API #}
|
||||
<div class="equipment-grid">
|
||||
{% set slots = [
|
||||
('weapon', 'Weapon'),
|
||||
('armor', 'Armor'),
|
||||
('off_hand', 'Off-Hand'),
|
||||
('helmet', 'Helmet'),
|
||||
('chest', 'Chest Armor'),
|
||||
('gloves', 'Gloves'),
|
||||
('boots', 'Boots'),
|
||||
('accessory', 'Accessory')
|
||||
('accessory_1', 'Accessory 1'),
|
||||
('accessory_2', 'Accessory 2')
|
||||
] %}
|
||||
|
||||
{% for slot_id, slot_name in slots %}
|
||||
@@ -34,11 +37,15 @@ Displays character's equipped gear and inventory summary
|
||||
{# Equipped Item #}
|
||||
<div class="slot-item">
|
||||
<div class="slot-icon">
|
||||
{% if item.item_type == 'weapon' %}⚔️
|
||||
{% elif item.item_type == 'armor' %}🛡️
|
||||
{% elif item.item_type == 'helmet' %}⛑️
|
||||
{% elif item.item_type == 'boots' %}👢
|
||||
{% elif item.item_type == 'accessory' %}💍
|
||||
{# Icon based on slot_id since item_type doesn't distinguish armor slots #}
|
||||
{% if slot_id == 'weapon' %}⚔️
|
||||
{% elif slot_id == 'off_hand' %}🛡️
|
||||
{% elif slot_id == 'helmet' %}⛑️
|
||||
{% elif slot_id == 'chest' %}🎽
|
||||
{% elif slot_id == 'gloves' %}🧤
|
||||
{% elif slot_id == 'boots' %}👢
|
||||
{% elif slot_id == 'accessory_1' %}💍
|
||||
{% elif slot_id == 'accessory_2' %}📿
|
||||
{% else %}📦{% endif %}
|
||||
</div>
|
||||
<div class="slot-details">
|
||||
@@ -63,10 +70,13 @@ Displays character's equipped gear and inventory summary
|
||||
<div class="slot-empty">
|
||||
<div class="slot-icon slot-icon--empty">
|
||||
{% if slot_id == 'weapon' %}⚔️
|
||||
{% elif slot_id == 'armor' %}🛡️
|
||||
{% elif slot_id == 'off_hand' %}🛡️
|
||||
{% elif slot_id == 'helmet' %}⛑️
|
||||
{% elif slot_id == 'chest' %}🎽
|
||||
{% elif slot_id == 'gloves' %}🧤
|
||||
{% elif slot_id == 'boots' %}👢
|
||||
{% elif slot_id == 'accessory' %}💍
|
||||
{% elif slot_id == 'accessory_1' %}💍
|
||||
{% elif slot_id == 'accessory_2' %}📿
|
||||
{% else %}📦{% endif %}
|
||||
</div>
|
||||
<div class="slot-empty-text">Empty</div>
|
||||
|
||||
@@ -96,7 +96,7 @@ Partial template loaded via HTMX when an item is selected
|
||||
hx-vals='{"item_id": "{{ item.item_id }}"{% if suggested_slot %}, "slot": "{{ suggested_slot }}"{% endif %}}'
|
||||
hx-target="#character-panel"
|
||||
hx-swap="innerHTML"
|
||||
onclick="closeModal()">
|
||||
hx-on::after-request="closeModal()">
|
||||
Equip
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user