disabled prompts are not visible. see #680
This commit is contained in:
parent
1984a70b28
commit
a5e3ac9a07
1 changed files with 12 additions and 3 deletions
|
|
@ -21,6 +21,7 @@ import { i18nConditionalGet } from '../../js/mzta-utils.js';
|
||||||
|
|
||||||
let allPrompts = [];
|
let allPrompts = [];
|
||||||
let allExcludedSpecialPrompts = []; // special prompts excluded from UI (hidden + inactive features), preserved on save
|
let allExcludedSpecialPrompts = []; // special prompts excluded from UI (hidden + inactive features), preserved on save
|
||||||
|
let allDisabledPrompts = []; // default/custom prompts disabled (enabled=0), excluded from UI, preserved on save
|
||||||
let currentPopupView = 'display'; // 'display' or 'compose'
|
let currentPopupView = 'display'; // 'display' or 'compose'
|
||||||
let hasUnsavedChanges = false;
|
let hasUnsavedChanges = false;
|
||||||
|
|
||||||
|
|
@ -37,6 +38,10 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
);
|
);
|
||||||
allPrompts = allPrompts.filter(p => !allExcludedSpecialPrompts.some(e => e.id === p.id));
|
allPrompts = allPrompts.filter(p => !allExcludedSpecialPrompts.some(e => e.id === p.id));
|
||||||
|
|
||||||
|
// Exclude disabled prompts (enabled=0) from the UI, preserve them for save
|
||||||
|
allDisabledPrompts = allPrompts.filter(p => String(p.enabled) === '0');
|
||||||
|
allPrompts = allPrompts.filter(p => String(p.enabled) !== '0');
|
||||||
|
|
||||||
// Resolve i18n names and assign initial position_context if missing
|
// Resolve i18n names and assign initial position_context if missing
|
||||||
let contextPos = 1;
|
let contextPos = 1;
|
||||||
const sortedForContext = [...allPrompts].sort((a, b) => {
|
const sortedForContext = [...allPrompts].sort((a, b) => {
|
||||||
|
|
@ -305,9 +310,13 @@ async function saveAll() {
|
||||||
const msgDisplay = document.getElementById('msgDisplay');
|
const msgDisplay = document.getElementById('msgDisplay');
|
||||||
btnSaveAll.disabled = true;
|
btnSaveAll.disabled = true;
|
||||||
|
|
||||||
const defaultPromptsToSave = allPrompts.filter(p => String(p.is_default) === '1' && String(p.is_special) !== '1');
|
const disabledDefaults = allDisabledPrompts.filter(p => String(p.is_default) === '1' && String(p.is_special) !== '1');
|
||||||
const customPromptsToSave = allPrompts.filter(p => String(p.is_default) === '0' && String(p.is_special) !== '1');
|
const disabledCustoms = allDisabledPrompts.filter(p => String(p.is_default) === '0' && String(p.is_special) !== '1');
|
||||||
const specialPromptsToSave = allPrompts.filter(p => String(p.is_special) === '1').concat(allExcludedSpecialPrompts);
|
const disabledSpecials = allDisabledPrompts.filter(p => String(p.is_special) === '1');
|
||||||
|
|
||||||
|
const defaultPromptsToSave = allPrompts.filter(p => String(p.is_default) === '1' && String(p.is_special) !== '1').concat(disabledDefaults);
|
||||||
|
const customPromptsToSave = allPrompts.filter(p => String(p.is_default) === '0' && String(p.is_special) !== '1').concat(disabledCustoms);
|
||||||
|
const specialPromptsToSave = allPrompts.filter(p => String(p.is_special) === '1').concat(disabledSpecials).concat(allExcludedSpecialPrompts);
|
||||||
|
|
||||||
await setDefaultPromptsProperties(defaultPromptsToSave);
|
await setDefaultPromptsProperties(defaultPromptsToSave);
|
||||||
await setCustomPrompts(customPromptsToSave);
|
await setCustomPrompts(customPromptsToSave);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue