diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-06-27 20:58:33 +0200 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-06-27 20:58:33 +0200 |
commit | aad51572a6c75a4cbd2d44804b82f634a4ddd732 (patch) | |
tree | eb1e50afb7f8667fc6d5ac4a856c5f1fd396efd7 /app/serializers | |
parent | 29213546a4468aa4a853dee8091bbd556f7d0f51 (diff) |
Add the possiblity to search the phone_books in the Switchboard#view
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 |