mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 09:23:58 +08:00
Merge pull request #216 from mlorb/ml_sci_555
Adding update notifications in settings [SCI-555]
This commit is contained in:
commit
78f7879c04
9 changed files with 86 additions and 25 deletions
|
@ -143,6 +143,26 @@
|
|||
function enableDependant(dependant) {
|
||||
dependant.checkboxpicker().prop('disabled', false);
|
||||
}
|
||||
|
||||
// Initialize system messages
|
||||
var system_message_notification = $('[name="system_message_notification"]');
|
||||
system_message_notification
|
||||
.checkboxpicker({
|
||||
onActiveCls: 'btn-primary'
|
||||
});
|
||||
system_message_notification.prop('checked', true);
|
||||
system_message_notification.prop('disabled', true);
|
||||
|
||||
// Initialize system messages email
|
||||
var system_message_notification_mail = $('[name="system_message_notification_email"]');
|
||||
system_message_notification_mail
|
||||
.checkboxpicker({
|
||||
onActiveCls: 'btn-primary'
|
||||
});
|
||||
system_message_notification_mail.prop(
|
||||
'checked',
|
||||
system_message_notification_mail.attr('value') === 'true'
|
||||
);
|
||||
}
|
||||
|
||||
// triggers submit action when the user clicks
|
||||
|
|
|
@ -149,7 +149,7 @@ table {
|
|||
width: 45px;
|
||||
}
|
||||
|
||||
.system_message {
|
||||
.system-message {
|
||||
background-color: $color-theme-secondary;
|
||||
border-radius: 50%;
|
||||
color: $color-wild-sand;
|
||||
|
@ -587,8 +587,8 @@ a[data-toggle="tooltip"] {
|
|||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.btn-group:last-child {
|
||||
margin-top: 15px;
|
||||
.btn-group {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.assignment {
|
||||
|
@ -599,6 +599,20 @@ a[data-toggle="tooltip"] {
|
|||
margin-left: 20px;
|
||||
margin-right: 15px;
|
||||
padding: 7px;
|
||||
padding-bottom: 5px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.system-message {
|
||||
background-color: $color-theme-secondary;
|
||||
border-radius: 50%;
|
||||
color: $color-wild-sand;
|
||||
font-size: 15px;
|
||||
margin-left: 20px;
|
||||
margin-right: 15px;
|
||||
padding: 8px;
|
||||
padding-bottom: 5px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.img-circle {
|
||||
|
|
|
@ -462,6 +462,8 @@ class Users::SettingsController < ApplicationController
|
|||
params[:recent_notification_email] ? true : false
|
||||
@user.assignments_notification_email =
|
||||
params[:assignments_notification_email] ? true : false
|
||||
@user.system_message_notification_email =
|
||||
params[:system_message_notification_email] ? true : false
|
||||
|
||||
if @user.save
|
||||
respond_to do |format|
|
||||
|
|
|
@ -33,7 +33,10 @@ class UserNotification < ActiveRecord::Base
|
|||
def send_email
|
||||
case notification.type_of
|
||||
when 'system_message'
|
||||
send_email_notification(user, notification)
|
||||
send_email_notification(
|
||||
user,
|
||||
notification
|
||||
) if user.system_message_notification_email
|
||||
when 'assignment'
|
||||
send_email_notification(
|
||||
user,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<% end %>
|
||||
<% if notification.type_of == 'system_message' %>
|
||||
<div class="text-center">
|
||||
<span class="system_message"><i class="glyphicon glyphicon-tower" aria-hidden="true"></i></span>
|
||||
<span class="system-message"><i class="glyphicon glyphicon-tower" aria-hidden="true"></i></span>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -49,7 +49,9 @@
|
|||
<%= image_tag 'icon_small/missing.png', class: 'img-circle ' %>
|
||||
<%= f.label t('notifications.form.recent_notification') %> <br>
|
||||
<span class="assignment hidden-sm"><%= fa_icon 'newspaper-o' %></span>
|
||||
<%= f.label t('notifications.form.assignments') %>
|
||||
<%= f.label t('notifications.form.assignments') %> <br>
|
||||
<span class="system-message hidden-sm"><i class="glyphicon glyphicon-tower" aria-hidden="true"></i></span>
|
||||
<%= f.label t('notifications.form.system_message') %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 col-sm-3 col-text-center">
|
||||
|
@ -57,14 +59,18 @@
|
|||
<h5 class="hidden-sm hidden-xs"><%= t('notifications.title') %></h5><br>
|
||||
<%= check_box_tag :recent_notification, @user.recent_notification %> <br>
|
||||
<%= f.label t('notifications.form.assignments'), class: 'visible-sm visible-xs' %>
|
||||
<%= check_box_tag :assignments_notification, @user.assignments_notification %>
|
||||
<%= check_box_tag :assignments_notification, @user.assignments_notification %> <br>
|
||||
<%= f.label t('notifications.form.system_message'), class: 'visible-sm visible-xs' %>
|
||||
<%= check_box_tag :system_message_notification %>
|
||||
</div>
|
||||
<div class="col-md-3 col-sm-3 col-text-center">
|
||||
<h5 class="hidden-sm hidden-xs"><%= t('notifications.form.email_settings') %></h5>
|
||||
<h5 class="hidden-sm hidden-xs"><%= t('notifications.email_settings') %></h5>
|
||||
<%= f.label t('notifications.form.recent_notification'), class: 'visible-sm visible-xs'%> <br>
|
||||
<%= check_box_tag :recent_notification_email, @user.recent_notification_email %> <br>
|
||||
<%= f.label t('notifications.form.assignments'), class: 'visible-sm visible-xs' %>
|
||||
<%= check_box_tag :assignments_notification_email, @user.assignments_notification_email %>
|
||||
<%= check_box_tag :assignments_notification_email, @user.assignments_notification_email %> <br>
|
||||
<%= f.label t('notifications.form.system_message'), class: 'visible-sm visible-xs' %>
|
||||
<%= check_box_tag :system_message_notification_email, @user.system_message_notification_email %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -1495,10 +1495,11 @@ en:
|
|||
|
||||
notifications:
|
||||
title: "Notifications"
|
||||
email_settings: "E-mail notifications"
|
||||
form:
|
||||
assignments: "Assignments notifications"
|
||||
recent_notification: "Change notifications"
|
||||
email_settings: "E-mail notifications"
|
||||
system_message: "Update notifications"
|
||||
show_all: "Show all notifications"
|
||||
show_more: "Show more notifications"
|
||||
no_notifications: "No notifications."
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
class AddEmailSystemNotificationSettingToUser < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :users,
|
||||
:system_message_notification_email,
|
||||
:boolean,
|
||||
default: false
|
||||
|
||||
User.update_all(system_message_notification_email: false)
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :users, :system_message_notification_email
|
||||
end
|
||||
end
|
31
db/schema.rb
31
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20161006065203) do
|
||||
ActiveRecord::Schema.define(version: 20161012112900) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -628,20 +628,20 @@ ActiveRecord::Schema.define(version: 20161006065203) do
|
|||
add_index "user_projects", ["user_id"], name: "index_user_projects_on_user_id", using: :btree
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "full_name", null: false
|
||||
t.string "initials", null: false
|
||||
t.string "email", default: "", null: false
|
||||
t.string "encrypted_password", default: "", null: false
|
||||
t.string "full_name", null: false
|
||||
t.string "initials", null: false
|
||||
t.string "email", default: "", null: false
|
||||
t.string "encrypted_password", default: "", null: false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.datetime "remember_created_at"
|
||||
t.integer "sign_in_count", default: 0, null: false
|
||||
t.integer "sign_in_count", default: 0, null: false
|
||||
t.datetime "current_sign_in_at"
|
||||
t.datetime "last_sign_in_at"
|
||||
t.string "current_sign_in_ip"
|
||||
t.string "last_sign_in_ip"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "avatar_file_name"
|
||||
t.string "avatar_content_type"
|
||||
t.integer "avatar_file_size"
|
||||
|
@ -650,7 +650,7 @@ ActiveRecord::Schema.define(version: 20161006065203) do
|
|||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
t.string "unconfirmed_email"
|
||||
t.string "time_zone", default: "UTC"
|
||||
t.string "time_zone", default: "UTC"
|
||||
t.string "invitation_token"
|
||||
t.datetime "invitation_created_at"
|
||||
t.datetime "invitation_sent_at"
|
||||
|
@ -658,12 +658,13 @@ ActiveRecord::Schema.define(version: 20161006065203) do
|
|||
t.integer "invitation_limit"
|
||||
t.integer "invited_by_id"
|
||||
t.string "invited_by_type"
|
||||
t.integer "invitations_count", default: 0
|
||||
t.integer "tutorial_status", default: 0, null: false
|
||||
t.boolean "assignments_notification", default: true
|
||||
t.boolean "recent_notification", default: true
|
||||
t.boolean "assignments_notification_email", default: false
|
||||
t.boolean "recent_notification_email", default: false
|
||||
t.integer "invitations_count", default: 0
|
||||
t.integer "tutorial_status", default: 0, null: false
|
||||
t.boolean "assignments_notification", default: true
|
||||
t.boolean "recent_notification", default: true
|
||||
t.boolean "assignments_notification_email", default: false
|
||||
t.boolean "recent_notification_email", default: false
|
||||
t.boolean "system_message_notification_email", default: false
|
||||
end
|
||||
|
||||
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
|
||||
|
|
Loading…
Reference in a new issue