diff --git a/Gemfile.lock b/Gemfile.lock
index 8fdeb3e4f..f81512db4 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -300,10 +300,10 @@ GEM
actionpack (>= 3.1, < 7.1)
railties (>= 3.1, < 7.1)
ruby2_keywords (0.0.5)
- sentry-rails (5.4.2)
+ sentry-rails (5.5.0)
railties (>= 5.0)
- sentry-ruby (~> 5.4.2)
- sentry-ruby (5.4.2)
+ sentry-ruby (~> 5.5.0)
+ sentry-ruby (5.5.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
shoulda-matchers (5.2.0)
activesupport (>= 5.2.0)
@@ -349,7 +349,7 @@ GEM
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
- zeitwerk (2.6.0)
+ zeitwerk (2.6.1)
PLATFORMS
ruby
diff --git a/app/furniture/marketplace.rb b/app/furniture/marketplace.rb
index 5d39e0f5d..cefb186ae 100644
--- a/app/furniture/marketplace.rb
+++ b/app/furniture/marketplace.rb
@@ -4,7 +4,7 @@ class Marketplace
def self.append_routes(router)
router.resource :marketplace, only: [] do
- router.resources :products, only: %i[create index], module: 'marketplace'
+ router.resources :products, only: %i[new create index], module: 'marketplace'
end
end
diff --git a/app/furniture/marketplace/_marketplace.html.erb b/app/furniture/marketplace/_marketplace.html.erb
index 1904c5960..27b30ca34 100644
--- a/app/furniture/marketplace/_marketplace.html.erb
+++ b/app/furniture/marketplace/_marketplace.html.erb
@@ -1,12 +1 @@
-
Marketplace
-
-
-
Products
- <%= render marketplace.products %>
-
-<%= form_with model: [marketplace.space, marketplace.room, marketplace.products.new] do |f| %>
- <%= render "text_field", { attribute: :name, form: f} %>
- <%= render "text_area", { attribute: :description, form: f} %>
- <%= render "number_field", { attribute: :price_cents, form: f} %>
- <%= f.submit %>
-<% end %>
+<%= render partial: "marketplace/marketplace/marketplace", object: marketplace %>
\ No newline at end of file
diff --git a/app/furniture/marketplace/marketplace/_marketplace.html.erb b/app/furniture/marketplace/marketplace/_marketplace.html.erb
new file mode 100644
index 000000000..c8c1b0d8e
--- /dev/null
+++ b/app/furniture/marketplace/marketplace/_marketplace.html.erb
@@ -0,0 +1,26 @@
+<%= turbo_frame_tag marketplace do %>
+
+
+
+
+
+ <%= Marketplace::Product.human_attribute_name(:name) %>
+ |
+
+ <%= Marketplace::Product.human_attribute_name(:description) %>
+ |
+
+ <%= Marketplace::Product.human_attribute_name(:price) %>
+ |
+
+ Actions
+ <%= render "buttons/new", title: t('marketplace.products.new'), href: [:new, marketplace.space, marketplace.room, marketplace, :product] %>
+ |
+
+
+
+ <%= render marketplace.products %>
+
+
+
+<%- end %>
\ No newline at end of file
diff --git a/app/furniture/marketplace/product.rb b/app/furniture/marketplace/product.rb
index 921a3cbe5..298f48f25 100644
--- a/app/furniture/marketplace/product.rb
+++ b/app/furniture/marketplace/product.rb
@@ -1,6 +1,11 @@
+# frozen_string_literal: true
+
class Marketplace
class Product < ApplicationRecord
self.table_name = 'marketplace_products'
+ attribute :name, :string
+ attribute :description, :string
+ monetize :price_cents
belongs_to :space
end
end
diff --git a/app/furniture/marketplace/products/_product.html.erb b/app/furniture/marketplace/products/_product.html.erb
index 2190ab805..15d776a7d 100644
--- a/app/furniture/marketplace/products/_product.html.erb
+++ b/app/furniture/marketplace/products/_product.html.erb
@@ -1,5 +1,18 @@
-<%= product.name %>
-
-<%= product.description %>
-
-
\ No newline at end of file
+
+
+ <%= product.name %>
+
+ - <%= product.class.human_attribute_name(:description) %>
+ - <%= product.description %>
+
+ |
+
+ <%= product.description %>
+ |
+
+ <%= humanized_money_with_symbol(product.price) %>
+ |
+
+ <%= render "buttons/new", label: "🛒", title: t('marketplace.products.new'), href: "#" %>
+ |
+
\ No newline at end of file
diff --git a/app/furniture/marketplace/products/create.turbo_stream.erb b/app/furniture/marketplace/products/create.turbo_stream.erb
new file mode 100644
index 000000000..ccc8a300a
--- /dev/null
+++ b/app/furniture/marketplace/products/create.turbo_stream.erb
@@ -0,0 +1 @@
+<%= turbo_stream.replace(marketplace, marketplace) %>
\ No newline at end of file
diff --git a/app/furniture/marketplace/products/new.html.erb b/app/furniture/marketplace/products/new.html.erb
new file mode 100644
index 000000000..c263ef1ca
--- /dev/null
+++ b/app/furniture/marketplace/products/new.html.erb
@@ -0,0 +1,8 @@
+<%= turbo_frame_tag marketplace do %>
+ <%= form_with model: [marketplace.space, marketplace.room, marketplace.products.new] do |f| %>
+ <%= render "text_field", { attribute: :name, form: f} %>
+ <%= render "text_area", { attribute: :description, form: f} %>
+ <%= render "number_field", { attribute: :price_cents, form: f} %>
+ <%= f.submit %>
+ <% end %>
+<%- end %>
\ No newline at end of file
diff --git a/app/furniture/marketplace/products_controller.rb b/app/furniture/marketplace/products_controller.rb
index 3a59d534e..f78d33d5b 100644
--- a/app/furniture/marketplace/products_controller.rb
+++ b/app/furniture/marketplace/products_controller.rb
@@ -1,13 +1,20 @@
class Marketplace
class ProductsController < FurnitureController
+ def new
+
+ end
+
def create
product = marketplace.products.new(product_params)
product.save!
- render product
+ respond_to do |format|
+ format.turbo_stream
+ format.html { redirect_to [space, room] }
+ end
end
- def marketplace
+ helper_method def marketplace
Marketplace.find_by(room: room)
end
diff --git a/app/furniture/spotlight.rb b/app/furniture/spotlight.rb
index 06286dd09..4a12eead8 100644
--- a/app/furniture/spotlight.rb
+++ b/app/furniture/spotlight.rb
@@ -2,6 +2,7 @@
class Spotlight
include Placeable
+ delegate :alt_text,:alt_text=, to: :image
def self.deprecated_append_routes(router)
router.scope module: 'spotlight' do
@@ -15,6 +16,10 @@ def image
Image.find_or_initialize_by(location: placement, space: placement.space)
end
+ def alt_text=text
+ image.update(alt_text:text)
+ end
+
def file=file
image.file.attach(file)
end
@@ -26,6 +31,6 @@ def in_room_template
end
def attribute_names
- %w[file]
+ %w[file alt_text]
end
end
diff --git a/app/furniture/spotlight/_form.html.erb b/app/furniture/spotlight/_form.html.erb
index a82d447e9..5a6645aa2 100644
--- a/app/furniture/spotlight/_form.html.erb
+++ b/app/furniture/spotlight/_form.html.erb
@@ -1,3 +1,4 @@
<%= form.fields_for(:furniture) do |furniture_fields| %>
<%= render "file_field", form: furniture_fields, attribute: :file %>
+ <%= render "text_field", form: furniture_fields, attribute: :alt_text %>
<%- end %>
\ No newline at end of file
diff --git a/app/furniture/spotlight/_in_room.html.erb b/app/furniture/spotlight/_in_room.html.erb
index 439491c11..f153f232c 100644
--- a/app/furniture/spotlight/_in_room.html.erb
+++ b/app/furniture/spotlight/_in_room.html.erb
@@ -1,4 +1,4 @@
<%- if furniture.image.file.present? %>
- <%= image_tag furniture.image.file %>
+ <%= image_tag furniture.image.file, alt: furniture.alt_text %>
<%- end %>
\ No newline at end of file
diff --git a/app/furniture/spotlight/image.rb b/app/furniture/spotlight/image.rb
index 814245d93..42fef10f7 100644
--- a/app/furniture/spotlight/image.rb
+++ b/app/furniture/spotlight/image.rb
@@ -3,5 +3,12 @@
class Spotlight
class Image < Item
has_one_attached :file
+ def alt_text=text
+ data["alt_text"]=text
+ end
+
+ def alt_text
+ data["alt_text"]
+ end
end
end
diff --git a/app/views/buttons/_new.html.erb b/app/views/buttons/_new.html.erb
new file mode 100644
index 000000000..be8a3e249
--- /dev/null
+++ b/app/views/buttons/_new.html.erb
@@ -0,0 +1,6 @@
+<%- label = local_assigns.fetch(:label, t('icons.new')) %>
+<%- title = local_assigns.fetch(:title) %>
+<%- href = local_assigns.fetch(:href) %>
+
+<%= link_to label, href, title: title,
+ class: 'no-underline bg-transparent hover:bg-primary-100 button' %>
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 9639c2860..964bc37e0 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -78,7 +78,7 @@
config.logger = ActiveSupport::Logger.new(STDOUT)
# Annotate rendered view with file names.
- # config.action_view.annotate_rendered_view_with_filenames = true
+ config.action_view.annotate_rendered_view_with_filenames = true
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
diff --git a/config/locales/icon/en.yml b/config/locales/icon/en.yml
index 24c40e136..3a1758717 100644
--- a/config/locales/icon/en.yml
+++ b/config/locales/icon/en.yml
@@ -1,4 +1,5 @@
en:
icons:
edit: '⚙️'
- remove: '🗑️'
\ No newline at end of file
+ remove: '🗑️'
+ new: '➕'
\ No newline at end of file
diff --git a/package.json b/package.json
index 27908d582..0f0e37d16 100644
--- a/package.json
+++ b/package.json
@@ -55,7 +55,7 @@
"@webpack-cli/serve": "^1.7.0",
"autoprefixer": "^10.4.12",
"event-target-shim": "^6.0.2",
- "postcss": "^8.4.16",
+ "postcss": "^8.4.17",
"postcss-cli": "^10.0.0",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-import": "^15.0.0",
diff --git a/yarn.lock b/yarn.lock
index fda4b6712..84afe66bf 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3433,10 +3433,10 @@ postcss-value-parser@^4.0.0, postcss-value-parser@^4.2.0:
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514"
integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==
-postcss@^8.4.14, postcss@^8.4.16:
- version "8.4.16"
- resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.16.tgz#33a1d675fac39941f5f445db0de4db2b6e01d43c"
- integrity sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ==
+postcss@^8.4.14, postcss@^8.4.17:
+ version "8.4.17"
+ resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.17.tgz#f87863ec7cd353f81f7ab2dec5d67d861bbb1be5"
+ integrity sha512-UNxNOLQydcOFi41yHNMcKRZ39NeXlr8AxGuZJsdub8vIb12fHzcq37DTU/QtbI6WLxNg2gF9Z+8qtRwTj1UI1Q==
dependencies:
nanoid "^3.3.4"
picocolors "^1.0.0"