-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning. |
||
output = content_tag(:div, 'drag', class: 'dd-handle dd3-handle') | ||
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. Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
|
||
output = content_tag :div, 'drag', class: 'dd-handle dd3-handle' | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [126/80] |
||
content += content_tag :div, action_links(tree_node), class: 'pull-right links' | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Style/RescueModifier: Avoid using rescue in its modifier form. |
||
model = type_class.find(value['id'].to_s) | ||
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. Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
model.parent = parent_node || nil | ||
model.send("#{@position_field}=".to_sym, (key.to_i + 1)) if @position_field.present? | ||
model.save!(validate: @enable_callback) | ||
|
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]