resetApiSettings method added. showing the reset button also in the new prompt form. see #623
This commit is contained in:
parent
6484e48964
commit
facc0bce74
1 changed files with 47 additions and 37 deletions
|
|
@ -145,7 +145,11 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
afterTrId: 'api_ui_anchor',
|
||||
selectId: 'new_prompt_api_type',
|
||||
no_chatgpt_web: true,
|
||||
taLog: taLog
|
||||
taLog: taLog,
|
||||
customButtonLabel: browser.i18n.getMessage("Reset"),
|
||||
customButtonCallback: () => {
|
||||
resetApiSettings('new_prompt_api_type');
|
||||
}
|
||||
});
|
||||
|
||||
// Fill defaults for new prompt form
|
||||
|
|
@ -477,6 +481,32 @@ function handleEditClick(e) {
|
|||
taLog: taLog,
|
||||
customButtonLabel: browser.i18n.getMessage("Reset"),
|
||||
customButtonCallback: () => {
|
||||
resetApiSettings(selectId, id);
|
||||
}
|
||||
}).then(() => {
|
||||
populateConnectionUI(tr, id, prefix, selectId);
|
||||
updateWarnings(prefix);
|
||||
});
|
||||
} else {
|
||||
populateConnectionUI(tr, id, prefix, selectId);
|
||||
updateWarnings(prefix);
|
||||
}
|
||||
|
||||
// Show/Hide buttons
|
||||
//console.log('>>>>>>>> tr: ' + tr.getAttribute('data-idnum'));
|
||||
e.target.style.display = 'none'; // Edit btn
|
||||
tr.querySelector('.btnConfirmItem').style.display = 'inline'; // Save btn
|
||||
tr.querySelector('.btnCancelItem').style.display = 'inline'; // Cancel btn
|
||||
// tr.querySelector('.btnEditItem').style.display = 'none'; // Edit btn
|
||||
tr.querySelector('.btnDeleteItem').style.display = 'none'; // Delete btn
|
||||
showItemRowEditor(tr);
|
||||
toggleDiffviewer(e);
|
||||
toggleAdditionalPropertiesShow(tr);
|
||||
}
|
||||
|
||||
function resetApiSettings(selectId, id = null) {
|
||||
let prefix = '';
|
||||
if (id) prefix = `prompt_${id}_`;
|
||||
const selectEl = document.getElementById(selectId);
|
||||
if (selectEl) {
|
||||
selectEl.value = '';
|
||||
|
|
@ -514,26 +544,6 @@ function handleEditClick(e) {
|
|||
}
|
||||
setSomethingChanged();
|
||||
}
|
||||
}).then(() => {
|
||||
populateConnectionUI(tr, id, prefix, selectId);
|
||||
updateWarnings(prefix);
|
||||
});
|
||||
} else {
|
||||
populateConnectionUI(tr, id, prefix, selectId);
|
||||
updateWarnings(prefix);
|
||||
}
|
||||
|
||||
// Show/Hide buttons
|
||||
//console.log('>>>>>>>> tr: ' + tr.getAttribute('data-idnum'));
|
||||
e.target.style.display = 'none'; // Edit btn
|
||||
tr.querySelector('.btnConfirmItem').style.display = 'inline'; // Save btn
|
||||
tr.querySelector('.btnCancelItem').style.display = 'inline'; // Cancel btn
|
||||
// tr.querySelector('.btnEditItem').style.display = 'none'; // Edit btn
|
||||
tr.querySelector('.btnDeleteItem').style.display = 'none'; // Delete btn
|
||||
showItemRowEditor(tr);
|
||||
toggleDiffviewer(e);
|
||||
toggleAdditionalPropertiesShow(tr);
|
||||
}
|
||||
|
||||
function populateConnectionUI(tr, id, prefix, selectId) {
|
||||
const item = promptsList.get('id', id)[0];
|
||||
|
|
|
|||
Loading…
Reference in a new issue