This repository was archived by the owner on Jul 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Don't allow a subcategory to be assigned to another subcategory to ensure 1 level of nesting max #1730
Merged
Merged
Don't allow a subcategory to be assigned to another subcategory to ensure 1 level of nesting max #1730
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
797cf3c
Improve category level limit validation
elvisserrao 8a7df90
Set categories list only for non parents
elvisserrao 2f708e5
Disable select field
elvisserrao 79ed958
Add info about the disabled select
elvisserrao 62d6efc
Don’t render a select input for parent categories
elvisserrao 4087275
Handle correctly turbo_stream request format
elvisserrao c6bf214
Add turbo_stream format to requests on create and update action's tests
elvisserrao 866140c
Remove no_content status from update action
elvisserrao 8097d49
Revert "Remove no_content status from update action"
elvisserrao 5a48184
Revert "Add turbo_stream format to requests on create and update acti…
elvisserrao 2926b84
Add correct redirect url for both html and turbo_stream formats
elvisserrao 2c07cd6
Remove useless turbo_frame_tag
elvisserrao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 %> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think here, we can just have a conditional: <% unless category.parent? %>
<%= f.select :parent_id ...
<% end %>That way, if the user is not allowed to assign a parent, we don't ever give them the option.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, i agree. |
||
| </div> | ||
| </section> | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.