Merge pull request #2344 from Wolfsblvt/fix-tags-on-char-creation

Fix adding tags on char/group creation again
This commit is contained in:
Cohee 2024-06-04 17:09:32 +03:00 committed by GitHub
commit 340b3920ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 6 deletions

View File

@ -178,6 +178,8 @@ import {
tag_filter_types, tag_filter_types,
compareTagsForSort, compareTagsForSort,
initTags, initTags,
applyTagsOnCharacterSelect,
applyTagsOnGroupSelect,
} from './scripts/tags.js'; } from './scripts/tags.js';
import { import {
SECRET_KEYS, SECRET_KEYS,
@ -1308,6 +1310,10 @@ export async function printCharacters(fullRefresh = false) {
printTagFilters(tag_filter_types.character); printTagFilters(tag_filter_types.character);
printTagFilters(tag_filter_types.group_member); printTagFilters(tag_filter_types.group_member);
// We are also always reprinting the lists on character/group edit window, as these ones doesn't get updated otherwise
applyTagsOnCharacterSelect();
applyTagsOnGroupSelect();
const entities = getEntitiesList({ doFilter: true }); const entities = getEntitiesList({ doFilter: true });
$('#rm_print_characters_pagination').pagination({ $('#rm_print_characters_pagination').pagination({

View File

@ -701,7 +701,7 @@ function createNewTag(tagName) {
name: tagName, name: tagName,
folder_type: TAG_FOLDER_DEFAULT_TYPE, folder_type: TAG_FOLDER_DEFAULT_TYPE,
filter_state: DEFAULT_FILTER_STATE, filter_state: DEFAULT_FILTER_STATE,
sort_order: tags.length, sort_order: Math.max(0, ...tags.map(t => t.sort_order)) + 1,
color: '', color: '',
color2: '', color2: '',
create_date: Date.now(), create_date: Date.now(),
@ -1046,14 +1046,29 @@ function onGroupCreateClick() {
} }
export function applyTagsOnCharacterSelect() { export function applyTagsOnCharacterSelect() {
//clearTagsFilter(); // If we are in create window, we cannot simply redraw, as there are no real persisted tags. Grab them, and pass them in
const chid = Number(this_chid); if (menu_type === 'create') {
const currentTagIds = $('#tagList').find('.tag').map((_, el) => $(el).attr('id')).get();
const currentTags = tags.filter(x => currentTagIds.includes(x.id));
printTagList($('#tagList'), { forEntityOrKey: null, tags: currentTags, tagOptions: { removable: true } });
return;
}
const chid = this_chid ? Number(this_chid) : null;
printTagList($('#tagList'), { forEntityOrKey: chid, tagOptions: { removable: true } }); printTagList($('#tagList'), { forEntityOrKey: chid, tagOptions: { removable: true } });
} }
function applyTagsOnGroupSelect() { export function applyTagsOnGroupSelect() {
//clearTagsFilter(); // If we are in create window, we explicitly have to tell the system to print for the new group, not the one selected in the background
// Nothing to do here at the moment. Tags in group interface get automatically redrawn. if (menu_type === 'group_create') {
const currentTagIds = $('#groupTagList').find('.tag').map((_, el) => $(el).attr('id')).get();
const currentTags = tags.filter(x => currentTagIds.includes(x.id));
printTagList($('#groupTagList'), { forEntityOrKey: null, tags: currentTags, tagOptions: { removable: true } });
return;
}
const groupId = selected_group;
printTagList($('#groupTagList'), { forEntityOrKey: groupId, tagOptions: { removable: true } });
} }
/** /**