summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/softkey.js.coffee6
-rw-r--r--app/assets/stylesheets/application.css1
-rw-r--r--app/assets/stylesheets/softkeys.css.scss5
-rw-r--r--app/controllers/softkeys_controller.rb21
-rw-r--r--app/models/sip_account.rb2
-rw-r--r--app/views/sip_accounts/show.html.haml8
-rw-r--r--app/views/softkeys/_index_core.html.haml32
7 files changed, 46 insertions, 29 deletions
diff --git a/app/assets/javascripts/softkey.js.coffee b/app/assets/javascripts/softkey.js.coffee
new file mode 100644
index 0000000..19103f0
--- /dev/null
+++ b/app/assets/javascripts/softkey.js.coffee
@@ -0,0 +1,6 @@
+jQuery ->
+ $("table tbody").sortable
+ axis: 'y'
+ handle: '.handle'
+ update: ->
+ $.post('/softkeys/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 999afb5..128a391 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -13,4 +13,5 @@
*= require bootstrap/bootstrap-responsive
*= require gemeinschaft-generic
*= require call_routes
+ *= require softkeys
*/
diff --git a/app/assets/stylesheets/softkeys.css.scss b/app/assets/stylesheets/softkeys.css.scss
new file mode 100644
index 0000000..425c6f1
--- /dev/null
+++ b/app/assets/stylesheets/softkeys.css.scss
@@ -0,0 +1,5 @@
+#softkeys .handle {
+ font-size: 12px;
+ color: #777;
+ cursor: move;
+} \ No newline at end of file
diff --git a/app/controllers/softkeys_controller.rb b/app/controllers/softkeys_controller.rb
index 8f363cd..c9e8c20 100644
--- a/app/controllers/softkeys_controller.rb
+++ b/app/controllers/softkeys_controller.rb
@@ -1,9 +1,9 @@
class SoftkeysController < ApplicationController
- load_and_authorize_resource :sip_account
- load_and_authorize_resource :softkey, :through => [:sip_account]
+ load_and_authorize_resource :sip_account, :except => [:sort]
+ load_and_authorize_resource :softkey, :through => [:sip_account], :except => [:sort]
before_filter :set_available_call_forwards_and_softkey_functions, :only => [ :new, :edit, :update ]
- before_filter :spread_breadcrumbs
+ before_filter :spread_breadcrumbs, :except => [:sort]
def index
end
@@ -44,16 +44,17 @@ class SoftkeysController < ApplicationController
redirect_to sip_account_softkeys_path(@softkey.sip_account), :notice => t('softkeys.controller.successfuly_destroyed')
end
- def move_higher
- @softkey.move_higher
- redirect_to :back
- end
+ def sort
+ sip_account = Softkey.find(params[:softkey].first).sip_account
+
+ params[:softkey].each do |softkey_id|
+ sip_account.softkeys.find(softkey_id).move_to_bottom
+ end
- def move_lower
- @softkey.move_lower
- redirect_to :back
+ render nothing: true
end
+
private
def set_available_call_forwards_and_softkey_functions
diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb
index 444eb12..9ba1f8b 100644
--- a/app/models/sip_account.rb
+++ b/app/models/sip_account.rb
@@ -21,7 +21,7 @@ class SipAccount < ActiveRecord::Base
belongs_to :tenant
belongs_to :sip_domain
- has_many :softkeys, :dependent => :destroy
+ has_many :softkeys, :dependent => :destroy, :order => :position
has_many :voicemail_messages, :foreign_key => 'username', :primary_key => 'auth_name'
diff --git a/app/views/sip_accounts/show.html.haml b/app/views/sip_accounts/show.html.haml
index 72e10df..f48d927 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.count > 0 || can?(:create, @sip_account.phone_numbers.build)
+- if @sip_account.phone_numbers.any? || can?(:create, @sip_account.phone_numbers.build)
%h2= t('phone_numbers.index.page_title')
- - if @sip_account.phone_numbers.count > 0
+ - if @sip_account.phone_numbers.any?
= 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.count > 0 || can?(:create, @sip_account.softkeys.build)
+- if @sip_account.softkeys.any? || can?(:create, @sip_account.softkeys.build)
%h2= t("softkeys.index.page_title")
- - if @sip_account.softkeys.count > 0
+ - if @sip_account.softkeys.any?
= 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 398ee51..4ebb29c 100644
--- a/app/views/softkeys/_index_core.html.haml
+++ b/app/views/softkeys/_index_core.html.haml
@@ -1,15 +1,19 @@
-%table.table.table-striped
- %thead
- %tr
- %th= t('softkeys.index.function')
- %th= t('softkeys.index.number')
- %th= t('softkeys.index.label')
-
- %tbody
- - for softkey in softkeys.order(:position)
+- cache(['softkeys', I18n.locale, current_user, softkeys]) do
+ %table.table.table-striped{ :id => "softkeys" }
+ %thead
%tr
- %td
- =softkey.to_s
- %td= softkey.number
- %td= softkey.label
- =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => softkey.sip_account, :child => softkey} \ No newline at end of file
+ %th
+ %th= t('softkeys.index.function')
+ %th= t('softkeys.index.number')
+ %th= t('softkeys.index.label')
+
+ %tbody
+ - for softkey in softkeys
+ = content_tag_for :tr, softkey do
+ %td
+ %span.handle
+ %i.icon-resize-vertical
+ %td= softkey.function
+ %td= softkey.number
+ %td= softkey.label
+ =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => softkey.sip_account, :child => softkey} \ No newline at end of file