-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
61 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
lib/atomic_web/live/organization_live/components/organization_departments.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
defmodule AtomicWeb.OrganizationLive.Components.OrganizationDepartments do | ||
@moduledoc """ | ||
Internal organization-related component for displaying its departments. | ||
""" | ||
use AtomicWeb, :component | ||
|
||
alias Atomic.Departments | ||
alias Atomic.Organizations.{Department, Organization} | ||
|
||
# FIXME: This should be a shared component | ||
import AtomicWeb.DepartmentLive.Components.DepartmentCard | ||
|
||
attr :organization, Organization, | ||
required: true, | ||
doc: "the organization which departments to display" | ||
|
||
def organization_departments(assigns) do | ||
~H""" | ||
<div id="organization-departments" class="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-2"> | ||
<%= for department <- list_departments(@organization) do %> | ||
<.link navigate={Routes.department_show_path(AtomicWeb.Endpoint, :show, @organization, department)}> | ||
<.department_card department={department} collaborators={list_department_collaborators(department)} /> | ||
</.link> | ||
<% end %> | ||
</div> | ||
""" | ||
end | ||
|
||
defp list_departments(%Organization{} = organization) do | ||
Departments.list_departments_by_organization_id(organization.id, | ||
preloads: [:organization], | ||
where: [archived: false] | ||
) | ||
end | ||
|
||
defp list_department_collaborators(%Department{} = department) do | ||
Departments.list_department_collaborators(department.id, | ||
preloads: [:user], | ||
where: [accepted: true] | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters