need_custom_text is now editable also in default prompts. fixes #135

This commit is contained in:
mic 2024-09-25 21:40:23 +02:00
parent f6badfb6a9
commit e1dce3d289
2 changed files with 10 additions and 4 deletions

View file

@ -18,6 +18,7 @@
import { getPrompts, setDefaultPromptsProperties, setCustomPrompts, preparePromptsForExport, preparePromptsForImport } from "../js/mzta-prompts.js";
import { isThunderbird128OrGreater, getCustomPromptsUsedSpace } from "../js/mzta-utils.js";
import { taLogger } from "../js/mzta-logger.js";
var promptsList = null;
var somethingChanged = false;
@ -25,8 +26,12 @@ var positionMax_compose = 0;
var positionMax_display = 0;
var idnumMax = 0;
var msgTimeout = null;
let taLog = null;
document.addEventListener('DOMContentLoaded', async () => {
let prefs_debug = await browser.storage.sync.get({do_debug: false});
taLog = new taLogger("mzta-custom-prompts", prefs_debug.do_debug);
setStorageSpace();
@ -415,7 +420,7 @@ function loadPromptsList(values){
<br>
<input type="checkbox" class="need_signature" disabled> __MSG_customPrompts_form_label_need_signature__
<br>
<input type="checkbox" class="need_custom_text" disabled> __MSG_customPrompts_form_label_need_custom_text__
<input type="checkbox" class="need_custom_text input_mod" > __MSG_customPrompts_form_label_need_custom_text__
<br>
<input type="checkbox" class="define_response_lang" disabled> __MSG_customPrompts_form_label_define_response_lang__
<br>
@ -584,6 +589,7 @@ async function saveAll() {
// For each item in the array, return only the '_values' part
return item.values();
});
taLog.log('newPrompts: ' + JSON.stringify(newPrompts));
// newPrompts.forEach(prompt => {
// console.log('>>>>>>>>>>>>> id: ' + JSON.stringify(prompt));
// });

View file

@ -169,7 +169,7 @@ export function preparePromptsForExport(prompts){
output.forEach(prompt => {
if(prompt.is_default == 1){
Object.keys(prompt).forEach(key => {
if(!['id', 'enabled', 'position_compose', 'position_display'].includes(key)){
if(!['id', 'enabled', 'position_compose', 'position_display', 'need_custom_text'].includes(key)){
delete prompt[key];
}
})
@ -214,6 +214,7 @@ async function getDefaultPrompts_withProps() {
prompt.position_compose = prefs._default_prompts_properties[prompt.id].position_compose;
prompt.position_display = prefs._default_prompts_properties[prompt.id].position_display;
prompt.enabled = prefs._default_prompts_properties[prompt.id].enabled;
prompt.need_custom_text = prefs._default_prompts_properties[prompt.id].need_custom_text;
}else{
prompt.position_display = pos;
prompt.position_compose = pos;
@ -238,7 +239,7 @@ async function getCustomPrompts() {
export async function setDefaultPromptsProperties(prompts) {
let default_prompts_properties = {};
prompts.forEach((prompt) => {
default_prompts_properties[prompt.id] = {position_compose: prompt.position_compose, position_display: prompt.position_display, enabled: prompt.enabled};
default_prompts_properties[prompt.id] = {position_compose: prompt.position_compose, position_display: prompt.position_display, enabled: prompt.enabled, need_custom_text: prompt.need_custom_text};
});
//console.log('>>>>>>>>>>>>>> default_prompts_properties: ' + JSON.stringify(default_prompts_properties));
await browser.storage.local.set({_default_prompts_properties: default_prompts_properties});
@ -248,4 +249,3 @@ export async function setDefaultPromptsProperties(prompts) {
export async function setCustomPrompts(prompts) {
await browser.storage.local.set({_custom_prompt: prompts});
}