From 72d38c71b5982ecbc94430593213ebaffdce4cc2 Mon Sep 17 00:00:00 2001 From: kamalogudah Date: Mon, 17 Jul 2023 00:58:22 +0300 Subject: [PATCH 1/2] Started on the edit modal --- lib/chat_app_live_web/live/chat_form_live.ex | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/chat_app_live_web/live/chat_form_live.ex b/lib/chat_app_live_web/live/chat_form_live.ex index f7350af..420128a 100644 --- a/lib/chat_app_live_web/live/chat_form_live.ex +++ b/lib/chat_app_live_web/live/chat_form_live.ex @@ -77,6 +77,7 @@ defmodule ChatAppLiveWeb.ChatFormLive do Edit @@ -106,6 +107,24 @@ defmodule ChatAppLiveWeb.ChatFormLive do <% end %> + + +

Edit Message

+ <.form for={@form} phx-submit="save"> + + <.input type="textarea" field={@form[:content]} /> + + +
+ +
+ +
""" end end From d28641a169d228dcb71bfd908859944a796293ee Mon Sep 17 00:00:00 2001 From: kamalogudah Date: Sun, 30 Jul 2023 16:39:28 +0300 Subject: [PATCH 2/2] Messages --- lib/chat_app_live_web/live/chat_form_live.ex | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/chat_app_live_web/live/chat_form_live.ex b/lib/chat_app_live_web/live/chat_form_live.ex index 420128a..c4e4b86 100644 --- a/lib/chat_app_live_web/live/chat_form_live.ex +++ b/lib/chat_app_live_web/live/chat_form_live.ex @@ -9,6 +9,13 @@ defmodule ChatAppLiveWeb.ChatFormLive do {:ok, assign(socket, form: to_form(Messages.change_message(%Message{})), messages: messages)} end + defp get_message!(message_id) do + case Repo.get(Message, message_id) do + nil -> {:error, "Message not found"} + message -> {:ok, message} + end + end + def handle_event("save", %{"message" => message_params}, socket) do case Messages.create_message(message_params) do {:ok, _message} -> @@ -115,6 +122,7 @@ defmodule ChatAppLiveWeb.ChatFormLive do <.input type="textarea" field={@form[:content]} /> +