move arround classes to removed deps on settings
This commit is contained in:
parent
274c165357
commit
39f7a3701a
11 changed files with 320 additions and 288 deletions
118
.dist/role.js
118
.dist/role.js
|
@ -43,3 +43,121 @@ class Role {
|
|||
}
|
||||
}
|
||||
export { Role };
|
||||
import { Options } from "./settings.js";
|
||||
class PermissionToggle {
|
||||
rolejson;
|
||||
permissions;
|
||||
owner;
|
||||
constructor(roleJSON, permissions, owner) {
|
||||
this.rolejson = roleJSON;
|
||||
this.permissions = permissions;
|
||||
this.owner = owner;
|
||||
}
|
||||
generateHTML() {
|
||||
const div = document.createElement("div");
|
||||
div.classList.add("setting");
|
||||
const name = document.createElement("span");
|
||||
name.textContent = this.rolejson.readableName;
|
||||
name.classList.add("settingsname");
|
||||
div.append(name);
|
||||
div.append(this.generateCheckbox());
|
||||
const p = document.createElement("p");
|
||||
p.textContent = this.rolejson.description;
|
||||
div.appendChild(p);
|
||||
return div;
|
||||
}
|
||||
generateCheckbox() {
|
||||
const div = document.createElement("div");
|
||||
div.classList.add("tritoggle");
|
||||
const state = this.permissions.getPermission(this.rolejson.name);
|
||||
const on = document.createElement("input");
|
||||
on.type = "radio";
|
||||
on.name = this.rolejson.name;
|
||||
div.append(on);
|
||||
if (state === 1) {
|
||||
on.checked = true;
|
||||
}
|
||||
;
|
||||
on.onclick = _ => {
|
||||
this.permissions.setPermission(this.rolejson.name, 1);
|
||||
this.owner.changed();
|
||||
};
|
||||
const no = document.createElement("input");
|
||||
no.type = "radio";
|
||||
no.name = this.rolejson.name;
|
||||
div.append(no);
|
||||
if (state === 0) {
|
||||
no.checked = true;
|
||||
}
|
||||
;
|
||||
no.onclick = _ => {
|
||||
this.permissions.setPermission(this.rolejson.name, 0);
|
||||
this.owner.changed();
|
||||
};
|
||||
if (this.permissions.hasDeny) {
|
||||
const off = document.createElement("input");
|
||||
off.type = "radio";
|
||||
off.name = this.rolejson.name;
|
||||
div.append(off);
|
||||
if (state === -1) {
|
||||
off.checked = true;
|
||||
}
|
||||
;
|
||||
off.onclick = _ => {
|
||||
this.permissions.setPermission(this.rolejson.name, -1);
|
||||
this.owner.changed();
|
||||
};
|
||||
}
|
||||
return div;
|
||||
}
|
||||
submit() {
|
||||
}
|
||||
}
|
||||
import { Buttons } from "./settings.js";
|
||||
class RoleList extends Buttons {
|
||||
permissions;
|
||||
permission;
|
||||
guild;
|
||||
channel;
|
||||
options;
|
||||
onchange;
|
||||
curid;
|
||||
constructor(permissions, guild, onchange, channel = false) {
|
||||
super("Roles");
|
||||
this.guild = guild;
|
||||
this.permissions = permissions;
|
||||
this.channel = channel;
|
||||
this.onchange = onchange;
|
||||
const options = new Options("", this);
|
||||
if (channel) {
|
||||
this.permission = new Permissions("0", "0");
|
||||
}
|
||||
else {
|
||||
this.permission = new Permissions("0");
|
||||
}
|
||||
for (const thing of Permissions.info) {
|
||||
options.options.push(new PermissionToggle(thing, this.permission, options));
|
||||
}
|
||||
for (const i of permissions) {
|
||||
console.log(i);
|
||||
this.buttons.push([i[0].getObject().name, i[0].id]); //
|
||||
}
|
||||
this.options = options;
|
||||
}
|
||||
handleString(str) {
|
||||
this.curid = str;
|
||||
const arr = this.permissions.find(_ => _[0].id === str);
|
||||
if (arr) {
|
||||
const perm = arr[1];
|
||||
this.permission.deny = perm.deny;
|
||||
this.permission.allow = perm.allow;
|
||||
this.options.name = SnowFlake.getSnowFlakeFromID(str, Role).getObject().name;
|
||||
this.options.haschanged = false;
|
||||
}
|
||||
return this.options.generateHTML();
|
||||
}
|
||||
save() {
|
||||
this.onchange(this.curid, this.permission);
|
||||
}
|
||||
}
|
||||
export { RoleList };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue