1
0
mirror of https://github.com/koloml/furbooru-tagging-assistant.git synced 2025-12-24 07:12:57 +00:00

Added tag category, storing the original category in the component class

This commit is contained in:
2025-01-03 05:13:29 +04:00
parent e06359a24a
commit b7a829ff12

View File

@@ -36,6 +36,11 @@ export class TagDropdownWrapper extends BaseComponent {
*/
#isEntered = false;
/**
* @type {string|undefined|null}
*/
#originalCategory = null;
build() {
this.#dropdownContainer = this.container.querySelector('.dropdown__content');
}
@@ -57,6 +62,41 @@ export class TagDropdownWrapper extends BaseComponent {
return this.container.dataset.tagName;
}
/**
* @return {string|undefined}
*/
get tagCategory() {
return this.container.dataset.tagCategory;
}
/**
* @param {string|undefined} targetCategory
*/
set tagCategory(targetCategory) {
// Make sure original category is properly stored.
this.originalCategory;
this.container.dataset.tagCategory = targetCategory;
if (targetCategory) {
this.container.setAttribute('data-tag-category', targetCategory);
return;
}
this.container.removeAttribute('data-tag-category');
}
/**
* @return {string|undefined}
*/
get originalCategory() {
if (this.#originalCategory === null) {
this.#originalCategory = this.tagCategory;
}
return this.#originalCategory;
}
#onDropdownEntered() {
this.#isEntered = true;
this.#updateButtons();