Skip to content

Commit

Permalink
Merge pull request #537 from richardlences/feature/remove_modal_from_…
Browse files Browse the repository at this point in the history
…group_admin

Remove modal from group admin
  • Loading branch information
luciajanikova authored Feb 15, 2025
2 parents f94db93 + edaf678 commit baeee7b
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 48 deletions.
73 changes: 33 additions & 40 deletions app/components/admin/groups/group_form_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,50 +1,43 @@
<%= tag.turbo_frame id: "modal" do %>
<div class="fixed inset-0 z-40 p-2" role="dialog" aria-modal="true">
<div class="fixed inset-0 transition-opacity bg-gray-400 bg-opacity-75" aria-hidden="true"></div>
<div class="relative flex items-center justify-center h-full">
<div class="flex flex-col justify-start items-start overflow-hidden rounded-lg bg-white border border-gray-300" style="box-shadow: 1px 1px 4px 0 rgba(0,0,0,0.1);">
<div class="flex justify-start items-center self-stretch flex-grow-0 flex-shrink-0 overflow-hidden gap-4 p-6 border-t-0 border-r-0 border-b border-l-0 border-gray-200">
<div class="flex flex-col justify-start items-start flex-grow relative">
<p class="self-stretch flex-grow w-[521px] text-xl font-semibold text-left text-gray-900"><%= @group.name %></p>
<p class="flex-grow-0 flex-shrink-0 text-xs text-left text-gray-500">Používatelia v skupine</p>
</div>
<%= render Common::CloseButtonComponent.new(link_to: admin_tenant_groups_path(Current.tenant)) %>
</div>
<div class="flex flex-col justify-start items-start self-stretch flex-grow-0 flex-shrink-0">
<% if !@readonly %>
<%= form_with url: search_non_members_admin_tenant_group_path(Current.tenant, @group),
<div class="w-full p-4 flex-col justify-start items-start gap-4 inline-flex">
<div class="self-stretch bg-white rounded-md border border-gray-200 flex-col justify-start items-start flex">
<div class="flex justify-start items-center self-stretch flex-grow-0 flex-shrink-0 overflow-hidden gap-4 p-6">
<div class="flex flex-col justify-start items-start flex-grow relative">
<p class="self-stretch flex-grow w-[521px] text-xl font-semibold text-left text-gray-900"><%= @group.name %></p>
<p class="flex-grow-0 flex-shrink-0 text-xs text-left text-gray-500">Používatelia v skupine</p>
</div>
</div>
<div class="flex flex-col justify-start items-start self-stretch flex-grow-0 flex-shrink-0">
<% if !@readonly %>
<%= form_with url: search_non_members_admin_tenant_group_path(Current.tenant, @group),
data: { controller: 'debounce', debounce_target: 'form'},
class: "flex justify-start items-center self-stretch flex-grow-0 flex-shrink-0 gap-4 p-6 border-t-0 border-r-0 border-b border-l-0 border-gray-200" do |form| %>
<div class="flex w-full items-center rounded-md shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-600">
<div class="p-2">
<%= render Icons::MagnifyingGlassComponent.gray(size: "5") %>
</div>
<%= tag.turbo_frame id:'user-search-results' %>
<%= form.search_field :name_search, value: params[:name_search], placeholder: "Vyhľadaj používateľa pre pridanie do skupiny",
<div class="flex w-full items-center rounded-md shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-600">
<div class="p-2">
<%= render Icons::MagnifyingGlassComponent.gray(size: "5") %>
</div>
<%= tag.turbo_frame id:'user-search-results' %>
<%= form.search_field :name_search, value: params[:name_search], placeholder: "Vyhľadaj používateľa pre pridanie do skupiny",
data: { action: 'input->debounce#debounce' },
onreset: "this.form.requestSubmit()",
class: "block w-full flex-1 border-0 bg-transparent py-1.5 pl-1 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6" %>
</div>
<% end %>
<% end %>
<div class="flex flex-col justify-start items-start self-stretch divide-y relative gap-2 p-2 border-t-0 border-r-0 border-b border-l-0 border-gray-200">
<% @group.group_memberships.each do |group_membership| %>
<div class="self-stretch p-6 flex justify-start items-start gap-6">
<% if !@readonly %>
<%= render Admin::Groups::MembersListRowComponent.new(group_membership) %>
<% else %>
<%= render Admin::Groups::MembersListRowViewOnlyComponent.new(group_membership) %>
<% end %>
</div>
<% end %>
</div>
</div>
<div class="flex justify-start items-start self-stretch flex-grow-0 flex-shrink-0 gap-2 p-6">
<%= link_to admin_tenant_groups_path(Current.tenant), data: { turbo_frame: "_top" }, class: "flex justify-center items-center flex-grow relative overflow-hidden gap-2.5 px-3.5 py-2.5 rounded-md bg-blue-600" do %>
<p class="flex-grow-0 flex-shrink-0 text-base font-medium text-left text-white">Zatvoriť</p>
<% end %>
<% end %>
<% if @group.group_memberships.any? %>
<div class="flex flex-col justify-start items-start self-stretch divide-y relative gap-2 p-2 border-t-0 border-r-0 border-b border-l-0 border-gray-200">
<% @group.group_memberships.each do |group_membership| %>
<div class="self-stretch p-6 flex justify-start items-start gap-6">
<% if !@readonly %>
<%= render Admin::Groups::MembersListRowComponent.new(group_membership) %>
<% else %>
<%= render Admin::Groups::MembersListRowViewOnlyComponent.new(group_membership) %>
<% end %>
</div>
<% end %>
</div>
<% else %>
<%= render Common::BlankResultsComponent.new(:group_users) %>
<% end %>
</div>
</div>
</div>
<% end %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="text-center text-gray-900 text-lg font-medium leading-loose">
<% if @group.renamable? %>
<%= render Common::InlineRenameComponent.new(name: @group.name, model: @group, url: admin_tenant_group_path(@group.tenant, @group)) %>
<% else %>
<% else %>
<%= @group.name %>
<% end %>
</div>
Expand All @@ -18,7 +18,7 @@
</div>
<div class="justify-start items-start gap-2 flex">
<% if @group.editable? %>
<%= link_to edit_members_admin_tenant_group_path(@group.tenant, @group), title: "Zmeniť členov skupiny", data: { turbo_frame: "modal" } do %>
<%= link_to edit_members_admin_tenant_group_path(@group.tenant, @group), title: "Zmeniť členov skupiny" do %>
<%= render Common::EditButtonComponent.new %>
<% end %>
<% if @group.destroyable? %>
Expand Down
2 changes: 1 addition & 1 deletion app/components/admin/groups/user_add_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="text-center text-gray-900 text-lg font-medium leading-loose"><%= @user.name %></div>
<div class="text-center text-gray-500 text-base font-normal leading-normal"><%= @user.email %></div>
</div>
<%= button_to admin_tenant_group_group_memberships_path(Current.tenant, @group, group_membership: { group_id: @group.id, user_id: @user.id }), title: "Pridať používateľa do skupiny", method: :post, data: { turbo_frame: "modal" } do %>
<%= button_to admin_tenant_group_group_memberships_path(Current.tenant, @group, group_membership: { group_id: @group.id, user_id: @user.id }), title: "Pridať používateľa do skupiny", method: :post, data: {turbo_frame: "_top"} do %>
<%= render Common::AddButtonComponent.new %>
<% end %>
</div>
3 changes: 2 additions & 1 deletion app/components/common/blank_results_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def before_render
tags: "tag-slash",
not_found: "magnifying-glass",
boxes: "inbox-stack",
notifications: "bell-slash"
notifications: "bell-slash",
group_users: "users"
}

@header = t "blank_results.#{@reason}.header"
Expand Down
4 changes: 2 additions & 2 deletions app/components/common/icon_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class IconComponent < ViewComponent::Base
"tag-slash" => "M9.568 3H5.25A2.25 2.25 0 0 0 3 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581c.699.699 1.78.872 2.607.33a18.095 18.095 0 0 0 5.223-5.223c.542-.827.369-1.908-.33-2.607L11.16 3.66A2.25 2.25 0 0 0 9.568 3Z M6 6h.008v.008H6V6ZM3 21l18-18",
"inbox-stack" => "m7.875 14.25 1.214 1.942a2.25 2.25 0 0 0 1.908 1.058h2.006c.776 0 1.497-.4 1.908-1.058l1.214-1.942M2.41 9h4.636a2.25 2.25 0 0 1 1.872 1.002l.164.246a2.25 2.25 0 0 0 1.872 1.002h2.092a2.25 2.25 0 0 0 1.872-1.002l.164-.246A2.25 2.25 0 0 1 16.954 9h4.636M2.41 9a2.25 2.25 0 0 0-.16.832V12a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 12V9.832c0-.287-.055-.57-.16-.832M2.41 9a2.25 2.25 0 0 1 .382-.632l3.285-3.832a2.25 2.25 0 0 1 1.708-.786h8.43c.657 0 1.281.287 1.709.786l3.284 3.832c.163.19.291.404.382.632M4.5 20.25h15A2.25 2.25 0 0 0 21.75 18v-2.625c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125V18a2.25 2.25 0 0 0 2.25 2.25Z",
"flag" => "M3 3v1.5M3 21v-6m0 0 2.77-.693a9 9 0 0 1 6.208.682l.108.054a9 9 0 0 0 6.086.71l3.114-.732a48.524 48.524 0 0 1-.005-10.499l-3.11.732a9 9 0 0 1-6.085-.711l-.108-.054a9 9 0 0 0-6.208-.682L3 4.5M3 15V4.5",
"puzzle-piece" => "M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 0 1-.657.643 48.39 48.39 0 0 1-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 0 1-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 0 0-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.039 48.039 0 0 1-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 0 0 .657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 0 1-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 0 0 5.427-.63 48.05 48.05 0 0 0 .582-4.717.532.532 0 0 0-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 0 0 .658-.663 48.422 48.422 0 0 0-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 0 1-.61-.58v0Z"

"puzzle-piece" => "M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 0 1-.657.643 48.39 48.39 0 0 1-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 0 1-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 0 0-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.039 48.039 0 0 1-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 0 0 .657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 0 1-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 0 0 5.427-.63 48.05 48.05 0 0 0 .582-4.717.532.532 0 0 0-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 0 0 .658-.663 48.422 48.422 0 0 0-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 0 1-.61-.58v0Z",
"users" => "M15 19.128a9.38 9.38 0 0 0 2.625.372 9.337 9.337 0 0 0 4.121-.952 4.125 4.125 0 0 0-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 0 1 8.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0 1 11.964-3.07M12 6.375a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0Zm8.25 2.25a2.625 2.625 0 1 1-5.25 0 2.625 2.625 0 0 1 5.25 0Z",
}.freeze

def initialize(icon, classes: "", stroke_width: 1.5)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/admin/group_memberships_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def create
if @group_membership.save
@group = @group_membership.group
flash[:notice] = 'Group membership was successfully created'
redirect_to edit_members_admin_tenant_group_path(Current.tenant, @group_membership.group)
else
render :new, status: :unprocessable_entity
end
Expand Down
3 changes: 3 additions & 0 deletions config/locales/sk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ sk:
notifications:
header: "Žiadne notifikácie"
description: "Nemáte žiadne notifikácie."
group_users:
header: "Žiadni používatelia"
description: "V tejto skupine zatiaľ nie sú žiadni používatelia."
feature_flags:
api:
name: "API"
Expand Down
2 changes: 0 additions & 2 deletions test/system/admin/group_management_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class GroupManagementTest < ApplicationSystemTestCase
fill_in "name_search", with: "Basi"

click_button "Pridať používateľa do skupiny"
click_link "Zatvoriť"

assert_text "Dummy Group"
end
Expand All @@ -31,7 +30,6 @@ class GroupManagementTest < ApplicationSystemTestCase

click_button "Pridať používateľa do skupiny"
assert_text "Basic"
click_link "Zatvoriť"
end

test "admin can delete a group" do
Expand Down

0 comments on commit baeee7b

Please sign in to comment.