diff options
-rw-r--r-- | app/controllers/switchboards_controller.rb | 3 | ||||
-rw-r--r-- | app/models/switchboard.rb | 6 | ||||
-rw-r--r-- | app/views/switchboards/_form_core.html.haml | 1 | ||||
-rw-r--r-- | app/views/switchboards/show.html.erb | 3 | ||||
-rw-r--r-- | config/locales/views/switchboards/de.yml | 13 | ||||
-rw-r--r-- | config/locales/views/switchboards/en.yml | 7 | ||||
-rw-r--r-- | db/migrate/20130404094648_add_amount_of_displayed_phone_numbers_to_switchboard.rb | 17 | ||||
-rw-r--r-- | public/js/app.js | 8 |
8 files changed, 50 insertions, 8 deletions
diff --git a/app/controllers/switchboards_controller.rb b/app/controllers/switchboards_controller.rb index f48e7fb..3e2f8d6 100644 --- a/app/controllers/switchboards_controller.rb +++ b/app/controllers/switchboards_controller.rb @@ -18,6 +18,7 @@ class SwitchboardsController < ApplicationController @switchboard.show_avatars = true @switchboard.entry_width = 2 @switchboard.reload_interval = 2000 + @switchboard.amount_of_displayed_phone_numbers = 1 spread_breadcrumbs end @@ -55,7 +56,7 @@ class SwitchboardsController < ApplicationController private def switchboard_params - params.require(:switchboard).permit(:name, :reload_interval, :show_avatars, :entry_width) + params.require(:switchboard).permit(:name, :reload_interval, :show_avatars, :entry_width, :amount_of_displayed_phone_numbers) end def spread_breadcrumbs diff --git a/app/models/switchboard.rb b/app/models/switchboard.rb index 53f69a4..cf8c708 100644 --- a/app/models/switchboard.rb +++ b/app/models/switchboard.rb @@ -18,6 +18,12 @@ class Switchboard < ActiveRecord::Base :less_than => 5 } + validates :amount_of_displayed_phone_numbers, + :numericality => { :only_integer => true, + :greater_than_or_equal_to => 0, + :less_than => 20 + } + belongs_to :user, :touch => true has_many :switchboard_entries, :dependent => :destroy has_many :sip_accounts, :through => :switchboard_entries diff --git a/app/views/switchboards/_form_core.html.haml b/app/views/switchboards/_form_core.html.haml index 59a2442..2258640 100644 --- a/app/views/switchboards/_form_core.html.haml +++ b/app/views/switchboards/_form_core.html.haml @@ -3,3 +3,4 @@ = f.input :reload_interval, :label => t('switchboards.form.reload_interval.label'), :hint => conditional_hint('switchboards.form.reload_interval.hint') = f.input :show_avatars, :label => t('switchboards.form.show_avatars.label'), :hint => conditional_hint('switchboards.form.show_avatars.hint') = f.input :entry_width, :label => t('switchboards.form.entry_width.label'), :hint => conditional_hint('switchboards.form.entry_width.hint') + = 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')
\ No newline at end of file diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb index 1fd9d9a..a240b55 100644 --- a/app/views/switchboards/show.html.erb +++ b/app/views/switchboards/show.html.erb @@ -4,6 +4,7 @@ var switchboard_id = <%= @switchboard.id %>; var show_avatars = <%= @switchboard.show_avatars.to_s %>; var reload_interval = <%= @switchboard.reload_interval.nil? ? 0 : @switchboard.reload_interval %>; + var amount_of_displayed_phone_numbers = <%= @switchboard.amount_of_displayed_phone_numbers %>; </script> <div class='row'> @@ -27,7 +28,7 @@ <small> {{switchboardEntry.name}}<br> - {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumbers}} + {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumberShortList}} <span class="label"> {{phoneNumber.number}} </span> diff --git a/config/locales/views/switchboards/de.yml b/config/locales/views/switchboards/de.yml index e73b100..1f66b9f 100644 --- a/config/locales/views/switchboards/de.yml +++ b/config/locales/views/switchboards/de.yml @@ -12,6 +12,7 @@ de: reload_interval:: 'Reload Interval' show_avatars: 'Show avatars' entry_width: 'Entry width' + amount_of_displayed_phone_numbers: 'Anzahl der angezeigten Telefonnummern' actions: confirm_destroy: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Switchboard' destroy: 'Löschen' @@ -26,6 +27,7 @@ de: reload_interval:: 'Reload Interval' show_avatars: 'Show avatars' entry_width: 'Entry width' + amount_of_displayed_phone_numbers: 'Anzahl der angezeigten Telefonnummern' actions: confirm_destroy: 'Sind Sie sicher, dass die dieses Element löschen möchten?' destroy: 'Löschen' @@ -50,11 +52,14 @@ de: hint: '' reload_interval: label: 'Reload Interval' - hint: 'Milliseconds. nil = no reload' + hint: 'Millisekunden. nil = kein reload' show_avatars: - label: 'Show avatars' + label: 'Avatare anzeigen' hint: '' entry_width: - label: 'Entry width' - hint: '' + label: 'Weite eines Eintrages' + hint: '1 - 4' + amount_of_displayed_phone_numbers: + label: 'Anzahl Telefonnummern' + hint: 'Wie viel Telefonnummern werden in einem Eintrag angezeigt.' 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 8489d28..fd160b5 100644 --- a/config/locales/views/switchboards/en.yml +++ b/config/locales/views/switchboards/en.yml @@ -12,6 +12,7 @@ en: reload_interval:: 'Reload Interval' show_avatars: 'Show avatars' entry_width: 'Entry width' + amount_of_displayed_phone_numbers: 'Amount of displayed phone numbers' actions: confirm_destroy: 'Are you sure you want to delete this Switchboard?' destroy: 'Delete' @@ -25,7 +26,8 @@ en: user_id: 'User' reload_interval:: 'Reload Interval' show_avatars: 'Show avatars' - entry_width: 'Entry width' + entry_width: 'Entry width' + amount_of_displayed_phone_numbers: 'Amount of displayed phone numbers' actions: confirm_destroy: 'Are you sure you want to delete this element?' destroy: 'Delete' @@ -57,4 +59,7 @@ en: entry_width: label: 'Entry width' hint: '' + amount_of_displayed_phone_numbers: + label: 'Amount of phone numbers' + hint: 'How many phone numbers should be displayed for a single entry.' submit: 'Submit'
\ No newline at end of file diff --git a/db/migrate/20130404094648_add_amount_of_displayed_phone_numbers_to_switchboard.rb b/db/migrate/20130404094648_add_amount_of_displayed_phone_numbers_to_switchboard.rb new file mode 100644 index 0000000..2f88ad4 --- /dev/null +++ b/db/migrate/20130404094648_add_amount_of_displayed_phone_numbers_to_switchboard.rb @@ -0,0 +1,17 @@ +class AddAmountOfDisplayedPhoneNumbersToSwitchboard < ActiveRecord::Migration + def up + add_column :switchboards, :amount_of_displayed_phone_numbers, :integer + + # Set a default for existing entries of + # 1 for amount_of_displayed_phone_numbers + # + Switchboard.all.each do |switchboard| + switchboard.amount_of_displayed_phone_numbers = 1 + switchboard.save + end + end + + def down + remove_column :switchboards, :amount_of_displayed_phone_numbers, :integer + end +end diff --git a/public/js/app.js b/public/js/app.js index 4bc8cc1..3124f41 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -71,7 +71,13 @@ App.SipAccount = DS.Model.extend({ switchboardEntrys: DS.hasMany('App.SwitchboardEntry'), phoneNumbers: DS.hasMany('App.PhoneNumber'), callerName: DS.attr('string'), - authName: DS.attr('string') + authName: DS.attr('string'), + + phoneNumberShortList: Ember.computed(function() { + var phoneNumbers = this.get('phoneNumbers'); + return phoneNumbers.slice(0,amount_of_displayed_phone_numbers); + }).property('phoneNumbers.@each.number') + }); App.PhoneNumber = DS.Model.extend({ |