Skip to content

Node.js based forum software built for the modern web

fix: #9351 bad logic when inserting rows to privilege tables, also a missing tfoot :foot:

Julian Lamc5e257888ad9
diff --git a/public/src/admin/manage/privileges.js b/public/src/admin/manage/privileges.js
index 3508240ac6..a34f49765a 100644
--- a/public/src/admin/manage/privileges.js
+++ b/public/src/admin/manage/privileges.js
@@ -363,16 +363,15 @@ define('admin/manage/privileges', [
],
},
}, function (html) {
- var tableEl = document.querySelector('.privilege-table');
- var rows = tableEl.querySelectorAll('tbody tr');
- html.insertBefore(rows[rows.length - 1]);
+ var tbodyEl = document.querySelector('.privilege-table tbody');
+ tbodyEl.append(html.get(0));
Privileges.exposeAssumedPrivileges();
hightlightRowByDataAttr('data-group-name', group);
cb();
});
}
- function addUserToCategory(user, cb) {
+ async function addUserToCategory(user, cb) {
cb = cb || function () {};
var userRow = document.querySelector('.privilege-table [data-uid="' + user.uid + '"]');
if (userRow) {
@@ -385,7 +384,7 @@ define('admin/manage/privileges', [
return memo;
}, {});
- app.parseAndTranslate('admin/partials/privileges/' + (isNaN(cid) ? 'global' : 'category'), 'privileges.users', {
+ const html = await app.parseAndTranslate('admin/partials/privileges/' + (isNaN(cid) ? 'global' : 'category'), 'privileges.users', {
privileges: {
users: [
{
@@ -399,13 +398,13 @@ define('admin/manage/privileges', [
},
],
},
- }, function (html) {
- var tableEl = document.querySelectorAll('.privilege-table');
- var rows = tableEl[1].querySelectorAll('tbody tr');
- html.insertBefore(rows[rows.length - 1]);
- hightlightRowByDataAttr('data-uid', user.uid);
- cb();
});
+
+ var tbodyEl = document.querySelectorAll('.privilege-table tbody');
+ tbodyEl[1].append(html.get(0));
+ Privileges.exposeAssumedPrivileges();
+ hightlightRowByDataAttr('data-uid', user.uid);
+ cb();
}
return Privileges;
diff --git a/src/views/admin/partials/privileges/category.tpl b/src/views/admin/partials/privileges/category.tpl
index 127e9b203a..1282120306 100644
--- a/src/views/admin/partials/privileges/category.tpl
+++ b/src/views/admin/partials/privileges/category.tpl
@@ -135,6 +135,8 @@
{function.spawnPrivilegeStates, privileges.users.username, ../privileges}
</tr>
<!-- END privileges.users -->
+ </tbody>
+ <tfoot>
<tr>
<td colspan="{privileges.columnCountUser}">
<button type="button" class="btn btn-default pull-right" data-ajaxify="false" data-action="search.user">
@@ -143,5 +145,5 @@
</button>
</td>
</tr>
- </tbody>
+ </tfoot>
</table>
diff --git a/src/views/admin/partials/privileges/global.tpl b/src/views/admin/partials/privileges/global.tpl
index b854eaa2f3..47da134ac2 100644
--- a/src/views/admin/partials/privileges/global.tpl
+++ b/src/views/admin/partials/privileges/global.tpl
@@ -81,6 +81,8 @@
{function.spawnPrivilegeStates, privileges.users.username, ../privileges}
</tr>
<!-- END privileges.users -->
+ </tbody>
+ <tfoot>
<tr>
<td colspan="{privileges.columnCount}">
<button type="button" class="btn btn-default pull-right" data-ajaxify="false" data-action="search.user">
@@ -89,5 +91,5 @@
</button>
</td>
</tr>
- </tbody>
+ </tfoot>
</table>