Refactor and improve bulk delete popup

- Improve bulk edit popup with display of avatars and better format
- Refactor both calls of bulk delete to use the same method
- Add display of filename on avatar hover for inline avatars (@Cohee you forgot this one (: )
This commit is contained in:
Wolfsblvt
2024-03-29 05:53:26 +01:00
parent 167673fcf5
commit bf8b6b80d7
4 changed files with 45 additions and 46 deletions

View File

@ -84,32 +84,8 @@ async function deleteCharacter(this_chid) {
async function onDeleteButtonClick() {
console.log('Delete button clicked');
// Create a mapping of chid to avatar
let toDelete = [];
$('.bulk_select_checkbox:checked').each((i, el) => {
const chid = $(el).parent().attr('chid');
const avatar = characters[chid].avatar;
// Add the avatar to the list of avatars to delete
toDelete.push(avatar);
});
const confirm = await callPopup('<h3>Are you sure you want to delete these characters?</h3>You would need to delete the chat files manually.<br>', 'confirm');
if (!confirm) {
console.log('User cancelled delete');
return;
}
// Delete the characters
for (const avatar of toDelete) {
console.log(`Deleting character with avatar ${avatar}`);
await getCharacters();
//chid should be the key of the character with the given avatar
const chid = Object.keys(characters).find((key) => characters[key].avatar === avatar);
console.log(`Deleting character with chid ${chid}`);
await deleteCharacter(chid);
}
// We just let the button trigger the context menu delete option
await characterGroupOverlay.handleContextMenuDelete();
}
/**