summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-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.haml9
-rw-r--r--app/views/sip_accounts/show.html.haml8
-rw-r--r--app/views/softkeys/_index_core.html.haml5
7 files changed, 47 insertions, 32 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..85982da 100644
--- a/app/views/phone_numbers/_index_core.html.haml
+++ b/app/views/phone_numbers/_index_core.html.haml
@@ -1,13 +1,18 @@
%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
+ - if phone_numbers.count > 1
+ %span.handle
+ %i.icon-resize-vertical
- if phone_number.phone_numberable_type == 'PhoneBookEntry'
%td= phone_number.name
%td= phone_number
diff --git a/app/views/sip_accounts/show.html.haml b/app/views/sip_accounts/show.html.haml
index f48d927..72e10df 100644
--- a/app/views/sip_accounts/show.html.haml
+++ b/app/views/sip_accounts/show.html.haml
@@ -65,16 +65,16 @@
= render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @sip_account.sip_accountable, :child => @sip_account }
-- if @sip_account.phone_numbers.any? || can?(:create, @sip_account.phone_numbers.build)
+- if @sip_account.phone_numbers.count > 0 || can?(:create, @sip_account.phone_numbers.build)
%h2= t('phone_numbers.index.page_title')
- - if @sip_account.phone_numbers.any?
+ - if @sip_account.phone_numbers.count > 0
= render "phone_numbers/index_core", :phone_numbers => @sip_account.phone_numbers
%br
= render :partial => 'shared/create_link', :locals => { :parent => @sip_account, :child_class => PhoneNumber }
-- if @sip_account.softkeys.any? || can?(:create, @sip_account.softkeys.build)
+- if @sip_account.softkeys.count > 0 || can?(:create, @sip_account.softkeys.build)
%h2= t("softkeys.index.page_title")
- - if @sip_account.softkeys.any?
+ - if @sip_account.softkeys.count > 0
= render "softkeys/index_core", :softkeys => @sip_account.softkeys
%br
= render :partial => 'shared/create_link', :locals => { :parent => @sip_account, :child_class => Softkey } \ No newline at end of file
diff --git a/app/views/softkeys/_index_core.html.haml b/app/views/softkeys/_index_core.html.haml
index 70c96bc..e2cb16c 100644
--- a/app/views/softkeys/_index_core.html.haml
+++ b/app/views/softkeys/_index_core.html.haml
@@ -12,8 +12,9 @@
- cache(['softkeys_table_tr', I18n.locale, current_user, softkey]) do
= content_tag_for :tr, softkey do
%td
- %span.handle
- %i.icon-resize-vertical
+ - if softkeys.count > 1
+ %span.handle
+ %i.icon-resize-vertical
%td= softkey.function
%td= softkey.number
%td= softkey.label