correctly setting the current model in the special prompts pages

This commit is contained in:
Mic 2026-03-25 00:13:00 +01:00
parent 7cde1f9b62
commit a1bd5d71e6
5 changed files with 68 additions and 54 deletions

View file

@ -330,19 +330,21 @@ async function restoreOptions() {
const restoreValue = result[element.id] || default_select_value;
// Check if option exists
let optionExists = Array.from(element.options).some(opt => opt.value === restoreValue);
// If it doesn't exist and restoreValue is not empty, create it
if (element.tomselect) {
if (!optionExists && restoreValue !== '') {
element.tomselect.addOption({ value: restoreValue, text: restoreValue });
}
element.tomselect.setValue(restoreValue, true);
setTomSelectBorder(element.tomselect);
} else {
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
// Set value
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = -1;
}
if (element.tomselect) {
element.tomselect.setValue(element.value, true);
setTomSelectBorder(element.tomselect);
}
}else{
console.error("[ThunderAI] Unhandled input type:", element.type);

View file

@ -227,19 +227,21 @@ async function restoreOptions() {
const restoreValue = result[element.id] || default_select_value;
// Check if option exists
let optionExists = Array.from(element.options).some(opt => opt.value === restoreValue);
// If it doesn't exist and restoreValue is not empty, create it
if (element.tomselect) {
if (!optionExists && restoreValue !== '') {
element.tomselect.addOption({ value: restoreValue, text: restoreValue });
}
element.tomselect.setValue(restoreValue, true);
setTomSelectBorder(element.tomselect);
} else {
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
// Set value
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = -1;
}
if (element.tomselect) {
element.tomselect.setValue(element.value, true);
setTomSelectBorder(element.tomselect);
}
}else{
console.error("[ThunderAI] Unhandled input type:", element.type);

View file

@ -180,19 +180,21 @@ async function restoreOptions() {
const restoreValue = result[element.id] || default_select_value;
// Check if option exists
let optionExists = Array.from(element.options).some(opt => opt.value === restoreValue);
// If it doesn't exist and restoreValue is not empty, create it
if (element.tomselect) {
if (!optionExists && restoreValue !== '') {
element.tomselect.addOption({ value: restoreValue, text: restoreValue });
}
element.tomselect.setValue(restoreValue, true);
setTomSelectBorder(element.tomselect);
} else {
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
// Set value
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = -1;
}
if (element.tomselect) {
element.tomselect.setValue(element.value, true);
setTomSelectBorder(element.tomselect);
}
}else{
console.error("[ThunderAI] Unhandled input type:", element.type);

View file

@ -326,6 +326,13 @@ async function restoreOptions() {
const restoreValue = result[element.id] || default_select_value;
// Ensure option exists before restoring
let optionExists = Array.from(element.options).some(opt => opt.value === restoreValue);
if (element.tomselect) {
if (!optionExists && restoreValue !== '') {
element.tomselect.addOption({ value: restoreValue, text: restoreValue });
}
element.tomselect.setValue(restoreValue, true);
setTomSelectBorder(element.tomselect);
} else {
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
@ -334,9 +341,6 @@ async function restoreOptions() {
if (element.value === '') {
element.selectedIndex = -1;
}
if (element.tomselect) {
element.tomselect.setValue(element.value, true);
setTomSelectBorder(element.tomselect);
}
}else{
console.error("[ThunderAI] Unhandled input type:", element.type);

View file

@ -32,7 +32,8 @@ import {
import { textareaAutocomplete } from "../../js/mzta-placeholders-autocomplete.js";
import {
normalizeStringList,
isAPIKeyValue
isAPIKeyValue,
setTomSelectBorder
} from "../../js/mzta-utils.js";
import {
initializeSpecificIntegrationUI
@ -246,18 +247,21 @@ async function restoreOptions() {
const restoreValue = result[element.id] ?? default_select_value;
// Check if option exists
let optionExists = Array.from(element.options).some(opt => opt.value === String(restoreValue));
// If it doesn't exist and restoreValue is not empty, create it
if (element.tomselect) {
if (!optionExists && restoreValue !== '') {
element.tomselect.addOption({ value: String(restoreValue), text: String(restoreValue) });
}
element.tomselect.setValue(String(restoreValue), true);
setTomSelectBorder(element.tomselect);
} else {
if (!optionExists && restoreValue !== '') {
let newOption = new Option(restoreValue, restoreValue);
element.add(newOption);
}
// Set value
element.value = restoreValue;
if (element.value === '') {
element.selectedIndex = 0;
}
if (element.tomselect) {
element.tomselect.setValue(element.value, true);
}
}else{
console.error("[ThunderAI] Unhandled input type:", element.type);