Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞🔨 Gizmo: Fix bug where removing a Gizmo fails #1592

Merged
merged 1 commit into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/assets/stylesheets/components/button.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* @todo DELETE ME */
@layer components {
[type="reset"],
[type="button"],
[type="submit"],
button,
.button {
@apply font-bold py-2 px-4 my-1 rounded bg-primary-500 text-white text-center transition ease-in-out duration-150;
@apply font-bold py-2 px-4 rounded bg-primary-500 text-white text-center transition ease-in-out duration-150;

&:hover {
@apply bg-primary-700;
Expand Down
8 changes: 7 additions & 1 deletion app/components/button_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
class ButtonComponent < ApplicationComponent
SCHEME_MAPPINGS = {
primary: :primary_classes,
secondary: :secondary_classes
secondary: :secondary_classes,
danger: :danger_classes
}.with_indifferent_access.freeze

def initialize(
Expand Down Expand Up @@ -61,6 +62,7 @@ def base_classes
"shadow-sm",
"ring-1",
"ring-inset",
"text-center",
"no-underline",
"focus-visible:outline",
"focus-visible:outline-2",
Expand All @@ -79,6 +81,10 @@ def secondary_classes
]
end

def danger_classes
["bg-danger-500 hover:bg-danger-700 active:bg-danger-200 text-white"]
end

def primary_classes
[
"bg-purple-600",
Expand Down
11 changes: 7 additions & 4 deletions app/views/furnitures/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<section id="<%= dom_id(furniture) %>">
<%- if policy(furniture).edit? %>
<%= form_with(model: [furniture.room.space, furniture.room, furniture], local: true) do |form| %>
<%= form_with(model: [furniture.room.space, furniture.room, furniture]) do |form| %>
<div>
<%= render partial: furniture.furniture.form_template, locals: { form: form } %>
</div>
<footer>
<%- if policy(furniture).destroy? %>
<%= form.button name: "_method", value: "delete", class: "--danger" do %>
<%=t('.destroy')%>
<%- end %>
<%= render ButtonComponent.new(
label: t('.destroy', name: furniture.furniture.model_name.human.titleize),
href: [furniture.room.space, furniture.room, furniture],
title: t('.destroy', name: furniture.furniture.model_name.human.titleize),
method: :delete,
scheme: :danger) %>
<%- end %>

<%- if furniture.furniture.attribute_names.present? %>
Expand Down
1 change: 1 addition & 0 deletions app/views/furnitures/_furniture.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
label: t('icons.edit'),
href: edit_href,
method: :get,
turbo_stream: true,
title: t('.edit_title', name: furniture.furniture.model_name.human.titleize),
scheme: :secondary) %>
<%- end %>
Expand Down
1 change: 0 additions & 1 deletion spec/system/furniture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
include ActiveJob::TestHelper
it "Managing Furniture" do
space = create(:space, :with_entrance, :with_members, member_count: 1)
# Sign in to the Space
sign_in(space.members.first, space)

add_gizmo("Markdown Text Block", room: space.entrance)
Expand Down