correctly setting the current model in the special prompts pages
This commit is contained in:
parent
7cde1f9b62
commit
a1bd5d71e6
5 changed files with 68 additions and 54 deletions
|
|
@ -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 (!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);
|
||||
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);
|
||||
}
|
||||
element.value = restoreValue;
|
||||
if (element.value === '') {
|
||||
element.selectedIndex = -1;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
console.error("[ThunderAI] Unhandled input type:", element.type);
|
||||
|
|
|
|||
|
|
@ -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 (!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);
|
||||
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);
|
||||
}
|
||||
element.value = restoreValue;
|
||||
if (element.value === '') {
|
||||
element.selectedIndex = -1;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
console.error("[ThunderAI] Unhandled input type:", element.type);
|
||||
|
|
|
|||
|
|
@ -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 (!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);
|
||||
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);
|
||||
}
|
||||
element.value = restoreValue;
|
||||
if (element.value === '') {
|
||||
element.selectedIndex = -1;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
console.error("[ThunderAI] Unhandled input type:", element.type);
|
||||
|
|
|
|||
|
|
@ -326,17 +326,21 @@ 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 (!optionExists && restoreValue !== '') {
|
||||
let newOption = new Option(restoreValue, restoreValue);
|
||||
element.add(newOption);
|
||||
}
|
||||
element.value = restoreValue;
|
||||
if (element.value === '') {
|
||||
element.selectedIndex = -1;
|
||||
}
|
||||
if (element.tomselect) {
|
||||
element.tomselect.setValue(element.value, true);
|
||||
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);
|
||||
}
|
||||
element.value = restoreValue;
|
||||
if (element.value === '') {
|
||||
element.selectedIndex = -1;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
console.error("[ThunderAI] Unhandled input type:", element.type);
|
||||
|
|
|
|||
|
|
@ -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 (!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);
|
||||
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);
|
||||
}
|
||||
element.value = restoreValue;
|
||||
if (element.value === '') {
|
||||
element.selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
console.error("[ThunderAI] Unhandled input type:", element.type);
|
||||
|
|
|
|||
Loading…
Reference in a new issue