Blocklist: Add frontend elements:

- New field in User profile edition to add/remove tags from their blocklist
- This field works as other tag fields, with auto-completion, and a proper list under the textbox
- User must have the right permissions to edit blocklist (either their own or other users')
This commit is contained in:
Soblow (Opale) Xaselgio
2024-03-03 16:53:23 +01:00
committed by Lugrim
parent f8242f8bea
commit e5f61d2c31
4 changed files with 49 additions and 0 deletions

View File

@ -4,6 +4,8 @@ const events = require("../events.js");
const api = require("../api.js");
const views = require("../util/views.js");
const FileDropperControl = require("../controls/file_dropper_control.js");
const TagInputControl = require("../controls/tag_input_control.js")
const misc = require("../util/misc.js");
const template = views.getTemplate("user-edit");
@ -41,6 +43,13 @@ class UserEditView extends events.EventTarget {
});
}
if (this._blocklistFieldNode) {
new TagInputControl(
this._blocklistFieldNode,
this._user.blocklist
);
}
this._formNode.addEventListener("submit", (e) => this._evtSubmit(e));
}
@ -83,6 +92,10 @@ class UserEditView extends events.EventTarget {
? this._rankInputNode.value
: undefined,
blocklist: this._blocklistFieldNode
? misc.splitByWhitespace(this._blocklistFieldNode.value)
: undefined,
avatarStyle: this._avatarStyleInputNode
? this._avatarStyleInputNode.value
: undefined,
@ -101,6 +114,10 @@ class UserEditView extends events.EventTarget {
return this._hostNode.querySelector("form");
}
get _blocklistFieldNode() {
return this._formNode.querySelector(".blocklist input");
}
get _rankInputNode() {
return this._formNode.querySelector("[name=rank]");
}