From bdfbf8da93c35f2baf2ed0f0a6c4c3c75307654f Mon Sep 17 00:00:00 2001 From: Cristine Guadelupe Date: Sat, 20 Jan 2024 18:36:37 -0300 Subject: [PATCH] Update data_options after deleting an operation --- lib/kino_explorer/data_transform_cell.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/kino_explorer/data_transform_cell.ex b/lib/kino_explorer/data_transform_cell.ex index 41d6937..ca0cd1a 100644 --- a/lib/kino_explorer/data_transform_cell.ex +++ b/lib/kino_explorer/data_transform_cell.ex @@ -332,8 +332,10 @@ defmodule KinoExplorer.DataTransformCell do end def handle_event("remove_operation", %{"idx" => idx}, ctx) do - updated_operations = if idx, do: List.delete_at(ctx.assigns.operations, idx), else: [] - ctx = assign(ctx, operations: updated_operations) + updated_operations = + if idx, do: List.delete_at(ctx.assigns.operations, idx) |> update_data_options(ctx) + + ctx = assign(ctx, operations: updated_operations || []) broadcast_event(ctx, "set_operations", %{"operations" => updated_operations}) {:noreply, ctx}