#267: added sound_notifications to User

This commit is contained in:
Vokhmin Alexey V 2013-08-21 00:10:25 +04:00
parent 6050727984
commit 75d98a75bc
9 changed files with 22 additions and 6 deletions

View File

@ -26,6 +26,7 @@ var LocalesHelper = function($locale) {
RosaABF.factory("LocalesHelper", ['$locale', LocalesHelper]); RosaABF.factory("LocalesHelper", ['$locale', LocalesHelper]);
var SoundNotificationsHelper = function() { var SoundNotificationsHelper = function() {
var isOn = true;
var statusChangedSound = null; var statusChangedSound = null;
soundManager.setup({ soundManager.setup({
url: '/assets/swf/', url: '/assets/swf/',
@ -35,8 +36,11 @@ var SoundNotificationsHelper = function() {
}); });
return { return {
buildStatusChanged: function() { buildStatusChanged: function() {
if (statusChangedSound) if (isOn && statusChangedSound)
statusChangedSound.play(); statusChangedSound.play();
},
enabled: function(status) {
isOn = status;
} }
} }
} }

View File

@ -1,7 +1,8 @@
RosaABF.controller('RosaABFController', ['$scope', 'LocalesHelper', function($scope, LocalesHelper) { RosaABF.controller('RosaABFController', ['$scope', 'LocalesHelper', 'SoundNotificationsHelper', function($scope, LocalesHelper, SoundNotificationsHelper) {
$scope.init = function(locale) { $scope.init = function(locale, sound_notifications) {
LocalesHelper.setLocale(locale); LocalesHelper.setLocale(locale);
SoundNotificationsHelper.enabled(sound_notifications);
} }
}]); }]);

View File

@ -41,7 +41,7 @@ class User < Avatar
validates :language, :inclusion => {:in => LANGUAGES}, :allow_blank => true validates :language, :inclusion => {:in => LANGUAGES}, :allow_blank => true
attr_accessible :email, :password, :password_confirmation, :current_password, :remember_me, :login, :name, :uname, :language, attr_accessible :email, :password, :password_confirmation, :current_password, :remember_me, :login, :name, :uname, :language,
:site, :company, :professional_experience, :location :site, :company, :professional_experience, :location, :sound_notifications
attr_readonly :uname attr_readonly :uname
attr_accessor :login attr_accessor :login

View File

@ -12,7 +12,7 @@
- if user_signed_in? - if user_signed_in?
= auto_discovery_link_tag :atom, atom_activity_feeds_path(:format => 'atom', :token => current_user.authentication_token), :title => t("layout.atom_link_tag_title", :nickname => current_user.uname, :app_name => APP_CONFIG['project_name']) = auto_discovery_link_tag :atom, atom_activity_feeds_path(:format => 'atom', :token => current_user.authentication_token), :title => t("layout.atom_link_tag_title", :nickname => current_user.uname, :app_name => APP_CONFIG['project_name'])
%body{'ng-app' => 'RosaABF', 'ng-controller' => 'RosaABFController', 'ng-init' => "init('#{I18n.locale}')"} %body{'ng-app' => 'RosaABF', 'ng-controller' => 'RosaABFController', 'ng-init' => "init('#{I18n.locale}', #{!!current_user.try(:sound_notifications)})"}
.wrap{:class => content_for?(:sidebar) ? 'columns' : ''} .wrap{:class => content_for?(:sidebar) ? 'columns' : ''}
%header %header
.left .left

View File

@ -32,6 +32,9 @@
.leftlist= f.label :professional_experience, t("activerecord.attributes.user.professional_experience") .leftlist= f.label :professional_experience, t("activerecord.attributes.user.professional_experience")
.rightlist= f.text_area :professional_experience .rightlist= f.text_area :professional_experience
.both .both
.leftlist= f.label :sound_notifications, t("activerecord.attributes.user.sound_notifications")
.rightlist= f.check_box :sound_notifications
.both
.leftlist .leftlist
\  \ 
.rightlist= submit_tag t('layout.save'), :data => {'disable-with' => t('layout.saving')} .rightlist= submit_tag t('layout.save'), :data => {'disable-with' => t('layout.saving')}

View File

@ -42,6 +42,7 @@ en:
role: Role role: Role
created_at: Created created_at: Created
updated_at: Updated updated_at: Updated
sound_notifications: Enable sound notifications
role: System role role: System role
language: Language language: Language
password: Password password: Password

View File

@ -42,6 +42,7 @@ ru:
role: Роль role: Роль
created_at: Создан created_at: Создан
updated_at: Обновлен updated_at: Обновлен
sound_notifications: Включить звуковые оповещения
role: Роль в системе role: Роль в системе
language: Язык language: Язык
password: Пароль password: Пароль

View File

@ -0,0 +1,5 @@
class AddSoundNotificationsToUser < ActiveRecord::Migration
def change
add_column :users, :sound_notifications, :boolean, :default => true
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130731130518) do ActiveRecord::Schema.define(:version => 20130820195938) do
create_table "activity_feeds", :force => true do |t| create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false t.integer "user_id", :null => false
@ -567,6 +567,7 @@ ActiveRecord::Schema.define(:version => 20130731130518) do
t.datetime "confirmation_sent_at" t.datetime "confirmation_sent_at"
t.string "authentication_token" t.string "authentication_token"
t.integer "build_priority", :default => 50 t.integer "build_priority", :default => 50
t.boolean "sound_notifications", :default => true
end end
add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token" add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token"