Display nickname before changing texture owner

This commit is contained in:
gplane 2017-04-26 15:28:53 +08:00
parent 4b8a40ce59
commit 44999af7d8
5 changed files with 44 additions and 3 deletions

View File

@ -343,4 +343,22 @@ class AdminController extends Controller
}
}
/**
* Get one user information
*
* @param string $uid
* @return JsonResponse
*/
public function getOneUser($uid, UserRepository $users)
{
$user = $users->get(intval($uid));
if ($user) {
return json('success', 0, ['user' => $user->makeHidden([
'password', 'ip', 'last_sign_at', 'register_at'
])->toArray()]);
} else {
return json('No such user.', 1);
}
}
}

View File

@ -108,6 +108,7 @@ Route::group(['middleware' => 'admin', 'prefix' => 'admin'], function ()
Route::get('/players', 'AdminController@players');
Route::get('/player-data', 'AdminController@getPlayerData');
Route::get('/user/{uid}', 'AdminController@getOneUser');
// ajax handlers
Route::post('/users', 'AdminController@userAjaxHandler');

View File

@ -2,7 +2,7 @@
* @Author: printempw
* @Date: 2016-07-22 14:02:44
* @Last Modified by: g-plane
* @Last Modified time: 2017-04-25 23:21:54
* @Last Modified time: 2017-04-26 15:12:19
*/
'use strict';
@ -299,7 +299,7 @@ function ajaxChangeTexture(pid) {
function changeOwner(pid) {
let dom = $(`#${pid} > td:nth-child(2)`);
swal({
text: trans('admin.changePlayerOwner'),
html: `${trans('admin.changePlayerOwner')}<br><small>&nbsp;</small>`,
input: 'number',
inputValue: dom.text(),
showCancelButton: true
@ -311,7 +311,7 @@ function changeOwner(pid) {
data: { 'pid': pid, 'uid': uid },
success: function (json) {
if (json.errno == 0) {
$($('#' + pid).children()[1]).text(uid);
dom.text(uid);
toastr.success(json.msg);
} else {
toastr.warning(json.msg);
@ -320,6 +320,24 @@ function changeOwner(pid) {
error: showAjaxError
});
});
$('.swal2-input').on('input', _.debounce(() => {
const uid = $('.swal2-input').val();
if (uid > 0) {
Promise.resolve($.ajax({
type: 'GET',
url: `./user/${uid}`,
dataType: 'json'
})).then(result => {
$('#swal2-content').html(
`${trans('admin.changePlayerOwner')}<br>
<small>${trans('admin.targetUser', { nickname: result.user.nickname })}</small>`
);
}).catch(() => {
$('#swal2-content').html(`${trans('admin.changePlayerOwner')}<br><small>${trans('admin.noSuchUser')}</small>`);
});
}
}, 350));
}
function deletePlayer(pid) {

View File

@ -137,6 +137,8 @@
deletePlayer: 'Delete',
changePlayerOwner: 'Please enter the id of user which this player should be transferred to:',
deletePlayerNotice: 'Are you sure to delete this player? It\' permanent.',
targetUser: 'Target user is :nickname',
noSuchUser: 'No such user',
// Index
textureUploads: 'Texture Uploads',

View File

@ -137,6 +137,8 @@
deletePlayer: '删除角色',
changePlayerOwner: '请输入此角色要让渡至的用户 UID',
deletePlayerNotice: '真的要删除此角色吗?此操作不可恢复',
targetUser: '目标用户::nickname',
noSuchUser: '没有这个用户哦~',
// Index
textureUploads: '材质上传',