Fix bulk edit
This commit is contained in:
parent
84283bc2b4
commit
cd8a24a712
|
@ -7032,13 +7032,13 @@ function doCloseChat() {
|
|||
*
|
||||
* @param {string} popup_type - The type of popup currently active.
|
||||
* @param {string} this_chid - The character ID to be deleted.
|
||||
* @param {boolean} delete_chats - Whether to delete chats or not.
|
||||
*/
|
||||
export async function handleDeleteCharacter(popup_type, this_chid) {
|
||||
export async function handleDeleteCharacter(popup_type, this_chid, delete_chats) {
|
||||
if (popup_type !== "del_ch") {
|
||||
return;
|
||||
}
|
||||
|
||||
const delete_chats = !!$("#del_char_checkbox").prop("checked");
|
||||
const avatar = characters[this_chid].avatar;
|
||||
const name = characters[this_chid].name;
|
||||
|
||||
|
@ -7476,7 +7476,8 @@ $(document).ready(function () {
|
|||
}, 200);
|
||||
}
|
||||
if (popup_type == "del_ch") {
|
||||
handleDeleteCharacter(popup_type, this_chid, characters);
|
||||
const deleteChats = !!$("#del_char_checkbox").prop("checked");
|
||||
await handleDeleteCharacter(popup_type, this_chid, deleteChats);
|
||||
}
|
||||
if (popup_type == "alternate_greeting" && menu_type !== "create") {
|
||||
createOrEditCharacter();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { characters, getCharacters, saveSettingsDebounced, handleDeleteCharacter } from "../../../script.js";
|
||||
import { characters, getCharacters, handleDeleteCharacter, callPopup } from "../../../script.js";
|
||||
|
||||
let is_bulk_edit = false;
|
||||
|
||||
|
@ -27,7 +27,7 @@ function onEditButtonClick() {
|
|||
* @param {string} this_chid - The chid of the character to delete.
|
||||
*/
|
||||
async function deleteCharacter(this_chid) {
|
||||
await handleDeleteCharacter("del_ch", this_chid);
|
||||
await handleDeleteCharacter("del_ch", this_chid, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,6 +45,13 @@ async function onDeleteButtonClick() {
|
|||
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}`);
|
||||
|
@ -78,7 +85,7 @@ function addButtons() {
|
|||
* Enables bulk selection by adding a checkbox next to each character.
|
||||
*/
|
||||
function enableBulkSelect() {
|
||||
$(".character_select").each((i, el) => {
|
||||
$("#rm_print_characters_block .character_select").each((i, el) => {
|
||||
const character = $(el).text();
|
||||
const checkbox = $("<input type='checkbox' class='bulk_select_checkbox'>");
|
||||
checkbox.on("change", () => {
|
||||
|
@ -86,6 +93,7 @@ function enableBulkSelect() {
|
|||
});
|
||||
$(el).prepend(checkbox);
|
||||
});
|
||||
$("#rm_print_characters_block").addClass("bulk_select");
|
||||
// We also need to disable the default click event for the character_select divs
|
||||
$(document).on("click", ".bulk_select_checkbox", function (event) {
|
||||
event.stopImmediatePropagation();
|
||||
|
@ -97,6 +105,7 @@ function enableBulkSelect() {
|
|||
*/
|
||||
function disableBulkSelect() {
|
||||
$(".bulk_select_checkbox").remove();
|
||||
$("#rm_print_characters_block").removeClass("bulk_select");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"requires": [],
|
||||
"optional": [],
|
||||
"js": "index.js",
|
||||
"css": "",
|
||||
"css": "style.css",
|
||||
"author": "city-unit",
|
||||
"version": "1.0.0",
|
||||
"homePage": "https://github.com/city-unit"
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
.bulk_select_checkbox {
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
#rm_print_characters_block .wide100pLess70px {
|
||||
width: calc(100% - 85px);
|
||||
}
|
|
@ -1169,7 +1169,7 @@ app.post("/deletecharacter", jsonParser, async function (request, response) {
|
|||
return response.sendStatus(403);
|
||||
}
|
||||
|
||||
if (request.body.delete_chats == 'true') {
|
||||
if (request.body.delete_chats == true) {
|
||||
try {
|
||||
await fs.promises.rm(path.join(chatsPath, sanitize(dir_name)), { recursive: true, force: true })
|
||||
} catch (err) {
|
||||
|
@ -3475,7 +3475,7 @@ app.post("/tokenize_via_api", jsonParser, async function (request, response) {
|
|||
body: JSON.stringify({ "prompt": text }),
|
||||
headers: { "Content-Type": "application/json" }
|
||||
};
|
||||
|
||||
|
||||
if (main_api == 'textgenerationwebui' && request.body.use_mancer) {
|
||||
args.headers = Object.assign(args.headers, get_mancer_headers());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue