summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/phone_number.js.coffee6
-rw-r--r--app/assets/stylesheets/application.css1
-rw-r--r--app/assets/stylesheets/phone_numbers.css.scss5
-rw-r--r--app/controllers/phone_numbers_controller.rb45
-rw-r--r--app/views/phone_numbers/_index_core.html.haml8
-rw-r--r--config/routes.rb83
6 files changed, 54 insertions, 94 deletions
diff --git a/app/assets/javascripts/phone_number.js.coffee b/app/assets/javascripts/phone_number.js.coffee
new file mode 100644
index 0000000..ee983ee
--- /dev/null
+++ b/app/assets/javascripts/phone_number.js.coffee
@@ -0,0 +1,6 @@
+jQuery ->
+ $('#phone_numbers').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 128a391..3e1cc66 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -14,4 +14,5 @@
*= require gemeinschaft-generic
*= require call_routes
*= require softkeys
+ *= require phone_numbers
*/
diff --git a/app/assets/stylesheets/phone_numbers.css.scss b/app/assets/stylesheets/phone_numbers.css.scss
new file mode 100644
index 0000000..141a1f7
--- /dev/null
+++ b/app/assets/stylesheets/phone_numbers.css.scss
@@ -0,0 +1,5 @@
+#phone_numbers .handle {
+ font-size: 12px;
+ color: #777;
+ cursor: move;
+} \ No newline at end of file
diff --git a/app/controllers/phone_numbers_controller.rb b/app/controllers/phone_numbers_controller.rb
index c562954..67c4922 100644
--- a/app/controllers/phone_numbers_controller.rb
+++ b/app/controllers/phone_numbers_controller.rb
@@ -1,22 +1,22 @@
class PhoneNumbersController < ApplicationController
- load_resource :phone_book_entry
- load_resource :sip_account
- load_resource :conference
- load_resource :fax_account
- load_resource :phone_number_range
- load_resource :callthrough
- load_resource :whitelist
- load_resource :access_authorization
- load_resource :hunt_group
- load_resource :hunt_group_member
- load_resource :automatic_call_distributor
- load_and_authorize_resource :phone_number, :through => [:phone_book_entry, :sip_account, :conference,
+ load_resource :phone_book_entry, :except => [:sort]
+ load_resource :sip_account, :except => [:sort]
+ load_resource :conference, :except => [:sort]
+ load_resource :fax_account, :except => [:sort]
+ load_resource :phone_number_range, :except => [:sort]
+ load_resource :callthrough, :except => [:sort]
+ load_resource :whitelist, :except => [:sort]
+ load_resource :access_authorization, :except => [:sort]
+ load_resource :hunt_group, :except => [:sort]
+ load_resource :hunt_group_member, :except => [:sort]
+ load_resource :automatic_call_distributor, :except => [:sort]
+ load_and_authorize_resource :phone_number, :except => [:sort], :through => [:phone_book_entry, :sip_account, :conference,
:fax_account, :phone_number_range, :callthrough,
:whitelist, :access_authorization, :hunt_group,
:hunt_group_member, :automatic_call_distributor]
- before_filter :set_and_authorize_parent
- before_filter :spread_breadcrumbs
+ before_filter :set_and_authorize_parent, :except => [:sort]
+ before_filter :spread_breadcrumbs, :except => [:sort]
def index
end
@@ -67,16 +67,6 @@ class PhoneNumbersController < ApplicationController
redirect_to m.(), :notice => t('phone_numbers.controller.successfuly_destroyed')
end
- def move_higher
- @phone_number.move_higher
- redirect_to :back
- end
-
- def move_lower
- @phone_number.move_lower
- redirect_to :back
- end
-
def call
sip_account = nil
current_user.sip_accounts.each do |user_sip_account|
@@ -94,6 +84,13 @@ class PhoneNumbersController < ApplicationController
redirect_to(:back)
end
+ def sort
+ params[:phone_number].each_with_index do |id, index|
+ PhoneNumber.update_all({position: index+1}, {id: id})
+ end
+ render nothing: true
+ end
+
private
def set_and_authorize_parent
@parent = @phone_book_entry || @sip_account || @conference || @fax_account ||
diff --git a/app/views/phone_numbers/_index_core.html.haml b/app/views/phone_numbers/_index_core.html.haml
index 80a1608..b68e5af 100644
--- a/app/views/phone_numbers/_index_core.html.haml
+++ b/app/views/phone_numbers/_index_core.html.haml
@@ -1,13 +1,17 @@
%table.table.table-striped
%thead
%tr
+ %th
- if phone_numbers.count > 1 && phone_numbers.first.phone_numberable_type == 'PhoneBookEntry'
%th= t('phone_numbers.index.name')
%th= t('phone_numbers.index.number')
- %tbody
+ %tbody{ :id => "phone_numbers", :'data-update-url' => sort_phone_numbers_url}
- for phone_number in phone_numbers.order(:position)
- %tr
+ = content_tag_for :tr, phone_number do
+ %td
+ %span.handle
+ %i.icon-resize-vertical
- if phone_number.phone_numberable_type == 'PhoneBookEntry'
%td= phone_number.name
%td= phone_number
diff --git a/config/routes.rb b/config/routes.rb
index 1ad621e..fbb32f6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -33,95 +33,54 @@ Gemeinschaft42c::Application.routes.draw do
resources :rows
end
+ resources :phone_numbers, :only => [:sort] do
+ collection { post :sort }
+ end
+
resources :acd_agents, :only => [] do
- resources :phone_numbers do
- member do
- put 'move_higher'
- put 'move_lower'
- end
- end
+ resources :phone_numbers
end
resources :automatic_call_distributors, :only => [] do
resources :acd_agents
- resources :phone_numbers do
- member do
- put 'move_higher'
- put 'move_lower'
- end
- end
+ resources :phone_numbers
end
resources :hunt_group_members, :only => [] do
- resources :phone_numbers do
- member do
- put 'move_higher'
- put 'move_lower'
- end
- end
+ resources :phone_numbers
end
resources :hunt_groups, :only => [] do
resources :hunt_group_members
- resources :phone_numbers do
- member do
- put 'move_higher'
- put 'move_lower'
- end
- end
+ resources :phone_numbers
end
if GsParameter.get('CALLTHROUGH_HAS_WHITELISTS') == true
resources :whitelists, :only => [] do
- resources :phone_numbers do
- member do
- put 'move_higher'
- put 'move_lower'
- end
- end
+ resources :phone_numbers
end
end
resources :access_authorizations, :only => [] do
- resources :phone_numbers do
- member do
- put 'move_higher'
- put 'move_lower'
- end
- end
+ resources :phone_numbers
end
resources :fax_documents
resources :fax_accounts, :only => [] do
resources :fax_documents
- resources :phone_numbers do
- member do
- put 'move_higher'
- put 'move_lower'
- end
- end
+ resources :phone_numbers
end
resources :gemeinschaft_setups, :only => [:new, :create]
resources :phone_number_ranges, :only => [] do
- resources :phone_numbers do
- member do
- put 'move_higher'
- put 'move_lower'
- end
- end
+ resources :phone_numbers
end
resources :conferences, :only => [] do
resources :conference_invitees
- resources :phone_numbers do
- member do
- put 'move_higher'
- put 'move_lower'
- end
- end
+ resources :phone_numbers
end
resources :phone_numbers, :only => [] do
@@ -260,12 +219,7 @@ Gemeinschaft42c::Application.routes.draw do
resources :callthroughs, :only => [] do
resources :access_authorizations
- resources :phone_numbers do
- member do
- put 'move_higher'
- put 'move_lower'
- end
- end
+ resources :phone_numbers
if GsParameter.get('CALLTHROUGH_HAS_WHITELISTS') == true
resources :whitelists
end
@@ -277,12 +231,7 @@ Gemeinschaft42c::Application.routes.draw do
resources :sip_accounts, :only => [] do
resources :phones_sip_accounts
- resources :phone_numbers do
- member do
- put 'move_higher'
- put 'move_lower'
- end
- end
+ resources :phone_numbers
resources :softkeys
resources :call_histories do
collection do
@@ -313,8 +262,6 @@ Gemeinschaft42c::Application.routes.draw do
resources :phone_book_entries, :only => [ :index, :show ] do
resources :phone_numbers do
member do
- put 'move_higher'
- put 'move_lower'
put 'call'
end
end