From 771a7672876ff2c9649c919395a4d23f2a66f16f Mon Sep 17 00:00:00 2001 From: David Gay Date: Sat, 5 Jun 2021 19:46:12 -0400 Subject: Bazaar: Merge "your orders" with "buy orders" and "sell orders", and sort buy orders highest price to lowest --- CHANGELOG.md | 5 ++++ app/controllers/bazaar_controller.rb | 2 +- app/views/bazaar/index.html.erb | 46 +++++++++++++----------------------- 3 files changed, 22 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da38aa4..4223b84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,11 @@ All notable changes to this project will be documented in this file. future. - Currently, non-combat activities do not put your items at risk. This will change in the future. +### Bazaar +- Buy orders are now sorted highest price to lowest price, so the most desirable orders are at the top. +- Removed "Your Orders" section, instead adding your orders back to the "Sell Orders" and "Buy Orders" lists, + including a "Cancel" button. + ## UI - Game now scales to screen size, and a bit more relative space is given to the main box. This may have introduced undesirable consequences, especially on mobile. Please report these consequences with screenshots, and let's work diff --git a/app/controllers/bazaar_controller.rb b/app/controllers/bazaar_controller.rb index 3492053..5ed8a59 100644 --- a/app/controllers/bazaar_controller.rb +++ b/app/controllers/bazaar_controller.rb @@ -1,6 +1,6 @@ class BazaarController < ApplicationController def index - @bazaar_orders = BazaarOrder.joins(:item).order("items.name ASC, price_each ASC, created_at ASC") + @bazaar_orders = BazaarOrder.joins(:item) @items = Item.all.order(:name) end diff --git a/app/views/bazaar/index.html.erb b/app/views/bazaar/index.html.erb index e41fb2c..28f7109 100644 --- a/app/views/bazaar/index.html.erb +++ b/app/views/bazaar/index.html.erb @@ -35,34 +35,6 @@ <% end %> -
-

Your Orders

- - - - - - - - - - - - <% @bazaar_orders.where(character: current_char).each do |bo| %> - - - - - - - - <% end %> - -
ItemQuantityTypePrice EachCancel
<%= bo.item.name %><%= bo.quantity %><%= bo.buy_order? ? "Buy" : "Sell" %><%= bo.price_each %> - <%= button_to "Cancel", bazzar_cancel_offer_path(id: bo.id), method: :delete %> -
-
-

Sell Orders

@@ -74,10 +46,12 @@ From Price Each Buy + Cancel - <% @bazaar_orders.where(buy_order: false).where.not(character: current_char).each do |bo| %> + <% @bazaar_orders.where(buy_order: false) + .order("items.name ASC, price_each ASC, created_at ASC").each do |bo| %> <%= bo.item.name %> <%= bo.quantity %> @@ -89,6 +63,11 @@ <%= f.submit "Buy" %> <% end %> + + <% if bo.character == current_char %> + <%= button_to "Cancel", bazzar_cancel_offer_path(id: bo.id), method: :delete %> + <% end %> + <% end %> @@ -106,10 +85,12 @@ From Price Each Sell + Cancel - <% @bazaar_orders.where(buy_order: true).where.not(character: current_char).each do |bo| %> + <% @bazaar_orders.where(buy_order: true) + .order("items.name ASC, price_each DESC, created_at ASC").each do |bo| %> <%= bo.item.name %> <%= bo.quantity %> @@ -121,6 +102,11 @@ <%= f.submit "Sell" %> <% end %> + + <% if bo.character == current_char %> + <%= button_to "Cancel", bazzar_cancel_offer_path(id: bo.id), method: :delete %> + <% end %> + <% end %> -- cgit v1.2.3