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

v1.18.x
Julian Lam 4 years ago
parent c265016944
commit c5e257888a

@ -363,16 +363,15 @@ define('admin/manage/privileges', [
], ],
}, },
}, function (html) { }, function (html) {
var tableEl = document.querySelector('.privilege-table'); var tbodyEl = document.querySelector('.privilege-table tbody');
var rows = tableEl.querySelectorAll('tbody tr'); tbodyEl.append(html.get(0));
html.insertBefore(rows[rows.length - 1]);
Privileges.exposeAssumedPrivileges(); Privileges.exposeAssumedPrivileges();
hightlightRowByDataAttr('data-group-name', group); hightlightRowByDataAttr('data-group-name', group);
cb(); cb();
}); });
} }
function addUserToCategory(user, cb) { async function addUserToCategory(user, cb) {
cb = cb || function () {}; cb = cb || function () {};
var userRow = document.querySelector('.privilege-table [data-uid="' + user.uid + '"]'); var userRow = document.querySelector('.privilege-table [data-uid="' + user.uid + '"]');
if (userRow) { if (userRow) {
@ -385,7 +384,7 @@ define('admin/manage/privileges', [
return memo; 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: { privileges: {
users: [ users: [
{ {
@ -399,13 +398,13 @@ define('admin/manage/privileges', [
}, },
], ],
}, },
}, function (html) { });
var tableEl = document.querySelectorAll('.privilege-table');
var rows = tableEl[1].querySelectorAll('tbody tr'); var tbodyEl = document.querySelectorAll('.privilege-table tbody');
html.insertBefore(rows[rows.length - 1]); tbodyEl[1].append(html.get(0));
Privileges.exposeAssumedPrivileges();
hightlightRowByDataAttr('data-uid', user.uid); hightlightRowByDataAttr('data-uid', user.uid);
cb(); cb();
});
} }
return Privileges; return Privileges;

@ -135,6 +135,8 @@
{function.spawnPrivilegeStates, privileges.users.username, ../privileges} {function.spawnPrivilegeStates, privileges.users.username, ../privileges}
</tr> </tr>
<!-- END privileges.users --> <!-- END privileges.users -->
</tbody>
<tfoot>
<tr> <tr>
<td colspan="{privileges.columnCountUser}"> <td colspan="{privileges.columnCountUser}">
<button type="button" class="btn btn-default pull-right" data-ajaxify="false" data-action="search.user"> <button type="button" class="btn btn-default pull-right" data-ajaxify="false" data-action="search.user">
@ -143,5 +145,5 @@
</button> </button>
</td> </td>
</tr> </tr>
</tbody> </tfoot>
</table> </table>

@ -81,6 +81,8 @@
{function.spawnPrivilegeStates, privileges.users.username, ../privileges} {function.spawnPrivilegeStates, privileges.users.username, ../privileges}
</tr> </tr>
<!-- END privileges.users --> <!-- END privileges.users -->
</tbody>
<tfoot>
<tr> <tr>
<td colspan="{privileges.columnCount}"> <td colspan="{privileges.columnCount}">
<button type="button" class="btn btn-default pull-right" data-ajaxify="false" data-action="search.user"> <button type="button" class="btn btn-default pull-right" data-ajaxify="false" data-action="search.user">
@ -89,5 +91,5 @@
</button> </button>
</td> </td>
</tr> </tr>
</tbody> </tfoot>
</table> </table>

Loading…
Cancel
Save