From bb41c570eb352056725b1e0b9fb56102285ba002 Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Tue, 19 Nov 2024 14:56:50 +0200 Subject: [PATCH] fix refresh newCategory page --- app/views/account/categories/new.html.erb | 18 +++--------------- .../account/categories/new.turbo_stream.erb | 4 ++++ .../categories/partials/new/_form.html.erb | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 app/views/account/categories/new.turbo_stream.erb create mode 100644 app/views/account/categories/partials/new/_form.html.erb diff --git a/app/views/account/categories/new.html.erb b/app/views/account/categories/new.html.erb index f9f6156d6..1bdd33494 100644 --- a/app/views/account/categories/new.html.erb +++ b/app/views/account/categories/new.html.erb @@ -1,15 +1,3 @@ -<%= simple_form_for @category, url: { action: "create" }, html: { novalidate: false } do |f| %> -
-
- <%= f.input :uk_name, class: "form-control col-sm-11" %> - <%= f.input :en_name, class: "form-control col-sm-11" %> - <%= f.input :priority, collection: Category::PRIORITY_RANGE, wrapper: :custom_vertical_select %> -
-
-
- <%= f.submit t(".form.create_category_button"), class: "btn btn-green me-2" %> - <%= link_to account_categories_path, class: "btn btn-danger d-flex align-items-center justify-content-center" do %> - <%= t("buttons.cancel") %> - <% end %> -
-<% end %> +
+ <%= render "account/categories/partials/new/form", category: @category %> +
diff --git a/app/views/account/categories/new.turbo_stream.erb b/app/views/account/categories/new.turbo_stream.erb new file mode 100644 index 000000000..0de8de8e1 --- /dev/null +++ b/app/views/account/categories/new.turbo_stream.erb @@ -0,0 +1,4 @@ +<%= turbo_stream.replace( + dom_id(@category, :form), + partial: "account/categories/partials/new/form", + locals: {category: @category}) %> diff --git a/app/views/account/categories/partials/new/_form.html.erb b/app/views/account/categories/partials/new/_form.html.erb new file mode 100644 index 000000000..f0ad59de7 --- /dev/null +++ b/app/views/account/categories/partials/new/_form.html.erb @@ -0,0 +1,15 @@ +<%= simple_form_for @category, url: { action: "create" }, html: { id: dom_id(category, :form) } do |f| %> +
+
+ <%= f.input :uk_name, class: "form-control col-sm-11" %> + <%= f.input :en_name, class: "form-control col-sm-11" %> + <%= f.input :priority, collection: Category::PRIORITY_RANGE, wrapper: :custom_vertical_select %> +
+
+
+ <%= f.submit t("account.categories.new.form.create_category_button"), class: "btn btn-green me-2" %> + <%= link_to account_categories_path, class: "btn btn-danger d-flex align-items-center justify-content-center" do %> + <%= t("buttons.cancel") %> + <% end %> +
+<% end %>