diff options
author | spag <spag@golwen.net> | 2013-02-04 13:11:10 +0100 |
---|---|---|
committer | spag <spag@golwen.net> | 2013-02-04 13:11:10 +0100 |
commit | 48e32b241d422a676b3e977dd1af3688f7ebe63d (patch) | |
tree | eb658714cdfd4f46fb805e770c3a0bc975014ee6 | |
parent | 242470bdb4fa67780e7467c6889b7869dff05d1c (diff) | |
parent | 049b3e62c2ad3e0affac17214baa38afb994b6ba (diff) |
Merge branch 'develop' of github.com:amooma/GS5 into develop
-rw-r--r-- | app/assets/javascripts/softkey.js.coffee | 6 | ||||
-rw-r--r-- | app/assets/stylesheets/application.css | 1 | ||||
-rw-r--r-- | app/assets/stylesheets/softkeys.css.scss | 5 | ||||
-rw-r--r-- | app/controllers/softkeys_controller.rb | 21 | ||||
-rw-r--r-- | app/models/sip_account.rb | 2 | ||||
-rw-r--r-- | app/views/sip_accounts/show.html.haml | 8 | ||||
-rw-r--r-- | app/views/softkeys/_index_core.html.haml | 32 | ||||
-rw-r--r-- | config/environments/development.rb | 2 | ||||
-rw-r--r-- | config/routes.rb | 11 |
9 files changed, 52 insertions, 36 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 diff --git a/config/environments/development.rb b/config/environments/development.rb index e677834..1a3acae 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -13,7 +13,7 @@ Gemeinschaft42c::Application.configure do config.consider_all_requests_local = true # Enable caching for development - config.action_controller.perform_caching = false + config.action_controller.perform_caching = true CacheDigests::TemplateDigestor.cache = ActiveSupport::Cache::NullStore.new # Don't care if the mailer can't send diff --git a/config/routes.rb b/config/routes.rb index 9a3b3a3..1ad621e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -271,6 +271,10 @@ Gemeinschaft42c::Application.routes.draw do end end + resources :softkeys, :only => [ :sort ] do + collection { post :sort } + end + resources :sip_accounts, :only => [] do resources :phones_sip_accounts resources :phone_numbers do @@ -279,12 +283,7 @@ Gemeinschaft42c::Application.routes.draw do put 'move_lower' end end - resources :softkeys do - member do - put 'move_higher' - put 'move_lower' - end - end + resources :softkeys resources :call_histories do collection do delete 'destroy_multiple' |