@@ -97,16 +101,16 @@ defmodule SanbaseWeb.MetricRegistryIndexLive do
)}
end
- def handle_event("apply_verified_changes", _params, socket) do
+ def handle_event("show_verified_changes_modal", _params, socket) do
{:noreply,
socket
|> assign(show_verified_changes_modal: true)}
end
- def handle_event("update_show_verified_changes_modal", %{"bool" => value}, socket) do
+ def handle_event("hide_show_verified_changes_modal", _params, socket) do
{:noreply,
socket
- |> assign(show_verified_changes_modal: value)}
+ |> assign(show_verified_changes_modal: false)}
end
def handle_event(
@@ -116,7 +120,7 @@ defmodule SanbaseWeb.MetricRegistryIndexLive do
) do
new_map =
Map.update(
- socket.assigns.metrics_verified_updates,
+ socket.assigns.verified_metrics_updates_map,
id,
# This will be invoked only the first time the metric registry is updated
%{old: Enum.find(socket.assigns.metrics, &(&1.id == id)).is_verified, new: bool},
@@ -125,14 +129,53 @@ defmodule SanbaseWeb.MetricRegistryIndexLive do
{:noreply,
assign(socket,
- verified_metrics_update: new_map,
+ verified_metrics_updates_map: new_map,
metrics: update_metric(socket.assigns.metrics, id, :is_verified, bool),
visible_metrics: update_metric(socket.assigns.visible_metrics, id, :is_verified, bool)
)}
end
defp list_metrics_verified_status_changed(assigns) do
+ changed_metrics_ids =
+ assigns.verified_metrics_updates_map
+ |> Enum.reduce([], fn {id, map}, acc ->
+ if map.new != map.old, do: [id | acc], else: acc
+ end)
+
+ changed_metrics = Enum.filter(assigns.metrics, &(&1.id in changed_metrics_ids))
+ assigns = assign(assigns, changed_metrics: changed_metrics)
+
~H"""
+
+ No changes
+
+
+ <.table id="uploaded_images" rows={@changed_metrics}>
+ <:col :let={row} label="Metric">
+ <.metric_names
+ metric={row.metric}
+ internal_metric={row.internal_metric}
+ human_readable_name={row.human_readable_name}
+ />
+
+ <:col :let={row} label="New Status">
+
VERIFIED
+
UNVERIFIED
+
+
+
+ <.phx_click_button
+ phx_click="confirm_verified_changes_update"
+ class="bg-green-500 hover:bg-green-900 text-white"
+ text="Confirm Changes"
+ />
+ <.phx_click_button
+ phx_click="close_verified_changes_update"
+ class="bg-white hover:bg-gray-100 text-gray-800"
+ text="Close"
+ />
+
+
"""
end
@@ -152,7 +195,7 @@ defmodule SanbaseWeb.MetricRegistryIndexLive do
VERIFIED
-
UNVERIFIED
+
UNVERIFIED
"""
end
@@ -200,12 +243,11 @@ defmodule SanbaseWeb.MetricRegistryIndexLive do
<.filter_not_verified />
- <.button
- phx-click="apply_verified_changes"
- class="text-gray-900 bg-white hover:bg-gray-100 border border-gray-200 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center gap-x-2"
- >
- Apply Verified Status Changes
-
+ <.phx_click_button
+ phx_click="show_verified_changes_modal"
+ class="text-gray-900 bg-white hover:bg-gray-100"
+ text="Apply Verified Status Changes"
+ />