Skip to content

Commit

Permalink
Merge branch 'develop' into mr/update-partners-page
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRodrigues10 authored Jul 1, 2024
2 parents c267f44 + 9aea5da commit 673ec83
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 54 deletions.
4 changes: 2 additions & 2 deletions lib/atomic_web/components/dropdown.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ defmodule AtomicWeb.Components.Dropdown do
<div id={@id} class={"#{if @orientation == :down, do: "origin-top-right top-full", else: "origin-bottom-right bottom-full"} absolute right-0 z-10 mt-2 hidden w-56 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5"}>
<div class="py-1" role="menu" aria-orientation="vertical" aria-labelledby="options-menu">
<%= for item <- @items do %>
<a href={item.link} class="block flex items-center gap-x-2 px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900" role="menuitem">
<.link href={item.link} class="block flex items-center gap-x-2 px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900" role="menuitem" method={Map.get(item, :method, "get")}>
<%= if item[:icon] do %>
<.icon solid={@icon_variant == :solid} mini={@icon_variant == :mini} name={item.icon} class="ml-2 inline-block h-5 w-5" />
<% end %>
<%= item.name %>
</a>
</.link>
<% end %>
</div>
</div>
Expand Down
10 changes: 10 additions & 0 deletions lib/atomic_web/live/announcement_live/edit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ defmodule AtomicWeb.AnnouncementLive.Edit do
{:ok, socket}
end

@impl true
def handle_event("delete", _params, socket) do
Organizations.delete_announcement(socket.assigns.announcement)

{:noreply,
socket
|> put_flash(:info, gettext("Announcement deleted successfully"))
|> push_navigate(to: Routes.announcement_index_path(socket, :index))}
end

@impl true
def handle_params(%{"organization_id" => _organization_id, "id" => id}, _, socket) do
announcement = Organizations.get_announcement!(id)
Expand Down
11 changes: 10 additions & 1 deletion lib/atomic_web/live/announcement_live/edit.html.heex
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
<.live_component module={AtomicWeb.AnnouncementLive.FormComponent} id={@announcement.id} organization={@current_organization} title={@page_title} action={@live_action} announcement={@announcement} return_to={Routes.announcement_show_path(@socket, :show, @announcement)} />
<.page title={gettext("Edit Announcement")}>
<:actions>
<.button size={:md} icon={:trash} color={:white} type="delete" phx-click="delete">
<%= gettext("Delete") %>
</.button>
</:actions>
<div class="pt-4 px-4">
<.live_component module={AtomicWeb.AnnouncementLive.FormComponent} id={@announcement.id} organization={@current_organization} title={@page_title} action={@live_action} announcement={@announcement} return_to={Routes.announcement_show_path(@socket, :show, @announcement)} />
</div>
</.page>
5 changes: 4 additions & 1 deletion lib/atomic_web/live/announcement_live/form_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ defmodule AtomicWeb.AnnouncementLive.FormComponent do

alias Atomic.Organizations

import AtomicWeb.Components.Forms

@impl true
def mount(socket) do
{:ok, socket}
Expand All @@ -28,6 +30,7 @@ defmodule AtomicWeb.AnnouncementLive.FormComponent do
{:noreply, assign(socket, :changeset, changeset)}
end

@impl true
def handle_event("save", %{"announcement" => announcement_params}, socket) do
save_announcement(socket, socket.assigns.action, announcement_params)
end
Expand All @@ -48,7 +51,7 @@ defmodule AtomicWeb.AnnouncementLive.FormComponent do
end
end

defp save_announcement(socket, :announcement, announcement_params) do
defp save_announcement(socket, :new, announcement_params) do
announcement_params =
Map.put(announcement_params, "organization_id", socket.assigns.organization.id)

Expand Down
14 changes: 4 additions & 10 deletions lib/atomic_web/live/announcement_live/form_component.html.heex
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
<div>
<h2><%= @title %></h2>

<.form :let={f} for={@changeset} id="announcement-form" phx-target={@myself} phx-change="validate" phx-submit="save">
<%= label(f, :title) %>
<%= text_input(f, :title) %>
<%= error_tag(f, :title) %>
<.field field={f[:title]} help_text={gettext("The title of the announcement")} type="text" placeholder="Title" required />

<%= label(f, :description) %>
<%= text_input(f, :description) %>
<%= error_tag(f, :description) %>
<.field field={f[:description]} help_text={gettext("Announcement description")} type="text" placeholder="Description" required />

<div>
<%= submit("Save", phx_disable_with: "Saving...") %>
<div class="mt-8 flex w-full justify-end">
<.button size={:md} color={:white} icon={:cube} type="submit"><%= gettext("Save Changes") %></.button>
</div>
</.form>
</div>
6 changes: 5 additions & 1 deletion lib/atomic_web/live/announcement_live/new.html.heex
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<.live_component module={AtomicWeb.AnnouncementLive.FormComponent} id={:new} organization={@current_organization} title={@page_title} action={@live_action} announcement={@announcement} return_to={Routes.announcement_index_path(@socket, :index)} />
<.page title={gettext("New Announcement")}>
<div class="pt-4 px-4">
<.live_component module={AtomicWeb.AnnouncementLive.FormComponent} id={:new} organization={@current_organization} title={@page_title} action={@live_action} announcement={@announcement} return_to={Routes.announcement_index_path(@socket, :index)} />
</div>
</.page>
4 changes: 2 additions & 2 deletions lib/atomic_web/live/announcement_live/show.html.heex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="py-4 px-4 sm:px-0">
<div class="flex flex-col gap-2 mt-6 sm:flex-row sm:items-center">
<div class="px-4 flex flex-col gap-2 mt-6 sm:flex-row sm:items-center">
<div>
<div class="flex justify-between items-center">
<h4 class="text-2xl font-bold text-zinc-800">
Expand All @@ -14,7 +14,7 @@
</div>

<%= if @has_permissions? do %>
<.link patch={Routes.announcement_edit_path(@socket, :edit, @announcement.organization, @announcement)} class="button">
<.link patch={Routes.announcement_edit_path(@socket, :edit, @announcement.organization, @announcement)} class="px-2 button">
<div type="button" class="inline-flex justify-center py-2 px-4 w-fit text-sm font-medium text-zinc-700 bg-white rounded-md border border-zinc-300 shadow-sm hover:bg-zinc-50" id="sort-menu-button" aria-expanded="false" aria-haspopup="true">
<.icon name={:pencil} solid class="mr-3 w-5 h-5 text-zinc-400" /> Edit
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/atomic_web/templates/layout/_live_navbar.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
orientation={:top}
items={[
%{name: "Your profile", link: Routes.profile_show_path(@socket, :show, @current_user)},
%{name: "Sign out", link: Routes.user_session_path(@socket, :delete)}
%{name: "Sign out", link: Routes.user_session_path(@socket, :delete), method: "delete"}
]}
id="user-menu-button"
>
Expand Down
36 changes: 0 additions & 36 deletions reviewpad.yml

This file was deleted.

0 comments on commit 673ec83

Please sign in to comment.