Add changing player name in admin panel
This commit is contained in:
parent
e134296565
commit
b54ddb6fb2
|
|
@ -340,6 +340,10 @@ class AdminController extends Controller
|
|||
$player->delete();
|
||||
|
||||
return json(trans('admin.players.delete.success'), 0);
|
||||
} elseif ($action == "name") {
|
||||
$player->rename($request->input('name'));
|
||||
|
||||
return json(trans('admin.players.name.success', ['player' => $player->player_name]), 0, ['name' => $player->player_name]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* @Author: printempw
|
||||
* @Date: 2016-07-22 14:02:44
|
||||
* @Last Modified by: g-plane
|
||||
* @Last Modified time: 2017-04-26 17:30:40
|
||||
* @Last Modified time: 2017-04-27 08:46:33
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
|
@ -296,6 +296,38 @@ function ajaxChangeTexture(pid) {
|
|||
});
|
||||
}
|
||||
|
||||
function changePlayerName(pid, oldName) {
|
||||
let dom = $(`tr#${pid} > td:nth-child(3)`);
|
||||
swal({
|
||||
text: trans('admin.changePlayerNameNotice'),
|
||||
input: 'text',
|
||||
inputValue: oldName,
|
||||
inputValidator: name => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (name) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(trans('admin.emptyPlayerName'));
|
||||
}
|
||||
})
|
||||
}
|
||||
}).then(name => {
|
||||
return Promise.resolve($.ajax({
|
||||
type: 'POST',
|
||||
url: './players?action=name',
|
||||
dataType: 'json',
|
||||
data: { pid: pid, name: name }
|
||||
}));
|
||||
}).then(json => {
|
||||
if (json.errno == 0) {
|
||||
dom.text(json.name);
|
||||
toastr.success(json.msg);
|
||||
} else {
|
||||
toastr.warning(json.msg);
|
||||
}
|
||||
}).catch(error => showAjaxError);
|
||||
}
|
||||
|
||||
function changeOwner(pid) {
|
||||
let dom = $(`#${pid} > td:nth-child(2)`);
|
||||
swal({
|
||||
|
|
@ -692,6 +724,7 @@ function initPlayersTable() {
|
|||
${trans('admin.operationsTitle')} <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="javascript:changeTexture(${row.pid}, '${row.player_name}');">${trans('admin.changeTexture')}</a></li>
|
||||
<li><a href="javascript:changePlayerName(${row.pid}, '${row.player_name}');">${trans('admin.changePlayerName')}</a></li>
|
||||
<li><a href="javascript:changeOwner(${row.pid});">${trans('admin.changeOwner')}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ players:
|
|||
change: Change Textures
|
||||
non-existent: No such texture tid.:tid
|
||||
success: The textures of :player has been updated.
|
||||
name:
|
||||
success: Player name has been updated to :player
|
||||
owner:
|
||||
change: Change Owner
|
||||
success: The player :player was transferred to user :user.
|
||||
|
|
|
|||
|
|
@ -134,12 +134,15 @@
|
|||
pidNotice: 'Please enter the tid of texture. Inputting 0 can clear texture of this player.',
|
||||
changePlayerTexture: 'Change textures of :player',
|
||||
changeTexture: 'Change Textures',
|
||||
changePlayerName: 'Change Player Name',
|
||||
changeOwner: 'Change Owner',
|
||||
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',
|
||||
changePlayerNameNotice: 'Please input new player name:',
|
||||
emptyPlayerName: 'Player name cannot be empty.',
|
||||
|
||||
// Index
|
||||
textureUploads: 'Texture Uploads',
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ players:
|
|||
change: 更换材质
|
||||
non-existent: 材质 tid.:tid 不存在
|
||||
success: 角色 :player 的材质修改成功
|
||||
name:
|
||||
success: 角色名成功更改为 :player
|
||||
owner:
|
||||
change: 更换角色拥有者
|
||||
success: 角色 :player 已成功让渡至 :user
|
||||
|
|
|
|||
|
|
@ -134,12 +134,15 @@
|
|||
pidNotice: '输入要更换的材质的 TID,输入 0 即可清除该角色的材质',
|
||||
changePlayerTexture: '更换角色 :player 的材质',
|
||||
changeTexture: '更换材质',
|
||||
changePlayerName: '更改角色名',
|
||||
changeOwner: '更换角色拥有者',
|
||||
deletePlayer: '删除角色',
|
||||
changePlayerOwner: '请输入此角色要让渡至的用户 UID:',
|
||||
deletePlayerNotice: '真的要删除此角色吗?此操作不可恢复',
|
||||
targetUser: '目标用户::nickname',
|
||||
noSuchUser: '没有这个用户哦~',
|
||||
changePlayerNameNotice: '请输入新的角色名:',
|
||||
emptyPlayerName: '您还没填写角色名呢',
|
||||
|
||||
// Index
|
||||
textureUploads: '材质上传',
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user