Просмотр исходного кода

Add a reset button for the filter

theenglishway (time) 4 лет назад
Родитель
Сommit
2af87e7f33
2 измененных файлов с 5 добавлено и 0 удалено
  1. 4 0
      lib/vaccins_web/live/index.ex
  2. 1 0
      lib/vaccins_web/live/index_live.html.leex

+ 4 - 0
lib/vaccins_web/live/index.ex

@@ -64,6 +64,10 @@ defmodule VaccinsWeb.IndexLive do
     {:noreply, socket |> push_patch(to: Routes.index_path(socket, :index))}
   end
 
+  def handle_event("areas_filter_reset", _, socket) do
+    {:noreply, socket |> push_patch(to: Routes.index_path(socket, :index))}
+  end
+
   def handle_event("add_location", %{"location_raw" => params}, socket) do
     case params |> LocationStore.add_location() do
       :ok -> {:noreply, socket |> push_patch(to: Routes.index_path(socket, :index))}

+ 1 - 0
lib/vaccins_web/live/index_live.html.leex

@@ -64,6 +64,7 @@
   <%= label f, :areas, "Filtrer par zone géographique" %>
   <%= multiple_select f, :areas, @all_areas |> Enum.map(& {&1, &1}), selected: @area_filters |> MapSet.to_list %>
 </form>
+<button phx-click="areas_filter_reset">Voir toutes les zones</button>
 
 <table class="locations-list">
   <thead>