diff --git a/public/scripts/BulkEditOverlay.js b/public/scripts/BulkEditOverlay.js index d121d0fc6..a70cfe782 100644 --- a/public/scripts/BulkEditOverlay.js +++ b/public/scripts/BulkEditOverlay.js @@ -18,7 +18,7 @@ import { import { favsToHotswap } from './RossAscends-mods.js'; import { hideLoader, showLoader } from './loader.js'; import { convertCharacterToPersona } from './personas.js'; -import { createTagInput, getTagKeyForEntity, getTagsList, printTagList, tag_map, compareTagsForSort, removeTagFromMap } from './tags.js'; +import { createTagInput, getTagKeyForEntity, getTagsList, printTagList, tag_map, compareTagsForSort, removeTagFromMap, importTags } from './tags.js'; /** * Static object representing the actions of the @@ -219,6 +219,9 @@ class BulkTagPopupHandler { Mutual + @@ -254,6 +257,18 @@ class BulkTagPopupHandler { document.querySelector('#bulk_tag_popup_reset').addEventListener('click', this.resetTags.bind(this)); document.querySelector('#bulk_tag_popup_remove_mutual').addEventListener('click', this.removeMutual.bind(this)); document.querySelector('#bulk_tag_popup_cancel').addEventListener('click', this.hide.bind(this)); + document.querySelector('#bulk_tag_popup_import_all_tags').addEventListener('click', this.importAllTags.bind(this)); + } + + /** + * Import all tags for all selected characters + */ + async importAllTags() { + for (const characterId of this.characterIds) { + await importTags(characters[characterId], { importAll: true }); + } + + $('#bulkTagList').empty(); } /** @@ -570,7 +585,7 @@ class BulkEditOverlay { this.container.removeEventListener('mouseup', cancelHold); this.container.removeEventListener('touchend', cancelHold); }, - BulkEditOverlay.longPressDelay); + BulkEditOverlay.longPressDelay); }; handleLongPressEnd = (event) => { diff --git a/public/scripts/tags.js b/public/scripts/tags.js index 43b52f74e..d563b00bc 100644 --- a/public/scripts/tags.js +++ b/public/scripts/tags.js @@ -708,12 +708,13 @@ const ANTI_TROLL_MAX_TAGS = 15; * * @param {Character} character - The character * @param {object} [options] - Options + * @param {boolean} [options.importAll=false] - Whether to import all tags without dialog * @param {boolean} [options.forceShow=false] - Whether to force showing the import dialog * @returns {Promise} Boolean indicating whether any tag was imported */ -async function importTags(character, { forceShow = false } = {}) { +async function importTags(character, { importAll = false, forceShow = false } = {}) { // Gather the tags to import based on the selected setting - const tagNamesToImport = await handleTagImport(character, { forceShow }); + const tagNamesToImport = await handleTagImport(character, { importAll, forceShow }); if (!tagNamesToImport?.length) { console.debug('No tags to import'); return; @@ -732,10 +733,11 @@ async function importTags(character, { forceShow = false } = {}) { * * @param {Character} character - The character * @param {object} [options] - Options + * @param {boolean} [options.importAll=false] - Whether to import all tags without dialog * @param {boolean} [options.forceShow=false] - Whether to force showing the import dialog * @returns {Promise} Array of strings representing the tags to import */ -async function handleTagImport(character, { forceShow = false } = {}) { +async function handleTagImport(character, { importAll = false, forceShow = false } = {}) { /** @type {string[]} */ const importTags = character.tags.map(t => t.trim()).filter(t => t) .filter(t => !IMPORT_EXLCUDED_TAGS.includes(t)) @@ -747,7 +749,8 @@ async function handleTagImport(character, { forceShow = false } = {}) { // Choose the setting for this dialog. If from settings, verify the setting really exists, otherwise take "ASK". const setting = forceShow ? tag_import_setting.ASK - : Object.values(tag_import_setting).find(setting => setting === power_user.tag_import_setting) ?? tag_import_setting.ASK; + : importAll ? tag_import_setting.ALL + : Object.values(tag_import_setting).find(setting => setting === power_user.tag_import_setting) ?? tag_import_setting.ASK; switch (setting) { case tag_import_setting.ALL: