-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to make sorting with different models #73
base: master
Are you sure you want to change the base?
Conversation
output += content_tag :div, class: 'dd3-content' do | ||
content = link_to object_label(tree_node), edit_path(@abstract_model, tree_node.id) | ||
content = link_to object_label(tree_node), edit_path(RailsAdmin::AbstractModel.new(tree_node.class), tree_node.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [126/80]
content_tag :li, class: li_classes, :'data-id' => tree_node.id do | ||
content_tag :li, class: li_classes, :'data-id' => tree_node.id, :'data-type' => tree_node.class.name do | ||
|
||
output = content_tag(:div, 'drag', class: 'dd-handle dd3-handle') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -5,11 +5,12 @@ def nested_tree_nodes(tree_nodes = []) | |||
tree_nodes.map do |tree_node, sub_tree_nodes| | |||
li_classes = 'dd-item dd3-item' | |||
|
|||
content_tag :li, class: li_classes, :'data-id' => tree_node.id do | |||
content_tag :li, class: li_classes, :'data-id' => tree_node.id, :'data-type' => tree_node.class.name do | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
@@ -5,11 +5,12 @@ def nested_tree_nodes(tree_nodes = []) | |||
tree_nodes.map do |tree_node, sub_tree_nodes| | |||
li_classes = 'dd-item dd3-item' | |||
|
|||
content_tag :li, class: li_classes, :'data-id' => tree_node.id do | |||
content_tag :li, class: li_classes, :'data-id' => tree_node.id, :'data-type' => tree_node.class.name do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
Metrics/LineLength: Line is too long. [111/80]
@@ -32,7 +32,8 @@ class Nestable < Base | |||
# Methods | |||
def update_tree(tree_nodes, parent_node = nil) | |||
tree_nodes.each do |key, value| | |||
model = @abstract_model.model.find(value['id'].to_s) | |||
type_class = value['type'].constantize rescue @abstract_model.model | |||
model = type_class.find(value['id'].to_s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -32,7 +32,8 @@ class Nestable < Base | |||
# Methods | |||
def update_tree(tree_nodes, parent_node = nil) | |||
tree_nodes.each do |key, value| | |||
model = @abstract_model.model.find(value['id'].to_s) | |||
type_class = value['type'].constantize rescue @abstract_model.model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RescueModifier: Avoid using rescue in its modifier form.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Metrics/LineLength: Line is too long. [83/80]
Example of usage:
I have two models:
CrewingTypeDocument
- sort of categoriesCrewingDocument
- sort of items, belongs to categoriesIn such configuration you can have sorting tree in
CrewingDocument
model where top level will beCrewingTypeDocument
, second level -CrewingDocument
.WARNING: if you want to sort groups and items in same form, you should use same
position_field
namesRailsAdmin configuration:
Example: