mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-27 06:29:19 +08:00
Fix status text of user management
This commit is contained in:
parent
93364ef723
commit
4b8a40ce59
@ -2,7 +2,7 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-07-22 14:02:44
|
||||
* @Last Modified by: g-plane
|
||||
* @Last Modified time: 2017-04-25 17:30:11
|
||||
* @Last Modified time: 2017-04-25 23:21:54
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@ -155,12 +155,16 @@ function changeBanStatus(uid) {
|
||||
data: { 'uid': uid },
|
||||
success: function(json) {
|
||||
if (json.errno == 0) {
|
||||
var object = $('#'+uid).find('a#ban');
|
||||
var dom = '<a id="ban" href="javascript:changeBanStatus('+uid+');">' +
|
||||
(object.text() == trans('admin.ban') ? trans('admin.unban') : trans('admin.ban')) + '</a>';
|
||||
object.html(dom);
|
||||
let dom = $(`#ban-${uid}`);
|
||||
if (dom.attr('data') == 'banned') {
|
||||
dom.text(trans('admin.ban'));
|
||||
dom.attr('data', 'normal');
|
||||
} else {
|
||||
dom.text(trans('admin.unban'));
|
||||
dom.attr('data', 'banned');
|
||||
}
|
||||
|
||||
$('#'+uid).find('#permission').text(json.permission == '-1' ? trans('admin.banned') : trans('admin.normal'));
|
||||
$(`#user-${uid} > td:nth-child(5)`).text(json.permission == -1 ? trans('admin.banned') : trans('admin.normal'));
|
||||
toastr.success(json.msg);
|
||||
} else {
|
||||
toastr.warning(json.msg);
|
||||
@ -178,12 +182,16 @@ function changeAdminStatus(uid) {
|
||||
data: { 'uid': uid },
|
||||
success: function(json) {
|
||||
if (json.errno == 0) {
|
||||
var object = $('#'+uid).find('a#admin');
|
||||
var dom = '<a href="javascript:changeAdminStatus('+uid+');">' +
|
||||
(object.text() == trans('admin.setAdmin') ? trans('admin.unsetAdmin') : trans('admin.setAdmin')) + '</a>';
|
||||
object.html(dom);
|
||||
let dom = $(`#admin-${uid}`);
|
||||
if (dom.attr('data') == 'admin') {
|
||||
dom.text(trans('admin.setAdmin'));
|
||||
dom.attr('data', 'normal');
|
||||
} else {
|
||||
dom.text(trans('admin.unsetAdmin'));
|
||||
dom.attr('data', 'admin');
|
||||
}
|
||||
|
||||
$('#'+uid).find('#permission').text(json.permission == '1' ? trans('admin.admin') : trans('admin.normal'));
|
||||
$(`#user-${uid} > td:nth-child(5)`).text(json.permission == 1 ? trans('admin.admin') : trans('admin.normal'));
|
||||
toastr.success(json.msg);
|
||||
} else {
|
||||
toastr.warning(json.msg);
|
||||
@ -498,6 +506,9 @@ function initUsersTable() {
|
||||
$('#user-table').DataTable({
|
||||
ajax: `${rootPath}/admin/user-data`,
|
||||
scrollY: ($('.content-wrapper').height() - $('.content-header').outerHeight()) * 0.7,
|
||||
rowCallback: (row, data) => {
|
||||
$(row).attr('id', `user-${data.uid}`);
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
targets: 0,
|
||||
@ -550,18 +561,18 @@ function initUsersTable() {
|
||||
if (data === 2) {
|
||||
if (row.permission === 1) {
|
||||
adminOption = `<li class="divider"></li>
|
||||
<li><a id="admin" href="javascript:changeAdminStatus(${row.uid});">${trans('admin.unsetAdmin')}</a></li>`;
|
||||
<li><a id="admin-${row.uid}" data="admin" href="javascript:changeAdminStatus(${row.uid});">${trans('admin.unsetAdmin')}</a></li>`;
|
||||
} else {
|
||||
adminOption = `<li class="divider"></li>
|
||||
<li><a id="admin" href="javascript:changeAdminStatus(${row.uid});">${trans('admin.setAdmin')}</a></li>`;
|
||||
<li><a id="admin-${row.uid}" data="normal" href="javascript:changeAdminStatus(${row.uid});">${trans('admin.setAdmin')}</a></li>`;
|
||||
}
|
||||
}
|
||||
if (row.permission === -1) {
|
||||
bannedOption = `<li class="divider"></li>
|
||||
<li><a id="ban" href="javascript:changeBanStatus(${row.uid});">${trans('admin.unban')}</a></li>`;
|
||||
<li><a id="ban-${row.uid}" data="banned" href="javascript:changeBanStatus(${row.uid});">${trans('admin.unban')}</a></li>`;
|
||||
} else {
|
||||
bannedOption = `<li class="divider"></li>
|
||||
<li><a id="ban" href="javascript:changeBanStatus(${row.uid});">${trans('admin.ban')}</a></li>`;
|
||||
<li><a id="ban-${row.uid}" data="normal" href="javascript:changeBanStatus(${row.uid});">${trans('admin.ban')}</a></li>`;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user