mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-29 11:45:18 +08:00
follow suggestions of @Ducz0r
This commit is contained in:
parent
754627efe7
commit
a020e23286
8 changed files with 43 additions and 37 deletions
|
@ -67,9 +67,10 @@ module ClientApi
|
|||
params.require(:user)
|
||||
.permit(:password, :initials, :email, :full_name,
|
||||
:password_confirmation, :current_password, :avatar,
|
||||
:assignments, :time_zone, :assignmentsNotification,
|
||||
:assignmentsEmailNotification, :recentNotification,
|
||||
:recentEmailNotification, :systemMessageEmailNotification)
|
||||
:time_zone, :assignments_notification,
|
||||
:assignments_email_notification, :recent_notification,
|
||||
:recent_email_notification,
|
||||
:system_message_email_notification)
|
||||
end
|
||||
|
||||
def success_response(template = nil, locals = nil)
|
||||
|
|
|
@ -6,7 +6,11 @@ import { connect } from "react-redux";
|
|||
import axios from "../../../config/axios";
|
||||
|
||||
import { LEAVE_TEAM_PATH } from "../../../config/api_endpoints";
|
||||
import { addTeamsData, setCurrentTeam, leaveTeamModalShow } from "../../actions/TeamsActions";
|
||||
import {
|
||||
addTeamsData,
|
||||
setCurrentTeam,
|
||||
leaveTeamModalShow
|
||||
} from "../../actions/TeamsActions";
|
||||
|
||||
class LeaveTeamModal extends Component {
|
||||
constructor(props) {
|
||||
|
@ -51,7 +55,10 @@ class LeaveTeamModal extends Component {
|
|||
</Modal.Header>
|
||||
<Modal.Body>
|
||||
<p>
|
||||
<FormattedMessage id="settings_page.leave_team_modal.subtitle" />
|
||||
<FormattedMessage
|
||||
id="settings_page.leave_team_modal.subtitle"
|
||||
values={{ teamName: this.props.team.name }}
|
||||
/>
|
||||
</p>
|
||||
<Alert bsStyle="danger">
|
||||
<Glyphicon glyph="exclamation-sign" />
|
||||
|
|
|
@ -5,8 +5,7 @@ const initialState = {
|
|||
fullName: "",
|
||||
initials: "",
|
||||
email: "",
|
||||
avatarPath: "",
|
||||
avatarThumbPath: ""
|
||||
avatarThumb: ""
|
||||
};
|
||||
|
||||
export function currentUser(state = initialState, action) {
|
||||
|
|
|
@ -11,7 +11,7 @@ export default {
|
|||
text_too_short: "is too short (minimum is {min_length} characters)",
|
||||
text_too_long: "is too long (maximum is {max_length} characters)",
|
||||
cant_be_blank: "can't be blank",
|
||||
invalid_email: "Invalid email.",
|
||||
invalid_email: "invalid email",
|
||||
passwords_dont_match: "Passwords don't match"
|
||||
},
|
||||
navbar: {
|
||||
|
@ -91,7 +91,6 @@ export default {
|
|||
time_zone: "Time zone",
|
||||
time_zone_warning:
|
||||
"Time zone setting affects all time & date fields throughout application.",
|
||||
repeat_tutorial: "Repeat tutorial",
|
||||
notifications: "Notifications",
|
||||
profile: "Profile",
|
||||
preferences: "Preferences",
|
||||
|
@ -111,7 +110,7 @@ export default {
|
|||
leave_team_modal: {
|
||||
title: "Leave team {teamName}",
|
||||
subtitle:
|
||||
"Are you sure you wish to leave team My projects? This action is irreversible.",
|
||||
"Are you sure you wish to leave team {teamName}? This action is irreversible.",
|
||||
warnings: "Leaving team has following consequences:",
|
||||
warning_message_one:
|
||||
"you will lose access to all content belonging to the team (including projects, tasks, protocols and activities);",
|
||||
|
|
|
@ -73,15 +73,15 @@ class NotificationsGroup extends Component {
|
|||
let params = {};
|
||||
switch (this.props.type) {
|
||||
case ASSIGNMENT_NOTIFICATION:
|
||||
params.assignmentsNotification = value;
|
||||
params.assignments_notification = value;
|
||||
if(!value) {
|
||||
params.assignmentsEmailNotification = false;
|
||||
params.assignments_email_notification = false;
|
||||
}
|
||||
break;
|
||||
case RECENT_NOTIFICATION:
|
||||
params.recentNotification = value;
|
||||
params.recent_notification = value;
|
||||
if(!value) {
|
||||
params.recentEmailNotification = false;
|
||||
params.recent_email_notification = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -93,11 +93,11 @@ class NotificationsGroup extends Component {
|
|||
emailNotificationField() {
|
||||
switch (this.props.type) {
|
||||
case ASSIGNMENT_NOTIFICATION:
|
||||
return "assignmentsEmailNotification";
|
||||
return "assignments_email_notification";
|
||||
case RECENT_NOTIFICATION:
|
||||
return "recentEmailNotification";
|
||||
return "recent_email_notification";
|
||||
case SYSTEM_NOTIFICATION:
|
||||
return "systemMessageEmailNotification"
|
||||
return "system_message_email_notification"
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -23,11 +23,11 @@ class SettingsPreferences extends Component {
|
|||
|
||||
this.state = {
|
||||
timeZone: "",
|
||||
assignmentsNotification: false,
|
||||
assignmentsEmailNotification: false,
|
||||
recentNotification: false,
|
||||
recentEmailNotification: false,
|
||||
systemMessageEmailNotification: false
|
||||
assignments_notification: false,
|
||||
assignments_email_notification: false,
|
||||
recent_notification: false,
|
||||
recent_email_motification: false,
|
||||
system_message_email_notification: false
|
||||
};
|
||||
|
||||
this.getPreferencesInfo = this.getPreferencesInfo.bind(this);
|
||||
|
@ -59,9 +59,9 @@ class SettingsPreferences extends Component {
|
|||
title="settings_page.assignement"
|
||||
subtitle="settings_page.assignement_msg"
|
||||
iconClasses="fa fa-newspaper-o"
|
||||
inAppNotification={this.state.assignmentsNotification}
|
||||
inAppNotification={this.state.assignments_notification}
|
||||
emailNotification={
|
||||
this.state.assignmentsEmailNotification
|
||||
this.state.assignments_email_notification
|
||||
}
|
||||
iconBackground={MAIN_COLOR_BLUE}
|
||||
reloadInfo={this.getPreferencesInfo}
|
||||
|
@ -70,8 +70,8 @@ class SettingsPreferences extends Component {
|
|||
type={RECENT_NOTIFICATION}
|
||||
title="settings_page.recent_changes"
|
||||
subtitle="settings_page.recent_changes_msg"
|
||||
inAppNotification={this.state.recentNotification}
|
||||
emailNotification={this.state.recentEmailNotification}
|
||||
inAppNotification={this.state.recent_notification}
|
||||
emailNotification={this.state.recent_email_notification}
|
||||
reloadInfo={this.getPreferencesInfo}
|
||||
/>
|
||||
<NotificationsGroup
|
||||
|
@ -79,7 +79,7 @@ class SettingsPreferences extends Component {
|
|||
title="settings_page.system_message"
|
||||
subtitle="settings_page.system_message_msg"
|
||||
emailNotification={
|
||||
this.state.systemMessageEmailNotification
|
||||
this.state.system_message_email_notification
|
||||
}
|
||||
iconClasses="glyphicon glyphicon-tower"
|
||||
iconBackground={ICON_GREEN_COLOR}
|
||||
|
|
|
@ -414,13 +414,13 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
# json friendly attributes
|
||||
NOTIFICATIONS_TYPES = %w(assignmentsNotification assignmentsEmailNotification
|
||||
recentNotification recentEmailNotification
|
||||
systemMessageEmailNotification)
|
||||
NOTIFICATIONS_TYPES = %w(assignments_notification assignments_email_notification
|
||||
recent_notification recent_email_notification
|
||||
system_message_email_notification)
|
||||
# declare notifications getters
|
||||
NOTIFICATIONS_TYPES.each do |name|
|
||||
define_method(name) do
|
||||
attr_name = name.gsub('Notification', '').underscore
|
||||
attr_name = name.gsub('_notification', '')
|
||||
self.notifications.fetch(attr_name.to_sym)
|
||||
end
|
||||
end
|
||||
|
@ -428,7 +428,7 @@ class User < ApplicationRecord
|
|||
# declare notifications setters
|
||||
NOTIFICATIONS_TYPES.each do |name|
|
||||
define_method("#{name}=") do |value|
|
||||
attr_name = name.gsub('Notification', '').underscore.to_sym
|
||||
attr_name = name.gsub('_notification', '').to_sym
|
||||
self.notifications[attr_name] = value
|
||||
save
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
json.timeZone timeZone
|
||||
json.assignmentsNotification notifications['assignments']
|
||||
json.assignmentsEmailNotification notifications['assignments_email']
|
||||
json.recentNotification notifications['recent']
|
||||
json.recentEmailNotification notifications['recent_email']
|
||||
json.systemMessageEmailNotification notifications['system_message_email']
|
||||
json.assignments_notification notifications['assignments']
|
||||
json.assignments_email_notification notifications['assignments_email']
|
||||
json.recent_notification notifications['recent']
|
||||
json.recent_email_notification notifications['recent_email']
|
||||
json.system_message_email_notification notifications['system_message_email']
|
||||
|
|
Loading…
Reference in a new issue