diff options
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/phone_book_entry_serializer.rb | 14 | ||||
-rw-r--r-- | app/serializers/switchboard_serializer.rb | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/app/serializers/phone_book_entry_serializer.rb b/app/serializers/phone_book_entry_serializer.rb new file mode 100644 index 0000000..ac25832 --- /dev/null +++ b/app/serializers/phone_book_entry_serializer.rb @@ -0,0 +1,14 @@ +class PhoneBookEntrySerializer < ActiveModel::Serializer + embed :ids, :include => true + + attributes :id, :first_name, :last_name, :organization, :search_result_display + has_many :phone_numbers + + def search_result_display + result = "#{object.last_name}, #{object.first_name}".strip.gsub(/^, /,'').gsub(/,$/,'') + if result.blank? + result = "#{object.organization}" + end + return result + end +end diff --git a/app/serializers/switchboard_serializer.rb b/app/serializers/switchboard_serializer.rb index 7ad7792..8a8bd42 100644 --- a/app/serializers/switchboard_serializer.rb +++ b/app/serializers/switchboard_serializer.rb @@ -1,7 +1,7 @@ class SwitchboardSerializer < ActiveModel::Serializer embed :ids, :include => true - attributes :id, :name, :show_avatars, :blind_transfer_activated, :attended_transfer_activated + attributes :id, :name, :show_avatars, :blind_transfer_activated, :attended_transfer_activated, :search_activated has_many :switchboard_entries has_many :sip_accounts, :through => :switchboard_entries has_many :phone_numbers |