in the add tags page now is possibile to manage the auto add tags list. see #289

This commit is contained in:
Mic 2025-09-01 23:25:00 +02:00
parent 7593ff0729
commit 3da11ef612
5 changed files with 53 additions and 3 deletions

View file

@ -1127,6 +1127,18 @@
"message": "If checked, the AI will add only existing tags and won't create new tags.", "message": "If checked, the AI will add only existing tags and won't create new tags.",
"description": "" "description": ""
}, },
"prefs_OptionText_add_tags_auto_uselist": {
"message": "Use only these tags",
"description": ""
},
"prefs_OptionText_add_tags_auto_uselist_Info": {
"message": "If checked, the AI will add only tags from the list below. The list must contain comma separated list of allowed tags.",
"description": ""
},
"prefs_OptionText_add_tags_auto_uselist_list_Info": {
"message": "The list must contain at least one tag. The tags must be separated by a comma.",
"description": ""
},
"prefs_OptionText_add_tags_auto_only_inbox": { "prefs_OptionText_add_tags_auto_only_inbox": {
"message": "Only add tags to inbox emails", "message": "Only add tags to inbox emails",
"description": "" "description": ""

View file

@ -62,6 +62,8 @@ export const prefs_default = {
add_tags_auto: false, add_tags_auto: false,
add_tags_auto_force_existing: false, add_tags_auto_force_existing: false,
add_tags_auto_only_inbox: true, add_tags_auto_only_inbox: true,
add_tags_auto_uselist: false,
add_tags_auto_uselist_list: '',
add_tags_context_menu: true, add_tags_context_menu: true,
add_tags_enabled_accounts: [], add_tags_enabled_accounts: [],
get_calendar_event: true, get_calendar_event: true,

View file

@ -17,10 +17,16 @@
margin: 40px auto; margin: 40px auto;
} }
#addtags_excl_list{ #addtags_excl_list, #add_tags_auto_uselist_list{
width: 30em; width: 30em;
} }
#add_tags_auto_uselist_list:disabled {
background-color: #eee;
color: #888;
cursor: not-allowed;
}
#account_selector_container{ #account_selector_container{
display: none; display: none;
} }
@ -37,13 +43,17 @@
background-color: #e9ffdf; background-color: #e9ffdf;
} }
tr.add_tags_auto_sub td{
padding-left: 0.8em !important;
}
.btn_div{ .btn_div{
width: 100%; width: 100%;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
#addtags_info_additional_statements, #add_tags_auto_only_inbox_tr{ #addtags_info_additional_statements, #add_tags_auto_only_inbox_tr, #add_tags_auto_uselist_tr{
display: none; display: none;
} }

View file

@ -68,7 +68,7 @@
</label> </label>
</td> </td>
</tr> </tr>
<tr class="add_tags_tr add_tags_auto" id="add_tags_auto_only_inbox_tr"> <tr class="add_tags_tr add_tags_auto add_tags_auto_sub" id="add_tags_auto_only_inbox_tr">
<td><span>__MSG_prefs_OptionText_add_tags_auto_only_inbox__</span></td> <td><span>__MSG_prefs_OptionText_add_tags_auto_only_inbox__</span></td>
<td> <td>
<label> <label>
@ -77,6 +77,17 @@
</label> </label>
</td> </td>
</tr> </tr>
<tr class="add_tags_tr add_tags_auto add_tags_auto_sub" id="add_tags_auto_uselist_tr">
<td><span>__MSG_prefs_OptionText_add_tags_auto_uselist__</span></td>
<td>
<label>
<input type="checkbox" id="add_tags_auto_uselist" name="add_tags_auto_uselist" class="option-input" />
__MSG_prefs_OptionText_add_tags_auto_uselist_Info__
<br/><textarea id="add_tags_auto_uselist_list" class="option-input" rows="7"></textarea>
<br/><span class="infoline">__MSG_prefs_OptionText_add_tags_auto_uselist_list_Info__</span>
</label>
</td>
</tr>
<tr class="add_tags_tr"> <tr class="add_tags_tr">
<td><span>__MSG_prefs_OptionText_add_tags_context_menu__</span></td> <td><span>__MSG_prefs_OptionText_add_tags_context_menu__</span></td>
<td> <td>

View file

@ -57,14 +57,25 @@ document.addEventListener('DOMContentLoaded', async () => {
let add_tags_auto_only_inbox_tr = document.getElementById('add_tags_auto_only_inbox_tr'); let add_tags_auto_only_inbox_tr = document.getElementById('add_tags_auto_only_inbox_tr');
let account_selector_container = document.getElementById('account_selector_container'); let account_selector_container = document.getElementById('account_selector_container');
let add_tags_auto_infoline = document.getElementById('add_tags_auto_infoline'); let add_tags_auto_infoline = document.getElementById('add_tags_auto_infoline');
let add_tags_auto_uselist_tr = document.getElementById('add_tags_auto_uselist_tr');
add_tags_auto_el.addEventListener('click', (event) => { add_tags_auto_el.addEventListener('click', (event) => {
add_tags_auto_only_inbox_tr.style.display = event.target.checked ? 'table-row' : 'none'; add_tags_auto_only_inbox_tr.style.display = event.target.checked ? 'table-row' : 'none';
account_selector_container.style.display = event.target.checked ? 'block' : 'none'; account_selector_container.style.display = event.target.checked ? 'block' : 'none';
add_tags_auto_infoline.style.display = event.target.checked ? 'inline' : 'none'; add_tags_auto_infoline.style.display = event.target.checked ? 'inline' : 'none';
add_tags_auto_uselist_tr.style.display = event.target.checked ? 'table-row' : 'none';
}); });
add_tags_auto_only_inbox_tr.style.display = add_tags_auto_el.checked ? 'table-row' : 'none'; add_tags_auto_only_inbox_tr.style.display = add_tags_auto_el.checked ? 'table-row' : 'none';
account_selector_container.style.display = add_tags_auto_el.checked ? 'block' : 'none'; account_selector_container.style.display = add_tags_auto_el.checked ? 'block' : 'none';
add_tags_auto_infoline.style.display = add_tags_auto_el.checked ? 'inline' : 'none'; add_tags_auto_infoline.style.display = add_tags_auto_el.checked ? 'inline' : 'none';
add_tags_auto_uselist_tr.style.display = add_tags_auto_el.checked ? 'table-row' : 'none';
let add_tags_auto_uselist = document.getElementById('add_tags_auto_uselist');
let add_tags_auto_uselist_list = document.getElementById('add_tags_auto_uselist_list');
add_tags_auto_uselist.addEventListener('click', (event) => {
add_tags_auto_uselist_list.disabled = !event.target.checked;
});
add_tags_auto_uselist_list.disabled = !add_tags_auto_uselist.checked;
addtags_reset_btn.addEventListener('click', () => { addtags_reset_btn.addEventListener('click', () => {
addtags_textarea.value = browser.i18n.getMessage('prompt_add_tags_full_text'); addtags_textarea.value = browser.i18n.getMessage('prompt_add_tags_full_text');
@ -221,6 +232,9 @@ function saveOptions(e) {
case 'select-one': case 'select-one':
options[element.id] = element.value; options[element.id] = element.value;
break; break;
case 'textarea':
options[element.id] = element.value.trim();
break;
default: default:
console.error("[ThunderAI] Unhandled input type:", element.type); console.error("[ThunderAI] Unhandled input type:", element.type);
} }
@ -243,6 +257,7 @@ async function restoreOptions() {
element.value = result[element.id] ?? default_number_value; element.value = result[element.id] ?? default_number_value;
break; break;
case 'text': case 'text':
case 'textarea':
case 'password': case 'password':
let default_text_value = ''; let default_text_value = '';
if(element.id == 'default_chatgpt_lang') default_text_value = prefs_default.default_chatgpt_lang; if(element.id == 'default_chatgpt_lang') default_text_value = prefs_default.default_chatgpt_lang;