From b838c52d7895e7d1e3ac206c8ff530a11a3f5789 Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 6 Jun 2021 00:47:30 -0400 Subject: Improved inventory section for equipped items --- CHANGELOG.md | 2 +- app/views/characters/items/index.html.erb | 38 +++++++++++++++---------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ee3152..d0840be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. ## [Unreleased] ### UI -- New inventory view, with items sorted into categories. +- New inventory view, with items sorted into categories, and a (hopefully) better section for equipped items. ## [0.1.7.2] - 2021-06-05 diff --git a/app/views/characters/items/index.html.erb b/app/views/characters/items/index.html.erb index 140b737..8d0220b 100644 --- a/app/views/characters/items/index.html.erb +++ b/app/views/characters/items/index.html.erb @@ -1,25 +1,23 @@ -

Equipped Items

+

Equipped Items

- - - - - - - - - - <% @character.equipment.order(:slot).each do |eq| %> - - - - - +
+ <% Equipment.slots.each do |slot| %> +
+
<%= slot[0].to_s.humanize %>
+ <% eq = @character.equipment.find_by(slot: slot)%> + <% if eq.present? %> +
<%= eq.item.name %>
+ <% else %> +
+ <% end %> + <% if eq.present? %> +
+ <%= button_to "Unequip", character_item_unequip_path(slot: eq.slot ) %> +
+ <% end %> +
<% end %> -
-
SlotItemUnequip
<%= eq.slot.to_s.humanize %><%= eq.item.name %> - <%= button_to "Unequip", character_item_unequip_path(slot: eq.slot ) %> -
+ <%= render "characters/items/inventory_section", heading: "Equipment", character_items: @character.character_items.ordered_by_item_name.select { |ci| -- cgit v1.2.3