-/**
- * @extends {Component}
- */
-class EntityPermissions {
+import {htmlToDom} from '../services/dom.ts';
+import {Component} from './component';
+
+export class EntityPermissions extends Component {
setup() {
this.container = this.$el;
// "Everyone Else" inherit toggle
this.everyoneInheritToggle.addEventListener('change', event => {
const inherit = event.target.checked;
- const permissions = document.querySelectorAll('input[type="checkbox"][name^="restrictions[0]["]');
+ const permissions = document.querySelectorAll('input[name^="permissions[0]["]');
for (const permission of permissions) {
permission.disabled = inherit;
permission.checked = false;
this.container.addEventListener('click', event => {
const button = event.target.closest('button');
if (button && button.dataset.roleId) {
- this.removeRowOnButtonClick(button)
+ this.removeRowOnButtonClick(button);
}
});
// Role select change
- this.roleSelect.addEventListener('change', event => {
+ this.roleSelect.addEventListener('change', () => {
const roleId = this.roleSelect.value;
if (roleId) {
this.addRoleRow(roleId);
// Get and insert new row
const resp = await window.$http.get(`/permissions/form-row/${this.entityType}/${roleId}`);
- const wrap = document.createElement('div');
- wrap.innerHTML = resp.data;
- const row = wrap.children[0];
+ const row = htmlToDom(resp.data);
this.roleContainer.append(row);
- window.components.init(row);
this.roleSelect.disabled = false;
}
removeRowOnButtonClick(button) {
- const row = button.closest('.content-permissions-row');
- const roleId = button.dataset.roleId;
- const roleName = button.dataset.roleName;
+ const row = button.closest('.item-list-row');
+ const {roleId} = button.dataset;
+ const {roleName} = button.dataset;
const option = document.createElement('option');
option.value = roleId;
}
}
-
-export default EntityPermissions;
\ No newline at end of file