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();
|
$player->delete();
|
||||||
|
|
||||||
return json(trans('admin.players.delete.success'), 0);
|
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
|
* @Author: printempw
|
||||||
* @Date: 2016-07-22 14:02:44
|
* @Date: 2016-07-22 14:02:44
|
||||||
* @Last Modified by: g-plane
|
* @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';
|
'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) {
|
function changeOwner(pid) {
|
||||||
let dom = $(`#${pid} > td:nth-child(2)`);
|
let dom = $(`#${pid} > td:nth-child(2)`);
|
||||||
swal({
|
swal({
|
||||||
|
|
@ -692,6 +724,7 @@ function initPlayersTable() {
|
||||||
${trans('admin.operationsTitle')} <span class="caret"></span></button>
|
${trans('admin.operationsTitle')} <span class="caret"></span></button>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="javascript:changeTexture(${row.pid}, '${row.player_name}');">${trans('admin.changeTexture')}</a></li>
|
<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>
|
<li><a href="javascript:changeOwner(${row.pid});">${trans('admin.changeOwner')}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,8 @@ players:
|
||||||
change: Change Textures
|
change: Change Textures
|
||||||
non-existent: No such texture tid.:tid
|
non-existent: No such texture tid.:tid
|
||||||
success: The textures of :player has been updated.
|
success: The textures of :player has been updated.
|
||||||
|
name:
|
||||||
|
success: Player name has been updated to :player
|
||||||
owner:
|
owner:
|
||||||
change: Change Owner
|
change: Change Owner
|
||||||
success: The player :player was transferred to user :user.
|
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.',
|
pidNotice: 'Please enter the tid of texture. Inputting 0 can clear texture of this player.',
|
||||||
changePlayerTexture: 'Change textures of :player',
|
changePlayerTexture: 'Change textures of :player',
|
||||||
changeTexture: 'Change Textures',
|
changeTexture: 'Change Textures',
|
||||||
|
changePlayerName: 'Change Player Name',
|
||||||
changeOwner: 'Change Owner',
|
changeOwner: 'Change Owner',
|
||||||
deletePlayer: 'Delete',
|
deletePlayer: 'Delete',
|
||||||
changePlayerOwner: 'Please enter the id of user which this player should be transferred to:',
|
changePlayerOwner: 'Please enter the id of user which this player should be transferred to:',
|
||||||
deletePlayerNotice: 'Are you sure to delete this player? It\' permanent.',
|
deletePlayerNotice: 'Are you sure to delete this player? It\' permanent.',
|
||||||
targetUser: 'Target user is :nickname',
|
targetUser: 'Target user is :nickname',
|
||||||
noSuchUser: 'No such user',
|
noSuchUser: 'No such user',
|
||||||
|
changePlayerNameNotice: 'Please input new player name:',
|
||||||
|
emptyPlayerName: 'Player name cannot be empty.',
|
||||||
|
|
||||||
// Index
|
// Index
|
||||||
textureUploads: 'Texture Uploads',
|
textureUploads: 'Texture Uploads',
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,8 @@ players:
|
||||||
change: 更换材质
|
change: 更换材质
|
||||||
non-existent: 材质 tid.:tid 不存在
|
non-existent: 材质 tid.:tid 不存在
|
||||||
success: 角色 :player 的材质修改成功
|
success: 角色 :player 的材质修改成功
|
||||||
|
name:
|
||||||
|
success: 角色名成功更改为 :player
|
||||||
owner:
|
owner:
|
||||||
change: 更换角色拥有者
|
change: 更换角色拥有者
|
||||||
success: 角色 :player 已成功让渡至 :user
|
success: 角色 :player 已成功让渡至 :user
|
||||||
|
|
|
||||||
|
|
@ -134,12 +134,15 @@
|
||||||
pidNotice: '输入要更换的材质的 TID,输入 0 即可清除该角色的材质',
|
pidNotice: '输入要更换的材质的 TID,输入 0 即可清除该角色的材质',
|
||||||
changePlayerTexture: '更换角色 :player 的材质',
|
changePlayerTexture: '更换角色 :player 的材质',
|
||||||
changeTexture: '更换材质',
|
changeTexture: '更换材质',
|
||||||
|
changePlayerName: '更改角色名',
|
||||||
changeOwner: '更换角色拥有者',
|
changeOwner: '更换角色拥有者',
|
||||||
deletePlayer: '删除角色',
|
deletePlayer: '删除角色',
|
||||||
changePlayerOwner: '请输入此角色要让渡至的用户 UID:',
|
changePlayerOwner: '请输入此角色要让渡至的用户 UID:',
|
||||||
deletePlayerNotice: '真的要删除此角色吗?此操作不可恢复',
|
deletePlayerNotice: '真的要删除此角色吗?此操作不可恢复',
|
||||||
targetUser: '目标用户::nickname',
|
targetUser: '目标用户::nickname',
|
||||||
noSuchUser: '没有这个用户哦~',
|
noSuchUser: '没有这个用户哦~',
|
||||||
|
changePlayerNameNotice: '请输入新的角色名:',
|
||||||
|
emptyPlayerName: '您还没填写角色名呢',
|
||||||
|
|
||||||
// Index
|
// Index
|
||||||
textureUploads: '材质上传',
|
textureUploads: '材质上传',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user