From acf3389e97eb245c3b9c9dbc0c96799696fb631b Mon Sep 17 00:00:00 2001 From: ruideassiscosta <102609685+ruideassiscosta@users.noreply.github.com> Date: Tue, 26 Jul 2022 17:52:47 +0100 Subject: [PATCH] Update modal forms (#24) --- .../form_component.html.heex | 39 ++++++++++---- .../live/admin/academic_year_live/index.ex | 2 +- .../admin/academic_year_live/index.html.heex | 2 +- .../admin/class_live/form_component.html.heex | 52 ++++++++++++++----- .../live/admin/class_live/index.ex | 2 +- .../degree_live/form_component.html.heex | 37 +++++++++---- .../live/admin/degree_live/index.ex | 2 +- .../live/admin/degree_live/index.html.heex | 2 +- .../live/admin/degree_live/show.html.heex | 4 +- lib/yearbook_web/live/live_helpers.ex | 19 ++++--- .../live/admin/academic_year_live_test.exs | 4 +- .../live/admin/degree_live_test.exs | 2 +- 12 files changed, 116 insertions(+), 51 deletions(-) diff --git a/lib/yearbook_web/live/admin/academic_year_live/form_component.html.heex b/lib/yearbook_web/live/admin/academic_year_live/form_component.html.heex index d7c2343..17a8678 100644 --- a/lib/yearbook_web/live/admin/academic_year_live/form_component.html.heex +++ b/lib/yearbook_web/live/admin/academic_year_live/form_component.html.heex @@ -1,17 +1,36 @@
-

<%= @title %>

- <.form let={f} for={@changeset} id="academic_year-form" phx-target={@myself} phx-change="validate" phx-submit="save"> - <%= label(f, :start) %> - <%= number_input(f, :start) %> - <%= error_tag(f, :start) %> +
+
+
+ +
- <%= label(f, :finish) %> - <%= number_input(f, :finish) %> - <%= error_tag(f, :finish) %> +
+ <%= label(f, "Começo", class: "block text-base font-medium text-gray-700") %> + +
+ <%= error_tag(f, :start) %> +
-
- <%= submit("Save", phx_disable_with: "Saving...") %> +
+ <%= label(f, "Fim", class: "block text-base font-medium text-gray-700") %> + +
+ <%= error_tag(f, :finish) %> +
+
+
+ <%= submit(class: "inline-flex items-center justify-center rounded-md border border-transparent bg-orange-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:ring-offset-2 sm:w-auto") do %> + Guardar + <% end %> +
diff --git a/lib/yearbook_web/live/admin/academic_year_live/index.ex b/lib/yearbook_web/live/admin/academic_year_live/index.ex index 53874d8..7290843 100644 --- a/lib/yearbook_web/live/admin/academic_year_live/index.ex +++ b/lib/yearbook_web/live/admin/academic_year_live/index.ex @@ -23,7 +23,7 @@ defmodule YearbookWeb.Admin.AcademicYearLive.Index do defp apply_action(socket, :new, _params) do socket - |> assign(:page_title, "New Academic year") + |> assign(:page_title, "Novo Ano") |> assign(:academic_year, %AcademicYear{}) end diff --git a/lib/yearbook_web/live/admin/academic_year_live/index.html.heex b/lib/yearbook_web/live/admin/academic_year_live/index.html.heex index 0a1d075..3eaf4f0 100644 --- a/lib/yearbook_web/live/admin/academic_year_live/index.html.heex +++ b/lib/yearbook_web/live/admin/academic_year_live/index.html.heex @@ -13,7 +13,7 @@
<%= live_patch to: Routes.admin_academic_year_index_path(@socket, :new) do %> <% end %>
diff --git a/lib/yearbook_web/live/admin/class_live/form_component.html.heex b/lib/yearbook_web/live/admin/class_live/form_component.html.heex index 87b07ac..6c232eb 100644 --- a/lib/yearbook_web/live/admin/class_live/form_component.html.heex +++ b/lib/yearbook_web/live/admin/class_live/form_component.html.heex @@ -1,21 +1,47 @@
-

<%= @title %>

- <.form let={f} for={@changeset} id="class-form" phx-target={@myself} phx-change="validate" phx-submit="save"> - <%= label(f, :degree_id) %> - <%= select(f, :degree_id, Enum.map(@degrees, &{&1.name, &1.id})) %> - <%= error_tag(f, :degree_id) %> +
+
+
+ +
+ +
+ <%= label(f, "Curso", class: "block text-base font-medium text-gray-700") %> + +
+ <%= error_tag(f, :degree_id) %> +
+
- <%= label(f, :academic_year_id) %> - <%= select(f, :academic_year_id, Enum.map(@academic_years, &{"#{&1.start}/#{&1.finish}", &1.id})) %> - <%= error_tag(f, :academic_year_id) %> +
+ <%= label(f, "Ano Letivo", class: "block text-base font-medium text-gray-700") %> + +
+ <%= error_tag(f, :academic_year_id) %> +
- <%= label(f, :year) %> - <%= number_input(f, :year) %> - <%= error_tag(f, :year) %> +
+ <%= label(f, "Ano", class: "block text-base font-medium text-gray-700") %> + +
+ <%= error_tag(f, :year) %> +
+
-
- <%= submit("Save", phx_disable_with: "Saving...") %> +
+ <%= submit(class: "inline-flex items-center justify-center rounded-md border border-transparent bg-orange-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:ring-offset-2 sm:w-auto") do %> + Guardar + <% end %> +
diff --git a/lib/yearbook_web/live/admin/class_live/index.ex b/lib/yearbook_web/live/admin/class_live/index.ex index 9eef3d9..2e6c130 100644 --- a/lib/yearbook_web/live/admin/class_live/index.ex +++ b/lib/yearbook_web/live/admin/class_live/index.ex @@ -23,7 +23,7 @@ defmodule YearbookWeb.Admin.ClassLive.Index do defp apply_action(socket, :new, _params) do socket - |> assign(:page_title, "New Class") + |> assign(:page_title, "Nova Turma") |> assign(:class, %Class{}) end diff --git a/lib/yearbook_web/live/admin/degree_live/form_component.html.heex b/lib/yearbook_web/live/admin/degree_live/form_component.html.heex index f267f7a..6ba4987 100644 --- a/lib/yearbook_web/live/admin/degree_live/form_component.html.heex +++ b/lib/yearbook_web/live/admin/degree_live/form_component.html.heex @@ -1,17 +1,34 @@
-

<%= @title %>

- <.form let={f} for={@changeset} id="degree-form" phx-target={@myself} phx-change="validate" phx-submit="save"> - <%= label(f, :name) %> - <%= text_input(f, :name) %> - <%= error_tag(f, :name) %> +
+
+
+ +
- <%= label(f, :cycle) %> - <%= number_input(f, :cycle) %> - <%= error_tag(f, :cycle) %> +
+ <%= label(f, "Curso", class: "block text-base font-medium text-gray-700") %> + <%= text_input(f, :name, autocomplete: "off", class: "mt-1 focus:ring-orange-500 focus:border-orange-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md") %> +
+ <%= error_tag(f, :name) %> +
-
- <%= submit("Save", phx_disable_with: "Saving...") %> +
+ <%= label(f, "Ciclo", class: "block text-base font-medium text-gray-700") %> + +
+ <%= error_tag(f, :cycle) %> +
+
+
+ <%= submit(class: "inline-flex items-center justify-center rounded-md border border-transparent bg-orange-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:ring-offset-2 sm:w-auto") do %> + Guardar + <% end %> +
diff --git a/lib/yearbook_web/live/admin/degree_live/index.ex b/lib/yearbook_web/live/admin/degree_live/index.ex index 1674e9d..69c1c85 100644 --- a/lib/yearbook_web/live/admin/degree_live/index.ex +++ b/lib/yearbook_web/live/admin/degree_live/index.ex @@ -23,7 +23,7 @@ defmodule YearbookWeb.Admin.DegreeLive.Index do defp apply_action(socket, :new, _params) do socket - |> assign(:page_title, "New Degree") + |> assign(:page_title, "Novo Curso") |> assign(:degree, %Degree{}) end diff --git a/lib/yearbook_web/live/admin/degree_live/index.html.heex b/lib/yearbook_web/live/admin/degree_live/index.html.heex index fd47535..fecb989 100644 --- a/lib/yearbook_web/live/admin/degree_live/index.html.heex +++ b/lib/yearbook_web/live/admin/degree_live/index.html.heex @@ -31,7 +31,7 @@ - + <%= for degree <- @degrees do %> diff --git a/lib/yearbook_web/live/admin/degree_live/show.html.heex b/lib/yearbook_web/live/admin/degree_live/show.html.heex index 66a38e2..09d8a7f 100644 --- a/lib/yearbook_web/live/admin/degree_live/show.html.heex +++ b/lib/yearbook_web/live/admin/degree_live/show.html.heex @@ -9,12 +9,12 @@
  • - Name: + Curso: <%= @degree.name %>
  • - Cycle: + Ciclo: <%= @degree.cycle %>
diff --git a/lib/yearbook_web/live/live_helpers.ex b/lib/yearbook_web/live/live_helpers.ex index bb23d0d..9fd63dc 100644 --- a/lib/yearbook_web/live/live_helpers.ex +++ b/lib/yearbook_web/live/live_helpers.ex @@ -31,16 +31,19 @@ defmodule YearbookWeb.LiveHelpers do ~H"""