From bb7992ac94e763c80fc7f4b5d850a19d88f5bf3b Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 19 Jan 2013 09:07:43 +0100 Subject: allow arrows if no parent defined --- app/views/shared/_index_view_edit_destroy_part.html.haml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/shared/_index_view_edit_destroy_part.html.haml b/app/views/shared/_index_view_edit_destroy_part.html.haml index 06ec904..ff5a988 100644 --- a/app/views/shared/_index_view_edit_destroy_part.html.haml +++ b/app/views/shared/_index_view_edit_destroy_part.html.haml @@ -26,4 +26,10 @@ = link_to t("#{child.class.name.underscore.pluralize}.index.actions.edit"), method( :"edit_#{child.class.name.underscore}_path" ).(child) %td{ :style => style } - if can? :destroy, child - = link_to t("#{child.class.name.underscore.pluralize}.index.actions.destroy"), method( :"#{child.class.name.underscore}_path" ).(child), :method => :delete \ No newline at end of file + = link_to t("#{child.class.name.underscore.pluralize}.index.actions.destroy"), method( :"#{child.class.name.underscore}_path" ).(child), :method => :delete + - if child.respond_to?(:move_up?) or child and child.respond_to?(:move_down?) + %td{ :style => style } + - if can? :move_down, child and child.respond_to?(:move_down?) and child.move_down? + = link_to '⇩'.html_safe, method( :"move_lower_#{child.class.name.underscore}_path" ).(child), :method => :put + - if can? :move_up, child and child.respond_to?(:move_up?) and child.move_up? + = link_to '⇧'.html_safe, method( :"move_higher_#{child.class.name.underscore}_path" ).(child), :method => :put -- cgit v1.2.3 From c1cdcc3927a8632157017cf15801d2a508eed2ad Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 19 Jan 2013 09:08:36 +0100 Subject: move methods added --- app/models/call_route.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/call_route.rb b/app/models/call_route.rb index 5d90901..1fe61e9 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -18,4 +18,12 @@ class CallRoute < ActiveRecord::Base def to_s name.to_s end + + def move_up? + return self.position.to_i > CallRoute.where(:routing_table => self.routing_table ).order(:position).first.position.to_i + end + + def move_down? + return self.position.to_i < CallRoute.where(:routing_table => self.routing_table ).order(:position).last.position.to_i + end end -- cgit v1.2.3 From 6defcadbb9500efbfcf487c384ad41f958f5e46f Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 19 Jan 2013 09:09:04 +0100 Subject: move actions added --- app/controllers/call_routes_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index cdb425b..5ef7c4b 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -42,6 +42,16 @@ class CallRoutesController < ApplicationController redirect_to call_routes_url, :notice => t('call_routes.controller.successfuly_destroyed') end + def move_higher + @call_route.move_higher + redirect_to :back + end + + def move_lower + @call_route.move_lower + redirect_to :back + end + private def call_route_parameter_params params.require(:call_route).permit(:routing_table, :name, :endpoint_type, :endpoint_id) -- cgit v1.2.3 From 4c141a6d1c20745addd135d1cdd6844b90a20c33 Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 19 Jan 2013 09:09:25 +0100 Subject: move actions added --- app/controllers/route_elements_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/route_elements_controller.rb b/app/controllers/route_elements_controller.rb index 699fcc6..c4e4c1a 100644 --- a/app/controllers/route_elements_controller.rb +++ b/app/controllers/route_elements_controller.rb @@ -44,6 +44,16 @@ class RouteElementsController < ApplicationController redirect_to call_route_route_elements_path(@call_route), :notice => t('route_elements.controller.successfuly_destroyed') end + def move_higher + @route_element.move_higher + redirect_to :back + end + + def move_lower + @route_element.move_lower + redirect_to :back + end + private def spread_breadcrumbs add_breadcrumb t("call_routes.index.page_title"), call_routes_path -- cgit v1.2.3 From 1e290840497225c50373d0b860036505fa91e13a Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 19 Jan 2013 09:09:53 +0100 Subject: move routes added --- config/routes.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 249c947..b25081a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,16 @@ Gemeinschaft42c::Application.routes.draw do resources :call_routes do - resources :route_elements + resources :route_elements do + member do + put 'move_higher' + put 'move_lower' + end + end + member do + put 'move_higher' + put 'move_lower' + end end resources :gateways do -- cgit v1.2.3 From bcbfb154a321953fd32696065e6af1bec85f9345 Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 19 Jan 2013 09:17:41 +0100 Subject: move methods added --- app/models/route_element.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/route_element.rb b/app/models/route_element.rb index 324a26d..94f0f84 100644 --- a/app/models/route_element.rb +++ b/app/models/route_element.rb @@ -16,4 +16,11 @@ class RouteElement < ActiveRecord::Base "#{pattern} => #{var_in} #{var_out}" end + def move_up? + #return self.position.to_i > RouteElement.where(:call_route_id => self.call_route_id ).order(:position).first.position.to_i + end + + def move_down? + #return self.position.to_i < RouteElement.where(:call_route_id => self.call_route_id ).order(:position).last.position.to_i + end end -- cgit v1.2.3