Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/rails_admin_nestable/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

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]


Copy link
Collaborator

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.

output = content_tag(:div, 'drag', class: 'dd-handle dd3-handle')
Copy link
Collaborator

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.


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)
Copy link
Collaborator

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 += content_tag :div, action_links(tree_node), class: 'pull-right links'
end

Expand Down
3 changes: 2 additions & 1 deletion lib/rails_admin_nestable/nestable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

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]

model = type_class.find(value['id'].to_s)
Copy link
Collaborator

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.

model.parent = parent_node || nil
model.send("#{@position_field}=".to_sym, (key.to_i + 1)) if @position_field.present?
model.save!(validate: @enable_callback)
Expand Down