summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-12 13:27:08 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-12 13:27:08 +0100
commit421249fc702fa76fe68530a1ab8bdde910814c6f (patch)
treeaa6ed467ba56ea74b0061af4d06cfb9b853da489
parentaa5a2b806d117ffde9888e282c7100066156d94b (diff)
parentf8f35f666613eff24d3988bda1a22cc40ef2ab30 (diff)
Merge branch 'call_routes' into develop
-rw-r--r--app/assets/javascripts/route_element.js.coffee6
-rw-r--r--app/assets/stylesheets/application.css1
-rw-r--r--app/assets/stylesheets/route_elements.css.scss5
-rw-r--r--app/controllers/route_elements_controller.rb14
-rw-r--r--app/models/call_route.rb2
-rw-r--r--app/views/call_routes/show.html.haml2
-rw-r--r--app/views/route_elements/_form_core.html.haml1
-rw-r--r--app/views/route_elements/_index_core.html.haml12
-rw-r--r--config/routes.rb4
9 files changed, 32 insertions, 15 deletions
diff --git a/app/assets/javascripts/route_element.js.coffee b/app/assets/javascripts/route_element.js.coffee
new file mode 100644
index 0000000..75dc553
--- /dev/null
+++ b/app/assets/javascripts/route_element.js.coffee
@@ -0,0 +1,6 @@
+jQuery ->
+ $('#route_elements').sortable
+ axis: 'y'
+ handle: '.handle'
+ update: ->
+ $.post($(this).data('update-url'), $(this).sortable('serialize')) \ No newline at end of file
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index 3e1cc66..44868e4 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -15,4 +15,5 @@
*= require call_routes
*= require softkeys
*= require phone_numbers
+ *= require route_elements
*/
diff --git a/app/assets/stylesheets/route_elements.css.scss b/app/assets/stylesheets/route_elements.css.scss
new file mode 100644
index 0000000..a0080ab
--- /dev/null
+++ b/app/assets/stylesheets/route_elements.css.scss
@@ -0,0 +1,5 @@
+#route_elements .handle {
+ font-size: 12px;
+ color: #777;
+ cursor: move;
+} \ No newline at end of file
diff --git a/app/controllers/route_elements_controller.rb b/app/controllers/route_elements_controller.rb
index 9c6f2b7..9c9033e 100644
--- a/app/controllers/route_elements_controller.rb
+++ b/app/controllers/route_elements_controller.rb
@@ -44,14 +44,14 @@ 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 sort
+ #call_route = RouteElement.find(params[:route_element].first).call_route
+
+ params[:route_element].each do |route_element_id|
+ @call_route.route_elements.find(route_element_id).move_to_bottom
+ end
- def move_lower
- @route_element.move_lower
- redirect_to :back
+ render nothing: true
end
private
diff --git a/app/models/call_route.rb b/app/models/call_route.rb
index 6e0dcab..8bc811a 100644
--- a/app/models/call_route.rb
+++ b/app/models/call_route.rb
@@ -4,7 +4,7 @@ class CallRoute < ActiveRecord::Base
ROUTING_TABLES = ['prerouting', 'outbound', 'inbound', 'dtmf']
- has_many :route_elements, :dependent => :destroy
+ has_many :route_elements, :dependent => :destroy, :order => :position
validates :name,
:presence => true
diff --git a/app/views/call_routes/show.html.haml b/app/views/call_routes/show.html.haml
index 998558e..7c695c8 100644
--- a/app/views/call_routes/show.html.haml
+++ b/app/views/call_routes/show.html.haml
@@ -22,7 +22,7 @@
- else
= @call_route.endpoint
-= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @call_route }
+ = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @call_route }
.row
.span12
diff --git a/app/views/route_elements/_form_core.html.haml b/app/views/route_elements/_form_core.html.haml
index d22467e..a9a38a7 100644
--- a/app/views/route_elements/_form_core.html.haml
+++ b/app/views/route_elements/_form_core.html.haml
@@ -4,5 +4,4 @@
= f.input :pattern, :label => t('route_elements.form.pattern.label'), :hint => conditional_hint('route_elements.form.pattern.hint')
= f.input :replacement, :label => t('route_elements.form.replacement.label'), :hint => conditional_hint('route_elements.form.replacement.hint')
= f.input :action, :collection => RouteElement::ELEMENT_ACTIONS, :label => t('route_elements.form.action.label'), :hint => conditional_hint('route_elements.form.action.hint'), :include_blank => false
- = f.input :position, :label => t('route_elements.form.position.label'), :hint => conditional_hint('route_elements.form.position.hint')
= f.input :mandatory, :label => t('route_elements.form.mandatory.label'), :hint => conditional_hint('route_elements.form.mandatory.hint')
diff --git a/app/views/route_elements/_index_core.html.haml b/app/views/route_elements/_index_core.html.haml
index f68a9ba..a88602f 100644
--- a/app/views/route_elements/_index_core.html.haml
+++ b/app/views/route_elements/_index_core.html.haml
@@ -1,7 +1,8 @@
%table.table.table-striped
%thead
%tr
- %th
+ - if route_elements.count > 1
+ %th
%th= t('route_elements.index.var_in')
%th= t('route_elements.index.var_out')
%th= t('route_elements.index.pattern')
@@ -9,10 +10,13 @@
%th= t('route_elements.index.action')
%th= t('route_elements.index.mandatory')
- %tbody
+ %tbody{ :id => "route_elements", :'data-update-url' => sort_call_route_route_elements_url(route_elements.first.call_route)}
- for route_element in route_elements
- %tr
- %td= route_element.position
+ = content_tag_for :tr, route_element do
+ - if route_elements.count > 1
+ %td
+ %span.handle
+ %i.icon-resize-vertical
%td= route_element.var_in
%td= route_element.var_out
%td= route_element.pattern
diff --git a/config/routes.rb b/config/routes.rb
index 05d09dc..6d7a2ad 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -14,7 +14,9 @@ Gemeinschaft42c::Application.routes.draw do
post :sort
get :show_variables
}
- resources :route_elements
+ resources :route_elements do
+ collection { post :sort }
+ end
end
resources :gateways do