diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-07-01 12:02:00 +0200 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-07-01 12:02:00 +0200 |
commit | 14363079481d3a985060820225b571aefd0e4a04 (patch) | |
tree | 8e226e860839bbfd518149eb2ce1db9e1ce1aec9 | |
parent | 9f23443a86ad145c2739ac289e42ac0f13ef0929 (diff) |
Added a reverse lookup switch. closes #295
-rw-r--r-- | app/controllers/api/v1/phone_book_entries_controller.rb | 3 | ||||
-rw-r--r-- | app/views/switchboards/_form_core.html.haml | 3 | ||||
-rw-r--r-- | config/locales/views/switchboards/de.yml | 5 | ||||
-rw-r--r-- | config/locales/views/switchboards/en.yml | 6 | ||||
-rw-r--r-- | db/migrate/20130701084803_add_reverse_lookup_to_switchboard.rb | 5 | ||||
-rw-r--r-- | public/js/app.js | 2 |
6 files changed, 20 insertions, 4 deletions
diff --git a/app/controllers/api/v1/phone_book_entries_controller.rb b/app/controllers/api/v1/phone_book_entries_controller.rb index cae3259..6a39623 100644 --- a/app/controllers/api/v1/phone_book_entries_controller.rb +++ b/app/controllers/api/v1/phone_book_entries_controller.rb @@ -5,13 +5,14 @@ module Api def index query = params[:query] + switchboard = Switchboard.find(params[:switchboard_id]) return nil if query.blank? current_ability = Ability.new(current_user) phone_book_entries = PhoneBookEntry.accessible_by(current_ability) - if query.match(/^\+?\d+$/) != nil + if query.match(/^\+?\d+$/) != nil && switchboard && switchboard.reverse_lookup_activated # Find by phone number phone_book_entries_ids = phone_book_entries.map{|entry| entry.id} found_phone_numbers = PhoneNumber. diff --git a/app/views/switchboards/_form_core.html.haml b/app/views/switchboards/_form_core.html.haml index 0bfcb86..db843ad 100644 --- a/app/views/switchboards/_form_core.html.haml +++ b/app/views/switchboards/_form_core.html.haml @@ -6,4 +6,5 @@ = f.input :amount_of_displayed_phone_numbers, :label => t('switchboards.form.amount_of_displayed_phone_numbers.label'), :hint => conditional_hint('switchboards.form.amount_of_displayed_phone_numbers.hint') = f.input :blind_transfer_activated, :label => t('switchboards.form.blind_transfer_activated.label'), :hint => conditional_hint('switchboards.form.blind_transfer_activated.hint') = f.input :attended_transfer_activated, :label => t('switchboards.form.attended_transfer_activated.label'), :hint => conditional_hint('switchboards.form.attended_transfer_activated.hint') - = f.input :search_activated, :label => t('switchboards.form.search_activated.label'), :hint => conditional_hint('switchboards.form.search_activated.hint')
\ No newline at end of file + = f.input :search_activated, :label => t('switchboards.form.search_activated.label'), :hint => conditional_hint('switchboards.form.search_activated.hint') + = f.input :reverse_lookup_activated, :label => t('switchboards.form.reverse_lookup_activated.label'), :hint => conditional_hint('switchboards.form.reverse_lookup_activated.hint')
\ No newline at end of file diff --git a/config/locales/views/switchboards/de.yml b/config/locales/views/switchboards/de.yml index 3bb45a5..f4cb0dd 100644 --- a/config/locales/views/switchboards/de.yml +++ b/config/locales/views/switchboards/de.yml @@ -16,6 +16,7 @@ de: blind_transfer_activated: 'Transfer' attended_transfer_activated: 'Transfer mit Rückfrage' search_activated: 'Suche' + reverse_lookup: 'Inverssuche' actions: confirm_destroy: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Switchboard' destroy: 'Löschen' @@ -30,10 +31,12 @@ de: reload_interval:: 'Reload Interval' show_avatars: 'Show avatars' entry_width: 'Entry width' + amount_of_displayed_phone_numbers: 'Anzahl der angezeigten Telefonnummern' blind_transfer_activated: 'Transfer' attended_transfer_activated: 'Transfer mit Rückfrage' search_activated: 'Suche' + reverse_lookup: 'Inverssuche' actions: confirm_destroy: 'Sind Sie sicher, dass die dieses Element löschen möchten?' destroy: 'Löschen' @@ -77,4 +80,6 @@ de: search_activated: label: 'Suche aktivieren' hint: '' + reverse_lookup: 'Inverssuche aktivieren' + hint: 'Bei der Eingabe eine Ziffernfolge wird nach einem Telefonbucheintrag gesucht.' submit: 'Absenden'
\ No newline at end of file diff --git a/config/locales/views/switchboards/en.yml b/config/locales/views/switchboards/en.yml index 0cc5ef2..28377e2 100644 --- a/config/locales/views/switchboards/en.yml +++ b/config/locales/views/switchboards/en.yml @@ -16,6 +16,7 @@ en: blind_transfer_activated: 'Blind Transfer' attended_transfer_activated: 'Attended Transfer' search_activated: 'Search function' + reverse_lookup: 'Reverse lookup' actions: confirm_destroy: 'Are you sure you want to delete this Switchboard?' destroy: 'Delete' @@ -34,6 +35,7 @@ en: blind_transfer_activated: 'Blind Transfer' attended_transfer_activated: 'Attended Transfer' search_activated: 'Search function' + reverse_lookup: 'Reverse lookup' actions: confirm_destroy: 'Are you sure you want to delete this element?' destroy: 'Delete' @@ -76,5 +78,7 @@ en: hint: 'Does not work with all phone models.' search_activated: label: 'Activate search function' - hint: '' + hint: '' + reverse_lookup: 'Activate reverse lookup' + hint: 'Bei der Eingabe eine Ziffernfolge wird nach einem Telefonbucheintrag gesucht.' submit: 'Submit'
\ No newline at end of file diff --git a/db/migrate/20130701084803_add_reverse_lookup_to_switchboard.rb b/db/migrate/20130701084803_add_reverse_lookup_to_switchboard.rb new file mode 100644 index 0000000..e16e8e2 --- /dev/null +++ b/db/migrate/20130701084803_add_reverse_lookup_to_switchboard.rb @@ -0,0 +1,5 @@ +class AddReverseLookupToSwitchboard < ActiveRecord::Migration + def change + add_column :switchboards, :reverse_lookup_activated, :boolean + end +end diff --git a/public/js/app.js b/public/js/app.js index 5560ae7..e389b9a 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -41,7 +41,7 @@ App.SwitchboardController = Ember.ObjectController.extend({ searchResults: function() { var searchText = this.get('searchText'); if (!searchText) { return; } - return App.PhoneBookEntry.find({ query: searchText }); + return App.PhoneBookEntry.find({ query: searchText, switchboard_id: switchboard_id }); }.property('searchText') }); |