diff --git a/lib/app/list.ex b/lib/app/list.ex index 5340c244..74d351b6 100644 --- a/lib/app/list.ex +++ b/lib/app/list.ex @@ -177,8 +177,8 @@ defmodule App.List do `add_item_to_list/3` adds the `item.cid` to the `list.cid` for the given `person_id`. """ def add_item_to_list(item_cid, list_cid, person_id) do - list = get_list_by_cid!(list_cid) |> dbg() - prev_seq = get_list_seq(list) |> dbg() + list = get_list_by_cid!(list_cid) + prev_seq = get_list_seq(list) seq = [item_cid | prev_seq] |> Enum.join(",") update_list(list, %{seq: seq, person_id: person_id}) end @@ -251,9 +251,7 @@ defmodule App.List do """ def add_all_items_to_all_list_for_person_id(person_id) do all_list = App.List.get_all_list_for_person(person_id) - # dbg(all_list) all_items = App.Item.all_items_for_person(person_id) - # dbg(all_items) prev_seq = get_list_seq(all_list) # Add add each `item.id` to the sequence of item ids: seq = diff --git a/lib/app_web/controllers/list_controller.ex b/lib/app_web/controllers/list_controller.ex index f841378f..48389105 100644 --- a/lib/app_web/controllers/list_controller.ex +++ b/lib/app_web/controllers/list_controller.ex @@ -26,7 +26,6 @@ defmodule AppWeb.ListController do end def create(conn, %{"list" => list_params}) do - dbg(list_params) person_id = conn.assigns[:person][:id] || 0 list_params = diff --git a/lib/app_web/live/app_live.ex b/lib/app_web/live/app_live.ex index be44e4fb..ef63cf6c 100644 --- a/lib/app_web/live/app_live.ex +++ b/lib/app_web/live/app_live.ex @@ -16,7 +16,6 @@ defmodule AppWeb.AppLive do defp get_list_name(assigns), do: assigns[:list_name] defp list_cid_from_url_params(params) do - dbg(Map.get(params, "list_cid")) if Map.has_key?(params, "list_cid"), do: Map.get(params, "list_cid", nil) end @@ -29,18 +28,21 @@ defmodule AppWeb.AppLive do person_id = Person.get_person_id(socket.assigns) custom_list = list_cid_from_url_params(params) - list_cid = if custom_list == nil do - # Create or Get the "all" list for the person_id - all_list = App.List.get_all_list_for_person(person_id) - # Temporary function to add All *existing* items to the "All" list: - App.List.add_all_items_to_all_list_for_person_id(person_id) + list_cid = + if custom_list == nil do + # Create or Get the "all" list for the person_id + all_list = App.List.get_all_list_for_person(person_id) + + # Temporary function to add All *existing* items to the "All" list: + App.List.add_all_items_to_all_list_for_person_id(person_id) + + # return the "all" list cid + all_list.cid + else + custom_list + end - # return the "all" list cid - all_list.cid - else - custom_list - end lists = App.List.get_lists_for_person(person_id) list = Enum.find(lists, fn list -> list.cid == list_cid end) @@ -94,6 +96,7 @@ defmodule AppWeb.AppLive do # Add this newly created `item` to the list current list: list_cid = get_list_cid(socket.assigns) list_name = get_list_name(socket.assigns) + if list_name !== "all" do App.List.add_item_to_list(item.cid, list_cid, person_id) end diff --git a/lib/app_web/templates/nav/nav.html.heex b/lib/app_web/templates/nav/nav.html.heex index 1c65ecaa..bdb34d3f 100644 --- a/lib/app_web/templates/nav/nav.html.heex +++ b/lib/app_web/templates/nav/nav.html.heex @@ -59,9 +59,10 @@