add_tags updating settings values from the special prompt
This commit is contained in:
parent
a7d42530fc
commit
2dcb661368
1 changed files with 20 additions and 4 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { prefs_default } from '../../options/mzta-options-default.js';
|
import { prefs_default, integration_options_config } from '../../options/mzta-options-default.js';
|
||||||
import { taLogger } from '../../js/mzta-logger.js';
|
import { taLogger } from '../../js/mzta-logger.js';
|
||||||
import {
|
import {
|
||||||
getSpecialPrompts,
|
getSpecialPrompts,
|
||||||
|
|
@ -44,6 +44,25 @@ let autocompleteSuggestions = [];
|
||||||
let taLog = new taLogger("mzta-addtags-page",true);
|
let taLog = new taLogger("mzta-addtags-page",true);
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
|
|
||||||
|
let specialPrompts = await getSpecialPrompts();
|
||||||
|
let addtags_prompt = specialPrompts.find(prompt => prompt.id === 'prompt_add_tags');
|
||||||
|
|
||||||
|
if (addtags_prompt && addtags_prompt.api && addtags_prompt.api !== '') {
|
||||||
|
let update_prefs = {};
|
||||||
|
update_prefs['add_tags_connection_type'] = addtags_prompt.api;
|
||||||
|
|
||||||
|
let integration = addtags_prompt.api.replace('_api', '');
|
||||||
|
if (integration_options_config && integration_options_config[integration]) {
|
||||||
|
for (const key of Object.keys(integration_options_config[integration])) {
|
||||||
|
if (addtags_prompt[key] !== undefined) {
|
||||||
|
update_prefs[`add_tags_${integration}_${key}`] = addtags_prompt[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await browser.storage.sync.set(update_prefs);
|
||||||
|
}
|
||||||
|
|
||||||
await initializeSpecificIntegrationUI({
|
await initializeSpecificIntegrationUI({
|
||||||
prefix: 'add_tags',
|
prefix: 'add_tags',
|
||||||
promptId: 'prompt_add_tags',
|
promptId: 'prompt_add_tags',
|
||||||
|
|
@ -62,9 +81,6 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
let addtags_save_btn = document.getElementById('btn_save_prompt');
|
let addtags_save_btn = document.getElementById('btn_save_prompt');
|
||||||
let addtags_reset_btn = document.getElementById('btn_reset_prompt');
|
let addtags_reset_btn = document.getElementById('btn_reset_prompt');
|
||||||
|
|
||||||
let specialPrompts = await getSpecialPrompts();
|
|
||||||
let addtags_prompt = specialPrompts.find(prompt => prompt.id === 'prompt_add_tags');
|
|
||||||
|
|
||||||
addtags_textarea.addEventListener('input', (event) => {
|
addtags_textarea.addEventListener('input', (event) => {
|
||||||
addtags_reset_btn.disabled = (event.target.value === browser.i18n.getMessage('prompt_add_tags_full_text'));
|
addtags_reset_btn.disabled = (event.target.value === browser.i18n.getMessage('prompt_add_tags_full_text'));
|
||||||
addtags_save_btn.disabled = (event.target.value === addtags_prompt.text);
|
addtags_save_btn.disabled = (event.target.value === addtags_prompt.text);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue