summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-02 11:44:11 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-02 11:44:11 +0100
commitb8c39c59cf7e698d5653cc49fa746506a9c41e24 (patch)
treeb5f782af7817270fc610f7756082608d00685e19
parentaad8a03991fe616f84fa18ed1db81831220f8d64 (diff)
parentba5b2737365592cc511a526a3b14be46c3a75467 (diff)
Merge branch 'sortable' into develop
-rw-r--r--app/assets/javascripts/application.js1
-rw-r--r--app/assets/javascripts/call_route.js.coffee6
-rw-r--r--app/assets/stylesheets/application.css1
-rw-r--r--app/assets/stylesheets/call_routes.css.scss5
-rw-r--r--app/controllers/call_routes_controller.rb27
-rw-r--r--app/views/call_routes/_index_core.html.haml58
-rw-r--r--app/views/call_routes/index.html.haml11
-rw-r--r--config/routes.rb12
8 files changed, 60 insertions, 61 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 9097d83..c6f4107 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -11,5 +11,6 @@
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
+//= require jquery-ui
//= require jquery_ujs
//= require_tree .
diff --git a/app/assets/javascripts/call_route.js.coffee b/app/assets/javascripts/call_route.js.coffee
new file mode 100644
index 0000000..f41d65b
--- /dev/null
+++ b/app/assets/javascripts/call_route.js.coffee
@@ -0,0 +1,6 @@
+jQuery ->
+ $("table tbody").sortable
+ axis: 'y'
+ handle: '.handle'
+ update: ->
+ $.post('call_routes/sort', $(this).sortable('serialize')) \ No newline at end of file
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index 9093f8e..999afb5 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -12,4 +12,5 @@
*= require bootstrap/bootstrap
*= require bootstrap/bootstrap-responsive
*= require gemeinschaft-generic
+ *= require call_routes
*/
diff --git a/app/assets/stylesheets/call_routes.css.scss b/app/assets/stylesheets/call_routes.css.scss
new file mode 100644
index 0000000..7face3b
--- /dev/null
+++ b/app/assets/stylesheets/call_routes.css.scss
@@ -0,0 +1,5 @@
+#call_routes .handle {
+ font-size: 12px;
+ color: #777;
+ cursor: move;
+} \ No newline at end of file
diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb
index 894dd61..779e23c 100644
--- a/app/controllers/call_routes_controller.rb
+++ b/app/controllers/call_routes_controller.rb
@@ -1,11 +1,11 @@
class CallRoutesController < ApplicationController
authorize_resource :call_route
- before_filter { |controller|
- if !params[:call_route].blank? and !params[:call_route][:endpoint_str].blank?
- params[:call_route][:endpoint_type], delimeter, params[:call_route][:endpoint_id] = params[:call_route][:endpoint_str].partition('=')
- end
- }
+ # before_filter { |controller|
+ # if !params[:call_route].blank? and !params[:call_route][:endpoint_str].blank?
+ # params[:call_route][:endpoint_type], delimeter, params[:call_route][:endpoint_id] = params[:call_route][:endpoint_str].partition('=')
+ # end
+ # }
def index
@call_routes = CallRoute.order([:routing_table, :position])
@@ -64,21 +64,16 @@ class CallRoutesController < ApplicationController
redirect_to call_routes_url, :notice => t('call_routes.controller.successfuly_destroyed')
end
- def move_higher
- @call_route = CallRoute.find(params[:id])
- @call_route.move_higher
- redirect_to :back
- end
-
- def move_lower
- @call_route = CallRoute.find(params[:id])
- @call_route.move_lower
- redirect_to :back
+ def sort
+ params[:call_route].each_with_index do |id, index|
+ CallRoute.update_all({position: index+1}, {id: id})
+ end
+ render nothing: true
end
private
def call_route_parameter_params
- params.require(:call_route).permit(:routing_table, :name, :endpoint_type, :endpoint_id)
+ params.require(:call_route).permit(:routing_table, :name, :endpoint_type, :endpoint_id, :position)
end
def spread_breadcrumbs
diff --git a/app/views/call_routes/_index_core.html.haml b/app/views/call_routes/_index_core.html.haml
index 52a45ba..9eae9ee 100644
--- a/app/views/call_routes/_index_core.html.haml
+++ b/app/views/call_routes/_index_core.html.haml
@@ -1,29 +1,31 @@
-- cache(['call_routes_table', call_routes.count, call_routes.reorder(:updated_at).last]) do
- %table.table.table-striped
- %thead
- %tr
- %th
- %th= t('call_routes.index.name')
- %th= t('route_elements.index.pattern')
- %th= t('call_routes.index.endpoint')
+/ - cache(['call_routes_table', call_routes.count, call_routes.reorder(:updated_at).last]) do
+%table.table.table-striped{ :id => "call_routes" }
+ %thead
+ %tr
+ %th
+ %th= t('call_routes.index.name')
+ %th= t('route_elements.index.pattern')
+ %th= t('call_routes.index.endpoint')
- %tbody
- - for call_route in call_routes
- - cache(['call_route_single_table_row', call_route, call_routes.count]) do
- %tr
- %td= call_route.position
- %td= call_route.name
- %td
- - if call_route.route_elements.any?
- = call_route.route_elements.first.pattern
- - if call_route.route_elements.count > 1
- = ', ...'
- - else
- = '-'
- %td
- - endpoint = call_route.endpoint
- - if endpoint
- = endpoint
- - else
- = call_route.endpoint_type
- =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => call_route}
+ %tbody
+ - for call_route in call_routes
+ / - cache(['call_route_single_table_row', call_route, call_routes.count]) do
+ = content_tag_for :tr, call_route do
+ %td
+ %span.handle
+ %i.icon-resize-vertical
+ %td= call_route.name
+ %td
+ - if call_route.route_elements.any?
+ = call_route.route_elements.first.pattern
+ - if call_route.route_elements.count > 1
+ = ', ...'
+ - else
+ = '-'
+ %td
+ - endpoint = call_route.endpoint
+ - if endpoint
+ = endpoint
+ - else
+ = call_route.endpoint_type
+ =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => call_route}
diff --git a/app/views/call_routes/index.html.haml b/app/views/call_routes/index.html.haml
index 488e1c7..d5181e3 100644
--- a/app/views/call_routes/index.html.haml
+++ b/app/views/call_routes/index.html.haml
@@ -1,11 +1,8 @@
- content_for :title, t("call_routes.index.page_title")
-- if @call_routes && @call_routes.count > 0
- %table.table.table-striped
- - @routing_tables.each do |routing_table|
- %tr
- %td{:colspan => 3}
- %h3= routing_table
- = render "index_core", :call_routes => @call_routes.where(:routing_table => routing_table)
+- if @call_routes && @call_routes.any?
+ - @routing_tables.each do |routing_table|
+ %h3= routing_table
+ = render "index_core", :call_routes => @call_routes.where(:routing_table => routing_table)
= render :partial => 'shared/create_link', :locals => {:child_class => CallRoute}
diff --git a/config/routes.rb b/config/routes.rb
index a0ac93a..9a3b3a3 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -6,16 +6,8 @@ Gemeinschaft42c::Application.routes.draw do
end
resources :call_routes do
- resources :route_elements do
- member do
- put 'move_higher'
- put 'move_lower'
- end
- end
- member do
- put 'move_higher'
- put 'move_lower'
- end
+ collection { post :sort }
+ resources :route_elements
end
resources :gateways do