From 1f7164c06713e914c180f1bc3e36357b7240abea Mon Sep 17 00:00:00 2001 From: shahryar tavakkoli Date: Mon, 6 Mar 2023 00:22:22 +0330 Subject: [PATCH] add entry view after selecting a setting, based on #4 , #44 --- .../components/blocks/content.ex | 2 +- .../components/blocks/settings.ex | 54 ++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/lib/mishka_template_creator/components/blocks/content.ex b/lib/mishka_template_creator/components/blocks/content.ex index 69b0173..93a428c 100644 --- a/lib/mishka_template_creator/components/blocks/content.ex +++ b/lib/mishka_template_creator/components/blocks/content.ex @@ -4,7 +4,7 @@ defmodule MishkaTemplateCreator.Components.Blocks.Content do attr :elemens, :list, required: true attr :selected_block, :string, required: true - attr :selected_setting, :string, required: true + attr :selected_setting, :map, required: true attr :submit, :string, required: true @spec content(map) :: Phoenix.LiveView.Rendered.t() diff --git a/lib/mishka_template_creator/components/blocks/settings.ex b/lib/mishka_template_creator/components/blocks/settings.ex index 218d08b..19862d1 100644 --- a/lib/mishka_template_creator/components/blocks/settings.ex +++ b/lib/mishka_template_creator/components/blocks/settings.ex @@ -70,9 +70,61 @@ defmodule MishkaTemplateCreator.Components.Blocks.Settings do OR put your custom classes

<% else %> - <%= @block_id %> +
+

+ You can change the default setting of + + <%= Map.get(@selected_setting, "id") %> + +

+ +
+ <.button + phx-click="reset_settings" + class="w-24 !bg-white border border-gray-300 shadow-sm text-black hover:bg-gray-400 hover:text-gray-400" + > +
+ Back + +
+ + + <.button + phx-click="reset_settings" + class="!bg-white border border-gray-300 shadow-sm text-black hover:bg-gray-400 hover:text-gray-400" + > +
+ Reset to default + +
+ +
+
+ <.get_form selected_setting={@selected_setting} /> +
<% end %> """ end + + attr :selected_setting, :map, required: true + + def get_form(assigns) do + ~H""" + <.simple_form + :let={f} + for={%{}} + as={:setting_form} + phx-submit="save_setting" + phx-change="validate_setting" + > + <.input field={f[:setting_form]} label="Tag Name" /> + <:actions> + <.button class="phx-submit-loading:opacity-75 rounded-lg bg-zinc-900 hover:bg-zinc-700 py-2 px-3 text-sm font-semibold leading-6 text-white active:text-white/80 disabled:bg-gray-400 disabled:text-white disabled:outline-none"> + Save + + + + """ + end end