mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 23:16:15 +08:00
adds apis for full_name and initials input fields
This commit is contained in:
parent
989be6563f
commit
ccd14f6b50
|
@ -11,6 +11,34 @@ module ClientApi
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def change_full_name
|
||||
user = current_user
|
||||
user.name = params['fullName']
|
||||
saved_name = if user.save
|
||||
user.name
|
||||
else
|
||||
user.reload.name
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: { fullName: saved_name } }
|
||||
end
|
||||
end
|
||||
|
||||
def change_initials
|
||||
user = current_user
|
||||
user.initials = params['initials']
|
||||
saved_initials = if user.save
|
||||
user.initials
|
||||
else
|
||||
user.reload.initials
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: { initials: saved_initials } }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,6 +23,8 @@ export const RECENT_NOTIFICATIONS_PATH = "/client_api/recent_notifications";
|
|||
|
||||
// users
|
||||
export const CURRENT_USER_PATH = "/client_api/current_user_info";
|
||||
export const CHANGE_USER_FULL_NAME_PATH = "/client_api/user/change_full_name";
|
||||
export const CHANGE_USER_INITIALS_PATH = "/client_api/user/change_initials";
|
||||
|
||||
// info dropdown_title
|
||||
export const CUSTOMER_SUPPORT_LINK = "http://scinote.net/support";
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
import axios from "../../app/axios";
|
||||
import { CURRENT_USER_PATH } from "../../app/routes";
|
||||
|
||||
import {
|
||||
CHANGE_USER_FULL_NAME_PATH,
|
||||
CURRENT_USER_PATH,
|
||||
CHANGE_USER_INITIALS_PATH
|
||||
} from "../../app/routes";
|
||||
|
||||
import {
|
||||
SET_CURRENT_USER,
|
||||
CHANGE_CURRENT_USER_FULL_NAME,
|
||||
|
@ -35,17 +41,45 @@ export function getCurrentUser() {
|
|||
};
|
||||
}
|
||||
|
||||
export function changeFullName(name) {
|
||||
export function savedChangedFullName({ fullName }) {
|
||||
return {
|
||||
type: CHANGE_CURRENT_USER_FULL_NAME,
|
||||
payload: name
|
||||
payload: fullName
|
||||
};
|
||||
}
|
||||
|
||||
export function changeFullName(name) {
|
||||
return dispatch => {
|
||||
axios
|
||||
.post(CHANGE_USER_FULL_NAME_PATH, {
|
||||
withCredentials: true,
|
||||
fullName: name
|
||||
})
|
||||
.then(({ data }) => {
|
||||
dispatch(savedChangedFullName(data));
|
||||
})
|
||||
.catch(err => console.log(err));
|
||||
};
|
||||
}
|
||||
|
||||
export function savedChangeInitials({ initials }) {
|
||||
return {
|
||||
type: CHANGE_CURRENT_USER_INITIALS,
|
||||
payload: initials
|
||||
};
|
||||
}
|
||||
|
||||
export function changeInitials(initials) {
|
||||
return {
|
||||
type: CHANGE_CURRENT_USER_INITIALS,
|
||||
payload: initials
|
||||
return dispatch => {
|
||||
axios
|
||||
.post(CHANGE_USER_INITIALS_PATH, {
|
||||
withCredentials: true,
|
||||
initials
|
||||
})
|
||||
.then(({ data }) => {
|
||||
dispatch(savedChangeInitials(data));
|
||||
})
|
||||
.catch(err => console.log(err));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -15,13 +15,18 @@ Rails.application.routes.draw do
|
|||
namespace :client_api, defaults: { format: 'json' } do
|
||||
# activities
|
||||
get '/activities', to: 'activities#index'
|
||||
|
||||
# teams
|
||||
get '/teams', to: 'teams#index'
|
||||
post '/change_team', to: 'teams#change_team'
|
||||
|
||||
# notifications
|
||||
get '/recent_notifications', to: 'notifications#recent_notifications'
|
||||
|
||||
# users
|
||||
get '/current_user_info', to: 'users/users#current_user_info'
|
||||
post '/user/change_full_name', to: 'users/users#change_full_name'
|
||||
post '/user/change_initials', to: 'users/users#change_initials'
|
||||
end
|
||||
|
||||
# Save sample table state
|
||||
|
|
Loading…
Reference in a new issue