summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-06-25 13:09:07 +0200
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-06-25 13:09:07 +0200
commit14da4be11fe13d4fcd55143c39b73c0d086b901b (patch)
tree2f6d2b9385b69852c9ea1c9e537aeefd0705ed24
parent17f94f46374d60e58a00071303c9081469e7997c (diff)
Show transfer buttons only for switchable incoming calls.
-rw-r--r--app/models/switchboard.rb6
-rw-r--r--app/serializers/switchboard_serializer.rb1
-rw-r--r--app/views/switchboards/show.html.erb8
-rw-r--r--public/js/app.js25
4 files changed, 33 insertions, 7 deletions
diff --git a/app/models/switchboard.rb b/app/models/switchboard.rb
index 73219e8..d62657f 100644
--- a/app/models/switchboard.rb
+++ b/app/models/switchboard.rb
@@ -25,7 +25,7 @@ class Switchboard < ActiveRecord::Base
}
belongs_to :user, :touch => true
-
+
has_many :switchboard_entries, :dependent => :destroy
has_many :switchable_switchboard_entries, :class_name => "SwitchboardEntry", :conditions => {:switchable => true}
@@ -41,11 +41,11 @@ class Switchboard < ActiveRecord::Base
end
def active_calls
- Call.where("sip_account_id = ? or b_sip_account_id = ?", self.switchable_sip_account_ids, self.switchable_sip_account_ids)
+ Call.where("sip_account_id = ? or b_sip_account_id = ?", self.switchable_sip_account_ids, self.switchable_sip_account_ids).order(:start_stamp)
end
def dispatchable_incoming_calls
- Call.where("b_sip_account_id = ?", self.switchable_sip_account_ids)
+ Call.where("b_sip_account_id = ?", self.switchable_sip_account_ids).order(:start_stamp)
end
private
diff --git a/app/serializers/switchboard_serializer.rb b/app/serializers/switchboard_serializer.rb
index 6d39667..7c21f82 100644
--- a/app/serializers/switchboard_serializer.rb
+++ b/app/serializers/switchboard_serializer.rb
@@ -6,4 +6,5 @@ class SwitchboardSerializer < ActiveModel::Serializer
has_many :sip_accounts, :through => :switchboard_entries
has_many :phone_numbers
has_many :active_calls
+ has_many :dispatchable_incoming_calls
end
diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb
index f3304cf..69b0ed6 100644
--- a/app/views/switchboards/show.html.erb
+++ b/app/views/switchboards/show.html.erb
@@ -46,11 +46,11 @@
{{phoneNumber.number}}
</span>
- {{#if activeCalls.length}}
+ {{#if dispatchableIncomingCalls.length}}
<p>
- {{#each activeCall in activeCalls}}
- <button {{action transfer_blind activeCall.id phoneNumber.number}} class="btn btn-small">Transfer</button>
- <button {{action transfer_attended activeCall.id phoneNumber.number}} class="btn btn-small">Attended Transfer</button>
+ {{#each dispatchableIncomingCall in dispatchableIncomingCalls}}
+ <button {{action transfer_blind dispatchableIncomingCall.id phoneNumber.number}} class="btn btn-small">Transfer</button>
+ <button {{action transfer_attended dispatchableIncomingCall.id phoneNumber.number}} class="btn btn-small">Attended Transfer</button>
{{/each}}
</p>
{{/if}}
diff --git a/public/js/app.js b/public/js/app.js
index efc0752..1dee270 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -51,6 +51,7 @@ DS.RESTAdapter.reopen({
App.Switchboard = DS.Model.extend({
switchboardEntrys: DS.hasMany('App.SwitchboardEntry'),
activeCalls: DS.hasMany('App.ActiveCall'),
+ dispatchableIncomingCalls: DS.hasMany('App.DispatchableIncomingCall'),
name: DS.attr('string')
});
@@ -87,6 +88,30 @@ App.ActiveCall = DS.Model.extend({
}.property('b_callstate')
});
+App.DispatchableIncomingCall = DS.Model.extend({
+ start_stamp: DS.attr('number'),
+ callstate: DS.attr('string'),
+ b_callstate: DS.attr('string'),
+ destination: DS.attr('string'),
+ b_caller_id_number: DS.attr('string'),
+
+ isActive: function() {
+ if (this.get('b_callstate') == 'ACTIVE') {
+ return true
+ } else {
+ return false
+ }
+ }.property('b_callstate'),
+
+ isRinging: function() {
+ if (this.get('b_callstate') == 'RINGING') {
+ return true
+ } else {
+ return false
+ }
+ }.property('b_callstate')
+});
+
App.Adapter = DS.RESTAdapter.extend();
App.store = App.Store.create({