Module: JquerySortableTreeController::DefineVariablesMethod
- Included in:
- ExpandNode, Rebuild
- Defined in:
- app/controllers/jquery_sortable_tree_controller.rb
Instance Method Summary collapse
- #id ⇒ Object
- #move_to ⇒ Object
- #move_to_next ⇒ Object
- #move_to_nowhere? ⇒ Boolean
- #move_to_parent ⇒ Object
- #move_to_prev ⇒ Object
- #next_id ⇒ Object
- #node ⇒ Object
- #node_id ⇒ Object
- #object_to_rebuild ⇒ Object
- #parent_id ⇒ Object
- #prev_id ⇒ Object
- #prev_next_parent ⇒ Object
- #sort ⇒ Object
- #sortable_collection ⇒ Object
- #sortable_model ⇒ Object
- #the_define_common_variables ⇒ Object
Instance Method Details
#id ⇒ Object
15 16 17 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 15 def id @id ||= params[:id].to_i end |
#move_to ⇒ Object
61 62 63 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 61 def move_to send("move_to_#{prev_next_parent}") end |
#move_to_next ⇒ Object
39 40 41 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 39 def move_to_next @move_to_next ||= params[:tree_sort] == 'reversed' ? :move_to_right_of : :move_to_left_of end |
#move_to_nowhere? ⇒ Boolean
51 52 53 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 51 def move_to_nowhere? parent_id.zero? && prev_id.zero? && next_id.zero? end |
#move_to_parent ⇒ Object
43 44 45 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 43 def move_to_parent :move_to_child_of end |
#move_to_prev ⇒ Object
35 36 37 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 35 def move_to_prev @move_to_prev ||= params[:tree_sort] == 'reversed' ? :move_to_left_of : :move_to_right_of end |
#next_id ⇒ Object
31 32 33 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 31 def next_id @next_id ||= params[:next_id].to_i end |
#node ⇒ Object
69 70 71 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 69 def node sortable_model.find(node_id) end |
#node_id ⇒ Object
65 66 67 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 65 def node_id send("#{prev_next_parent}_id") end |
#object_to_rebuild ⇒ Object
47 48 49 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 47 def object_to_rebuild self.sortable_model.find(id) end |
#parent_id ⇒ Object
19 20 21 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 19 def parent_id @parent_id ||= params[:parent_id].to_i end |
#prev_id ⇒ Object
27 28 29 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 27 def prev_id @prev_id ||= params[:prev_id].to_i end |
#prev_next_parent ⇒ Object
55 56 57 58 59 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 55 def prev_next_parent return 'prev' unless prev_id.zero? return 'next' unless next_id.zero? return 'parent' unless parent_id.zero? end |
#sort ⇒ Object
23 24 25 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 23 def sort @sort ||= params[:tree_sort] == 'reversed' ? 'reversed_nested_set' : 'nested_set' end |
#sortable_collection ⇒ Object
7 8 9 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 7 def sortable_collection @sortable_collection ||= self.class.to_s.split(':').last.sub(/Controller/,'').underscore.downcase end |
#sortable_model ⇒ Object
3 4 5 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 3 def sortable_model @sortable_model ||= self.class.to_s.split(':').last.sub(/Controller/, '').singularize.constantize end |
#the_define_common_variables ⇒ Object
11 12 13 |
# File 'app/controllers/jquery_sortable_tree_controller.rb', line 11 def the_define_common_variables ["@#{sortable_collection.singularize}", sortable_collection, sortable_model] end |