Skip to content

Commit

Permalink
fix: render relationship inputs even when type is not a map
Browse files Browse the repository at this point in the history
fix: properly render tenant form on mobile sidebar

closes #121
  • Loading branch information
zachdaniel committed May 16, 2024
1 parent 243a436 commit 809f041
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dev/resources/accounts/resources/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule Demo.Accounts.User do
multitenancy do
strategy :attribute
attribute :org
# global? true
global? true
end

policies do
Expand Down
8 changes: 7 additions & 1 deletion dev/resources/tickets/resources/ticket/ticket.ex
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ defmodule Demo.Tickets.Ticket do
change manage_relationship(:tickets, :source_links, on_lookup: {:relate_and_update, :create, :read, :all})
end

update :update, primary?: true
update :update do
primary? true
argument :organization_id, :uuid
require_atomic? false

change manage_relationship(:organization_id, :organization, type: :append_and_remove)
end

update :assign do
accept []
Expand Down
3 changes: 2 additions & 1 deletion lib/ash_admin/components/resource/form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ defmodule AshAdmin.Components.Resource.Form do
skip: skip
)


~H"""
<% {attributes, flags, bottom_attributes, relationship_args} =
attributes(@resource, @action, @exactly) %>
Expand Down Expand Up @@ -1611,7 +1612,7 @@ defmodule AshAdmin.Components.Resource.Form do
end

defp manages_relationship(argument, action) do
if action.changes && map_type?(argument.type) do
if action.changes do
Enum.find_value(action.changes, fn
%{change: {Ash.Resource.Change.ManageRelationship, opts}} ->
if opts[:argument] == argument.name do
Expand Down
5 changes: 2 additions & 3 deletions lib/ash_admin/components/top_nav.ex
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,10 @@ defmodule AshAdmin.Components.TopNav do
/>
</div>
<div class="block px-4 py-2 text-sm">
<.live_component
<TenantForm.tenant_form
:if={show_tenant_form?(@domains)}
module={TenantForm}
tenant={@tenant}
id="tenant_editor_drawer"
editing_tenant={@editing_tenant}
set_tenant={@set_tenant}
clear_tenant={@clear_tenant}
/>
Expand Down

0 comments on commit 809f041

Please sign in to comment.