From 9c7a690944cbc3cc78c810da2db8381d2a9be37c Mon Sep 17 00:00:00 2001 From: zmagod Date: Wed, 5 Oct 2016 14:33:22 +0200 Subject: [PATCH] fixed type, fixed settings controller, fixes setting view on mobile devices --- app/assets/stylesheets/themes/scinote.scss | 10 +++------- app/controllers/users/settings_controller.rb | 14 +++----------- app/views/users/settings/preferences.html.erb | 12 +++++++----- ...04074754_add_notifications_settings_to_user.rb} | 2 +- 4 files changed, 14 insertions(+), 24 deletions(-) rename db/migrate/{20161004074754_add_notifivations_settings_to_user.rb => 20161004074754_add_notifications_settings_to_user.rb} (85%) diff --git a/app/assets/stylesheets/themes/scinote.scss b/app/assets/stylesheets/themes/scinote.scss index 72c881acf..5045ac035 100644 --- a/app/assets/stylesheets/themes/scinote.scss +++ b/app/assets/stylesheets/themes/scinote.scss @@ -555,15 +555,11 @@ a[data-toggle="tooltip"] { } .notification-settings-container { - margin-top: 50px; margin-bottom: 50px; + margin-top: 50px; - .col-xs-2 { - padding-top: 20px; - } - - .col-xs-3 { - padding-top: 30px; + .col-md-4 { + margin-top: 25px; } .btn-group { diff --git a/app/controllers/users/settings_controller.rb b/app/controllers/users/settings_controller.rb index c0ab920d2..bd89daef8 100644 --- a/app/controllers/users/settings_controller.rb +++ b/app/controllers/users/settings_controller.rb @@ -458,16 +458,8 @@ class Users::SettingsController < ApplicationController end def notifications_settings - if params[:assignments_notification] - @user.assignments_notification = true - else - @user.assignments_notification = false - end - if params[:recent_notification] - @user.recent_notification = true - else - @user.recent_notification = false - end + @user.assignments_notification = params[:assignments_notification] + @user.recent_notification = params[:recent_notification] if @user.save respond_to do |format| @@ -575,7 +567,7 @@ class Users::SettingsController < ApplicationController message: ActionController::Base.helpers.sanitize(message), ) - + if target_user.assignments_notification UserNotification.create(notification: notification, user: target_user) end diff --git a/app/views/users/settings/preferences.html.erb b/app/views/users/settings/preferences.html.erb index 62b61e9e0..2a02808b8 100644 --- a/app/views/users/settings/preferences.html.erb +++ b/app/views/users/settings/preferences.html.erb @@ -42,17 +42,19 @@ html: { method: :post, id: 'notifications-settings-panel' }, remote: true) do |f| %>
-
+ -
-
<%= t('notifications.title') %>
+
+ + <%= f.label t('notifications.form.recent_notification'), class: 'visible-sm visible-xs'%>
<%= check_box_tag :recent_notification, @user.recent_notification %>
+ <%= f.label t('notifications.form.assignments'), class: 'visible-sm visible-xs' %> <%= check_box_tag :assignments_notification, @user.assignments_notification %>
diff --git a/db/migrate/20161004074754_add_notifivations_settings_to_user.rb b/db/migrate/20161004074754_add_notifications_settings_to_user.rb similarity index 85% rename from db/migrate/20161004074754_add_notifivations_settings_to_user.rb rename to db/migrate/20161004074754_add_notifications_settings_to_user.rb index 1217c8e07..d9599c118 100644 --- a/db/migrate/20161004074754_add_notifivations_settings_to_user.rb +++ b/db/migrate/20161004074754_add_notifications_settings_to_user.rb @@ -1,4 +1,4 @@ -class AddNotifivationsSettingsToUser < ActiveRecord::Migration +class AddNotificationsSettingsToUser < ActiveRecord::Migration def up add_column :users, :assignments_notification, :boolean, default: true add_column :users, :recent_notification, :boolean, default: true