mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 20:14:08 +00:00
Don't allow a subcategory to be assigned to another subcategory to ensure 1 level of nesting max (#1730)
* Improve category level limit validation * Set categories list only for non parents * Disable select field * Add info about the disabled select * Don’t render a select input for parent categories * Handle correctly turbo_stream request format * Add turbo_stream format to requests on create and update action's tests * Remove no_content status from update action * Revert "Remove no_content status from update action" This reverts commit 866140c196337d0f38ecf42fc3808fee3d502708. * Revert "Add turbo_stream format to requests on create and update action's tests" This reverts commit c6bf21490f79c657acbdda58c4cece7ba25d999a. * Add correct redirect url for both html and turbo_stream formats * Remove useless turbo_frame_tag
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<%# locals: (category:, categories:) %>
|
||||
|
||||
<div data-controller="color-avatar">
|
||||
<%= styled_form_with model: category, class: "space-y-4", data: { turbo_frame: :_top } do |f| %>
|
||||
<%= styled_form_with model: category, class: "space-y-4" do |f| %>
|
||||
<section class="space-y-4">
|
||||
<div class="w-fit m-auto">
|
||||
<%= render partial: "shared/color_avatar", locals: { name: category.name, color: category.color } %>
|
||||
@@ -34,7 +34,9 @@
|
||||
<div class="space-y-2">
|
||||
<%= f.select :classification, [["Income", "income"], ["Expense", "expense"]], { label: "Classification" }, required: true %>
|
||||
<%= f.text_field :name, placeholder: t(".placeholder"), required: true, autofocus: true, label: "Name", data: { color_avatar_target: "name" } %>
|
||||
<%= f.select :parent_id, categories.pluck(:name, :id), { include_blank: "(unassigned)", label: "Parent category (optional)" } %>
|
||||
<% unless category.parent? %>
|
||||
<%= f.select :parent_id, categories.pluck(:name, :id), { include_blank: "(unassigned)", label: "Parent category (optional)" }, disabled: category.parent? %>
|
||||
<% end %>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user