This commit is contained in:
		| @@ -50,17 +50,17 @@ defmodule CanneryWeb.InviteLive.FormComponent do | ||||
|           </div> | ||||
|         <% end %> | ||||
|  | ||||
|         <%= label(f, :name, class: "title text-lg text-primary-500") %> | ||||
|         <%= label(f, :name, gettext("Name"), class: "title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :name, class: "input input-primary col-span-2") %> | ||||
|         <%= error_tag(f, :name, "col-span-3") %> | ||||
|  | ||||
|         <%= label(f, :uses_left, class: "title text-lg text-primary-500") %> | ||||
|         <%= label(f, :uses_left, gettext("Uses left"), class: "title text-lg text-primary-500") %> | ||||
|         <%= number_input(f, :uses_left, min: 0, class: "input input-primary col-span-2") %> | ||||
|         <%= error_tag(f, :uses_left, "col-span-3") %> | ||||
|  | ||||
|         <%= submit("Save", | ||||
|         <%= submit(dgettext("actions", "Save"), | ||||
|           class: "mx-auto btn btn-primary col-span-3", | ||||
|           phx_disable_with: "Saving..." | ||||
|           phx_disable_with: dgettext("prompts", "Saving...") | ||||
|         ) %> | ||||
|       </.form> | ||||
|     </div> | ||||
| @@ -72,7 +72,7 @@ defmodule CanneryWeb.InviteLive.FormComponent do | ||||
|       {:ok, _invite} -> | ||||
|         {:noreply, | ||||
|          socket | ||||
|          |> put_flash(:info, "Invite updated successfully") | ||||
|          |> put_flash(:info, dgettext("prompts", "Invite updated successfully")) | ||||
|          |> push_redirect(to: socket.assigns.return_to)} | ||||
|  | ||||
|       {:error, %Changeset{} = changeset} -> | ||||
| @@ -85,7 +85,7 @@ defmodule CanneryWeb.InviteLive.FormComponent do | ||||
|       {:ok, _invite} -> | ||||
|         {:noreply, | ||||
|          socket | ||||
|          |> put_flash(:info, "Invite created successfully") | ||||
|          |> put_flash(:info, dgettext("prompts", "Invite created successfully")) | ||||
|          |> push_redirect(to: socket.assigns.return_to)} | ||||
|  | ||||
|       {:error, %Changeset{} = changeset} -> | ||||
|   | ||||
| @@ -20,17 +20,17 @@ defmodule CanneryWeb.InviteLive.Index do | ||||
|  | ||||
|   defp apply_action(socket, :edit, %{"id" => id}) do | ||||
|     socket | ||||
|     |> assign(page_title: "Edit Invite", invite: Invites.get_invite!(id)) | ||||
|     |> assign(page_title: gettext("Edit Invite"), invite: Invites.get_invite!(id)) | ||||
|   end | ||||
|  | ||||
|   defp apply_action(socket, :new, _params) do | ||||
|     socket | ||||
|     |> assign(page_title: "New Invite", invite: %Invite{}) | ||||
|     |> assign(page_title: gettext("New Invite"), invite: %Invite{}) | ||||
|   end | ||||
|  | ||||
|   defp apply_action(socket, :index, _params) do | ||||
|     socket | ||||
|     |> assign(page_title: "Listing Invites", invite: nil) | ||||
|     |> assign(page_title: gettext("Listing Invites"), invite: nil) | ||||
|   end | ||||
|  | ||||
|   @impl true | ||||
|   | ||||
| @@ -1,22 +1,20 @@ | ||||
| <div class="flex flex-col space-y-8 justify-center items-center"> | ||||
|   <h1 class="title text-2xl title-primary-500"> | ||||
|     Listing Invites | ||||
|     <%= gettext("Listing Invites") %> | ||||
|   </h1> | ||||
|  | ||||
|   <%= if @invites |> Enum.empty?() do %> | ||||
|     <h1 class="title text-xl text-primary-500"> | ||||
|       No invites 😔 | ||||
|       <%= gettext("No invites") %> 😔 | ||||
|     </h1> | ||||
|  | ||||
|     <%= live_patch to: Routes.invite_index_path(@socket, :new), | ||||
|       class: "btn btn-primary" do %> | ||||
|       Invite someone new! | ||||
|     <% end %> | ||||
|     <%= live_patch dgettext("actions", "Invite someone new!"), | ||||
|       to: Routes.invite_index_path(@socket, :new), | ||||
|       class: "btn btn-primary" %> | ||||
|   <% else %> | ||||
|     <%= live_patch to: Routes.invite_index_path(@socket, :new), | ||||
|       class: "btn btn-primary" do %> | ||||
|       Create Invite | ||||
|     <% end %> | ||||
|     <%= live_patch dgettext("actions", "Create Invite"), | ||||
|       to: Routes.invite_index_path(@socket, :new), | ||||
|       class: "btn btn-primary" %> | ||||
|   <% end %> | ||||
|  | ||||
|   <div class="flex flex-row flex-wrap space-x-4 space-y-4"> | ||||
| @@ -29,11 +27,12 @@ | ||||
|  | ||||
|         <%= if invite.disabled_at |> is_nil() do %> | ||||
|           <h2 class="title text-md"> | ||||
|             Uses Left: <%= invite.uses_left || "Unlimited" %> | ||||
|             <%= gettext("Uses Left:") %> | ||||
|             <%= invite.uses_left || "Unlimited" %> | ||||
|           </h2> | ||||
|         <% else %> | ||||
|           <h2 class="title text-md"> | ||||
|             Invite Disabled | ||||
|             <%= gettext("Invite Disabled") %> | ||||
|           </h2> | ||||
|         <% end %> | ||||
|  | ||||
| @@ -51,27 +50,27 @@ | ||||
|               class: "text-primary-500 link", | ||||
|               phx_click: "delete", | ||||
|             phx_value_id: invite.id, | ||||
|             data: [confirm: "Are you sure you want to delete the invite for #{invite.name}?"] do %> | ||||
|             data: [confirm: dgettext("prompts", "Are you sure you want to delete the invite for %{name}?", name: invite.name)] do %> | ||||
|             <i class="fa-fw fa-lg fas fa-trash"></i> | ||||
|           <% end %> | ||||
|  | ||||
|           <%= if invite.disabled_at |> is_nil() do %> | ||||
|             <a href="#" class="btn btn-primary" | ||||
|               phx-click="disable" phx-value-id="<%= invite.id %>"> | ||||
|               Disable | ||||
|               <%= gettext("Disable") %> | ||||
|             </a> | ||||
|           <% else %> | ||||
|             <a href="#" class="btn btn-primary" | ||||
|               phx-click="enable" phx-value-id="<%= invite.id %>"> | ||||
|               Enable | ||||
|               <%= gettext("Enable") %> | ||||
|             </a> | ||||
|           <% end %> | ||||
|  | ||||
|           <%= if invite.disabled_at |> is_nil() and not(invite.uses_left |> is_nil()) do %> | ||||
|             <a href="#" class="btn btn-primary" | ||||
|               phx-click="set_unlimited" phx-value-id="<%= invite.id %>" | ||||
|               data-confirm="Are you sure you want to make this invite unlimited?"> | ||||
|               Set Unlimited | ||||
|               data-confirm={dgettext("prompts", "Are you sure you want to make this invite unlimited?")}> | ||||
|               <%= gettext("Set Unlimited") %> | ||||
|             </a> | ||||
|           <% end %> | ||||
|         </div> | ||||
|   | ||||
| @@ -21,14 +21,11 @@ defmodule CanneryWeb.TagLive.FormComponent do | ||||
|   @impl true | ||||
|   def handle_event("validate", %{"tag" => tag_params}, socket) do | ||||
|     tag_params = tag_params |> Map.put("user_id", socket.assigns.current_user.id) | ||||
|  | ||||
|     changeset = socket.assigns.tag |> Tags.change_tag(tag_params) | ||||
|  | ||||
|     {:noreply, socket |> assign(:changeset, changeset)} | ||||
|   end | ||||
|  | ||||
|   def handle_event("save", %{"tag" => tag_params}, socket) do | ||||
|     tag_params = tag_params |> Map.put("user_id", socket.assigns.current_user.id) | ||||
|     save_tag(socket, socket.assigns.action, tag_params) | ||||
|   end | ||||
|  | ||||
| @@ -54,25 +51,25 @@ defmodule CanneryWeb.TagLive.FormComponent do | ||||
|           </div> | ||||
|         <% end %> | ||||
|  | ||||
|         <%= label(f, :name, class: "title text-lg text-primary-500") %> | ||||
|         <%= label(f, :name, gettext("Name"), class: "title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :name, class: "input input-primary col-span-2") %> | ||||
|         <%= error_tag(f, :name, "col-span-3") %> | ||||
|  | ||||
|         <%= label(f, :bg_color, class: "title text-lg text-primary-500") %> | ||||
|         <%= label(f, :bg_color, gettext("Background color"), class: "title text-lg text-primary-500") %> | ||||
|         <span class="mx-auto col-span-2" phx-update="ignore"> | ||||
|           <%= color_input(f, :bg_color) %> | ||||
|         </span> | ||||
|         <%= error_tag(f, :bg_color, "col-span-3") %> | ||||
|  | ||||
|         <%= label(f, :text_color, class: "title text-lg text-primary-500") %> | ||||
|         <%= label(f, :text_color, gettext("Text color"), class: "title text-lg text-primary-500") %> | ||||
|         <span class="mx-auto col-span-2" phx-update="ignore"> | ||||
|           <%= color_input(f, :text_color) %> | ||||
|         </span> | ||||
|         <%= error_tag(f, :text_color, "col-span-3") %> | ||||
|  | ||||
|         <%= submit("Save", | ||||
|         <%= submit(dgettext("actions", "Save"), | ||||
|           class: "mx-auto btn btn-primary col-span-3", | ||||
|           phx_disable_with: "Saving..." | ||||
|           phx_disable_with: dgettext("prompts", "Saving...") | ||||
|         ) %> | ||||
|       </.form> | ||||
|     </div> | ||||
| @@ -84,7 +81,7 @@ defmodule CanneryWeb.TagLive.FormComponent do | ||||
|       {:ok, _tag} -> | ||||
|         {:noreply, | ||||
|          socket | ||||
|          |> put_flash(:info, "Tag updated successfully") | ||||
|          |> put_flash(:info, dgettext("prompts", "Tag updated successfully")) | ||||
|          |> push_redirect(to: socket.assigns.return_to)} | ||||
|  | ||||
|       {:error, %Changeset{} = changeset} -> | ||||
| @@ -93,11 +90,14 @@ defmodule CanneryWeb.TagLive.FormComponent do | ||||
|   end | ||||
|  | ||||
|   defp save_tag(socket, :new, tag_params) do | ||||
|     case Tags.create_tag(tag_params) do | ||||
|     tag_params | ||||
|     |> Map.put("user_id", socket.assigns.current_user.id) | ||||
|     |> Tags.create_tag() | ||||
|     |> case do | ||||
|       {:ok, _tag} -> | ||||
|         {:noreply, | ||||
|          socket | ||||
|          |> put_flash(:info, "Tag created successfully") | ||||
|          |> put_flash(:info, dgettext("prompts", "Tag created successfully")) | ||||
|          |> push_redirect(to: socket.assigns.return_to)} | ||||
|  | ||||
|       {:error, %Changeset{} = changeset} -> | ||||
|   | ||||
| @@ -20,19 +20,19 @@ defmodule CanneryWeb.TagLive.Index do | ||||
|  | ||||
|   defp apply_action(socket, :edit, %{"id" => id}) do | ||||
|     socket | ||||
|     |> assign(:page_title, "Edit Tag") | ||||
|     |> assign(:page_title, gettext("Edit Tag")) | ||||
|     |> assign(:tag, Tags.get_tag!(id)) | ||||
|   end | ||||
|  | ||||
|   defp apply_action(socket, :new, _params) do | ||||
|     socket | ||||
|     |> assign(:page_title, "New Tag") | ||||
|     |> assign(:page_title, gettext("New Tag")) | ||||
|     |> assign(:tag, %Tag{bg_color: Tags.random_bg_color(), text_color: "#ffffff"}) | ||||
|   end | ||||
|  | ||||
|   defp apply_action(socket, :index, _params) do | ||||
|     socket | ||||
|     |> assign(:page_title, "Listing Tags") | ||||
|     |> assign(:page_title, gettext("Listing Tags")) | ||||
|     |> assign(:tag, nil) | ||||
|   end | ||||
|  | ||||
| @@ -40,7 +40,7 @@ defmodule CanneryWeb.TagLive.Index do | ||||
|   def handle_event("delete", %{"id" => id}, socket) do | ||||
|     tag = Tags.get_tag!(id) | ||||
|     {:ok, _} = Tags.delete_tag(tag) | ||||
|     socket = socket |> put_flash(:info, "Tag deleted succesfully") | ||||
|     socket = socket |> put_flash(:info, dgettext("prompts", "Tag deleted succesfully")) | ||||
|     {:noreply, socket |> display_tags()} | ||||
|   end | ||||
|  | ||||
|   | ||||
| @@ -1,21 +1,21 @@ | ||||
| <div class="flex flex-col space-y-8 justify-center items-center"> | ||||
|   <h1 class="title text-2xl title-primary-500"> | ||||
|     Listing Tags | ||||
|     <%= gettext("Listing Tags") %> | ||||
|   </h1> | ||||
|   <p class="title text-md text-primary-500"> | ||||
|     Tags can be added to your containers to help you organize | ||||
|     <%= gettext("Tags can be added to your containers to help you organize") %> | ||||
|   </p> | ||||
|   <%= if @tags |> Enum.empty?() do %> | ||||
|     <h2 class="title text-xl text-primary-500"> | ||||
|       No tags 😔 | ||||
|       <%= gettext("No tags") %> 😔 | ||||
|     </h2> | ||||
|  | ||||
|     <%= live_patch("Make your first tag!", | ||||
|     <%= live_patch(dgettext("actions", "Make your first tag!"), | ||||
|       to: Routes.tag_index_path(@socket, :new), | ||||
|       class: "btn btn-primary" | ||||
|     ) %> | ||||
|   <% else %> | ||||
|     <%= live_patch("New Tag", | ||||
|     <%= live_patch(dgettext("actions", "New Tag"), | ||||
|       to: Routes.tag_index_path(@socket, :new), | ||||
|       class: "btn btn-primary" | ||||
|     ) %> | ||||
|   | ||||
| @@ -29,7 +29,9 @@ defmodule CanneryWeb.TagLive.TagCard do | ||||
|            class: "text-primary-500 link", | ||||
|            phx_click: "delete", | ||||
|            phx_value_id: @tag.id, | ||||
|            data: [confirm: "Are you sure you want to delete #{@tag.name}?"] do %> | ||||
|            data: [ | ||||
|              confirm: dgettext("prompts", "Are you sure you want to delete %{name}?", name: @tag.name) | ||||
|            ] do %> | ||||
|         <i class="fa-fw fa-lg fas fa-trash"></i> | ||||
|       <% end %> | ||||
|     </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user