follow suggestions of @Ducz0r

This commit is contained in:
zmagod 2017-10-05 13:56:56 +02:00
parent 754627efe7
commit a020e23286
8 changed files with 43 additions and 37 deletions

View file

@ -67,9 +67,10 @@ module ClientApi
params.require(:user) params.require(:user)
.permit(:password, :initials, :email, :full_name, .permit(:password, :initials, :email, :full_name,
:password_confirmation, :current_password, :avatar, :password_confirmation, :current_password, :avatar,
:assignments, :time_zone, :assignmentsNotification, :time_zone, :assignments_notification,
:assignmentsEmailNotification, :recentNotification, :assignments_email_notification, :recent_notification,
:recentEmailNotification, :systemMessageEmailNotification) :recent_email_notification,
:system_message_email_notification)
end end
def success_response(template = nil, locals = nil) def success_response(template = nil, locals = nil)

View file

@ -6,7 +6,11 @@ import { connect } from "react-redux";
import axios from "../../../config/axios"; import axios from "../../../config/axios";
import { LEAVE_TEAM_PATH } from "../../../config/api_endpoints"; 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 { class LeaveTeamModal extends Component {
constructor(props) { constructor(props) {
@ -51,7 +55,10 @@ class LeaveTeamModal extends Component {
</Modal.Header> </Modal.Header>
<Modal.Body> <Modal.Body>
<p> <p>
<FormattedMessage id="settings_page.leave_team_modal.subtitle" /> <FormattedMessage
id="settings_page.leave_team_modal.subtitle"
values={{ teamName: this.props.team.name }}
/>
</p> </p>
<Alert bsStyle="danger"> <Alert bsStyle="danger">
<Glyphicon glyph="exclamation-sign" />&nbsp; <Glyphicon glyph="exclamation-sign" />&nbsp;

View file

@ -5,8 +5,7 @@ const initialState = {
fullName: "", fullName: "",
initials: "", initials: "",
email: "", email: "",
avatarPath: "", avatarThumb: ""
avatarThumbPath: ""
}; };
export function currentUser(state = initialState, action) { export function currentUser(state = initialState, action) {

View file

@ -11,7 +11,7 @@ export default {
text_too_short: "is too short (minimum is {min_length} characters)", text_too_short: "is too short (minimum is {min_length} characters)",
text_too_long: "is too long (maximum is {max_length} characters)", text_too_long: "is too long (maximum is {max_length} characters)",
cant_be_blank: "can't be blank", cant_be_blank: "can't be blank",
invalid_email: "Invalid email.", invalid_email: "invalid email",
passwords_dont_match: "Passwords don't match" passwords_dont_match: "Passwords don't match"
}, },
navbar: { navbar: {
@ -91,7 +91,6 @@ export default {
time_zone: "Time zone", time_zone: "Time zone",
time_zone_warning: time_zone_warning:
"Time zone setting affects all time & date fields throughout application.", "Time zone setting affects all time & date fields throughout application.",
repeat_tutorial: "Repeat tutorial",
notifications: "Notifications", notifications: "Notifications",
profile: "Profile", profile: "Profile",
preferences: "Preferences", preferences: "Preferences",
@ -111,7 +110,7 @@ export default {
leave_team_modal: { leave_team_modal: {
title: "Leave team {teamName}", title: "Leave team {teamName}",
subtitle: 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:", warnings: "Leaving team has following consequences:",
warning_message_one: warning_message_one:
"you will lose access to all content belonging to the team (including projects, tasks, protocols and activities);", "you will lose access to all content belonging to the team (including projects, tasks, protocols and activities);",

View file

@ -73,15 +73,15 @@ class NotificationsGroup extends Component {
let params = {}; let params = {};
switch (this.props.type) { switch (this.props.type) {
case ASSIGNMENT_NOTIFICATION: case ASSIGNMENT_NOTIFICATION:
params.assignmentsNotification = value; params.assignments_notification = value;
if(!value) { if(!value) {
params.assignmentsEmailNotification = false; params.assignments_email_notification = false;
} }
break; break;
case RECENT_NOTIFICATION: case RECENT_NOTIFICATION:
params.recentNotification = value; params.recent_notification = value;
if(!value) { if(!value) {
params.recentEmailNotification = false; params.recent_email_notification = false;
} }
break; break;
default: default:
@ -93,11 +93,11 @@ class NotificationsGroup extends Component {
emailNotificationField() { emailNotificationField() {
switch (this.props.type) { switch (this.props.type) {
case ASSIGNMENT_NOTIFICATION: case ASSIGNMENT_NOTIFICATION:
return "assignmentsEmailNotification"; return "assignments_email_notification";
case RECENT_NOTIFICATION: case RECENT_NOTIFICATION:
return "recentEmailNotification"; return "recent_email_notification";
case SYSTEM_NOTIFICATION: case SYSTEM_NOTIFICATION:
return "systemMessageEmailNotification" return "system_message_email_notification"
default: default:
return ""; return "";
} }

View file

@ -23,11 +23,11 @@ class SettingsPreferences extends Component {
this.state = { this.state = {
timeZone: "", timeZone: "",
assignmentsNotification: false, assignments_notification: false,
assignmentsEmailNotification: false, assignments_email_notification: false,
recentNotification: false, recent_notification: false,
recentEmailNotification: false, recent_email_motification: false,
systemMessageEmailNotification: false system_message_email_notification: false
}; };
this.getPreferencesInfo = this.getPreferencesInfo.bind(this); this.getPreferencesInfo = this.getPreferencesInfo.bind(this);
@ -59,9 +59,9 @@ class SettingsPreferences extends Component {
title="settings_page.assignement" title="settings_page.assignement"
subtitle="settings_page.assignement_msg" subtitle="settings_page.assignement_msg"
iconClasses="fa fa-newspaper-o" iconClasses="fa fa-newspaper-o"
inAppNotification={this.state.assignmentsNotification} inAppNotification={this.state.assignments_notification}
emailNotification={ emailNotification={
this.state.assignmentsEmailNotification this.state.assignments_email_notification
} }
iconBackground={MAIN_COLOR_BLUE} iconBackground={MAIN_COLOR_BLUE}
reloadInfo={this.getPreferencesInfo} reloadInfo={this.getPreferencesInfo}
@ -70,8 +70,8 @@ class SettingsPreferences extends Component {
type={RECENT_NOTIFICATION} type={RECENT_NOTIFICATION}
title="settings_page.recent_changes" title="settings_page.recent_changes"
subtitle="settings_page.recent_changes_msg" subtitle="settings_page.recent_changes_msg"
inAppNotification={this.state.recentNotification} inAppNotification={this.state.recent_notification}
emailNotification={this.state.recentEmailNotification} emailNotification={this.state.recent_email_notification}
reloadInfo={this.getPreferencesInfo} reloadInfo={this.getPreferencesInfo}
/> />
<NotificationsGroup <NotificationsGroup
@ -79,7 +79,7 @@ class SettingsPreferences extends Component {
title="settings_page.system_message" title="settings_page.system_message"
subtitle="settings_page.system_message_msg" subtitle="settings_page.system_message_msg"
emailNotification={ emailNotification={
this.state.systemMessageEmailNotification this.state.system_message_email_notification
} }
iconClasses="glyphicon glyphicon-tower" iconClasses="glyphicon glyphicon-tower"
iconBackground={ICON_GREEN_COLOR} iconBackground={ICON_GREEN_COLOR}

View file

@ -414,13 +414,13 @@ class User < ApplicationRecord
end end
# json friendly attributes # json friendly attributes
NOTIFICATIONS_TYPES = %w(assignmentsNotification assignmentsEmailNotification NOTIFICATIONS_TYPES = %w(assignments_notification assignments_email_notification
recentNotification recentEmailNotification recent_notification recent_email_notification
systemMessageEmailNotification) system_message_email_notification)
# declare notifications getters # declare notifications getters
NOTIFICATIONS_TYPES.each do |name| NOTIFICATIONS_TYPES.each do |name|
define_method(name) do define_method(name) do
attr_name = name.gsub('Notification', '').underscore attr_name = name.gsub('_notification', '')
self.notifications.fetch(attr_name.to_sym) self.notifications.fetch(attr_name.to_sym)
end end
end end
@ -428,7 +428,7 @@ class User < ApplicationRecord
# declare notifications setters # declare notifications setters
NOTIFICATIONS_TYPES.each do |name| NOTIFICATIONS_TYPES.each do |name|
define_method("#{name}=") do |value| 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 self.notifications[attr_name] = value
save save
end end

View file

@ -1,6 +1,6 @@
json.timeZone timeZone json.timeZone timeZone
json.assignmentsNotification notifications['assignments'] json.assignments_notification notifications['assignments']
json.assignmentsEmailNotification notifications['assignments_email'] json.assignments_email_notification notifications['assignments_email']
json.recentNotification notifications['recent'] json.recent_notification notifications['recent']
json.recentEmailNotification notifications['recent_email'] json.recent_email_notification notifications['recent_email']
json.systemMessageEmailNotification notifications['system_message_email'] json.system_message_email_notification notifications['system_message_email']